瀏覽代碼

Merge branch 'master' of https://github.com/Yakindu/statecharts.git

Andreas Muelder 9 年之前
父節點
當前提交
6da3831c02

+ 12 - 1
.travis.yml

@@ -1,6 +1,8 @@
 sudo: false
 language: java
-jdk: oraclejdk7
+jdk: 
+ - oraclejdk7
+ - oraclejdk8
 addons:
  apt:
   packages:
@@ -24,6 +26,15 @@ env:
   matrix:
   - TARGET=Mars.target
   - TARGET=Luna.target
+  - TARGET=Neon.target
+matrix:
+  exclude:
+   - jdk: oraclejdk8
+     env: TARGET=Mars.target
+   - jdk: oraclejdk8
+     env: TARGET=Luna.target
+   - jdk: oraclejdk7
+     env: TARGET=Neon.target
 before_script:
  - mkdir gtest 
  - cd gtest

+ 16 - 3
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/pages/ExampleContentProvider.java

@@ -10,8 +10,11 @@
  */
 package org.yakindu.sct.examples.wizard.pages;
 
+import java.text.Collator;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -19,6 +22,8 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 import org.yakindu.sct.examples.wizard.service.ExampleData;
 
+import com.google.common.collect.Lists;
+
 /**
  * 
  * @author t00manysecretss
@@ -52,7 +57,7 @@ public class ExampleContentProvider implements ITreeContentProvider {
 	private Map<String, Category> categories;
 
 	public ExampleContentProvider() {
-		categories = new HashMap<>();
+		categories = new LinkedHashMap<>();
 	}
 
 	@SuppressWarnings("unchecked")
@@ -77,7 +82,15 @@ public class ExampleContentProvider implements ITreeContentProvider {
 
 	@Override
 	public Object[] getElements(Object inputElement) {
-		return categories.values().toArray();
+		List<Category> values = Lists.newArrayList();
+		values.addAll(categories.values());
+		Collections.sort(values, new Comparator<Category>() {
+			@Override
+			public int compare(Category o1, Category o2) {
+				return Collator.getInstance().compare(o1.getName(), o2.getName());
+			}
+		});
+		return values.toArray();
 	}
 
 	@Override

+ 33 - 12
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/pages/SelectExamplePage.java

@@ -19,6 +19,8 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 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.DelegatingStyledCellLabelProvider;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -35,6 +37,8 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
+import org.yakindu.sct.examples.wizard.ExampleActivator;
+import org.yakindu.sct.examples.wizard.preferences.ExamplesPreferenceConstants;
 import org.yakindu.sct.examples.wizard.service.ExampleData;
 import org.yakindu.sct.examples.wizard.service.ExampleWizardConstants;
 import org.yakindu.sct.examples.wizard.service.IExampleService;
@@ -49,7 +53,7 @@ import com.google.inject.Inject;
  */
 
 public class SelectExamplePage extends WizardPage
