소스 검색

Merge pull request #183 from Yakindu/Bugfix_159

Bugfix 159
Axel Terfloth 9 년 전
부모
커밋
472c7df2bb

+ 0 - 2
plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/highlighting/HighlightingSupportAdapter.java

@@ -161,8 +161,6 @@ public class HighlightingSupportAdapter implements IHighlightingSupport {
 		if(editPart == null) {
 			return;
 		}
-		// ensure the edit part is made visible.
-		diagramWorkbenchPart.getDiagramGraphicalViewer().reveal(editPart);
 
 		final IFigure figure = getTargetFigure(editPart);
 				

+ 145 - 140
plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/DomainRegistry.java

@@ -1,140 +1,145 @@
-/**
- * Copyright (c) 2015 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.domain.extension;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.framework.Bundle;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.Statechart;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class DomainRegistry {
-
-	private static final String EXTENSION_POINT = "org.yakindu.sct.domain";
-	private static final String DOMAIN_ID = "domainID";
-	private static final String DESCRIPTION = "description";
-	private static final String IMAGE = "image";
-	private static final String NAME = "name";
-	private static final String MODULE_PROVIDER = "domainModuleProvider";
-
-	private DomainRegistry() {
-	}
-
-	private static List<DomainDescriptor> descriptors = null;
-
-	public static final class DomainDescriptor {
-
-		private final IConfigurationElement configElement;
-
-		private Image image;
-
-		DomainDescriptor(IConfigurationElement configElement) {
-			this.configElement = configElement;
-		}
-
-		public String getDomainID() {
-			return configElement.getAttribute(DOMAIN_ID);
-		}
-
-		public String getName() {
-			return configElement.getAttribute(NAME);
-		}
-
-		public String getDescription() {
-			return configElement.getAttribute(DESCRIPTION);
-		}
-
-		public IDomainInjectorProvider getDomainInjectorProvider() {
-			try {
-				return (IDomainInjectorProvider) configElement.createExecutableExtension(MODULE_PROVIDER);
-			} catch (CoreException e) {
-				e.printStackTrace();
-			}
-			return null;
-		}
-
-		public Image getImage() {
-			if (image != null)
-				return image;
-			String path = configElement.getAttribute(IMAGE);
-			if (path == null)
-				return null;
-
-			Bundle extensionBundle = Platform.getBundle(configElement.getContributor().getName());
-			URL entry = extensionBundle.getEntry(path);
-			ImageDescriptor descriptor = ImageDescriptor.createFromURL(entry);
-			image = descriptor.createImage();
-			return image;
-		}
-
-		public IConfigurationElement getConfigElement() {
-			return configElement;
-		}
-
-		public void setImage(Image image) {
-			this.image = image;
-		}
-	}
-
-	public static List<DomainDescriptor> getDomainDescriptors() {
-		if (descriptors == null) {
-			descriptors = new ArrayList<DomainDescriptor>();
-			IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
-					.getConfigurationElementsFor(EXTENSION_POINT);
-			for (IConfigurationElement iConfigurationElement : configurationElements) {
-				descriptors.add(new DomainDescriptor(iConfigurationElement));
-			}
-		}
-		return descriptors;
-	}
-
-	public static DomainDescriptor getDomainDescriptor(final String id) {
-		final String defaultDomainID = SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral();
-		try {
-			return Iterables.find(getDomainDescriptors(), new Predicate<DomainDescriptor>() {
-				@Override
-				public boolean apply(DomainDescriptor input) {
-					return input.getDomainID().equals(id != null ? id : defaultDomainID);
-				}
-			});
-		} catch (NoSuchElementException e) {
-			if(defaultDomainID.equals(id)){
-				throw new IllegalArgumentException("No default domain found!");
-			}
-			System.err.println("Could not find domain descriptor for id " + id + " - > using default domain");
-			return getDomainDescriptor(defaultDomainID);
-		}
-	}
-
-	public static DomainDescriptor getDomainDescriptor(EObject object) {
-		EObject rootContainer = EcoreUtil.getRootContainer(object);
-		Assert.isTrue(rootContainer instanceof Statechart);
-		return getDomainDescriptor(((Statechart) rootContainer).getDomainID());
-	}
-}
+/**
+ * Copyright (c) 2015 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.domain.extension;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class DomainRegistry {
+
+	private static final String EXTENSION_POINT = "org.yakindu.sct.domain";
+	private static final String DOMAIN_ID = "domainID";
+	private static final String DESCRIPTION = "description";
+	private static final String IMAGE = "image";
+	private static final String NAME = "name";
+	private static final String MODULE_PROVIDER = "domainModuleProvider";
+
+	private DomainRegistry() {
+	}
+
+	private static List<DomainDescriptor> descriptors = null;
+
+	public static final class DomainDescriptor {
+
+		private final IConfigurationElement configElement;
+
+		private Image image;
+
+		private IDomainInjectorProvider injectorProvider;
+
+		DomainDescriptor(IConfigurationElement configElement) {
+			this.configElement = configElement;
+		}
+
+		public String getDomainID() {
+			return configElement.getAttribute(DOMAIN_ID);
+		}
+
+		public String getName() {
+			return configElement.getAttribute(NAME);
+		}
+
+		public String getDescription() {
+			return configElement.getAttribute(DESCRIPTION);
+		}
+
+		public IDomainInjectorProvider getDomainInjectorProvider() {
+			if (injectorProvider == null) {
+				try {
+					injectorProvider = (IDomainInjectorProvider) configElement
+							.createExecutableExtension(MODULE_PROVIDER);
+				} catch (CoreException e) {
+					e.printStackTrace();
+				}
+			}
+			return injectorProvider;
+		}
+
+		public Image getImage() {
+			if (image != null)
+				return image;
+			String path = configElement.getAttribute(IMAGE);
+			if (path == null)
+				return null;
+
+			Bundle extensionBundle = Platform.getBundle(configElement.getContributor().getName());
+			URL entry = extensionBundle.getEntry(path);
+			ImageDescriptor descriptor = ImageDescriptor.createFromURL(entry);
+			image = descriptor.createImage();
+			return image;
+		}
+
+		public IConfigurationElement getConfigElement() {
+			return configElement;
+		}
+
+		public void setImage(Image image) {
+			this.image = image;
+		}
+	}
+
+	public static List<DomainDescriptor> getDomainDescriptors() {
+		if (descriptors == null) {
+			descriptors = new ArrayList<DomainDescriptor>();
+			IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
+					.getConfigurationElementsFor(EXTENSION_POINT);
+			for (IConfigurationElement iConfigurationElement : configurationElements) {
+				descriptors.add(new DomainDescriptor(iConfigurationElement));
+			}
+		}
+		return descriptors;
+	}
+
+	public static DomainDescriptor getDomainDescriptor(final String id) {
+		final String defaultDomainID = SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral();
+		try {
+			return Iterables.find(getDomainDescriptors(), new Predicate<DomainDescriptor>() {
+				@Override
+				public boolean apply(DomainDescriptor input) {
+					return input.getDomainID().equals(id != null ? id : defaultDomainID);
+				}
+			});
+		} catch (NoSuchElementException e) {
+			if (defaultDomainID.equals(id)) {
+				throw new IllegalArgumentException("No default domain found!");
+			}
+			System.err.println("Could not find domain descriptor for id " + id + " - > using default domain");
+			return getDomainDescriptor(defaultDomainID);
+		}
+	}
+
+	public static DomainDescriptor getDomainDescriptor(EObject object) {
+		EObject rootContainer = EcoreUtil.getRootContainer(object);
+		Assert.isTrue(rootContainer instanceof Statechart);
+		return getDomainDescriptor(((Statechart) rootContainer).getDomainID());
+	}
+}

+ 16 - 15
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -37,7 +37,6 @@ import org.yakindu.base.expressions.expressions.FeatureCall;
 import org.yakindu.base.types.ComplexType;
 import org.yakindu.base.types.Declaration;
 import org.yakindu.base.types.EnumerationType;
-import org.yakindu.base.types.TypesPackage;
 import org.yakindu.base.xtext.utils.jface.viewers.ContextElementAdapter;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Scope;
@@ -118,16 +117,18 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		IScope unnamedScope = getUnnamedTopLevelScope(context, reference);
 		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
 		unnamedScope = new FilteringScope(unnamedScope, predicate);
-		// add enum types
-		IScope enumerations = new FilteringScope(getDelegate().getScope(context, reference),
-				new Predicate<IEObjectDescription>() {
-					@Override
-					public boolean apply(IEObjectDescription input) {
-						return input.getEClass() == TypesPackage.Literals.ENUMERATION_TYPE;
-					}
-				});
-		return new SimpleScope(Iterables.concat(namdScope.getAllElements(), unnamedScope.getAllElements(),
-				enumerations.getAllElements()));
+		// TODO: Performance problem -> fix this in context of Add Support for
+		// Enumerations #165
+		// // add enum types
+		// IScope enumerations = new
+		// FilteringScope(getDelegate().getScope(context, reference),
+		// new Predicate<IEObjectDescription>() {
+		// @Override
+		// public boolean apply(IEObjectDescription input) {
+		// return input.getEClass() == TypesPackage.Literals.ENUMERATION_TYPE;
+		// }
+		// });
+		return new SimpleScope(Iterables.concat(namdScope.getAllElements(), unnamedScope.getAllElements()));
 	}
 
 	public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
@@ -214,8 +215,8 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		if (importedNamespace == null || importedNamespace.getSegmentCount() < 1) {
 			return null;
 		}
-		boolean hasWildCard = ignoreCase ? importedNamespace.getLastSegment().equalsIgnoreCase("*") : importedNamespace
-				.getLastSegment().equals("*");
+		boolean hasWildCard = ignoreCase ? importedNamespace.getLastSegment().equalsIgnoreCase("*")
+				: importedNamespace.getLastSegment().equals("*");
 		if (hasWildCard) {
 			if (importedNamespace.getSegmentCount() <= 1)
 				return null;
@@ -271,8 +272,8 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 	 * Returns the {@link Statechart} for a context element
 	 */
 	protected Statechart getStatechart(EObject context) {
-		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(
-				context.eResource(), ContextElementAdapter.class);
+		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context.eResource(),
+				ContextElementAdapter.class);
 
 		if (provider == null) {
 			return EcoreUtil2.getContainerOfType(context, Statechart.class);

+ 20 - 17
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java

@@ -103,27 +103,29 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget, ISt
 		for (RegularState vertex : activeLeafStates) {
 			activeRegions.add(vertex.getParentRegion());
 		}
-		// Remove orphaned debug threads
-		Iterator<SCTDebugThread> iterator = threads.iterator();
-		while (iterator.hasNext()) {
-			SCTDebugThread next = iterator.next();
-			if (!activeRegions.contains(next.getElement())) {
-				iterator.remove();
-			}
-		}
-		// Add new debug threads
-		for (Region region : activeRegions) {
-			boolean found = false;
-			for (SCTDebugThread thread : threads) {
-				if (thread.getElement() == region) {
-					found = true;
+		synchronized (threads) {
+			// Remove orphaned debug threads
+			Iterator<SCTDebugThread> iterator = threads.iterator();
+			while (iterator.hasNext()) {
+				SCTDebugThread next = iterator.next();
+				if (!activeRegions.contains(next.getElement())) {
+					iterator.remove();
 				}
 			}
-			if (!found) {
-				threads.add(new SCTDebugThread(this, engine, getResourceString(), region));
+			// Add new debug threads
+			for (Region region : activeRegions) {
+				boolean found = false;
+				for (SCTDebugThread thread : threads) {
+					if (thread.getElement() == region) {
+						found = true;
+					}
+				}
+				if (!found) {
+					threads.add(new SCTDebugThread(this, engine, getResourceString(), region));
+				}
 			}
+			return threads.toArray(new IThread[] {});
 		}
-		return threads.toArray(new IThread[] {});
 	}
 
 	public boolean hasThreads() throws DebugException {
@@ -216,6 +218,7 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget, ISt
 		return this;
 	}
 
+	@SuppressWarnings("unchecked")
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
 		if (adapter == ISimulationEngine.class)
 			return engine;

+ 12 - 10
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java

@@ -58,19 +58,20 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 				break;
 			}
 		}
-
-		if (activeState != null && lastActiveState != activeState) {
-			lastActiveState = activeState;
-			EObject container = activeState;
-			stateStack = new ArrayList<SCTStackFrame>();
-			while (container != null) {
-				if (container instanceof RegularState) {
-					stateStack.add(new SCTStackFrame(this, (RegularState) container, getResourceString()));
+		synchronized (stateStack) {
+			if (activeState != null && lastActiveState != activeState) {
+				lastActiveState = activeState;
+				EObject container = activeState;
+				stateStack = new ArrayList<SCTStackFrame>();
+				while (container != null) {
+					if (container instanceof RegularState) {
+						stateStack.add(new SCTStackFrame(this, (RegularState) container, getResourceString()));
+					}
+					container = container.eContainer();
 				}
-				container = container.eContainer();
 			}
+			return stateStack.toArray(new IStackFrame[] {});
 		}
-		return stateStack.toArray(new IStackFrame[] {});
 	}
 
 	public boolean hasStackFrames() throws DebugException {
@@ -147,6 +148,7 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 		return null;
 	}
 
+	@SuppressWarnings("unchecked")
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
 		if (adapter == ISimulationEngine.class)
 			return container;

+ 1 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java

@@ -152,6 +152,7 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 		return element.eResource().getURI().toPlatformString(true);
 	}
 
+	@SuppressWarnings("unchecked")
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
 		if (adapter == EObject.class)
 			return element;