summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhubner2008-10-27 11:27:17 (EDT)
committerdhubner2008-10-27 11:27:17 (EDT)
commit131ac6f9df82507ea2ac397ccfdaa41bcc0e0d75 (patch)
tree6cf69d0cf6cb092581691eb7f0afb777989b760b
parent0f74d93e4d6456916abf5bdbaac97689d9804ef6 (diff)
downloadorg.eclipse.xpand-131ac6f9df82507ea2ac397ccfdaa41bcc0e0d75.zip
org.eclipse.xpand-131ac6f9df82507ea2ac397ccfdaa41bcc0e0d75.tar.gz
org.eclipse.xpand-131ac6f9df82507ea2ac397ccfdaa41bcc0e0d75.tar.bz2
checks/extensions enabled
-rw-r--r--examples/org.eclipse.emf.generic.editor/META-INF/MANIFEST.MF11
-rw-r--r--examples/org.eclipse.emf.generic.editor/plugin.xml34
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/EEditor.java68
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ModelCheckor.java44
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java (renamed from examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawFacade.java)59
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptHelper.java (renamed from examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawHelper.java)4
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/WorkspaceResourceManager.java51
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/WorkspaceResourceManager.java56
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ClasspathUriResolver.java3
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ExtendedLabelProvider.java6
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/GenericDetailsPage.java2
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/ProposalCreator.java6
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/EmfSwtBindingFactory.java74
-rw-r--r--examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/SelectionProviderMultipleSelectionObservableList.java122
14 files changed, 248 insertions, 292 deletions
diff --git a/examples/org.eclipse.emf.generic.editor/META-INF/MANIFEST.MF b/examples/org.eclipse.emf.generic.editor/META-INF/MANIFEST.MF
index eb515dc..4cdd526 100644
--- a/examples/org.eclipse.emf.generic.editor/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.emf.generic.editor/META-INF/MANIFEST.MF
@@ -9,15 +9,14 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.forms,
org.eclipse.core.resources,
org.eclipse.jface.databinding,
- org.eclipse.emf.databinding,
org.eclipse.emf.databinding.edit,
- org.eclipse.xtend;bundle-version="0.7.0",
- org.eclipse.xtend.util.stdlib;bundle-version="0.7.0",
- org.eclipse.xtend.typesystem.emf;bundle-version="0.7.0",
- org.eclipse.jdt.core;bundle-version="3.4.2"
+ org.eclipse.xtend,
+ org.eclipse.xtend.typesystem.emf,
+ org.eclipse.jdt.core;bundle-version="3.4.2",
+ org.eclipse.xtend.shared.ui
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.emf.editor,
- org.eclipse.emf.editor.oaw,
+ org.eclipse.emf.editor.extxpt,
org.eclipse.emf.editor.provider,
org.eclipse.emf.editor.ui,
org.eclipse.emf.editor.ui.binding
diff --git a/examples/org.eclipse.emf.generic.editor/plugin.xml b/examples/org.eclipse.emf.generic.editor/plugin.xml
index f908d6f..a18f52f 100644
--- a/examples/org.eclipse.emf.generic.editor/plugin.xml
+++ b/examples/org.eclipse.emf.generic.editor/plugin.xml
@@ -10,18 +10,30 @@
id="org.eclipse.emf.genericEditor"
name="Generic EMF Form Editor">
<contentTypeBinding
- contentTypeId="org.eclipse.emf.generic.editor.contentTypeBinding1">
+ contentTypeId="org.eclipse.emf.ecore.xmi">
+ </contentTypeBinding>
+ <contentTypeBinding
+ contentTypeId="org.eclipse.emf.emof">
+ </contentTypeBinding>
+ <contentTypeBinding
+ contentTypeId="org.eclipse.emf.generic.xmi">
</contentTypeBinding>
</editor>
</extension>
- <extension
- point="org.eclipse.core.contenttype.contentTypes">
- <content-type
- file-extensions="xmi,dsl"
- id="org.eclipse.emf.generic.editor.emf-instance"
- name="Dynamic Ecore Instance"
- priority="high">
- </content-type>
- </extension>
-
+<extension
+ point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.core.runtime.xml"
+ id="org.eclipse.emf.generic.xmi"
+ name="Ecore Instance"
+ priority="high">
+ <describer
+ class="org.eclipse.emf.ecore.xmi.impl.XMLContentHandlerImpl$XMI$Describer">
+ <parameter
+ name="org.eclipse.emf.generic.editor.parameter1"
+ value="org.eclipse.emf.generic.editor.parameter1">
+ </parameter>
+ </describer>
+ </content-type>
+ </extension>
</plugin>
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 9cd5087..5c068e9 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
@@ -15,6 +15,7 @@
*/
package org.eclipse.emf.editor;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -23,8 +24,11 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
@@ -35,7 +39,8 @@ import org.eclipse.emf.ecore.presentation.EcoreEditor;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.editor.oaw.OawFacade;
+import org.eclipse.emf.editor.extxpt.ExtXptFacade;
+import org.eclipse.emf.editor.extxpt.WorkspaceResourceManager;
import org.eclipse.emf.editor.provider.ExtendedLabelProvider;
import org.eclipse.emf.editor.provider.ExtendedReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.editor.provider.ExtendedReflectiveItemProviderAdapterFactory.ExtendedReflectiveItemProvider;
@@ -44,6 +49,7 @@ import org.eclipse.emf.editor.ui.EEMasterDetailsBlock;
import org.eclipse.emf.editor.ui.ImageRegistry;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -55,6 +61,7 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.IMessage;
import org.eclipse.ui.forms.IMessageManager;
@@ -66,21 +73,22 @@ import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.xtend.expression.ExecutionContext;
import org.eclipse.xtend.expression.ExecutionContextImpl;
import org.eclipse.xtend.expression.TypeSystemImpl;
+import org.eclipse.xtend.shared.ui.Activator;
import org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel;
/**
- * @author Dennis Huebner
+ * @author Dennis Hübner - Initial contribution and API
*
*/
public class EEditor extends EcoreEditor implements ChangeListener {
private static final String ESTRUCTURALFEATURE_KEY = EcorePackage.Literals.ESTRUCTURAL_FEATURE.getName();
- protected static final String MARKER_ID = null;
+ protected static final String MARKER_ID = Activator.getId() + ".problem";
private ManagedForm managedForm;
private EEMasterDetailsBlock mdBlock;
private IProject project;
- private OawFacade facade;
+ private ExtXptFacade facade;
private ExtendedReflectiveItemProvider extendedReflectiveItemProvider;
public EEditor() {
@@ -225,7 +233,7 @@ public class EEditor extends EcoreEditor implements ChangeListener {
*/
private void initInternal() {
project = getFile().getProject();
- facade = createOawFacade();
+ facade = createExtXptFacade();
if (editingDomain.getAdapterFactory() instanceof ComposedAdapterFactory) {
ComposedAdapterFactory caf = (ComposedAdapterFactory) editingDomain.getAdapterFactory();
rejectFactory(caf);
@@ -260,7 +268,7 @@ public class EEditor extends EcoreEditor implements ChangeListener {
*
*/
public void checkModel() {
- final List<MessageData> messages = new ModelCheckor().check(getEditingDomain().getResourceSet());
+ final List<MessageData> messages = new ModelCheckor(facade).check(getEditingDomain().getResourceSet());
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
IMessageManager messageManager = managedForm.getMessageManager();
@@ -268,6 +276,8 @@ public class EEditor extends EcoreEditor implements ChangeListener {
messageManager.setAutoUpdate(false);
for (MessageData md : messages) {
messageManager.addMessage(md.getKey(), md.getMessage(), md.getData(), md.getStatus());
+ if (getFile() != null)
+ addMarker(getFile(), md.getMessage(), md.getStatus());
}
messageManager.update();
messageManager.setAutoUpdate(true);
@@ -275,7 +285,41 @@ public class EEditor extends EcoreEditor implements ChangeListener {
});
}
- private OawFacade createOawFacade() {
+ private void addMarker(final IFile file, final String message, final int severity) {
+ try {
+ new WorkspaceModifyOperation() {
+
+ @Override
+ protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException,
+ InterruptedException {
+
+ try {
+ // FIXME own MarkerType
+ IMarker marker = file.createMarker(MARKER_ID);
+ marker.setAttribute(IMarker.MESSAGE, message);
+ int status = IMarker.SEVERITY_INFO;
+ switch (severity) {
+ case IMessageProvider.ERROR:
+ status = IMarker.SEVERITY_ERROR;
+ break;
+ case IMessageProvider.WARNING:
+ status = IMarker.SEVERITY_WARNING;
+ break;
+ }
+ marker.setAttribute(IMarker.SEVERITY, status);
+ }
+ catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }.run(new NullProgressMonitor());
+ }
+ catch (final Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private ExtXptFacade createExtXptFacade() {
final List<EPackage> packs = findMetaModelPackages();
TypeSystemImpl ts = new TypeSystemImpl();
ts.registerMetaModel(new EmfRegistryMetaModel() {
@@ -284,10 +328,10 @@ public class EEditor extends EcoreEditor implements ChangeListener {
return packs.toArray(new EPackage[packs.size()]);
}
});
- // FIXME new WorkspaceResourceManager(OawPlugin.getOawModelManager()
- // .findProject(project)),
- ExecutionContext context = new ExecutionContextImpl(ts, null);
- return new OawFacade(project, context);
+ ExecutionContext context = new ExecutionContextImpl(new WorkspaceResourceManager(Activator
+ .getExtXptModelManager().findProject(project)), ts, null);
+ return new ExtXptFacade(project, context);
+
}
private List<EPackage> findMetaModelPackages() {
@@ -326,7 +370,7 @@ public class EEditor extends EcoreEditor implements ChangeListener {
});
}
- public OawFacade getOawFacade() {
+ public ExtXptFacade getExtXptFacade() {
return facade;
}
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 b4a7e98..c582fd8 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
@@ -24,10 +24,15 @@ import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.Diagnostician;
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.mwe.core.issues.Issues;
+import org.eclipse.emf.mwe.core.issues.MWEDiagnostic;
import org.eclipse.jface.dialogs.IMessageProvider;
/**
@@ -38,6 +43,12 @@ public class ModelCheckor {
private EclipseResourcesUtil eclipseResourcesUtil = EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE ? new EclipseResourcesUtil()
: null;
+ private final ExtXptFacade facade;
+
+ public ModelCheckor(ExtXptFacade facade) {
+ super();
+ this.facade = facade;
+ }
public List<MessageData> check(ResourceSet toCheck) {
List<MessageData> messages = new ArrayList<MessageData>();
@@ -53,7 +64,15 @@ public class ModelCheckor {
continue;
EObject rootObject = allContents.next();
- messages.addAll(ecoreValidation(rootObject));
+ Issues issues = facade.check(rootObject);
+ for (MWEDiagnostic issue : issues.getErrors()) {
+ messages.add(createMessageFromIssue(issue, IMessageProvider.ERROR));
+ }
+ for (MWEDiagnostic issue : issues.getWarnings()) {
+ messages.add(createMessageFromIssue(issue, IMessageProvider.WARNING));
+ }
+ List<MessageData> ecoreValidation = ecoreValidation(rootObject);
+ messages.addAll(ecoreValidation);
}
}
}
@@ -72,7 +91,7 @@ public class ModelCheckor {
int status = IMessageProvider.INFORMATION;
// Clear Marker
if (eclipseResourcesUtil != null) {
- eclipseResourcesUtil.deleteMarkers(rootObject);
+ //eclipseResourcesUtil.deleteMarkers(rootObject);
}
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(rootObject);
@@ -109,4 +128,25 @@ public class ModelCheckor {
}
return mds;
}
+
+ /**
+ * @param issue
+ * @return
+ */
+ private MessageData createMessageFromIssue(MWEDiagnostic issue, int type) {
+ String message = issue.getMessage();
+ Object element = issue.getElement();
+ MessageData md = new MessageData(element, message, null, 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);
+ if (feature != null) {
+ data.add(1, feature);
+ }
+ }
+ md.setData(data);
+ return md;
+ }
} \ No newline at end of file
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawFacade.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java
index 66cbf77..45378bd 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawFacade.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java
@@ -13,7 +13,7 @@
* </copyright>
*
*/
-package org.eclipse.emf.editor.oaw;
+package org.eclipse.emf.editor.extxpt;
import java.util.ArrayList;
import java.util.List;
@@ -32,12 +32,15 @@ import org.eclipse.xtend.XtendFacade;
import org.eclipse.xtend.check.CheckUtils;
import org.eclipse.xtend.expression.EvaluationException;
import org.eclipse.xtend.expression.ExecutionContext;
+import org.eclipse.xtend.shared.ui.Activator;
+import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
+import org.eclipse.xtend.shared.ui.core.IXtendXpandResource;
/**
- * @author Dennis Huebner
+ * @author Dennis Hübner - Initial contribution and API
*
*/
-public class OawFacade {
+public class ExtXptFacade {
private IProject project;
private final ExecutionContext context;
@@ -45,13 +48,13 @@ public class OawFacade {
public static final String STYLE_EXT = "ItemLabelProvider";
public static final String PROPOSAL_EXT = "Proposals";
- public OawFacade(IProject project, ExecutionContext context) {
+ public ExtXptFacade(IProject project, ExecutionContext context) {
this.project = project;
this.context = context;
}
public Object style(String extension, EObject object) {
- String extendFile = path(object) + OawFacade.STYLE_EXT;
+ String extendFile = path(object) + ExtXptFacade.STYLE_EXT;
Object retVal = evaluate(extendFile, extension, object);
return retVal;
}
@@ -86,7 +89,7 @@ public class OawFacade {
// TODO split method
public List<?> proposals(EStructuralFeature feature, EObject ctx, List<?> fromList) {
- String extFile = path(ctx) + OawFacade.PROPOSAL_EXT;
+ String extFile = path(ctx) + ExtXptFacade.PROPOSAL_EXT;
List<?> retVal = new ArrayList<Object>();
Object eval;
if (fromList != null) {
@@ -108,37 +111,33 @@ public class OawFacade {
}
public Issues check(EObject rootObject) {
- String checkFile = path(rootObject) + OawFacade.CHECK_EXT;
+ String checkFile = path(rootObject) + ExtXptFacade.CHECK_EXT;
List<EObject> all = new ArrayList<EObject>();
all.add(rootObject);
EObject rootContainer = EcoreUtil.getRootContainer(rootObject);
TreeIterator<EObject> iter = rootContainer.eAllContents();
while (iter.hasNext())
all.add(iter.next());
-
IssuesImpl issuesImpl = new IssuesImpl();
- // FIXME IOawProject oAWProject =
- // OawPlugin.getOawModelManager().findProject(project);
- // if (oAWProject != null) {
- // IOawResource oawResource = oAWProject.findOawResource(checkFile,
- // CheckUtils.FILE_EXTENSION);
- // if (oawResource != null) {
- // ExtensionFile file = (ExtensionFile) oawResource.getOawResource();
- // try {
- // file.check(context, all, issuesImpl, false);
- // }
- // catch (IllegalArgumentException e) {
- // // no extension specified
- // }
- // catch (Exception e) {
- // EEPlugin.logError("Exception during check evaluation", e);
- // }
- // }
- // }
- // else {
- // EEPlugin.logWarning("Enable oAW-Nature for '" + project.getName() +
- // "' to check models.");
- // }
+ IXtendXpandProject extxptProject = Activator.getExtXptModelManager().findProject(project);
+ if (extxptProject != null) {
+ IXtendXpandResource extxptResource = extxptProject.findExtXptResource(checkFile, CheckUtils.FILE_EXTENSION);
+ if (extxptResource != null) {
+ ExtensionFile file = (ExtensionFile) extxptResource.getExtXptResource();
+ try {
+ file.check(context, all, issuesImpl, false);
+ }
+ catch (IllegalArgumentException e) {
+ // no extension specified
+ }
+ catch (Exception e) {
+ EEPlugin.logError("Exception during check evaluation", e);
+ }
+ }
+ }
+ else {
+ EEPlugin.logWarning("Enable Xtend/Xpand-Nature for '" + project.getName() + "' to check models.");
+ }
return issuesImpl;
}
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawHelper.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptHelper.java
index 0e18287..919a71a 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawHelper.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptHelper.java
@@ -13,7 +13,7 @@
* </copyright>
*
*/
-package org.eclipse.emf.editor.oaw;
+package org.eclipse.emf.editor.extxpt;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -24,7 +24,7 @@ import org.eclipse.emf.editor.MessageData;
* @author Dennis Huebner
*
*/
-public class OawHelper {
+public class ExtXptHelper {
static public EStructuralFeature extractFeatureFromMessage(EObject eObject,
MessageData md) {
String message = md.getMessage();
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/WorkspaceResourceManager.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/WorkspaceResourceManager.java
new file mode 100644
index 0000000..9a6aaf5
--- /dev/null
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/WorkspaceResourceManager.java
@@ -0,0 +1,51 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2008 itemis AG 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:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.emf.editor.extxpt;
+
+import org.eclipse.xtend.expression.Resource;
+import org.eclipse.xtend.expression.ResourceManager;
+import org.eclipse.xtend.expression.ResourceParser;
+import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
+import org.eclipse.xtend.shared.ui.core.IXtendXpandResource;
+
+/**
+ * @author Dennis Huebner
+ *
+ */
+public class WorkspaceResourceManager implements ResourceManager {
+
+ private IXtendXpandProject project;
+
+ public WorkspaceResourceManager(IXtendXpandProject p) {
+ this.project = p;
+ }
+
+ public Resource loadResource(String fullyQualifiedName, String extension) {
+ IXtendXpandResource extxptResource = project.findExtXptResource(fullyQualifiedName, extension);
+ if (extxptResource != null)
+ return extxptResource.getExtXptResource();
+ return null;
+ }
+
+ public void registerParser(String template_extension, ResourceParser parser) {
+ // not needed
+ }
+
+ public void setFileEncoding(String fileEncoding) {
+ // not needed
+ }
+
+}
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/WorkspaceResourceManager.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/WorkspaceResourceManager.java
deleted file mode 100644
index d41c88f..0000000
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/WorkspaceResourceManager.java
+++ /dev/null
@@ -1,56 +0,0 @@
-///**
-// * <copyright>
-// *
-// * Copyright (c) 2008 itemis AG 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:
-// * itemis AG - Initial API and implementation
-// *
-// * </copyright>
-// *
-// */
-//package org.eclipse.emf.editor.oaw;
-//
-//import org.eclipse.core.resources.IProject;
-//import org.eclipse.core.resources.IResource;
-//import org.eclipse.xtend.expression.Resource;
-//import org.eclipse.xtend.expression.ResourceManager;
-//import org.eclipse.xtend.expression.ResourceParser;
-//
-//
-///**
-// * @author Dennis Huebner
-// *
-// */
-//public class WorkspaceResourceManager implements ResourceManager {
-//
-// private IProject project;
-//
-// public WorkspaceResourceManager(IProject p) {
-// this.project = p;
-// }
-//
-// /* (non-Javadoc)
-// * @see org.eclipse.xtend.expression.ResourceManager#loadResource(java.lang.String, java.lang.String)
-// */
-// public Resource loadResource(String fullyQualifiedName, String extension) {
-// IResource oawResource = project.findOawResource(fullyQualifiedName,
-// extension);
-// if (oawResource != null)
-// return oawResource.getOawResource();
-// return null;
-// }
-//
-// public void registerParser(String template_extension, ResourceParser parser) {
-// // not needed
-// }
-//
-// public void setFileEncoding(String fileEncoding) {
-// // not needed
-// }
-//
-//}
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ClasspathUriResolver.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ClasspathUriResolver.java
index bfea535..57b1965 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ClasspathUriResolver.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ClasspathUriResolver.java
@@ -62,6 +62,7 @@ import org.osgi.framework.Bundle;
*
* @author koehnlein
*/
+@SuppressWarnings("restriction")
public class ClasspathUriResolver {
public static final String CLASSPATH_SCHEME = "classpath";
@@ -132,7 +133,6 @@ public class ClasspathUriResolver {
return fileUri;
}
- @SuppressWarnings("restriction")
private URI findResourceInBundle(Bundle bundle, URI classpathUri) throws MalformedURLException, IOException {
Path fullPath = new Path(classpathUri.path());
if (bundle != null) {
@@ -153,7 +153,6 @@ public class ClasspathUriResolver {
return classpathUri;
}
- @SuppressWarnings("restriction")
private URI findResourceInWorkspace(IJavaProject javaProject, URI classpathUri) throws JavaModelException,
CoreException {
Path fullPath = new Path(classpathUri.path());
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ExtendedLabelProvider.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ExtendedLabelProvider.java
index a3ca32b..b1e1c31 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ExtendedLabelProvider.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/provider/ExtendedLabelProvider.java
@@ -30,7 +30,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.editor.EEPlugin;
-import org.eclipse.emf.editor.oaw.OawFacade;
+import org.eclipse.emf.editor.extxpt.ExtXptFacade;
import org.eclipse.emf.editor.ui.ImageRegistry;
/**
@@ -42,10 +42,10 @@ public class ExtendedLabelProvider implements IItemLabelProvider {
private static final String ICONS_FOLDER = "icons";
private static final String ICON_EXTENSION_NAME = "icon";
private static final String LABEL_EXTENSION_NAME = "label";
- private final OawFacade facade;
+ private final ExtXptFacade facade;
private IItemLabelProvider registryItemLabelProvider;
- public ExtendedLabelProvider(OawFacade facade) {
+ public ExtendedLabelProvider(ExtXptFacade facade) {
this.facade = facade;
this.registryItemLabelProvider = new RegistryItemLabelProvider();
}
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/GenericDetailsPage.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/GenericDetailsPage.java
index 7df3042..b6c9314 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/GenericDetailsPage.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/GenericDetailsPage.java
@@ -157,7 +157,7 @@ public class GenericDetailsPage extends AbstractFormPart implements
factory = new EmfSwtBindingFactory(editor.getAdapterFactory(),
editor.getEditingDomain(), input, main, getManagedForm()
- .getToolkit(), editor.getOawFacade());
+ .getToolkit(), editor.getExtXptFacade());
final IActionBars actionBars = editor.getActionBars();
final IAction ecoreCopy = actionBars
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/ProposalCreator.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/ProposalCreator.java
index 65d0c5e..dc6138c 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/ProposalCreator.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/ProposalCreator.java
@@ -31,7 +31,7 @@ import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.impl.EEnumImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.editor.oaw.OawFacade;
+import org.eclipse.emf.editor.extxpt.ExtXptFacade;
/**
* @author Dennis Hübner
@@ -39,9 +39,9 @@ import org.eclipse.emf.editor.oaw.OawFacade;
*/
public class ProposalCreator {
private EditingDomain domain;
- private final OawFacade facade;
+ private final ExtXptFacade facade;
- public ProposalCreator(EditingDomain domain, OawFacade facade) {
+ public ProposalCreator(EditingDomain domain, ExtXptFacade facade) {
super();
this.domain = domain;
this.facade = facade;
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/EmfSwtBindingFactory.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/EmfSwtBindingFactory.java
index de02981..0c45aa3 100644
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/EmfSwtBindingFactory.java
+++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/EmfSwtBindingFactory.java
@@ -34,7 +34,7 @@ import org.eclipse.emf.ecore.impl.EEnumImpl;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.editor.EEPlugin;
-import org.eclipse.emf.editor.oaw.OawFacade;
+import org.eclipse.emf.editor.extxpt.ExtXptFacade;
import org.eclipse.emf.editor.ui.ProposalCreator;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
@@ -46,6 +46,7 @@ import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.jface.internal.databinding.viewers.SelectionProviderMultipleSelectionObservableList;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.swt.SWT;
@@ -61,6 +62,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
* @author Dennis Huebner
*
*/
+@SuppressWarnings("restriction")
public class EmfSwtBindingFactory {
private Composite parent = null;
private FormToolkit toolkit = null;
@@ -69,14 +71,11 @@ public class EmfSwtBindingFactory {
private final EMFDataBindingContext edbc;
private final AdapterFactory adapterFactory;
private final ProposalCreator proposalcreator;
- public static final String EOBJECT_KEY = EcorePackage.Literals.EOBJECT
- .getName();
- public static final String ESTRUCTURALFEATURE_KEY = EcorePackage.Literals.ESTRUCTURAL_FEATURE
- .getName();
+ public static final String EOBJECT_KEY = EcorePackage.Literals.EOBJECT.getName();
+ public static final String ESTRUCTURALFEATURE_KEY = EcorePackage.Literals.ESTRUCTURAL_FEATURE.getName();
- public EmfSwtBindingFactory(AdapterFactory adapterFactory,
- EditingDomain domain, EObject owner, Composite parent,
- FormToolkit toolkit, OawFacade facade) {
+ public EmfSwtBindingFactory(AdapterFactory adapterFactory, EditingDomain domain, EObject owner, Composite parent,
+ FormToolkit toolkit, ExtXptFacade facade) {
this.adapterFactory = adapterFactory;
this.edbc = new EMFDataBindingContext();
this.domain = domain;
@@ -98,7 +97,8 @@ public class EmfSwtBindingFactory {
Control retVal = null;
if (feature.isMany()) {
retVal = bindList(feature);
- } else {
+ }
+ else {
retVal = bindValue(feature);
}
setupControl(feature, retVal);
@@ -106,17 +106,14 @@ public class EmfSwtBindingFactory {
}
private Control bindList(EStructuralFeature feature) {
- IObservableList source = EMFEditObservables.observeList(domain, owner,
- feature);
+ IObservableList source = EMFEditObservables.observeList(domain, owner, feature);
List<?> choice = proposalcreator.proposals(owner, feature);
- MultipleFeatureControl mfc = new MultipleFeatureControl(parent,
- toolkit, new AdapterFactoryLabelProvider(adapterFactory),
- owner, feature, choice);
+ MultipleFeatureControl mfc = new MultipleFeatureControl(parent, toolkit, new AdapterFactoryLabelProvider(
+ adapterFactory), owner, feature, choice);
- IObservableList target = new SelectionProviderMultipleSelectionObservableList(
- SWTObservables.getRealm(Display.getDefault()), mfc
- .getInternalSelectionProvider(), Object.class);
+ IObservableList target = new SelectionProviderMultipleSelectionObservableList(SWTObservables.getRealm(Display
+ .getDefault()), mfc.getInternalSelectionProvider(), Object.class);
Binding binding = edbc.bindList(target, source, null, null);
binding.updateModelToTarget();
return mfc;
@@ -124,58 +121,52 @@ public class EmfSwtBindingFactory {
private Control bindValue(EStructuralFeature feature) {
Control retVal = null;
- IObservableValue source = EMFEditObservables.observeValue(domain,
- owner, feature);
+ IObservableValue source = EMFEditObservables.observeValue(domain, owner, feature);
IObservableValue target = null;
if (feature.getEType().equals(EcorePackage.Literals.EBOOLEAN)
- || feature.getEType().equals(
- EcorePackage.Literals.EBOOLEAN_OBJECT)
- || (feature.getEType() instanceof EDataType && (feature
- .getEType().getInstanceClass() == Boolean.class || feature
+ || feature.getEType().equals(EcorePackage.Literals.EBOOLEAN_OBJECT)
+ || (feature.getEType() instanceof EDataType && (feature.getEType().getInstanceClass() == Boolean.class || feature
.getEType().getInstanceClass() == Boolean.TYPE))) {
Button b = toolkit.createButton(parent, "", SWT.CHECK);
target = SWTObservables.observeSelection(b);
retVal = b;
- } else if (feature instanceof EReference
- || feature.getEType() instanceof EEnumImpl) {
+ }
+ else if (feature instanceof EReference || feature.getEType() instanceof EEnumImpl) {
ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY);
toolkit.adapt(combo.getCombo());
combo.setContentProvider(new ArrayContentProvider());
- combo.setLabelProvider(new AdapterFactoryLabelProvider(
- adapterFactory));
+ combo.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
combo.setInput(proposalcreator.proposals(owner, feature));
target = ViewersObservables.observeSingleSelection(combo);
retVal = combo.getCombo();
- } else {
+ }
+ else {
Text t = toolkit.createText(parent, new String());
t.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
List<?> proposals = proposalcreator.proposals(owner, feature);
if (proposals != null && !proposals.isEmpty()) {
- // TODO prevert adding null to a list, for example a Collection
+ // TODO prevent adding null to a list, for example a Collection
// Type
while (proposals.remove(null)) {
// clear null entries
}
ControlDecoration field = new ControlDecoration(t, SWT.BORDER);
- FieldDecoration requiredFieldIndicator = FieldDecorationRegistry
- .getDefault().getFieldDecoration(
- FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
field.setImage(requiredFieldIndicator.getImage());
- field.setDescriptionText(requiredFieldIndicator
- .getDescription());
+ field.setDescriptionText(requiredFieldIndicator.getDescription());
KeyStroke keyStroke = null;
String string = new String();
try {
string = "Ctrl+Space";
keyStroke = KeyStroke.getInstance(string);
- } catch (ParseException e) {
+ }
+ catch (ParseException e) {
EEPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, EEPlugin.PLUGIN_ID,
- "Error while parse: " + string, e));
+ new Status(IStatus.ERROR, EEPlugin.PLUGIN_ID, "Error while parse: " + string, e));
}
- new ContentProposalAdapter(t, new TextContentAdapter(),
- new SimpleContentProposalProvider(proposals
- .toArray(new String[] {})), keyStroke, null);
+ new ContentProposalAdapter(t, new TextContentAdapter(), new SimpleContentProposalProvider(proposals
+ .toArray(new String[] {})), keyStroke, null);
}
target = SWTObservables.observeText(t, SWT.Modify);
retVal = t;
@@ -188,8 +179,7 @@ public class EmfSwtBindingFactory {
private void setupControl(EStructuralFeature f, Control c) {
// disable unchangeable and unserializable
c.setEnabled(f.isChangeable()
- && (!(f.getEType() instanceof EDataType && !((EDataType) f
- .getEType()).isSerializable())));
+ && (!(f.getEType() instanceof EDataType && !((EDataType) f.getEType()).isSerializable())));
c.setData(EmfSwtBindingFactory.ESTRUCTURALFEATURE_KEY, f);
c.setData(EmfSwtBindingFactory.EOBJECT_KEY, owner);
c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/SelectionProviderMultipleSelectionObservableList.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/SelectionProviderMultipleSelectionObservableList.java
deleted file mode 100644
index a80711e..0000000
--- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/SelectionProviderMultipleSelectionObservableList.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Peter Centgraf 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:
- * Peter Centgraf - initial API and implementation, bug 124683
- * Boris Bokowski, IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.editor.ui.binding;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.databinding.observable.Diffs;
-import org.eclipse.core.databinding.observable.Realm;
-import org.eclipse.core.databinding.observable.list.ListDiff;
-import org.eclipse.core.databinding.observable.list.WritableList;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-/**
- * Observes multiple-selection of an {@link ISelectionProvider}. Copied from
- * jface!!!
- *
- * @since 1.2
- */
-public class SelectionProviderMultipleSelectionObservableList extends
- WritableList {
-
- protected ISelectionProvider selectionProvider;
- protected boolean handlingSelection;
- protected boolean updating;
- protected SelectionListener selectionListener = new SelectionListener();
-
- class SelectionListener implements ISelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent event) {
- if (updating) {
- return;
- }
- handlingSelection = true;
- try {
- updateWrappedList(new ArrayList<Object>(getSelectionList(event
- .getSelection())));
- } finally {
- handlingSelection = false;
- }
- }
- }
-
- /**
- * Create a new observable list based on the current selection of the given
- * selection provider. Assumes that the selection provider provides
- * structured selections.
- *
- * @param realm
- * @param selectionProvider
- * @param elementType
- */
- public SelectionProviderMultipleSelectionObservableList(Realm realm,
- ISelectionProvider selectionProvider, Object elementType) {
- super(realm,
- new ArrayList<Object>(getSelectionList(selectionProvider)),
- elementType);
- this.selectionProvider = selectionProvider;
- selectionProvider.addSelectionChangedListener(selectionListener);
- }
-
- @Override
- protected void fireListChange(ListDiff diff) {
- if (handlingSelection) {
- super.fireListChange(diff);
- } else {
- // this is a bit of a hack - we are changing the diff to match the
- // order
- // of elements returned by the selection provider after we've set
- // the
- // selection.
- updating = true;
- try {
- List<?> oldList = getSelectionList(selectionProvider);
- selectionProvider.setSelection(new StructuredSelection(
- wrappedList));
- wrappedList = new ArrayList<Object>(
- getSelectionList(selectionProvider));
- super.fireListChange(Diffs
- .computeListDiff(oldList, wrappedList));
- } finally {
- updating = false;
- }
- }
- }
-
- protected static List<?> getSelectionList(
- ISelectionProvider selectionProvider) {
- if (selectionProvider == null) {
- throw new IllegalArgumentException();
- }
- return getSelectionList(selectionProvider.getSelection());
- }
-
- protected static List<?> getSelectionList(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- return ((IStructuredSelection) sel).toList();
- }
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public synchronized void dispose() {
- selectionProvider.removeSelectionChangedListener(selectionListener);
- selectionProvider = null;
- super.dispose();
- }
-}