Explorar el Código

added implicit imports for active scoping (#1294) (#1667)

* added implicit imports for active scoping (#1294)

added navigation to states from active statement
removed states from global scope

* Resource Description optimizations

* Resource Description optimizations
Andreas Mülder hace 8 años
padre
commit
df7e048851

+ 20 - 22
plugins/org.yakindu.base.types/src/org/yakindu/base/types/resource/TypedResourceDescriptionStrategy.java

@@ -1,3 +1,11 @@
+/**
+ * Copyright (c) 2013 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.base.types.resource;
 
 import java.util.Map;
@@ -9,42 +17,41 @@ import org.eclipse.xtext.resource.IEObjectDescription;
 import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy;
 import org.eclipse.xtext.util.IAcceptor;
 import org.yakindu.base.types.EnumerationType;
+import org.yakindu.base.types.Package;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.TypeAlias;
 import org.yakindu.base.types.TypedElement;
 
 import com.google.common.collect.Maps;
 
-public  class TypedResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy {
+public class TypedResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy {
 
 	/**
 	 * This flag is true if the element has or contains elements with an unknown
 	 * resp. unsupported type
 	 */
 	public static final String HAS_UNKNOWN_TYPE = "has_unknown_type";
-	
+
 	/**
-	 * For types that are visible (<code>Type.isVisible()==true</code>) this
-	 * flag is true, otherwise false
+	 * For types that are visible (<code>Type.isVisible()==true</code>) this flag is
+	 * true, otherwise false
 	 */
 	public static final String IS_VISIBLE_TYPE = "is_visible_type";
 
 	/**
-	 * Type aliases whose original type is an enumeration type will have this
-	 * flag set to true, otherwise this flag is missing
+	 * Type aliases whose original type is an enumeration type will have this flag
+	 * set to true, otherwise this flag is missing
 	 */
 	public static final String IS_ALIAS_ON_ENUM = "is_alias_on_enum";
-	
-	/** 
+
+	/**
 	 * This flag indicates the if the type of a TypedElelemnt is complex or not
 	 */
 	public static final String HAS_COMPLEX_TYPE = "has_complex_type";
-	
+
 	public boolean createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
 		if (getQualifiedNameProvider() == null)
 			return false;
-		if(!shouldCreateDescription(eObject))
-			return false;
 		try {
 			QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(eObject);
 			if (qualifiedName != null) {
@@ -55,14 +62,9 @@ public  class TypedResourceDescriptionStrategy extends DefaultResourceDescriptio
 		} catch (Exception exc) {
 			exc.printStackTrace();
 		}
-		return true;
-	}
-	
-	protected boolean shouldCreateDescription(EObject object){
-		return true;
+		return eObject instanceof Package;
 	}
 
-
 	protected void defineUserData(EObject eObject, Map<String, String> userData) {
 		if (eObject instanceof TypedElement) {
 			userData.put(HAS_UNKNOWN_TYPE, String.valueOf(isUnknownType((TypedElement) eObject)));
@@ -78,16 +80,12 @@ public  class TypedResourceDescriptionStrategy extends DefaultResourceDescriptio
 		}
 	}
 
-
-	
 	protected boolean isUnknownType(TypedElement element) {
 		return false;
 	}
 
-	
 	protected boolean hasComplexType(TypedElement element) {
-		return false ; //element.getType() instanceof ComplexType; 
+		return false; // element.getType() instanceof ComplexType;
 	}
-	
 
 }

+ 13 - 2
plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/contentassist/STextProposalProvider.java

@@ -36,6 +36,7 @@ import org.yakindu.base.expressions.expressions.ElementReferenceExpression;
 import org.yakindu.base.expressions.expressions.FeatureCall;
 import org.yakindu.base.types.Operation;
 import org.yakindu.base.types.Type;
+import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.stext.services.STextGrammarAccess;
 import org.yakindu.sct.model.stext.stext.InterfaceScope;
 import org.yakindu.sct.model.stext.stext.InternalScope;
@@ -242,6 +243,11 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		if (element instanceof Type) {
 			return super.getDisplayString(element, qualifiedNameAsString, shortName);
 		}
+		if (element instanceof State) {
+			qualifiedNameAsString = getQualifiedNameConverter()
+					.toString(getQualifiedNameConverter().toQualifiedName(qualifiedNameAsString).skipFirst(1));
+			return super.getDisplayString(element, qualifiedNameAsString, shortName);
+		}
 
 		if (element == null || element.eIsProxy()) {
 			return qualifiedNameAsString;
@@ -302,6 +308,11 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		priorityOptimizer.accept(proposal);
 	}
 
+	public void completeActiveStateReferenceExpression_Value(EObject model, Assignment assignment,
+			ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+		lookupCrossReference(((CrossReference) assignment.getTerminal()), context, acceptor);
+	}
+
 	private void alterPriority(ICompletionProposal proposal, int delta) {
 		if (proposal == null || !(proposal instanceof ConfigurableCompletionProposal))
 			return;
@@ -310,8 +321,8 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 	}
 
 	/**
-	 * The acceptor delegate creates a Dummy EObject of type Keyword for the
-	 * User Help Hover integration
+	 * The acceptor delegate creates a Dummy EObject of type Keyword for the User
+	 * Help Hover integration
 	 * 
 	 */
 	public class AcceptorDelegate implements ICompletionProposalAcceptor {

+ 18 - 5
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/resource/SCTResourceDescriptionStrategy.java

@@ -14,9 +14,12 @@ import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy;
 import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy;
 import org.eclipse.xtext.util.IAcceptor;
-import org.yakindu.base.types.resource.TypedResourceDescriptionStrategy;
+import org.yakindu.base.types.Declaration;
+import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.stext.stext.InternalScope;
 
 /**
  * This implementation of {@link IDefaultResourceDescriptionStrategy} avoids the
@@ -25,14 +28,24 @@ import org.yakindu.sct.model.sgraph.Statechart;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class SCTResourceDescriptionStrategy extends TypedResourceDescriptionStrategy {
+public class SCTResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy {
 
 	@Override
 	public boolean createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
-		if (EcoreUtil.getRootContainer(eObject) instanceof Statechart)
-			return super.createEObjectDescriptions(eObject, acceptor);
+		if (EcoreUtil.getRootContainer(eObject) instanceof Statechart) {
+			if (eObject instanceof InternalScope)
+				return false;
+			if (shouldCreateEObjectDescription(eObject)) {
+				super.createEObjectDescriptions(eObject, acceptor);
+			}
+			return true;
+
+		}
 		return false;
 	}
-	
+
+	protected boolean shouldCreateEObjectDescription(EObject eObject) {
+		return eObject instanceof Statechart || eObject instanceof State || eObject instanceof Declaration;
+	}
 
 }

+ 0 - 37
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

@@ -30,7 +30,6 @@ import org.eclipse.xtext.resource.IEObjectDescription;
 import org.eclipse.xtext.resource.IResourceDescription;
 import org.eclipse.xtext.resource.IResourceDescriptions;
 import org.eclipse.xtext.scoping.IScope;
-import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider;
 import org.eclipse.xtext.scoping.impl.FilteringScope;
 import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
 import org.eclipse.xtext.scoping.impl.MapBasedScope;
@@ -71,8 +70,6 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 	@Inject
 	private IResourceScopeCache cache;
 	@Inject
-	private DefaultGlobalScopeProvider delegate;
-	@Inject
 	private STextLibraryGlobalScopeProvider libraryScope;
 	@Inject
 	private IPackageImport2URIMapper mapper;
@@ -86,12 +83,7 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 	public static final String FILE_EXTENSION = "sct";
 
 	public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
-		if (reference.getEReferenceType() == TypesPackage.Literals.PACKAGE) {
-			return delegate.getScope(context, reference, filter);
-		}
 		IScope parentScope = super.getScope(context, reference, filter);
-		parentScope = new SimpleScope(parentScope, delegate.getScope(context, reference, filter).getAllElements());
-		parentScope = filterExternalDeclarations(context, parentScope);
 		parentScope = new SimpleScope(parentScope, filterPropertiesOfLibrary(context, reference, filter).getAllElements());
 		final Statechart statechart = getStatechart(context);
 		parentScope = new TypeSystemAwareScope(parentScope, typeSystem, qualifiedNameProvider,
@@ -130,14 +122,6 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 		});
 	}
 
-	@Override
-	public IScope getScope(Resource resource, EReference reference) {
-		if (reference.getEReferenceType() == TypesPackage.Literals.PACKAGE) {
-			return delegate.getScope(resource, reference);
-		}
-		return super.getScope(resource, reference);
-	}
-
 	protected LinkedHashSet<URI> getImportedUris(final Resource resource) {
 		return cache.get(ImportUriGlobalScopeProvider.class.getName(), resource, new Provider<LinkedHashSet<URI>>() {
 			@Override
@@ -218,25 +202,4 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 			return IScope.NULLSCOPE;
 		return SelectableBasedScope.createScope(parent, description, filter, type, ignoreCase);
 	}
-
-	/**
-	 * Filter all Elements that are part of an SCT file from other resources to
-	 * avoid cross document referencing
-	 */
-	protected IScope filterExternalDeclarations(Resource context, IScope parentScope) {
-		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context,
-				ContextElementAdapter.class);
-		final URI resourceURI = provider != null ? provider.getElement().eResource().getURI() : context.getURI();
-		parentScope = new FilteringScope(parentScope, new Predicate<IEObjectDescription>() {
-			public boolean apply(IEObjectDescription input) {
-				if (FILE_EXTENSION.equals(input.getEObjectURI().fileExtension())) {
-					URI sourceURI = input.getEObjectURI().trimFragment();
-					return sourceURI.equals(resourceURI);
-				}
-				return true;
-			}
-		});
-		return parentScope;
-	}
-
 }

