|
@@ -17,33 +17,32 @@ import java.util.List;
|
|
|
import org.eclipse.core.runtime.IProgressMonitor;
|
|
|
import org.eclipse.core.runtime.IStatus;
|
|
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
|
+import org.eclipse.core.runtime.Platform;
|
|
|
import org.eclipse.jface.layout.GridDataFactory;
|
|
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
|
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
|
|
+import org.eclipse.jface.viewers.ArrayContentProvider;
|
|
|
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
|
|
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
|
import org.eclipse.jface.viewers.StructuredSelection;
|
|
|
-import org.eclipse.jface.viewers.TreeViewer;
|
|
|
+import org.eclipse.jface.viewers.TableViewer;
|
|
|
import org.eclipse.jface.viewers.Viewer;
|
|
|
import org.eclipse.jface.viewers.ViewerFilter;
|
|
|
import org.eclipse.jface.wizard.WizardPage;
|
|
|
import org.eclipse.swt.SWT;
|
|
|
import org.eclipse.swt.browser.Browser;
|
|
|
import org.eclipse.swt.custom.SashForm;
|
|
|
-import org.eclipse.swt.events.SelectionAdapter;
|
|
|
import org.eclipse.swt.events.SelectionEvent;
|
|
|
import org.eclipse.swt.events.SelectionListener;
|
|
|
import org.eclipse.swt.layout.FillLayout;
|
|
|
import org.eclipse.swt.layout.GridData;
|
|
|
import org.eclipse.swt.layout.GridLayout;
|
|
|
+import org.eclipse.swt.program.Program;
|
|
|
import org.eclipse.swt.widgets.Composite;
|
|
|
import org.eclipse.swt.widgets.Display;
|
|
|
-import org.eclipse.swt.widgets.ToolBar;
|
|
|
-import org.eclipse.swt.widgets.ToolItem;
|
|
|
import org.yakindu.sct.examples.wizard.ExampleActivator;
|
|
|
-import org.yakindu.sct.examples.wizard.ExampleWizardImages;
|
|
|
import org.yakindu.sct.examples.wizard.preferences.ExamplesPreferenceConstants;
|
|
|
import org.yakindu.sct.examples.wizard.service.ExampleData;
|
|
|
import org.yakindu.sct.examples.wizard.service.ExampleWizardConstants;
|
|
@@ -61,15 +60,13 @@ import com.google.inject.Inject;
|
|
|
*/
|
|
|
|
|
|
public class SelectExamplePage extends WizardPage
|
|
|
- implements
|
|
|
- ExampleWizardConstants,
|
|
|
- ISelectionChangedListener,
|
|
|
- SelectionListener,
|
|
|
- IPropertyChangeListener {
|
|
|
+ implements ExampleWizardConstants, ISelectionChangedListener, SelectionListener, IPropertyChangeListener {
|
|
|
|
|
|
+ private static final String PRO_BUNDLE = "com.yakindu.sct.domain.c";
|
|
|
+ private static final String PRO_UPDATE_SITE = "https://info.itemis.com/yakindu/statecharts/pro/";
|
|
|
@Inject
|
|
|
private IExampleService exampleService;
|
|
|
- private TreeViewer viewer;
|
|
|
+ private TableViewer viewer;
|
|
|
private ExampleData selection;
|
|
|
private Browser browser;
|
|
|
private MessageArea messageArea;
|
|
@@ -95,38 +92,16 @@ public class SelectExamplePage extends WizardPage
|
|
|
Composite root = new Composite(parent, SWT.NONE);
|
|
|
root.setLayout(new GridLayout(1, true));
|
|
|
createUpdateGroup(root);
|
|
|
- createToolbar(root);
|
|
|
SashForm container = new SashForm(root, SWT.NONE);
|
|
|
GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
|
|
|
GridLayout layout = new GridLayout(2, false);
|
|
|
container.setLayout(layout);
|
|
|
createTreeViewer(container);
|
|
|
createDetailsPane(container);
|
|
|
- container.setWeights(new int[]{1, 2});
|
|
|
+ container.setWeights(new int[] { 1, 2 });
|
|
|
setControl(container);
|
|
|
}
|
|
|
|
|
|
- protected void createToolbar(Composite root) {
|
|
|
- ToolBar tb = new ToolBar(root, SWT.NONE);
|
|
|
- GridDataFactory.fillDefaults().grab(true, false).applyTo(tb);
|
|
|
- ToolItem collapseAllItem = new ToolItem(tb, SWT.NONE);
|
|
|
- collapseAllItem.setImage(ExampleWizardImages.COLLAPSE_ALL.image());
|
|
|
- collapseAllItem.addSelectionListener(new SelectionAdapter() {
|
|
|
- @Override
|
|
|
- public void widgetSelected(SelectionEvent e) {
|
|
|
- viewer.collapseAll();
|
|
|
- }
|
|
|
- });
|
|
|
- ToolItem expandAllItem = new ToolItem(tb, SWT.NONE);
|
|
|
- expandAllItem.setImage(ExampleWizardImages.EXPAND_ALL.image());
|
|
|
- expandAllItem.addSelectionListener(new SelectionAdapter() {
|
|
|
- @Override
|
|
|
- public void widgetSelected(SelectionEvent e) {
|
|
|
- viewer.expandAll();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
private void createUpdateGroup(Composite root) {
|
|
|
messageArea = new MessageArea(root);
|
|
|
GridDataFactory.fillDefaults().grab(true, false).applyTo(messageArea);
|
|
@@ -158,7 +133,7 @@ public class SelectExamplePage extends WizardPage
|
|
|
init(monitor);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
if (revealExamplesAutomatically()) {
|
|
|
Display.getCurrent().asyncExec(new Runnable() {
|
|
|
@Override
|
|
@@ -184,6 +159,7 @@ public class SelectExamplePage extends WizardPage
|
|
|
});
|
|
|
} else if (!exampleService.isUpToDate(monitor)) {
|
|
|
Display.getDefault().syncExec(new Runnable() {
|
|
|
+
|
|
|
@Override
|
|
|
public void run() {
|
|
|
setInput(monitor);
|
|
@@ -199,6 +175,7 @@ public class SelectExamplePage extends WizardPage
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protected void setInput(final IProgressMonitor monitor) {
|
|
@@ -206,14 +183,13 @@ public class SelectExamplePage extends WizardPage
|
|
|
|
|
|
messageArea.hide();
|
|
|
viewer.setInput(input);
|
|
|
- viewer.expandAll();
|
|
|
// explicit layouting required for Unix systems
|
|
|
viewer.getControl().getParent().getParent().layout(true);
|
|
|
|
|
|
filterAndSelectExampleToInstall(viewer, input);
|
|
|
}
|
|
|
|
|
|
- protected void filterAndSelectExampleToInstall(TreeViewer viewer, List<ExampleData> input) {
|
|
|
+ protected void filterAndSelectExampleToInstall(TableViewer viewer, List<ExampleData> input) {
|
|
|
final ExampleData exampleToInstall = Iterables.find(input, new Predicate<ExampleData>() {
|
|
|
@Override
|
|
|
public boolean apply(ExampleData input) {
|
|
@@ -236,7 +212,7 @@ public class SelectExamplePage extends WizardPage
|
|
|
return exampleIdToInstall.equals(((ExampleData) element).getId());
|
|
|
}
|
|
|
if (element instanceof ExampleContentProvider.Category) {
|
|
|
- return ((ExampleContentProvider.Category)element).getChildren().contains(exampleToInstall);
|
|
|
+ return ((ExampleContentProvider.Category) element).getChildren().contains(exampleToInstall);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -246,9 +222,9 @@ public class SelectExamplePage extends WizardPage
|
|
|
}
|
|
|
|
|
|
protected void createTreeViewer(Composite container) {
|
|
|
- viewer = new TreeViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE);
|
|
|
+ viewer = new TableViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE);
|
|
|
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
|
|
|
- viewer.setContentProvider(new ExampleContentProvider());
|
|
|
+ viewer.setContentProvider(new ArrayContentProvider());
|
|
|
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExampleLabelProvider()));
|
|
|
viewer.addSelectionChangedListener(this);
|
|
|
}
|
|
@@ -258,9 +234,20 @@ public class SelectExamplePage extends WizardPage
|
|
|
setDetailPaneContent(data);
|
|
|
setPageComplete(true);
|
|
|
setErrorMessage(null);
|
|
|
+ checkInstalledPlugins(data);
|
|
|
viewer.refresh();
|
|
|
}
|
|
|
|
|
|
+ private void checkInstalledPlugins(ExampleData data) {
|
|
|
+ if (data.isProfessional() && Platform.getBundle(PRO_BUNDLE) == null) {
|
|
|
+ messageArea.showProInstall();
|
|
|
+ } else {
|
|
|
+ messageArea.hide();
|
|
|
+ }
|
|
|
+ messageArea.getParent().layout(true);
|
|
|
+ this.getControl().update();
|
|
|
+ }
|
|
|
+
|
|
|
protected void setDetailPaneContent(ExampleData exampleData) {
|
|
|
String url = exampleData.getProjectDir().getAbsolutePath() + File.separator + "index.html";
|
|
|
browser.setUrl(url);
|
|
@@ -286,7 +273,16 @@ public class SelectExamplePage extends WizardPage
|
|
|
|
|
|
@Override
|
|
|
public void widgetSelected(SelectionEvent e) {
|
|
|
- revealExamples();
|
|
|
+ switch (messageArea.getState()) {
|
|
|
+ case UPDATE:
|
|
|
+ revealExamples();
|
|
|
+ break;
|
|
|
+ case INSTALL:
|
|
|
+ Program.launch(PRO_UPDATE_SITE);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
protected void revealExamples() {
|