瀏覽代碼

Refactored integrated resource and validation infrastructure

Andreas Mülder 13 年之前
父節點
當前提交
5b115eadc6

+ 1 - 0
plugins/org.yakindu.sct.ui.editor/META-INF/MANIFEST.MF

@@ -62,5 +62,6 @@ Export-Package: org.yakindu.sct.ui.editor,
  org.yakindu.sct.ui.editor.providers,
  org.yakindu.sct.ui.editor.providers,
  org.yakindu.sct.ui.editor.submachine,
  org.yakindu.sct.ui.editor.submachine,
  org.yakindu.sct.ui.editor.utils,
  org.yakindu.sct.ui.editor.utils,
+ org.yakindu.sct.ui.editor.validation,
  org.yakindu.sct.ui.editor.wizards
  org.yakindu.sct.ui.editor.wizards
 Bundle-Vendor: YAKINDU
 Bundle-Vendor: YAKINDU

+ 2 - 0
plugins/org.yakindu.sct.ui.editor/plugin.xml

@@ -581,12 +581,14 @@
     <extension id="org.yakindu.sct.ui.editor.diagnostic" name="Statechart Diagram problems" point="org.eclipse.core.resources.markers">
     <extension id="org.yakindu.sct.ui.editor.diagnostic" name="Statechart Diagram problems" point="org.eclipse.core.resources.markers">
       <super type="org.eclipse.core.resources.problemmarker"/>
       <super type="org.eclipse.core.resources.problemmarker"/>
       <super type="org.eclipse.gmf.runtime.common.ui.services.marker"/>
       <super type="org.eclipse.gmf.runtime.common.ui.services.marker"/>
+      <super type="org.eclipse.xtext.ui.check.fast" />
       <persistent value="true"/>
       <persistent value="true"/>
    </extension>   
    </extension>   
    
    
     <extension id="org.yakindu.sct.ui.editor.xtext.diagnostic" name="Statechart Expression problems" point="org.eclipse.core.resources.markers">
     <extension id="org.yakindu.sct.ui.editor.xtext.diagnostic" name="Statechart Expression problems" point="org.eclipse.core.resources.markers">
       <super type="org.eclipse.core.resources.problemmarker"/>
       <super type="org.eclipse.core.resources.problemmarker"/>
       <super type="org.eclipse.gmf.runtime.common.ui.services.marker"/>
       <super type="org.eclipse.gmf.runtime.common.ui.services.marker"/>
+      <super type="org.eclipse.xtext.ui.check.fast" />
       <persistent value="true"/>
       <persistent value="true"/>
    </extension>   
    </extension>   
   
   

+ 39 - 14
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/StatechartDiagramEditor.java

@@ -10,12 +10,15 @@
  */
  */
 package org.yakindu.sct.ui.editor.editor;
 package org.yakindu.sct.ui.editor.editor;
 
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.draw2d.ConnectionLayer;
 import org.eclipse.draw2d.ConnectionLayer;
 import org.eclipse.draw2d.ViewportAwareConnectionLayerClippingStrategy;
 import org.eclipse.draw2d.ViewportAwareConnectionLayerClippingStrategy;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.transaction.ResourceSetChangeEvent;
 import org.eclipse.emf.transaction.ResourceSetChangeEvent;
 import org.eclipse.emf.transaction.ResourceSetListener;
 import org.eclipse.emf.transaction.ResourceSetListener;
 import org.eclipse.emf.transaction.ResourceSetListenerImpl;
 import org.eclipse.emf.transaction.ResourceSetListenerImpl;
@@ -35,9 +38,15 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
 import org.eclipse.ui.ide.IGotoMarker;
 import org.eclipse.ui.ide.IGotoMarker;
 import org.eclipse.xtext.ui.XtextProjectHelper;
 import org.eclipse.xtext.ui.XtextProjectHelper;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.ui.editor.DiagramActivator;
 import org.yakindu.sct.ui.editor.DiagramActivator;