+ 46 - 7
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -20,10 +20,15 @@ import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
 import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.resource.impl.EObjectDescriptionLookUp;
 import org.eclipse.xtext.scoping.IScope;
 import org.eclipse.xtext.scoping.Scopes;
 import org.eclipse.xtext.scoping.impl.FilteringScope;
+import org.eclipse.xtext.scoping.impl.ImportNormalizer;
+import org.eclipse.xtext.scoping.impl.ImportScope;
 import org.eclipse.xtext.scoping.impl.SimpleScope;
 import org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler;
 import org.yakindu.base.expressions.expressions.ElementReferenceExpression;
@@ -36,8 +41,11 @@ import org.yakindu.base.types.Type;
 import org.yakindu.base.types.inferrer.ITypeSystemInferrer;
 import org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult;
 import org.yakindu.base.types.typesystem.ITypeSystem;
+import org.yakindu.sct.model.sgraph.Region;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.SpecificationElement;
+import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.model.sgraph.util.ContextElementAdapter;
 import org.yakindu.sct.model.stext.scoping.ContextPredicateProvider.EmptyPredicate;
@@ -61,6 +69,10 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
 	private ITypeSystemInferrer typeInferrer;
 	@Inject 
 	private ITypeSystem typeSystem;
+	@Inject
+	private IQualifiedNameProvider nameProvider;
+	@Inject
+	private ContextPredicateProvider predicateProvider;
 	
 	private static class ErrorHandlerDelegate<T> implements ErrorHandler<T> {
 
@@ -96,10 +108,29 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
 			return null;
 		}
 	}
