소스 검색

added pro icon for pro examples, added install option

Andreas Muelder 9 년 전
부모
커밋
c6cd754809

+ 1 - 3
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/pages/ExampleLabelProvider.java

@@ -10,8 +10,6 @@
  */
  */
 package org.yakindu.sct.examples.wizard.pages;
 package org.yakindu.sct.examples.wizard.pages;
 
 
-import java.util.Arrays;
-
 import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
 import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.StyledString;
 import org.eclipse.jface.viewers.StyledString;
@@ -40,7 +38,7 @@ public class ExampleLabelProvider extends LabelProvider implements IStyledLabelP
 	@Override
 	@Override
 	public Image getImage(Object element) {
 	public Image getImage(Object element) {
 		if (element instanceof ExampleData) {
 		if (element instanceof ExampleData) {
-			if (Arrays.asList(((ExampleData) element).getCategory()).contains("professional")) {
+			if (((ExampleData) element).isProfessional()) {
 				return StatechartImages.PRO_LOGO.image();
 				return StatechartImages.PRO_LOGO.image();
 			} else {
 			} else {
 				return StatechartImages.LOGO.image();
 				return StatechartImages.LOGO.image();

+ 11 - 1
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/pages/MessageArea.java

@@ -44,7 +44,7 @@ public class MessageArea extends Composite {
 	private Group group;
 	private Group group;
 
 
 	public static enum State {
 	public static enum State {
-		DOWNLOAD, UPDATE, ERROR, HIDE
+		DOWNLOAD, UPDATE, INSTALL, ERROR, HIDE
 	}
 	}
 
 
 	private State state = State.HIDE;
 	private State state = State.HIDE;
@@ -100,6 +100,16 @@ public class MessageArea extends Composite {
 		button.setVisible(true);
 		button.setVisible(true);
 		show();
 		show();
 	}
 	}
+	
+	public void showProInstall() {
+		state = State.INSTALL;
+		imageLabel.setImage(Display.getDefault().getSystemImage(SWT.ICON_INFORMATION));
+		textLabel.setText("This example requires YAKINDU Statechart Tools professional. Do you want to download it?");
+		textLabel.pack();
+		button.setText("Download");
+		button.setVisible(true);
+		show();
+	}
 
 
 	public void showError() {
 	public void showError() {
 		state = State.ERROR;
 		state = State.ERROR;

+ 31 - 9
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/pages/SelectExamplePage.java

@@ -17,6 +17,7 @@ import java.util.List;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.IPropertyChangeListener;
@@ -38,6 +39,7 @@ import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.program.Program;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Display;
 import org.yakindu.sct.examples.wizard.ExampleActivator;
 import org.yakindu.sct.examples.wizard.ExampleActivator;
@@ -58,12 +60,10 @@ import com.google.inject.Inject;
  */
  */
 
 
 public class SelectExamplePage extends WizardPage
 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
 	@Inject
 	private IExampleService exampleService;
 	private IExampleService exampleService;
 	private TableViewer viewer;
 	private TableViewer viewer;
@@ -98,7 +98,7 @@ public class SelectExamplePage extends WizardPage
 		container.setLayout(layout);
 		container.setLayout(layout);
 		createTreeViewer(container);
 		createTreeViewer(container);
 		createDetailsPane(container);
 		createDetailsPane(container);
-		container.setWeights(new int[]{1, 2});
+		container.setWeights(new int[] { 1, 2 });
 		setControl(container);
 		setControl(container);
 	}
 	}
 
 
@@ -133,7 +133,7 @@ public class SelectExamplePage extends WizardPage
 					init(monitor);
 					init(monitor);
 				}
 				}
 			});
 			});
-			
+
 			if (revealExamplesAutomatically()) {
 			if (revealExamplesAutomatically()) {
 				Display.getCurrent().asyncExec(new Runnable() {
 				Display.getCurrent().asyncExec(new Runnable() {
 					@Override
 					@Override
@@ -159,6 +159,7 @@ public class SelectExamplePage extends WizardPage
 			});
 			});
 		} else if (!exampleService.isUpToDate(monitor)) {
 		} else if (!exampleService.isUpToDate(monitor)) {
 			Display.getDefault().syncExec(new Runnable() {
 			Display.getDefault().syncExec(new Runnable() {
+
 				@Override
 				@Override
 				public void run() {
 				public void run() {
 					setInput(monitor);
 					setInput(monitor);
@@ -174,6 +175,7 @@ public class SelectExamplePage extends WizardPage
 				}
 				}
 			});
 			});
 		}
 		}
+
 	}
 	}
 
 
 	protected void setInput(final IProgressMonitor monitor) {
 	protected void setInput(final IProgressMonitor monitor) {
@@ -210,7 +212,7 @@ public class SelectExamplePage extends WizardPage
 						return exampleIdToInstall.equals(((ExampleData) element).getId());
 						return exampleIdToInstall.equals(((ExampleData) element).getId());
 					}
 					}
 					if (element instanceof ExampleContentProvider.Category) {
 					if (element instanceof ExampleContentProvider.Category) {
-						return ((ExampleContentProvider.Category)element).getChildren().contains(exampleToInstall);
+						return ((ExampleContentProvider.Category) element).getChildren().contains(exampleToInstall);
 					}
 					}
 					return true;
 					return true;
 				}
 				}
@@ -232,9 +234,20 @@ public class SelectExamplePage extends WizardPage
 		setDetailPaneContent(data);
 		setDetailPaneContent(data);
 		setPageComplete(true);
 		setPageComplete(true);
 		setErrorMessage(null);
 		setErrorMessage(null);
+		checkInstalledPlugins(data);
 		viewer.refresh();
 		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) {
 	protected void setDetailPaneContent(ExampleData exampleData) {
 		String url = exampleData.getProjectDir().getAbsolutePath() + File.separator + "index.html";
 		String url = exampleData.getProjectDir().getAbsolutePath() + File.separator + "index.html";
 		browser.setUrl(url);
 		browser.setUrl(url);
@@ -260,7 +273,16 @@ public class SelectExamplePage extends WizardPage
 
 
 	@Override
 	@Override
 	public void widgetSelected(SelectionEvent e) {
 	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() {
 	protected void revealExamples() {

+ 5 - 0
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/service/ExampleData.java

@@ -20,6 +20,7 @@ import java.util.Arrays;
  */
  */
 public class ExampleData {
 public class ExampleData {
 
 
+	private static final String PRO_EXAMPLE = "professional";
 	private String id;
 	private String id;
 	private String title;
 	private String title;
 	private String[] category;
 	private String[] category;
@@ -92,6 +93,10 @@ public class ExampleData {
 		this.projectDir = projectDir;
 		this.projectDir = projectDir;
 	}
 	}
 
 
+	public boolean isProfessional() {
+		return Arrays.asList(getCategory()).contains(PRO_EXAMPLE);
+	}
+
 	@Override
 	@Override
 	public int hashCode() {
 	public int hashCode() {
 		final int prime = 31;
 		final int prime = 31;