+import org.yakindu.sct.ui.editor.extensions.ExpressionLanguageProviderExtensions;
+import org.yakindu.sct.ui.editor.extensions.ExpressionLanguageProviderExtensions.SemanticTarget;
+import org.yakindu.sct.ui.editor.extensions.IExpressionLanguageProvider;
 import org.yakindu.sct.ui.editor.utils.HelpContextIds;
 import org.yakindu.sct.ui.editor.utils.HelpContextIds;
-import org.yakindu.sct.ui.editor.validation.ValidationAction;
+import org.yakindu.sct.ui.editor.validation.SCTValidationJob;
+
+import com.google.inject.Injector;
 
 
 import de.itemis.xtext.utils.gmf.resource.DirtyStateListener;
 import de.itemis.xtext.utils.gmf.resource.DirtyStateListener;
 
 
@@ -52,14 +61,29 @@ public class StatechartDiagramEditor extends DiagramDocumentEditor implements
 	public static final String ID = "org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor";
 	public static final String ID = "org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor";
 
 
 	private ResourceSetListener validationListener = new ResourceSetListenerImpl() {
 	private ResourceSetListener validationListener = new ResourceSetListenerImpl() {
+
 		@Override
 		@Override
 		public void resourceSetChanged(ResourceSetChangeEvent event) {
 		public void resourceSetChanged(ResourceSetChangeEvent event) {
-			validate();
+			for (Notification notification : event.getNotifications()) {
+				if (notification.getNotifier() instanceof EObject
+						&& notification.getEventType() != Notification.REMOVING_ADAPTER
+						&& notification.getEventType() != Notification.RESOLVE) {
+					EObject eObject = (EObject) notification.getNotifier();
+					if (SGraphPackage.eINSTANCE == eObject.eClass()
+							.getEPackage()) {
+						validationJob.cancel();
+						validationJob.schedule();
+						return;
+					}
+				}
+			}
 		}
 		}
 	};
 	};
 
 
 	private DirtyStateListener domainAdapter;
 	private DirtyStateListener domainAdapter;
 
 
+	private SCTValidationJob validationJob;
+
 	public StatechartDiagramEditor() {
 	public StatechartDiagramEditor() {
 		super(true);
 		super(true);
 	}
 	}
@@ -70,6 +94,18 @@ public class StatechartDiagramEditor extends DiagramDocumentEditor implements
 		super.init(site, input);
 		super.init(site, input);
 		getEditingDomain().addResourceSetListener(validationListener);
 		getEditingDomain().addResourceSetListener(validationListener);
 		checkXtextNature();
 		checkXtextNature();
+		initValidationJob();
+	}
+
+	private void initValidationJob() {
+		final IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+		validationJob = new SCTValidationJob(getDiagram());
+		IExpressionLanguageProvider registeredProvider = ExpressionLanguageProviderExtensions
+				.getRegisteredProvider(SemanticTarget.StatechartSpecification,
+						file.getFileExtension());
+		Injector injector = registeredProvider.getInjector();
+		injector.injectMembers(validationJob);
+		validationJob.setRule(file);
 	}
 	}
 
 
 	private void checkXtextNature() {
 	private void checkXtextNature() {
@@ -103,18 +139,6 @@ public class StatechartDiagramEditor extends DiagramDocumentEditor implements
 		return domain;
 		return domain;
 	}
 	}
 
 
-	@Override
-	protected void sanityCheckState(IEditorInput input) {
-		super.sanityCheckState(input);
-		validate();
-	}
-
-	protected void validate() {
-		if (getDiagram() != null) {
-			ValidationAction.validate(getDiagramEditPart(), getDiagram());
-		}
-	}
-
 	public void gotoMarker(IMarker marker) {
 	public void gotoMarker(IMarker marker) {
 		MarkerNavigationService.getInstance().gotoMarker(this, marker);
 		MarkerNavigationService.getInstance().gotoMarker(this, marker);
 	}
 	}