-		implements ExampleWizardConstants, ISelectionChangedListener, SelectionListener {
+		implements ExampleWizardConstants, ISelectionChangedListener, SelectionListener, IPropertyChangeListener {
 
 	@Inject
 	private IExampleService exampleService;
@@ -63,6 +67,13 @@ public class SelectExamplePage extends WizardPage
 		setTitle(SELECT_PAGE_TITLE);
 		setDescription(SELECT_PAGE_DESCRIPTION);
 		setPageComplete(false);
+		ExampleActivator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+	}
+
+	@Override
+	public void dispose() {
+		ExampleActivator.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+		super.dispose();
 	}
 
 	public void createControl(Composite parent) {
@@ -91,17 +102,7 @@ public class SelectExamplePage extends WizardPage
 	public void setVisible(boolean visible) {
 		super.setVisible(visible);
 		if (visible) {
-			try {
-				getWizard().getContainer().run(true, false, new IRunnableWithProgress() {
-					@Override
-					public void run(final IProgressMonitor monitor)
-							throws InvocationTargetException, InterruptedException {
-						init(monitor);
-					}
-				});
-			} catch (InvocationTargetException | InterruptedException e) {
-				e.printStackTrace();
-			}
+			initAsync();
 		} else {
 			viewer.setInput(null);
 			browser.setUrl("about:blank");
@@ -109,6 +110,19 @@ public class SelectExamplePage extends WizardPage
 
 	}
 
+	private void initAsync() {
+		try {
+			getWizard().getContainer().run(true, false, new IRunnableWithProgress() {
+				@Override
+				public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+					init(monitor);
+				}
+			});
+		} catch (InvocationTargetException | InterruptedException e) {
+			e.printStackTrace();
+		}
+	}
+
 	private void init(final IProgressMonitor monitor) {
 		if (!exampleService.exists()) {
 			Display.getDefault().syncExec(new Runnable() {
@@ -214,4 +228,11 @@ public class SelectExamplePage extends WizardPage
 
 	}
 
+	@Override
+	public void propertyChange(PropertyChangeEvent event) {
+		if (ExamplesPreferenceConstants.STORAGE_LOCATION.equals(event.getProperty())) {
+			initAsync();
+		}
+	}
+
 }

+ 17 - 17
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/service/git/GitRepositoryExampleService.java

@@ -67,30 +67,26 @@ public class GitRepositoryExampleService implements IExampleService {
 	private String repositoryURL;
 	@Inject
 	private IExampleDataReader reader;
-	private java.nio.file.Path gitRepo;
 
-	public GitRepositoryExampleService() {
-		gitRepo = java.nio.file.Paths.get(getStorageLocation());
-	}
-
-	private String getStorageLocation() {
-		return ExampleActivator.getDefault().getPreferenceStore()
-				.getString(ExamplesPreferenceConstants.STORAGE_LOCATION);
+	protected java.nio.file.Path getStorageLocation() {
+		return java.nio.file.Paths.get(ExampleActivator.getDefault().getPreferenceStore()
+				.getString(ExamplesPreferenceConstants.STORAGE_LOCATION));
 	}
 
 	@Override
 	public boolean exists() {
-		return Files.exists(gitRepo);
+		return Files.exists(getStorageLocation());
 	}
 
 	@Override
 	public IStatus fetchAllExamples(IProgressMonitor monitor) {
 		if (!exists()) {
+			java.nio.file.Path storageLocation = getStorageLocation();
 			try {
-				Files.createDirectories(gitRepo);
+				Files.createDirectories(storageLocation);
 			} catch (IOException e1) {
 				return new Status(IStatus.ERROR, ExampleActivator.PLUGIN_ID,
-						"Unable to create folder " + gitRepo.getFileName());
+						"Unable to create folder " + storageLocation.getFileName());
 			}
 			return cloneRepository(monitor);
 		} else {
@@ -100,7 +96,8 @@ public class GitRepositoryExampleService implements IExampleService {
 
 	protected IStatus updateRepository(IProgressMonitor monitor) {
 		try {
-			PullResult result = Git.open(gitRepo.toFile()).pull()
+			java.nio.file.Path storageLocation = getStorageLocation();
+			PullResult result = Git.open(storageLocation.toFile()).pull()
 					.setProgressMonitor(new EclipseGitProgressTransformer(monitor)).call();
 			if (!result.isSuccessful()) {
 				return new Status(IStatus.ERROR, ExampleActivator.PLUGIN_ID,
@@ -115,12 +112,13 @@ public class GitRepositoryExampleService implements IExampleService {
 
 	protected IStatus cloneRepository(IProgressMonitor monitor) {
 		Git call = null;
+		java.nio.file.Path storageLocation = getStorageLocation();
 		try {
-			call = Git.cloneRepository().setURI(repositoryURL).setDirectory(gitRepo.toFile())
+			call = Git.cloneRepository().setURI(repositoryURL).setDirectory(storageLocation.toFile())
 					.setProgressMonitor(new EclipseGitProgressTransformer(monitor)).setBranch(RELEASE).call();
 		} catch (GitAPIException e) {
 			try {
-				deleteFolder(gitRepo);
+				deleteFolder(storageLocation);
 			} catch (IOException ex) {
 				ex.printStackTrace();
 			}
@@ -131,7 +129,7 @@ public class GitRepositoryExampleService implements IExampleService {
 				call.close();
 			if (monitor.isCanceled()) {
 				try {
-					deleteFolder(gitRepo);
+					deleteFolder(storageLocation);
 				} catch (IOException e) {
 					e.printStackTrace();
 				}
@@ -142,8 +140,9 @@ public class GitRepositoryExampleService implements IExampleService {
 
 	@Override
 	public List<ExampleData> getExamples(IProgressMonitor monitor) {
+		java.nio.file.Path storageLocation = getStorageLocation();
 		List<java.nio.file.Path> projects = new ArrayList<>();
-		findMetaData(projects, gitRepo);
+		findMetaData(projects, storageLocation);
 		List<ExampleData> result = reader.parse(projects);
 		return result;
 	}
@@ -218,8 +217,9 @@ public class GitRepositoryExampleService implements IExampleService {
 
 	@Override
 	public boolean isUpToDate(IProgressMonitor monitor) {
+		java.nio.file.Path storageLocation = getStorageLocation();
 		try {
-			FetchCommand fetch = Git.open(gitRepo.toFile()).fetch();
+			FetchCommand fetch = Git.open(storageLocation.toFile()).fetch();
 			FetchResult result = fetch.setProgressMonitor(new EclipseGitProgressTransformer(monitor)).setDryRun(true)
 					.call();
 			Collection<TrackingRefUpdate> trackingRefUpdates = result.getTrackingRefUpdates();