+	
+	public IScope scope_ActiveStateReferenceExpression_value(EObject context, EReference reference) {
+		Statechart statechart = getStatechart(context);
+		if (statechart == null)
+			return IScope.NULLSCOPE;
+		List<State> allStates = EcoreUtil2.getAllContentsOfType(statechart, State.class);
+		IScope scope = Scopes.scopeFor(allStates, nameProvider, IScope.NULLSCOPE);
+		return new ImportScope(getActiveStateNormalizer(context), scope,
+				new EObjectDescriptionLookUp(Lists.newArrayList(scope.getAllElements())), reference.getEReferenceType(),
+				false);
+	}
 
-	@Inject
-	private ContextPredicateProvider predicateProvider;
-
+	protected List<ImportNormalizer> getActiveStateNormalizer(EObject context) {
+		SpecificationElement contextElement = getContextElement(context);
+		Region containingRegion = EcoreUtil2.getContainerOfType(contextElement, Region.class);
+		QualifiedName fullyQualifiedName = nameProvider.getFullyQualifiedName(containingRegion);
+		List<ImportNormalizer> normalizer = Lists.newArrayList();
+		while (!fullyQualifiedName.getSegments().isEmpty()) {
+			normalizer.add(new ImportNormalizer(fullyQualifiedName, true, false));
+			fullyQualifiedName = fullyQualifiedName.skipLast(1);
+		}
+		return normalizer;
+	}
 	/**
 	 * Scoping for types and taking imported namespaces into account e.g. in
 	 * variable declarations.
@@ -117,7 +148,7 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
 		unnamedScope = new FilteringScope(unnamedScope, predicate);
 		return new SimpleScope(unnamedScope, namedScope.getAllElements());
 	}
-
+	
 	public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
 
 		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
@@ -225,9 +256,17 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
 		return Scopes.scopeFor(scopeCandidates, scope);
 	}
 
-	/**
-	 * Returns the {@link Statechart} for a context element
-	 */
+	protected SpecificationElement getContextElement(EObject context) {
+		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context.eResource(),
+				ContextElementAdapter.class);
+
+		if (provider == null) {
+			return EcoreUtil2.getContainerOfType(context, SpecificationElement.class);
+		} else {
+			return (SpecificationElement) provider.getElement();
+		}
+	}
+	
 	protected Statechart getStatechart(EObject context) {
 		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context.eResource(),
 				ContextElementAdapter.class);

