summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhubner2008-11-26 10:33:29 (EST)
committerdhubner2008-11-26 10:33:29 (EST)
commit20d3ec8eec5c50d9c172d99ca72d27e6fc4f4b0b (patch)
tree53636631730759415d886afca5a8f78fe208ebbc
parentaae51df0e8a0df03b107dac14fd3676d6f8fc82b (diff)
downloadorg.eclipse.xpand-20d3ec8eec5c50d9c172d99ca72d27e6fc4f4b0b.zip
org.eclipse.xpand-20d3ec8eec5c50d9c172d99ca72d27e6fc4f4b0b.tar.gz
org.eclipse.xpand-20d3ec8eec5c50d9c172d99ca72d27e6fc4f4b0b.tar.bz2
[254711] Constraints per Property
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/EEditor.java7
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/MarkerHandler.java5
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ModelCheckor.java39
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java2
4 files changed, 41 insertions, 12 deletions
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/EEditor.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/EEditor.java
index 77029da..876c3a6 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/EEditor.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/EEditor.java
@@ -100,7 +100,7 @@ public class EEditor extends EcoreEditor implements ChangeListener {
}
/**
- * To provide custom (oAW-Powered) labels and images
+ * To provide custom (Xtend/Xpand-Powered) labels and images
*
* @param caf
*
@@ -114,7 +114,7 @@ public class EEditor extends EcoreEditor implements ChangeListener {
ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
ExtendedReflectiveItemProviderAdapterFactory extendedReflectiveItemProviderAdapterFactory = new ExtendedReflectiveItemProviderAdapterFactory(
- new DecoratingItemLabelProvider(customProvider, decorator),facade);
+ new DecoratingItemLabelProvider(customProvider, decorator), facade);
caf.addAdapterFactory(extendedReflectiveItemProviderAdapterFactory);
// register item provider for details view
@@ -265,7 +265,8 @@ public class EEditor extends EcoreEditor implements ChangeListener {
}
public void checkModel() {
- final List<MessageData> messages = new ModelCheckor(facade).check(getEditingDomain(), getFile());
+ final List<MessageData> messages = new ModelCheckor(facade).check(extendedReflectiveItemProvider,
+ getEditingDomain(), getFile());
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/MarkerHandler.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/MarkerHandler.java
index f9cfafe..f626472 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/MarkerHandler.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/MarkerHandler.java
@@ -49,7 +49,7 @@ public class MarkerHandler {
}
}
- void addMarker(final IFile file, final String message, final int severity) {
+ void addMarker(final IFile file, final String message, final int severity, final String location) {
checkResource(file);
run(new WorkspaceModifyOperation() {
@@ -71,6 +71,8 @@ public class MarkerHandler {
break;
}
marker.setAttribute(IMarker.SEVERITY, status);
+ if (location != null)
+ marker.setAttribute(IMarker.LOCATION, location);
}
catch (CoreException e) {
e.printStackTrace();
@@ -78,5 +80,4 @@ public class MarkerHandler {
}
}, new NullProgressMonitor());
}
-
} \ No newline at end of file
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ModelCheckor.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ModelCheckor.java
index 5d4ed7d..a4dff78 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ModelCheckor.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ModelCheckor.java
@@ -16,6 +16,7 @@
package org.eclipse.emf.editor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -34,6 +35,7 @@ import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.action.ValidateAction.EclipseResourcesUtil;
import org.eclipse.emf.editor.extxpt.ExtXptFacade;
import org.eclipse.emf.editor.extxpt.ExtXptHelper;
+import org.eclipse.emf.editor.provider.ExtendedReflectiveItemProviderAdapterFactory.ExtendedReflectiveItemProvider;
import org.eclipse.emf.mwe.core.issues.Issues;
import org.eclipse.emf.mwe.core.issues.MWEDiagnostic;
import org.eclipse.jface.dialogs.IMessageProvider;
@@ -54,7 +56,8 @@ public class ModelCheckor {
this.facade = facade;
}
- public List<MessageData> check(EditingDomain ed, IFile file) {
+ public List<MessageData> check(ExtendedReflectiveItemProvider extendedReflectiveItemProvider, EditingDomain ed,
+ IFile file) {
ResourceSet toCheck = ed.getResourceSet();
List<MessageData> messages = new ArrayList<MessageData>();
markerHandler.deleteMarkers(file, new NullProgressMonitor());
@@ -75,7 +78,23 @@ public class ModelCheckor {
// xtend checks
List<MessageData> checkValidation = checkValidation(rootObject);
for (MessageData md : checkValidation) {
- markerHandler.addMarker(file, md.getMessage(), md.getStatus());
+ List<?> data = md.getData();
+ String location = null;
+ Iterator<?> iterator = data.iterator();
+ Object o = iterator.next();// object index 0
+ if (o instanceof EObject) {
+ EObject eO = (EObject) o;
+ location = extendedReflectiveItemProvider.getText(eO);
+ Object obj = iterator.next();// feature index 1
+ // TODO get location using Element and Feature
+ // from
+ // md.getData()
+ if (obj instanceof EStructuralFeature) {
+ EStructuralFeature f = (EStructuralFeature) obj;
+ location += ("#" + f.getName());
+ }
+ }
+ markerHandler.addMarker(file, md.getMessage(), md.getStatus(), location);
}
// ecore
messages.addAll(checkValidation);
@@ -150,18 +169,26 @@ public class ModelCheckor {
private MessageData createMessageFromIssue(MWEDiagnostic issue, int type) {
String message = issue.getMessage();
Object element = issue.getElement();
- MessageData md = new MessageData(element, message, null, type);
+ MessageData md = new MessageData(element, message, issue.getData(), type);
List<Object> data = new ArrayList<Object>();
if (element instanceof EObject) {
EObject eObject = (EObject) element;
data.add(0, element);
- EStructuralFeature feature = ExtXptHelper.extractFeatureFromMessage(eObject, md);
+ EStructuralFeature feature = null;
+ // read fetureName stored in the data
+ if (issue.getData() != null && issue.getData().size() > 1
+ && String.class.isInstance(issue.getData().get(1))) {
+ feature = eObject.eClass().getEStructuralFeature((String) issue.getData().get(1));
+ }
+ // if nothing found try old extract from message way
+ else {
+ feature = ExtXptHelper.extractFeatureFromMessage(eObject, md);
+ }
if (feature != null) {
data.add(1, feature);
}
}
- md.setData(data);
-
+ md.setData(Collections.unmodifiableList(data));
return md;
}
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java
index 45378bd..1c99501 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java
@@ -118,7 +118,7 @@ public class ExtXptFacade {
TreeIterator<EObject> iter = rootContainer.eAllContents();
while (iter.hasNext())
all.add(iter.next());
- IssuesImpl issuesImpl = new IssuesImpl();
+ Issues issuesImpl = new IssuesImpl();
IXtendXpandProject extxptProject = Activator.getExtXptModelManager().findProject(project);
if (extxptProject != null) {
IXtendXpandResource extxptResource = extxptProject.findExtXptResource(checkFile, CheckUtils.FILE_EXTENSION);