From 131ac6f9df82507ea2ac397ccfdaa41bcc0e0d75 Mon Sep 17 00:00:00 2001 From: dhubner Date: Mon, 27 Oct 2008 15:27:17 +0000 Subject: checks/extensions enabled --- .../META-INF/MANIFEST.MF | 11 +- examples/org.eclipse.emf.generic.editor/plugin.xml | 34 +++-- .../src/org/eclipse/emf/editor/EEditor.java | 68 +++++++-- .../src/org/eclipse/emf/editor/ModelCheckor.java | 44 +++++- .../eclipse/emf/editor/extxpt/ExtXptFacade.java | 151 ++++++++++++++++++++ .../eclipse/emf/editor/extxpt/ExtXptHelper.java | 41 ++++++ .../editor/extxpt/WorkspaceResourceManager.java | 51 +++++++ .../src/org/eclipse/emf/editor/oaw/OawFacade.java | 152 --------------------- .../src/org/eclipse/emf/editor/oaw/OawHelper.java | 41 ------ .../emf/editor/oaw/WorkspaceResourceManager.java | 56 -------- .../emf/editor/provider/ClasspathUriResolver.java | 3 +- .../emf/editor/provider/ExtendedLabelProvider.java | 6 +- .../eclipse/emf/editor/ui/GenericDetailsPage.java | 2 +- .../org/eclipse/emf/editor/ui/ProposalCreator.java | 6 +- .../editor/ui/binding/EmfSwtBindingFactory.java | 74 +++++----- ...ionProviderMultipleSelectionObservableList.java | 122 ----------------- 16 files changed, 409 insertions(+), 453 deletions(-) create mode 100644 examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java create mode 100644 examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptHelper.java create mode 100644 examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/WorkspaceResourceManager.java delete mode 100644 examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawFacade.java delete mode 100644 examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawHelper.java delete mode 100644 examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/WorkspaceResourceManager.java delete mode 100644 examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/ui/binding/SelectionProviderMultipleSelectionObservableList.java 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 eb515dc2..4cdd5260 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 f908d6f6..a18f52ff 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"> + contentTypeId="org.eclipse.emf.ecore.xmi"> + + + + - - - - - + + + + + + + + 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 9cd5087b..5c068e91 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 messages = new ModelCheckor().check(getEditingDomain().getResourceSet()); + final List 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 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 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 b4a7e986..c582fd8e 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 check(ResourceSet toCheck) { List messages = new ArrayList(); @@ -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 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 data = new ArrayList(); + 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/extxpt/ExtXptFacade.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java new file mode 100644 index 00000000..45378bd3 --- /dev/null +++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptFacade.java @@ -0,0 +1,151 @@ +/** + * + * + * 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 + * + * + * + */ +package org.eclipse.emf.editor.extxpt; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.editor.EEPlugin; +import org.eclipse.emf.mwe.core.issues.Issues; +import org.eclipse.emf.mwe.core.issues.IssuesImpl; +import org.eclipse.internal.xtend.expression.parser.SyntaxConstants; +import org.eclipse.internal.xtend.xtend.ast.ExtensionFile; +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 Hübner - Initial contribution and API + * + */ +public class ExtXptFacade { + + private IProject project; + private final ExecutionContext context; + public static final String CHECK_EXT = "Checks"; + public static final String STYLE_EXT = "ItemLabelProvider"; + public static final String PROPOSAL_EXT = "Proposals"; + + public ExtXptFacade(IProject project, ExecutionContext context) { + this.project = project; + this.context = context; + } + + public Object style(String extension, EObject object) { + String extendFile = path(object) + ExtXptFacade.STYLE_EXT; + Object retVal = evaluate(extendFile, extension, object); + return retVal; + } + + /** + * @param extensionFile + * @param extensionName + * @param params + * @return + */ + private Object evaluate(String extensionFile, String extensionName, Object... params) { + Object retVal = null; + try { + XtendFacade facade = XtendFacade.create(context, extensionFile); + retVal = facade.call(extensionName, params); + } + catch (IllegalArgumentException e) { + // no extension specified + } + catch (EvaluationException e) { + EEPlugin.logError("Exception during extension evaluation", e); + } + catch (RuntimeException e) { + // TODO check file exists + // extension file not found + } + catch (Throwable e) { + EEPlugin.logError("Exception during extension evaluation", new RuntimeException(e)); + } + return retVal; + } + + // TODO split method + public List proposals(EStructuralFeature feature, EObject ctx, List fromList) { + String extFile = path(ctx) + ExtXptFacade.PROPOSAL_EXT; + List retVal = new ArrayList(); + Object eval; + if (fromList != null) { + retVal = fromList; + eval = evaluate(extFile, feature.getName(), ctx, fromList); + } + else { + eval = evaluate(extFile, feature.getName(), ctx); + } + if (eval != null) { + if (eval instanceof List) { + retVal = (List) eval; + } + else { + EEPlugin.logError("Returned type must be a List! File:" + extFile + ", Extension:" + feature.getName()); + } + } + return retVal; + } + + public Issues check(EObject rootObject) { + String checkFile = path(rootObject) + ExtXptFacade.CHECK_EXT; + List all = new ArrayList(); + all.add(rootObject); + EObject rootContainer = EcoreUtil.getRootContainer(rootObject); + TreeIterator iter = rootContainer.eAllContents(); + while (iter.hasNext()) + all.add(iter.next()); + IssuesImpl issuesImpl = new IssuesImpl(); + 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; + } + + private String path(EObject object) { + return object.eClass().getEPackage().getName() + SyntaxConstants.NS_DELIM; + } + + public IProject getProject() { + return project; + } +} diff --git a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptHelper.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptHelper.java new file mode 100644 index 00000000..919a71a7 --- /dev/null +++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/ExtXptHelper.java @@ -0,0 +1,41 @@ +/** + * + * + * 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 + * + * + * + */ +package org.eclipse.emf.editor.extxpt; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.editor.MessageData; + + +/** + * @author Dennis Huebner + * + */ +public class ExtXptHelper { + static public EStructuralFeature extractFeatureFromMessage(EObject eObject, + MessageData md) { + String message = md.getMessage(); + int i = message.indexOf('#'); + if (i > 0 && i < message.length() - 1) { + String featureName = message.substring(0, i); + message = message.substring(i + 1); + md.setMessage(message); + return eObject.eClass().getEStructuralFeature(featureName); + } + return null; + } + +} 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 00000000..9a6aaf5a --- /dev/null +++ b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/extxpt/WorkspaceResourceManager.java @@ -0,0 +1,51 @@ +/** + * + * + * 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 + * + * + * + */ +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/OawFacade.java b/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawFacade.java deleted file mode 100644 index 66cbf77e..00000000 --- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawFacade.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * - * - * 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 - * - * - * - */ -package org.eclipse.emf.editor.oaw; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.editor.EEPlugin; -import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.issues.IssuesImpl; -import org.eclipse.internal.xtend.expression.parser.SyntaxConstants; -import org.eclipse.internal.xtend.xtend.ast.ExtensionFile; -import org.eclipse.xtend.XtendFacade; -import org.eclipse.xtend.check.CheckUtils; -import org.eclipse.xtend.expression.EvaluationException; -import org.eclipse.xtend.expression.ExecutionContext; - -/** - * @author Dennis Huebner - * - */ -public class OawFacade { - - private IProject project; - private final ExecutionContext context; - public static final String CHECK_EXT = "Checks"; - public static final String STYLE_EXT = "ItemLabelProvider"; - public static final String PROPOSAL_EXT = "Proposals"; - - public OawFacade(IProject project, ExecutionContext context) { - this.project = project; - this.context = context; - } - - public Object style(String extension, EObject object) { - String extendFile = path(object) + OawFacade.STYLE_EXT; - Object retVal = evaluate(extendFile, extension, object); - return retVal; - } - - /** - * @param extensionFile - * @param extensionName - * @param params - * @return - */ - private Object evaluate(String extensionFile, String extensionName, Object... params) { - Object retVal = null; - try { - XtendFacade facade = XtendFacade.create(context, extensionFile); - retVal = facade.call(extensionName, params); - } - catch (IllegalArgumentException e) { - // no extension specified - } - catch (EvaluationException e) { - EEPlugin.logError("Exception during extension evaluation", e); - } - catch (RuntimeException e) { - // TODO check file exists - // extension file not found - } - catch (Throwable e) { - EEPlugin.logError("Exception during extension evaluation", new RuntimeException(e)); - } - return retVal; - } - - // TODO split method - public List proposals(EStructuralFeature feature, EObject ctx, List fromList) { - String extFile = path(ctx) + OawFacade.PROPOSAL_EXT; - List retVal = new ArrayList(); - Object eval; - if (fromList != null) { - retVal = fromList; - eval = evaluate(extFile, feature.getName(), ctx, fromList); - } - else { - eval = evaluate(extFile, feature.getName(), ctx); - } - if (eval != null) { - if (eval instanceof List) { - retVal = (List) eval; - } - else { - EEPlugin.logError("Returned type must be a List! File:" + extFile + ", Extension:" + feature.getName()); - } - } - return retVal; - } - - public Issues check(EObject rootObject) { - String checkFile = path(rootObject) + OawFacade.CHECK_EXT; - List all = new ArrayList(); - all.add(rootObject); - EObject rootContainer = EcoreUtil.getRootContainer(rootObject); - TreeIterator 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."); - // } - return issuesImpl; - } - - private String path(EObject object) { - return object.eClass().getEPackage().getName() + SyntaxConstants.NS_DELIM; - } - - public IProject getProject() { - return project; - } -} 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/oaw/OawHelper.java deleted file mode 100644 index 0e182875..00000000 --- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/OawHelper.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - * - * 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 - * - * - * - */ -package org.eclipse.emf.editor.oaw; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.editor.MessageData; - - -/** - * @author Dennis Huebner - * - */ -public class OawHelper { - static public EStructuralFeature extractFeatureFromMessage(EObject eObject, - MessageData md) { - String message = md.getMessage(); - int i = message.indexOf('#'); - if (i > 0 && i < message.length() - 1) { - String featureName = message.substring(0, i); - message = message.substring(i + 1); - md.setMessage(message); - return eObject.eClass().getEStructuralFeature(featureName); - } - return null; - } - -} 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 d41c88f0..00000000 --- a/examples/org.eclipse.emf.generic.editor/src/org/eclipse/emf/editor/oaw/WorkspaceResourceManager.java +++ /dev/null @@ -1,56 +0,0 @@ -///** -// * -// * -// * 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 -// * -// * -// * -// */ -//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 bfea5350..57b1965b 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 a3ca32b9..b1e1c316 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 7df3042d..b6c93142 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 65d0c5e3..dc6138cc 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 de029816..0c45aa3c 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 a80711ee..00000000 --- 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(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(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( - 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(); - } -} -- cgit v1.2.3