+ 34 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/SCTFileEditorOpener.java

@@ -10,15 +10,24 @@
 */
 package org.yakindu.sct.ui.editor.editor;
 
+import java.util.Arrays;
+import java.util.Map;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.FileEditorInput;
 import org.eclipse.xtext.ui.editor.IURIEditorOpener;
+import org.yakindu.sct.ui.editor.partitioning.DiagramPartitioningUtil;
 
 /**
  * Opens <code>.sct</code> files in corresponding statechart diagramm editor.
@@ -33,8 +42,31 @@ public class SCTFileEditorOpener implements IURIEditorOpener {
 		try {
 			IFile fileToOpen = toFile(uri);
 			if (fileToOpen != null) {
-				return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+				IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
 						.openEditor(new FileEditorInput(fileToOpen), StatechartDiagramEditor.ID);
+
+				if (editor instanceof DiagramEditor) {
+					DiagramEditor diagramEditor = (DiagramEditor) editor;
+					EObject targetElement = (EObject) diagramEditor.getDiagram().eResource().getEObject(uri.fragment());
+					if (targetElement == null) {
+						return editor;
+					}
+					View view = DiagramPartitioningUtil.findNotationView(targetElement);
+					if (view == null) {
+						return editor;
+					}
+					Diagram element = DiagramPartitioningUtil.getDiagramContaining(view.getElement());
+					diagramEditor = (DiagramEditor) DiagramPartitioningUtil.openEditor(element);
+					@SuppressWarnings("rawtypes")
+					Map editPartRegistry = diagramEditor.getDiagramGraphicalViewer().getEditPartRegistry();
+					EditPart targetEditPart = (EditPart) editPartRegistry.get(view);
+					if (targetEditPart != null) {
+						DiagramPartitioningUtil.selectElementsInDiagram(diagramEditor,
+								Arrays.asList(new EditPart[] { targetEditPart }));
+					}
+
+				}
+				return editor;
 			}
 		} catch (PartInitException e) {
 			e.printStackTrace();
@@ -46,7 +78,7 @@ public class SCTFileEditorOpener implements IURIEditorOpener {
 	public IEditorPart open(URI referenceOwnerURI, EReference reference, int indexInList, boolean select) {
 		return open(referenceOwnerURI, select);
 	}
-	
+
 	public IFile toFile(URI uri) {
 		if (uri.isPlatformResource()) {
 			String platformString = uri.toPlatformString(true);

+ 39 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/partitioning/DiagramPartitioningUtil.java

@@ -13,6 +13,7 @@ package org.yakindu.sct.ui.editor.partitioning;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import org.eclipse.core.resources.IFile;
@@ -24,7 +25,10 @@ import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.emf.transaction.TransactionalEditingDomain;
 import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart;
 import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
 import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
 import org.eclipse.gmf.runtime.notation.Diagram;
 import org.eclipse.gmf.runtime.notation.NotationFactory;
@@ -161,6 +165,41 @@ public class DiagramPartitioningUtil {
 		}
 		return null;
 	}
+	
+	
+	public static View findNotationView(EObject semanticElement) {
+		Collection<Diagram> objects = EcoreUtil.getObjectsByType(semanticElement.eResource().getContents(),
+				NotationPackage.Literals.DIAGRAM);
+		for (Diagram diagram : objects) {
+			TreeIterator<EObject> eAllContents = diagram.eAllContents();
+			while (eAllContents.hasNext()) {
+				EObject next = eAllContents.next();
+				if (next instanceof View) {
+					if (((View) next).getElement() == semanticElement) {
+						return ((View) next);
+					}
+				}
+			}
+		}
+		return null;
+	}
+	
+	public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
+		diagramPart.getDiagramGraphicalViewer().deselectAll();
+
+		EditPart firstPrimary = null;
+		for (Iterator<EditPart> it = editParts.iterator(); it.hasNext();) {
+			EditPart nextPart = it.next();
+			diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
+			if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
+				firstPrimary = nextPart;
+			}
+		}
+		if (!editParts.isEmpty()) {
+			diagramPart.getDiagramGraphicalViewer()
+					.reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0));
+		}
+	}
 
 	/**
 	 * Forces the user to close all opened editors for subdiagrams that are inlined.

+ 2 - 43
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/StatechartMarkerNavigationProvider.java

@@ -11,25 +11,18 @@
 package org.yakindu.sct.ui.editor.providers;
 
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.TreeIterator;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.gef.EditPart;
 import org.eclipse.gef.requests.DirectEditRequest;
 import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart;
 import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
 import org.eclipse.gmf.runtime.emf.ui.providers.marker.AbstractModelMarkerNavigationProvider;
 import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.xtext.EcoreUtil2;
 import org.yakindu.base.xtext.utils.gmf.directedit.IXtextAwareEditPart;
@@ -57,7 +50,7 @@ public class StatechartMarkerNavigationProvider extends AbstractModelMarkerNavig
 		if (targetElement == null) {
 			return;
 		}
-		View view = findNotationView(targetElement);
+		View view = DiagramPartitioningUtil.findNotationView(targetElement);
 		if (view == null) {
 			return;
 		}
@@ -67,7 +60,7 @@ public class StatechartMarkerNavigationProvider extends AbstractModelMarkerNavig
 
 		EditPart targetEditPart = (EditPart) editPartRegistry.get(view);
 		if (targetEditPart != null) {
-			selectElementsInDiagram(editor, Arrays.asList(new EditPart[] { targetEditPart }));
+			DiagramPartitioningUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[] { targetEditPart }));
 		}
 
 		try {
@@ -89,38 +82,4 @@ public class StatechartMarkerNavigationProvider extends AbstractModelMarkerNavig
 		}
 	}
 
-	protected View findNotationView(EObject semanticElement) {
-		Collection<Diagram> objects = EcoreUtil.getObjectsByType(semanticElement.eResource().getContents(),
-				NotationPackage.Literals.DIAGRAM);
-		for (Diagram diagram : objects) {
-			TreeIterator<EObject> eAllContents = diagram.eAllContents();
-			while (eAllContents.hasNext()) {
-				EObject next = eAllContents.next();
-				if (next instanceof View) {
-					if (((View) next).getElement() == semanticElement) {
-						return ((View) next);
-					}
-				}
-			}
-		}
-		return null;
-	}
-
-	public void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
-		diagramPart.getDiagramGraphicalViewer().deselectAll();
-
-		EditPart firstPrimary = null;
-		for (Iterator<EditPart> it = editParts.iterator(); it.hasNext();) {
-			EditPart nextPart = it.next();
-			diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
-			if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
-				firstPrimary = nextPart;
-			}
-		}
-		if (!editParts.isEmpty()) {
-			diagramPart.getDiagramGraphicalViewer()
-					.reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0));
-		}
-	}
-
 }