Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2014-03-07 12:46:03 +0000
committerptessier2014-03-07 12:46:03 +0000
commit7e718ad89e3cb484c4643c98e0a8d97218911858 (patch)
tree52b4232a07f100bf87da320f42deb441f9767d95 /plugins/views
parent0c4da7c9bb907a7a57822264b8dd49fe76571e63 (diff)
parent6f332093a09441066c01c24f8f6389dfcf514384 (diff)
downloadorg.eclipse.papyrus-7e718ad89e3cb484c4643c98e0a8d97218911858.tar.gz
org.eclipse.papyrus-7e718ad89e3cb484c4643c98e0a8d97218911858.tar.xz
org.eclipse.papyrus-7e718ad89e3cb484c4643c98e0a8d97218911858.zip
Merge branch 'master' into bugs/386118-emf-facet
Conflicts: plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/Messages.java plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/ui/CreateUmlElementDialog.java plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/BehaviorPortEditPolicy.java plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/BehaviorSymbolEditPolicy.java plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/ui/InterfaceManagerDialog.java plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.edit/META-INF/MANIFEST.MF plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/AbstractCommandHandler.java
Diffstat (limited to 'plugins/views')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java3
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java22
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/AbstractCommandHandler.java71
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java73
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java79
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AnnotationModelElement.java9
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java26
7 files changed, 207 insertions, 76 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java
index a4841993af4..61581ca5d52 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java
@@ -47,6 +47,7 @@ public class DirectEditorEditingSupport extends EditingSupport {
ICustomDirectEditorConfiguration configuration = getConfigurationAE(element);
EObject semanticObject = EMFHelper.getEObject(element);
Composite parent = (Composite) getViewer().getControl();
+ configuration.preEditAction(semanticObject);
return configuration.createCellEditor(parent, semanticObject);
}
@@ -112,4 +113,4 @@ public class DirectEditorEditingSupport extends EditingSupport {
}
return null;
}
-} \ No newline at end of file
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
index 13201dff933..dfe453e837b 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
@@ -927,10 +927,17 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
}
if(r != null) {
- ResourceSet rs = r.getResourceSet();
+ final ResourceSet rs = r.getResourceSet();
+ final Resource resource = r;
if(rs instanceof ModelSet && AdditionalResourcesModel.isAdditionalResource((ModelSet)rs, r.getURI())) {
- commonViewer.expandToLevel(new ReferencableMatchingItem(rs), 1);
- commonViewer.expandToLevel(new ReferencableMatchingItem(r), 1);
+ commonViewer.getControl().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ commonViewer.expandToLevel(new ReferencableMatchingItem(rs), 1);
+ commonViewer.expandToLevel(new ReferencableMatchingItem(resource), 1);
+ }
+ });
+
}
}
@@ -1003,12 +1010,17 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
* @param viewer
* The ComonViewer to select it in
*/
- public static void reveal(ISelection selection, CommonViewer viewer) {
+ public static void reveal(final ISelection selection, final CommonViewer viewer) {
if(selection instanceof IStructuredSelection) {
IStructuredSelection structured = (IStructuredSelection)selection;
reveal(Lists.newArrayList(structured.iterator()), viewer);
} else {
- viewer.setSelection(selection);
+ viewer.getControl().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ viewer.setSelection(selection);
+ }
+ });
}
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/AbstractCommandHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/AbstractCommandHandler.java
index 8348119ae07..a28069085ec 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/AbstractCommandHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/AbstractCommandHandler.java
@@ -1,18 +1,18 @@
/*****************************************************************************
* Copyright (c) 2010, 2013 CEA LIST.
*
- *
+ *
* 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:
- *
+ *
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
* Christian W. Damus (CEA) - Refactoring package/profile import/apply UI for CDO
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.handler;
@@ -37,27 +37,27 @@ import org.eclipse.ui.handlers.HandlerUtil;
/**
* <pre>
- *
+ *
* This abstract command handler manages:
* - current selection in order to build a list of the selected {@link EObject}
* - execute the command (returned by children) in Papyrus {@link TransactionalEditingDomain}
* - calculate the command enablement and visibility regarding the command executability
* (the command is now shown in menu if not executable).
- *
+ *
* </pre>
*/
public abstract class AbstractCommandHandler extends AbstractModelExplorerHandler {
private List<?> selection = Collections.EMPTY_LIST;
-
+
/**
* <pre>
- *
+ *
* Returns the command to execute (to be implemented
* in children implementing this class)
- *
+ *
* @return the command to execute
- *
+ *
* </pre>
*/
protected abstract Command getCommand();
@@ -65,15 +65,15 @@ public abstract class AbstractCommandHandler extends AbstractModelExplorerHandle
protected List<?> getSelection() {
return selection;
}
-
+
/**
* <pre>
* Get the selected element, the first selected element if several are selected or null
* if no selection or the selection is not an {@link EObject}.
- *
+ *
* @return selected {@link EObject} or null
* </pre>
- *
+ *
*/
protected EObject getSelectedElement() {
EObject eObject = null;
@@ -82,11 +82,10 @@ public abstract class AbstractCommandHandler extends AbstractModelExplorerHandle
List<?> selection = getSelection();
// Treat non-null selected object (try to adapt and return EObject)
- if (!selection.isEmpty()) {
+ if(!selection.isEmpty()) {
// Get first element if the selection is an IStructuredSelection
- Object first = selection.get(0);
-
+ Object first = selection.get(0);
EObject businessObject = EMFHelper.getEObject(first);
if(businessObject != null) {
@@ -101,13 +100,13 @@ public abstract class AbstractCommandHandler extends AbstractModelExplorerHandle
* <pre>
* Parse current selection and extract the list of {@link EObject} from
* this selection.
- *
+ *
* This also tries to adapt selected element into {@link EObject}
* (for example to get the {@link EObject} from a selection in the ModelExplorer).
- *
+ *
* @return a list of currently selected {@link EObject}
* </pre>
- *
+ *
*/
protected List<EObject> getSelectedElements() {
@@ -117,13 +116,13 @@ public abstract class AbstractCommandHandler extends AbstractModelExplorerHandle
Collection<?> selection = getSelection();
// Treat non-null selected object (try to adapt and return EObject)
- if (!selection.isEmpty()) {
+ if(!selection.isEmpty()) {
// Parse current selection
- for (Object current : selection) {
+ for(Object current : selection) {
// Adapt current selection to EObject
EObject selectedEObject = EMFHelper.getEObject(current);
- if (selectedEObject != null) {
+ if(selectedEObject != null) {
//we avoid to add null element in the list!
selectedEObjects.add(selectedEObject);
}
@@ -134,9 +133,9 @@ public abstract class AbstractCommandHandler extends AbstractModelExplorerHandle
}
/**
- *
+ *
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
+ *
* @param event
* @return null
* @throws ExecutionException
@@ -144,13 +143,9 @@ public abstract class AbstractCommandHandler extends AbstractModelExplorerHandle
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
ISelection selection = HandlerUtil.getCurrentSelection(event);
- this.selection = (selection instanceof IStructuredSelection)
- ? ((IStructuredSelection) selection).toList()
- : Collections.EMPTY_LIST;
-
- ServiceUtilsForHandlers.getInstance()
- .getTransactionalEditingDomain(event).getCommandStack()
- .execute(getCommand());
+ this.selection = (selection instanceof IStructuredSelection) ? ((IStructuredSelection)selection).toList() : Collections.EMPTY_LIST;
+
+ ServiceUtilsForHandlers.getInstance().getTransactionalEditingDomain(event).getCommandStack().execute(getCommand());
} catch (ServiceException e) {
Activator.log.error("Unexpected error while executing command.", e); //$NON-NLS-1$
} finally {
@@ -163,24 +158,22 @@ public abstract class AbstractCommandHandler extends AbstractModelExplorerHandle
protected boolean computeEnabled() {
boolean result = false;
-
+
Command command = getCommand();
- if (command != null) {
+ if(command != null) {
result = getCommand().canExecute();
command.dispose();
}
-
+
return result;
}
@Override
public void setEnabled(Object evaluationContext) {
- if (evaluationContext instanceof IEvaluationContext) {
- Object selection = ((IEvaluationContext) evaluationContext).getDefaultVariable();
- if (selection instanceof Collection<?>) {
- this.selection = (selection instanceof List<?>)
- ? (List<?>) selection
- : new java.util.ArrayList<Object>((Collection<?>) selection);
+ if(evaluationContext instanceof IEvaluationContext) {
+ Object selection = ((IEvaluationContext)evaluationContext).getDefaultVariable();
+ if(selection instanceof Collection<?>) {
+ this.selection = (selection instanceof List<?>) ? (List<?>)selection : new java.util.ArrayList<Object>((Collection<?>)selection);
setBaseEnabled(computeEnabled());
this.selection = Collections.EMPTY_LIST;
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java
index f9da5ab4928..e17e7831e6b 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 402525
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.properties.creation;
@@ -16,17 +18,23 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.emf.dialog.NestedEditingDialogContext;
import org.eclipse.papyrus.infra.emf.utils.EClassNameComparator;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.views.properties.Activator;
+import org.eclipse.papyrus.views.properties.contexts.View;
import org.eclipse.papyrus.views.properties.messages.Messages;
import org.eclipse.papyrus.views.properties.providers.CreateInFeatureContentProvider;
import org.eclipse.swt.SWT;
@@ -185,17 +193,67 @@ public class EcorePropertyEditorFactory extends PropertyEditorFactory {
* {@inheritDoc}
*/
@Override
- public Object createObject(Control widget) {
+ public final Object createObject(Control widget, Object context) {
+ Object result;
+
+ final ResourceSet previous = NestedEditingDialogContext.getInstance().push(context);
+
+ try {
+ result = doCreateObject(widget, context);
+ } finally {
+ NestedEditingDialogContext.getInstance().pop(previous);
+ }
+
+ return result;
+ }
+
+ protected Object doCreateObject(Control widget, Object context) {
Object instance;
+
if(referenceIn.isContainment()) {
instance = simpleCreateObject(widget);
} else {
instance = createObjectInDifferentContainer(widget);
}
- return super.createObject(widget, instance);
+ return createObject(widget, context, instance);
}
+ @Override
+ protected Object doEdit(final Control widget, final Object source, final Set<View> views, final String dialogTitle) {
+ Object result;
+
+ try {
+ NestedEditingDialogContext.getInstance().enter();
+ try {
+ result = getOperationExecutor(source).execute(new Callable<Object>() {
+ public Object call() throws Exception {
+ return basicDoEdit(widget, source, views, dialogTitle);
+ }
+ }, dialogTitle);
+ } finally {
+ NestedEditingDialogContext.getInstance().exit();
+ }
+ } catch (OperationCanceledException e) {
+ if(!NestedEditingDialogContext.getInstance().isNested()) {
+ // Propagate to the caller if not in a nested edit dialog
+ throw e;
+ }
+ result = null;
+ }
+
+ return result;
+ }
+
+ protected final Object basicDoEdit(Control widget, Object source, Set<View> views, String dialogTitle) {
+ return super.doEdit(widget, source, views, dialogTitle);
+ }
+
+ @Override
+ protected void handleEditCancelled(Control widget, Object source) {
+ throw new OperationCanceledException();
+ }
+
protected EObject simpleCreateObject(Control widget) {
EClass eClass = chooseEClass(widget);
if(eClass == null) {
@@ -212,7 +270,14 @@ public class EcorePropertyEditorFactory extends PropertyEditorFactory {
return null;
}
- containerContentProvider.inputChanged(null, null, instance);
+ // Try to get the current resource set for a wide scope of places to put a new element
+ Object containerInput = NestedEditingDialogContext.getInstance().getResourceSet();
+ if (containerInput == null) {
+ // Only have the object that we've created for context
+ containerInput = instance;
+ }
+
+ containerContentProvider.inputChanged(null, null, containerInput);
referenceContentProvider.setType(instance.eClass());
CreateInDialog dialog = new CreateInDialog(widget.getShell(), instance);
dialog.setProviders(containerContentProvider, referenceContentProvider, containerLabelProvider, referenceLabelProvider);
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java
index 4e86109ca2b..93eb38b7ef1 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,15 +8,20 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 402525
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.properties.creation;
import java.util.Collection;
import java.util.Set;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.widgets.creation.IAtomicOperationExecutor;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.views.properties.contexts.View;
import org.eclipse.papyrus.views.properties.messages.Messages;
@@ -51,15 +56,18 @@ public class PropertyEditorFactory implements ReferenceValueFactory {
* Return a null value. Implementors should override when object creation
* needs to be supported. Implementors may rely on {@link #createObject(Control, Object)}
*
- * @see org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory#createObject(org.eclipse.swt.widgets.Control)
- * @see #createObject(org.eclipse.swt.widgets.Control, Object)
- *
* @param widget
* The widget from which this method is called. May be used to retrieve the current shell
+ * @param context
+ * The object being edited, in which context the new object is to be created and which will as a result have a reference to the new object.
+ * If there is no context object (creation of a free-floating object) or it cannot be determined, this may be {@code null}
* @return
* The newly created object
+ *
+ * @see ReferenceValueFactory#createObject(Control, Object)
+ * @see #createObject(Control, Object, Object)
*/
- public Object createObject(Control widget) {
+ public Object createObject(Control widget, Object context) {
return null;
}
@@ -72,12 +80,15 @@ public class PropertyEditorFactory implements ReferenceValueFactory {
*
* @param widget
* The widget used to open the dialog
+ * @param context
+ * The object being edited, in which context the new object is to be created and which will as a result have a reference to the new object.
+ * If there is no context object (creation of a free-floating object) or it cannot be determined, this may be {@code null}
* @param source
* The created EObject. If null, nothing will happen
* @return
* The source EObject, which potential in-place modifications
*/
- protected Object createObject(Control widget, Object source) {
+ protected Object createObject(Control widget, Object context, Object source) {
if(source == null) {
return null;
}
@@ -87,15 +98,7 @@ public class PropertyEditorFactory implements ReferenceValueFactory {
ViewConstraintEngine constraintEngine = ConfigurationManager.getInstance().getConstraintEngine();
Set<View> views = constraintEngine.getViews(selection);
if(!views.isEmpty()) {
- EditionDialog dialog = new EditionDialog(widget.getShell(), true);
- dialog.setViews(views);
- dialog.setInput(source);
- dialog.setTitle(getCreationDialogTitle());
-
- int result = dialog.open();
- if(result != Window.OK) {
- return null;
- }
+ return doEdit(widget, source, views, getCreationDialogTitle());
}
return source;
@@ -134,17 +137,30 @@ public class PropertyEditorFactory implements ReferenceValueFactory {
Set<View> views = constraintEngine.getViews(selection);
if(!views.isEmpty()) {
- EditionDialog dialog = new EditionDialog(widget.getShell());
- dialog.setTitle(getEditionDialogTitle(source));
- dialog.setViews(views);
- dialog.setInput(source);
-
- dialog.open();
+ return doEdit(widget, source, views, getEditionDialogTitle(source));
}
return source;
}
+ protected Object doEdit(Control widget, Object source, Set<View> views, String dialogTitle) {
+ EditionDialog dialog = new EditionDialog(widget.getShell(), true);
+ dialog.setTitle(dialogTitle);
+ dialog.setViews(views);
+ dialog.setInput(source);
+
+ if (dialog.open() != Window.OK) {
+ handleEditCancelled(widget, source);
+ return null;
+ }
+
+ return source;
+ }
+
+ protected void handleEditCancelled(Control widget, Object source) {
+ // Pass
+ }
+
/**
* The standard Property Editor Factory cannot instantiate new objects.
* However, subclasses may override this method to return true if they
@@ -173,4 +189,25 @@ public class PropertyEditorFactory implements ReferenceValueFactory {
public String getEditionDialogTitle(Object objectToEdit) {
return "Edit an element";
}
+
+ /**
+ * Obtains the most appropriate operation executor for the object being edited.
+ *
+ * @param context the object being edited
+ * @return the executor to use to run operations (never {@code null})
+ */
+ public IAtomicOperationExecutor getOperationExecutor(Object context) {
+ IAtomicOperationExecutor result;
+ if(context instanceof IAdaptable) {
+ result = (IAtomicOperationExecutor)((IAdaptable)context).getAdapter(IAtomicOperationExecutor.class);
+ } else {
+ result = (IAtomicOperationExecutor)Platform.getAdapterManager().getAdapter(context, IAtomicOperationExecutor.class);
+ }
+
+ if (result == null) {
+ result = IAtomicOperationExecutor.DEFAULT;
+ }
+
+ return result;
+ }
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AnnotationModelElement.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AnnotationModelElement.java
index 9aa30330743..beca09c8205 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AnnotationModelElement.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AnnotationModelElement.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.properties.modelelement;
@@ -15,6 +17,7 @@ import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.emf.databinding.AnnotationObservableValue;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
/**
* A ModelElement for handling EAnnotations
@@ -63,4 +66,8 @@ public class AnnotationModelElement extends AbstractModelElement {
return new AnnotationObservableValue(source, domain, annotationName, propertyPath);
}
+ @Override
+ public boolean isEditable(String propertyPath) {
+ return !EMFHelper.isReadOnly(source);
+ }
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
index cf40594c4ef..bbe0b763493 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,9 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 402525
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.properties.modelelement;
@@ -27,10 +30,12 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.databinding.EMFObservableList;
import org.eclipse.papyrus.infra.emf.databinding.EMFObservableValue;
+import org.eclipse.papyrus.infra.emf.dialog.NestedEditingDialogContext;
import org.eclipse.papyrus.infra.emf.providers.EMFContentProvider;
import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
@@ -199,7 +204,10 @@ public class EMFModelElement extends AbstractModelElement {
@Override
public ILabelProvider getLabelProvider(String propertyPath) {
try {
- return ServiceUtilsForEObject.getInstance().getServiceRegistry(source).getService(LabelProviderService.class).getLabelProvider();
+ LabelProviderService lpSvc = (source.eResource() != null) //
+ ? ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, source) //
+ : ServiceUtilsForResourceSet.getInstance().getService(LabelProviderService.class, NestedEditingDialogContext.getInstance().getResourceSet());
+ return lpSvc.getLabelProvider();
} catch (ServiceException ex) {
Activator.log.error(ex);
return new EMFLabelProvider();
@@ -235,14 +243,22 @@ public class EMFModelElement extends AbstractModelElement {
}
@Override
- public boolean isEditable(String propertyPath) {
+ public final boolean isEditable(String propertyPath) {
+ return isFeatureEditable(propertyPath) && isElementEditable();
+ }
+
+ protected boolean isFeatureEditable(String propertyPath) {
EStructuralFeature feature = getFeature(propertyPath);
if(feature == null) {
return false;
}
- return feature.isChangeable() && !EMFHelper.isReadOnly(source);
+ return feature.isChangeable();
}
-
+
+ protected boolean isElementEditable() {
+ return !EMFHelper.isReadOnly(source);
+ }
+
@Override
public boolean forceRefresh(String propertyPath) {
EStructuralFeature feature = getFeature(propertyPath);

Back to the top