@@ -156,6 +180,7 @@ public class StatechartDiagramEditor extends DiagramDocumentEditor implements
 
 
 	@Override
 	@Override
 	public void dispose() {
 	public void dispose() {
+		validationJob.cancel();
 		getEditingDomain().removeResourceSetListener(validationListener);
 		getEditingDomain().removeResourceSetListener(validationListener);
 		getEditingDomain().removeResourceSetListener(domainAdapter);
 		getEditingDomain().removeResourceSetListener(domainAdapter);
 		domainAdapter.dispose();
 		domainAdapter.dispose();

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

@@ -68,7 +68,7 @@ public class StatechartMarkerNavigationProvider extends
 
 
 		try {
 		try {
 			String type = marker.getType();
 			String type = marker.getType();
-			if (type.equals(XTEXT_MARKER_TYPE)) {
+			if (type.equals(SCT_MARKER_TYPE)) {
 				final DirectEditRequest request = new DirectEditRequest();
 				final DirectEditRequest request = new DirectEditRequest();
 				request.setDirectEditFeature(SGraphPackage.eINSTANCE
 				request.setDirectEditFeature(SGraphPackage.eINSTANCE
 						.getSpecificationElement_Specification());
 						.getSpecificationElement_Specification());

+ 11 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/StatechartPaletteProvider.java

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2010 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.ui.editor.providers;
 package org.yakindu.sct.ui.editor.providers;
 
 
 import java.util.Map;
 import java.util.Map;
@@ -11,7 +21,7 @@ public class StatechartPaletteProvider extends DefaultPaletteProvider {
 
 
 	@Override
 	@Override
 	public void contributeToPalette(IEditorPart editor, Object content,
 	public void contributeToPalette(IEditorPart editor, Object content,
-			PaletteRoot root, Map predefinedEntries) {
+			PaletteRoot root, @SuppressWarnings("rawtypes") Map predefinedEntries) {
 		if (editor instanceof StatechartDiagramEditor) {
 		if (editor instanceof StatechartDiagramEditor) {
 			StatechartDiagramEditor scEditor = (StatechartDiagramEditor) editor;
 			StatechartDiagramEditor scEditor = (StatechartDiagramEditor) editor;
 			if (StatechartDiagramEditor.ID.equals(scEditor.getContributorId())) {
 			if (StatechartDiagramEditor.ID.equals(scEditor.getContributorId())) {

+ 2 - 9
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/StatechartValidationDecorationProvider.java

@@ -78,10 +78,6 @@ public class StatechartValidationDecorationProvider extends AbstractProvider
 			Object model = editPart.getModel();
 			Object model = editPart.getModel();
 			if ((model instanceof View)) {
 			if ((model instanceof View)) {
 				View view = (View) model;
 				View view = (View) model;
-				// FIXME
-				// if (!(view instanceof Edge) && !view.isSetElement()) {
-				// return;
-				// }
 			}
 			}
 			EditDomain ed = editPart.getViewer().getEditDomain();
 			EditDomain ed = editPart.getViewer().getEditDomain();
 			if (!(ed instanceof DiagramEditDomain)) {
 			if (!(ed instanceof DiagramEditDomain)) {
@@ -175,9 +171,7 @@ public class StatechartValidationDecorationProvider extends AbstractProvider
 			List<IMarker> markers = Lists.newArrayList();
 			List<IMarker> markers = Lists.newArrayList();
 			try {
 			try {
 				markers.addAll(Arrays.asList(resource.findMarkers(
 				markers.addAll(Arrays.asList(resource.findMarkers(
-						DIAGRAM_MARKER_TYPE, true, IResource.DEPTH_INFINITE)));
-				markers.addAll(Arrays.asList(resource.findMarkers(
-						XTEXT_MARKER_TYPE, true, IResource.DEPTH_INFINITE)));
+						SCT_MARKER_TYPE, true, IResource.DEPTH_INFINITE)));
 			} catch (CoreException e) {
 			} catch (CoreException e) {
 				e.printStackTrace();
 				e.printStackTrace();
 			}
 			}
@@ -354,8 +348,7 @@ public class StatechartValidationDecorationProvider extends AbstractProvider
 		}
 		}
 
 
 		public void handleMarkerChanged(IMarker marker) {
 		public void handleMarkerChanged(IMarker marker) {
-			if (!DIAGRAM_MARKER_TYPE.equals(getType(marker))
-					&& !XTEXT_MARKER_TYPE.equals(getType(marker))) {
+			if (!SCT_MARKER_TYPE.equals(getType(marker))) {
 				return;
 				return;
 			}
 			}
 			String viewId = marker
 			String viewId = marker

+ 0 - 121
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/validation/GMFMarkerUtil.java

@@ -1,121 +0,0 @@
-/**
- * Copyright (c) 2011 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.ui.editor.validation;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.xtext.EcoreUtil2;
-
-/**
- * Utility class to create GMF specific {@link IMarker}s
- * 
- * @author andreas muelder
- * 
- */
-public final class GMFMarkerUtil {
-
-	private GMFMarkerUtil() {
-		// Not to be instantiated
-	}
-
-	/**
-	 * Creates an marker with additional GMF specific attributes.
-	 * 
-	 * @param target
-	 *            The {@link IResource} where to create the marker
-	 * @param validationStatus
-	 *            Can be ERROR, WARNING, INFO
-	 * @param diagram
-	 *            the GMF Notation model diagram
-	 * @param markerType
-	 *            marker type
-	 * @param semanticTarget
-	 *            the semantic object where the problem occured
-	 */
-	public static void createMarker(IFile target, IStatus validationStatus,
-			Diagram diagram, String markerType, EObject semanticTarget) {
-		if (validationStatus.isOK()) {
-			return;
-		}
-		View view = findNotationView(diagram, semanticTarget);
-		if (view == null)
-			return;
-		String uriFragment = view.eResource().getURIFragment(view);
-
-		addMarker(target, uriFragment,
-				EMFCoreUtil.getQualifiedName(semanticTarget, true),
-				validationStatus.getMessage(), validationStatus.getSeverity(),
-				markerType);
-
-	}
-
-	private static View findNotationView(Diagram diagram,
-			EObject semanticElement) {
-		List<EObject> allNotationElements = EcoreUtil2
-				.eAllContentsAsList(diagram);
-		for (EObject eObject : allNotationElements) {
-			if (eObject instanceof View
-					&& semanticElement.equals(((View) eObject).getElement())) {
-				return (View) eObject;
-			}
-		}
-		if (semanticElement.eContainer() != null) {
-			return findNotationView(diagram, semanticElement.eContainer());
-		}
-		return null;
-
-	}
-
-	public static IFile getTargetFile(View view) {
-		IFile target = view.eResource() != null ? WorkspaceSynchronizer
-				.getFile(view.eResource().getResourceSet().getResources()
-						.get(0)) : null;
-		return target;
-	}
-
-	private static IMarker addMarker(IFile file, String elementId,
-			String location, String message, int statusSeverity,
-			String markerType) {
-		IMarker marker = null;
-		try {
-			marker = file.createMarker(markerType);
-			marker.setAttribute(IMarker.MESSAGE, message);
-			marker.setAttribute(IMarker.LOCATION, location);
-			org.eclipse.core.runtime.Assert.isNotNull(elementId);
-			org.eclipse.core.runtime.Assert.isTrue(elementId.length() > 0);
-			marker.setAttribute(
-					org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID,
-					elementId);
-			int markerSeverity = IMarker.SEVERITY_INFO;
-			if (statusSeverity == IStatus.WARNING) {
-				markerSeverity = IMarker.SEVERITY_WARNING;
-			} else if (statusSeverity == IStatus.ERROR
-					|| statusSeverity == IStatus.CANCEL) {
-				markerSeverity = IMarker.SEVERITY_ERROR;
-			}
-			marker.setAttribute(IMarker.SEVERITY, markerSeverity);
-		} catch (CoreException e) {
-			e.printStackTrace();
-		}
-		return marker;
-	}
-
-}

+ 1 - 4
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/validation/IMarkerType.java

@@ -19,10 +19,7 @@ import org.yakindu.sct.ui.editor.DiagramActivator;
  */
  */
 public interface IMarkerType {
 public interface IMarkerType {
 
 
-	public static final String DIAGRAM_MARKER_TYPE = DiagramActivator.PLUGIN_ID
+	public static final String SCT_MARKER_TYPE = DiagramActivator.PLUGIN_ID
 			+ ".diagnostic";
 			+ ".diagnostic";
 
 
-	public static final String XTEXT_MARKER_TYPE = DiagramActivator.PLUGIN_ID
-			+ ".xtext.diagnostic";
-
 }
 }

+ 169 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/validation/SCTValidationJob.java

@@ -0,0 +1,169 @@
+/**
+ * Copyright (c) 2012 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.ui.editor.validation;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.xtext.ui.editor.validation.MarkerCreator;
+import org.eclipse.xtext.util.CancelIndicator;
+import org.eclipse.xtext.validation.CheckMode;
+import org.eclipse.xtext.validation.IResourceValidator;
+import org.eclipse.xtext.validation.Issue;
+import org.yakindu.sct.model.sgraph.resource.AbstractSCTResource;
+import org.yakindu.sct.ui.editor.DiagramActivator;
+
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SCTValidationJob extends Job implements IMarkerType {
+
+	@Inject
+	private IResourceValidator validator;
+	@Inject
+	private MarkerCreator creator;
+
+	private Diagram diagram;
+
+	/**
+	 * Wrappes the {@link IResourceValidator} validate within a
+	 * {@link RunnableWithResult} to execute within a read only transaction
+	 * 
+	 * @author andreas muelder - Initial contribution and API
+	 * 
+	 */
+	public static class TransactionalValidationRunner extends
+			RunnableWithResult.Impl<List<Issue>> {
+
+		private IResourceValidator validator;
+		private Resource resource;
+		private CheckMode checkMode;
+		private CancelIndicator indicator;
+
+		public TransactionalValidationRunner(IResourceValidator validator,
+				Resource resource, CheckMode checkMode,
+				CancelIndicator indicator) {
+			this.validator = validator;
+			this.resource = resource;
+			this.checkMode = checkMode;
+			this.indicator = indicator;
+
+		}
+
+		public void run() {
+			List<Issue> result = validator.validate(resource, checkMode,
+					indicator);
+			setResult(result);
+			setStatus(Status.OK_STATUS);
+		}
+	}
+
+	public SCTValidationJob(final Diagram diagram) {
+		super("validation");
+		this.diagram = diagram;
+	}
+
+	@Override
+	public IStatus run(final IProgressMonitor monitor) {
+		try {
+			final AbstractSCTResource eResource = (AbstractSCTResource) diagram
+					.eResource();
+			final IFile target = WorkspaceSynchronizer.getFile(eResource);
+			relinkModel(monitor, eResource);
+			if (monitor.isCanceled())
+				return Status.CANCEL_STATUS;
+
+			TransactionalValidationRunner runner = new TransactionalValidationRunner(
+					validator, eResource, CheckMode.ALL, new CancelIndicator() {
+						public boolean isCanceled() {
+							return monitor.isCanceled();
+
+						}
+					});
+			TransactionUtil.getEditingDomain(diagram).runExclusive(runner);
+			final List<Issue> issues = runner.getResult();
+
+			if (issues == null)
+				return Status.CANCEL_STATUS;
+			refreshMarkers(target, issues, monitor);
+
+		} catch (Exception ex) {
+			ex.printStackTrace();
+			return new Status(IStatus.ERROR, DiagramActivator.PLUGIN_ID,
+					ex.getMessage());
+		}
+		return Status.OK_STATUS;
+	}
+
+	/**
+	 * Updates the markers. Execute the marker update in the UI thread, the
+	 * problem markers // will flicker otherwise
+	 */
+	private void refreshMarkers(final IFile target, final List<Issue> issues,
+			final IProgressMonitor monitor) {
+		PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+			public void run() {
+				try {
+					target.deleteMarkers(SCT_MARKER_TYPE, true,
+							IResource.DEPTH_ZERO);
+					for (Issue issue : issues) {
+						if (monitor.isCanceled())
+							return;
+						creator.createMarker(issue, target, SCT_MARKER_TYPE);
+					}
+				} catch (CoreException e) {
+					throw new WrappedException(e);
+				}
+			}
+		});
+	}
+
+	/**
+	 * relinks the model before validation is executed
+	 */
+	protected void relinkModel(final IProgressMonitor monitor,
+			final AbstractSCTResource eResource) throws ExecutionException {
+		AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(
+				TransactionUtil.getEditingDomain(eResource), "", null) {
+			@Override
+			protected CommandResult doExecuteWithResult(
+					IProgressMonitor monitor, IAdaptable info)
+					throws ExecutionException {
+				eResource.linkSpecificationElements();
+				return CommandResult.newOKCommandResult();
+
+			}
+		};
+		cmd.execute(monitor, null);
+	}
+
+}

+ 0 - 75
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/validation/ValidationAction.java

@@ -1,75 +0,0 @@
-/**
- * Copyright (c) 2011 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.ui.editor.validation;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.BasicDiagnostic;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.Diagnostician;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.notation.Diagram;
-
-import de.itemis.xtext.utils.gmf.resource.InjectMembersResource;
-
-/**
- * Executes the Validation and creates Problem Markers on the resource.
- * 
- * @author andreas muelder
- * 
- */
-public class ValidationAction implements IMarkerType {
-
-	/**
-	 * Perform the validation as a job to avoid blocking the UI Thread.
-	 */
-	public static void validate(DiagramEditPart diagramEditPart,
-			final Diagram view) {
-
-		IFile target = GMFMarkerUtil.getTargetFile(view);
-		if (target != null) {
-			try {
-				target.deleteMarkers(DIAGRAM_MARKER_TYPE, true,
-						IResource.DEPTH_ZERO);
-				target.deleteMarkers(XTEXT_MARKER_TYPE, true,
-						IResource.DEPTH_ZERO);
-			} catch (CoreException e) {
-				e.printStackTrace();
-			}
-		}
-
-		// // Ecore constraints
-		Diagnostic diagnostic = Diagnostician.INSTANCE.validate(view
-				.getElement());
-		List<Diagnostic> children = diagnostic.getChildren();
-		for (Diagnostic child : children) {
-			GMFMarkerUtil.createMarker(target,
-					BasicDiagnostic.toIStatus(child), view,
-					DIAGRAM_MARKER_TYPE, (EObject) child.getData().get(0));
-		}
-
-		// Diagnosticans from the InjectMembersResoruce
-		if (view.eResource() instanceof InjectMembersResource) {
-			InjectMembersResource resource = (InjectMembersResource) view
-					.eResource();
-			List<Diagnostic> diagnostics = resource.getDiagnostics();
-			for (Diagnostic child : diagnostics) {
-				GMFMarkerUtil.createMarker(target,
-						BasicDiagnostic.toIStatus(child), view,
-						XTEXT_MARKER_TYPE, (EObject) child.getData().get(0));
-			}
-		}
-	}
-}