Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFanch BONNABESSE2016-08-04 12:24:14 +0000
committerGerrit Code Review @ Eclipse.org2016-08-11 13:27:34 +0000
commitf0a5f7b106f3e393bbebb8e988e0dc7850423089 (patch)
tree838a6605731e88b171627220177c74b0420d108c /plugins/views
parente28b5ed336c6b23e88eaf0c48cc75c95897df822 (diff)
downloadorg.eclipse.papyrus-f0a5f7b106f3e393bbebb8e988e0dc7850423089.tar.gz
org.eclipse.papyrus-f0a5f7b106f3e393bbebb8e988e0dc7850423089.tar.xz
org.eclipse.papyrus-f0a5f7b106f3e393bbebb8e988e0dc7850423089.zip
Bug 497289: [Model Explorer] Renaming an element in the model explorer
should not open a modal editor https://bugs.eclipse.org/bugs/show_bug.cgi?id=497289 Activation of the DirectEditor configuration on the ModelExplorer view for: - NamedElement - Diagram - Table Add a Preference on "Papyrus > Papyrus Model Explorer > New Child Menu" Change-Id: I760b84ee4b30f8f05ccb6c2f001a4e0f1e82d150 Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
Diffstat (limited to 'plugins/views')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties1
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java23
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/commands/EditResultCommand.java135
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java9
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java40
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java10
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java11
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java71
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java26
9 files changed, 288 insertions, 38 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties
index c425ccb8551..58e18778e51 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties
@@ -1,2 +1,3 @@
NewChildPreferencePage.desciption=Behaviour after creation of a new child in the model:
NewChildPreferencePage.selection.label=Select the new element(s)
+NewChildPreferencePage.edition.label=Edit the new element(s)
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java
index dbbdf8d4397..013736f5a9e 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 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
* which accompanies this distribution, and is available at
@@ -8,8 +8,9 @@
*
* Contributors:
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
- * Patrik Nandorf (Ericsson AB) patrik.nandorf@ericsson.com - Bug 425565
- *
+ * Patrik Nandorf (Ericsson AB) patrik.nandorf@ericsson.com - Bug 425565
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.newchild;
@@ -25,20 +26,23 @@ import org.eclipse.papyrus.infra.newchild.CreationMenuFactory;
import org.eclipse.papyrus.infra.newchild.elementcreationmenumodel.CreationMenu;
import org.eclipse.papyrus.infra.widgets.util.RevealResultCommand;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
import org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.MultiViewPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.newchild.commands.EditResultCommand;
import org.eclipse.papyrus.views.modelexplorer.newchild.preferences.NewChildPreferences;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
/**
- * Override of creation menu factory to select created element in Model Explorer view.
- *
+ * Override of creation menu factory to select and edit created element in Model Explorer view.
+ *
* @author Gabriel Pascual
*
*/
public class ModelExplorerMenuFactory extends CreationMenuFactory {
private boolean defaultSelectionPreference;
+ private boolean defaultEditionPreference;
private IViewPart viewPart;
@@ -50,6 +54,7 @@ public class ModelExplorerMenuFactory extends CreationMenuFactory {
public ModelExplorerMenuFactory(TransactionalEditingDomain editingDomain) {
super(editingDomain);
defaultSelectionPreference = Activator.getDefault().getPreferenceStore().getBoolean(NewChildPreferences.DEFAULT_SELECTION);
+ defaultEditionPreference = Activator.getDefault().getPreferenceStore().getBoolean(NewChildPreferences.DEFAULT_EDITION);
viewPart = getActiveViewPart();
}
@@ -58,7 +63,7 @@ public class ModelExplorerMenuFactory extends CreationMenuFactory {
*
* @param reference
* @param container
- * @param creationMenu
+ * @param creationMenu
* @return
*/
@Override
@@ -72,6 +77,12 @@ public class ModelExplorerMenuFactory extends CreationMenuFactory {
if (defaultSelectionPreference) {
// Wrap command to select created element
buildCommand = RevealResultCommand.wrap(buildCommand, viewPart, container);
+
+ if (defaultEditionPreference) {
+ if (viewPart instanceof ModelExplorerView) {
+ buildCommand = EditResultCommand.wrap(buildCommand, viewPart);
+ }
+ }
}
return buildCommand;
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/commands/EditResultCommand.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/commands/EditResultCommand.java
new file mode 100644
index 00000000000..ca9f3fe11be
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/commands/EditResultCommand.java
@@ -0,0 +1,135 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.newchild.commands;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandWrapper;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * A Command to edit an element of a viewer.
+ */
+public class EditResultCommand extends CommandWrapper {
+
+ /** The ViewPart */
+ private IViewPart viewPart = null;
+
+ /** Number of the column which contains the element. */
+ private int numColumn = 0;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param command
+ * The command.
+ * @param viewPart
+ * The IViewPart
+ * @param numColumn
+ * The number of the column.
+ */
+ public EditResultCommand(Command command, IViewPart viewPart, int numColumn) {
+ super(command);
+ this.viewPart = viewPart;
+ this.numColumn = numColumn;
+ }
+
+ /**
+ * Wrap.
+ *
+ * @param command
+ * The command.
+ * @param viewPart
+ * The IViewPart.
+ * @param numColumn
+ * The number of the column.
+ * @return The wrapped column.
+ */
+ public static Command wrap(Command command, IViewPart viewPart, int numColumn) {
+ return new EditResultCommand(command, viewPart, numColumn);
+ }
+
+ /**
+ * Wrap.
+ *
+ * @param command
+ * The command.
+ * @param viewPart
+ * The IViewPart.
+ * @return The wrapped command.
+ */
+ public static Command wrap(Command command, IViewPart viewPart) {
+ return wrap(command, viewPart, 0);
+ }
+
+
+ /**
+ * Gets the results command.
+ *
+ * @return the results command
+ */
+ private Collection<?> getResultsCommand() {
+ // Get results list
+ Collection<?> resultsCommand = getResult();
+ if (getResult().isEmpty()) {
+
+ // Get affected objects list if it is not a command with result
+ resultsCommand = getAffectedObjects();
+ }
+
+ return resultsCommand;
+ }
+
+ /**
+ * Edit the result of the command.
+ */
+ private void editResult() {
+ Collection<?> results = getResultsCommand();
+ if (!results.isEmpty()) {
+ Iterator<?> resultIterator = results.iterator();
+
+ // Get first result
+ final Object result = resultIterator.next();
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+
+ if (viewPart instanceof ModelExplorerView) {
+ if (result instanceof EObject) {
+ ((ModelExplorerView) viewPart).editElement((EObject) result, numColumn);
+ }
+ }
+ }
+ });
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void execute() {
+ super.execute();
+ editResult();
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java
index 8d6220631d0..3de2dbbeea3 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 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
* which accompanies this distribution, and is available at
@@ -8,7 +8,8 @@
*
* Contributors:
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
- *
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.newchild.preferences;
@@ -19,7 +20,7 @@ import org.eclipse.papyrus.views.modelexplorer.newchild.Activator;
/**
* Initialiser for new child preferences in Model Explorer.
- *
+ *
* @author Gabriel Pascual
*
*/
@@ -41,7 +42,7 @@ public class NewChildPreferenceInitializer extends AbstractPreferenceInitializer
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(NewChildPreferences.DEFAULT_SELECTION, true);
-
+ store.setDefault(NewChildPreferences.DEFAULT_EDITION, true);
}
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java
index 7ca0d19571a..98312d3039d 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 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
* which accompanies this distribution, and is available at
@@ -8,7 +8,8 @@
*
* Contributors:
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
- *
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.newchild.preferences;
@@ -22,7 +23,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
/**
* Preference page to define enable/disable default selection in Model Explorer.
- *
+ *
* @author Gabriel Pascual
*
*/
@@ -34,12 +35,18 @@ public class NewChildPreferencePage extends FieldEditorPreferencePage implements
/** The Constant PAGE_DESCRIPTION. */
private static final String PAGE_DESCRIPTION = Messages.getString("NewChildPreferencePage.desciption"); //$NON-NLS-1$
+ /** The Constant DEFAULT_EDITION_LABEL. */
+ private static final String DEFAULT_EDITION_LABEL = Messages.getString("NewChildPreferencePage.edition.label"); //$NON-NLS-1$
+
+ /** The field editor to indicate if the new element will be edit. */
+ private BooleanFieldEditor editionFieldEditor;
+
/**
* Constructor.
*
*/
public NewChildPreferencePage() {
- super();
+ super(GRID);
}
/**
@@ -61,11 +68,30 @@ public class NewChildPreferencePage extends FieldEditorPreferencePage implements
*/
@Override
protected void createFieldEditors() {
- addField(new BooleanFieldEditor(NewChildPreferences.DEFAULT_SELECTION, DEFAULT_SELECTION_LABEL, getFieldEditorParent()));
-
- }
+ final BooleanFieldEditor selectionFieldEditor = new BooleanFieldEditor(NewChildPreferences.DEFAULT_SELECTION, DEFAULT_SELECTION_LABEL, getFieldEditorParent()) {
+ /**
+ * @see org.eclipse.jface.preference.BooleanFieldEditor#valueCh
+ * anged(boolean, boolean)
+ *
+ * @param oldValue
+ * @param newValue
+ */
+ @Override
+ protected void valueChanged(boolean oldValue, boolean newValue) {
+ super.valueChanged(oldValue, newValue);
+ if (null != editionFieldEditor) {
+ editionFieldEditor.setEnabled(newValue, getFieldEditorParent());
+ }
+ }
+ };
+ editionFieldEditor = new BooleanFieldEditor(NewChildPreferences.DEFAULT_EDITION, DEFAULT_EDITION_LABEL, getFieldEditorParent());
+ boolean defaultSelection = Activator.getDefault().getPreferenceStore().getBoolean(NewChildPreferences.DEFAULT_SELECTION);
+ editionFieldEditor.setEnabled(defaultSelection, getFieldEditorParent());
+ addField(selectionFieldEditor);
+ addField(editionFieldEditor);
+ }
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java
index f6012323b70..4759d7ea999 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 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
* which accompanies this distribution, and is available at
@@ -8,14 +8,15 @@
*
* Contributors:
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
- *
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.newchild.preferences;
/**
* Preference's keys for new child behaviour of Model Explorer view.
- *
+ *
* @author Gabriel Pascual
*
*/
@@ -23,4 +24,7 @@ public interface NewChildPreferences {
/** The Constant DEFAULT_SELECTION. */
public static final String DEFAULT_SELECTION = "defaultSelection"; //$NON-NLS-1$
+
+ /** The Constant DEFAULT_EDITION. */
+ public static final String DEFAULT_EDITION = "defaultEdition"; //$NON-NLS-1$
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java
index 398f0364ec2..d10ed59aa39 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
*
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer;
@@ -48,6 +49,7 @@ public class CustomCommonViewer extends CommonViewer {
// TODO Auto-generated constructor stub
setComparer(new IElementComparer() {
+ @Override
public int hashCode(Object element) {
if (element instanceof EObjectTreeElement) {
EObject eObject = ((EObjectTreeElement) element).getEObject();
@@ -70,6 +72,7 @@ public class CustomCommonViewer extends CommonViewer {
return element.hashCode();
}
+ @Override
public boolean equals(Object a, Object b) {
if (a instanceof IMatchingItem) {
return ((IMatchingItem) a).matchingItemEquals(b);
@@ -131,8 +134,8 @@ public class CustomCommonViewer extends CommonViewer {
ColumnViewerEditorActivationEvent event) {
// activation will uses F2 (also used by rename-popup, but not taken into account by the latter
// for model elements for which a direct-editor exists)
- return event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED &&
- event.keyCode == SWT.F2;
+ return (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED &&
+ event.keyCode == SWT.F2) || (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC);
}
}, ColumnViewerEditor.KEYBOARD_ACTIVATION);
ColumnViewerEditor editor = this.getColumnViewerEditor();
@@ -146,8 +149,8 @@ public class CustomCommonViewer extends CommonViewer {
*/
@Override
public void dispose() {
- //Remove the custom column viewer editor which causes NPE after dispose
- //ViewerEditor cannot be nulled or disposed, so we just recreate a default one
+ // Remove the custom column viewer editor which causes NPE after dispose
+ // ViewerEditor cannot be nulled or disposed, so we just recreate a default one
setColumnViewerEditor(super.createViewerEditor());
super.dispose();
}
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 fcc9fae4ffe..52109dc3526 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
@@ -7,12 +7,15 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
* Andreas Muelder - Initial contribution and API
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
*
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
@@ -85,7 +88,7 @@ public class DirectEditorEditingSupport extends EditingSupport {
* an adaptable element
* @return The direct editor configuration, if it exists.
*/
- public static ICustomDirectEditorConfiguration getConfigurationAE(Object element) {
+ public static ICustomDirectEditorConfiguration getConfigurationAE(final Object element) {
EObject semanticObject = EMFHelper.getEObject(element);
return getConfiguration(semanticObject);
}
@@ -93,23 +96,67 @@ public class DirectEditorEditingSupport extends EditingSupport {
/**
* Obtain direct editor configuration for a semantic element
*
- * @param element
- * a sementic element
+ * @param semanticElement
+ * a semantic element
* @return The direct editor configuration, if it exists.
*/
- public static ICustomDirectEditorConfiguration getConfiguration(EObject semanticElement) {
-
+ public static ICustomDirectEditorConfiguration getConfiguration(final EObject semanticElement) {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String semanticClassName = semanticElement.eClass().getInstanceClassName();
+ EClass eClass = semanticElement.eClass();
+ String semanticClassName = eClass.getInstanceClassName();
String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT + semanticClassName;
String languagePreferred = store.getString(key);
- if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$
- IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, semanticElement, semanticElement);
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- return (ICustomDirectEditorConfiguration) configuration;
- }
+ IDirectEditorConfiguration configuration = null;
+
+ if (null != languagePreferred && !languagePreferred.isEmpty()) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, semanticElement, semanticElement);
+ } else {
+ configuration = getConfigurationSuperType(eClass, semanticElement);
+ }
+
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ return (ICustomDirectEditorConfiguration) configuration;
}
return null;
}
+
+ /**
+ * Obtain an editor configuration compatible with a superType of an EClass.
+ *
+ * @param basedEClass
+ * The based EClass.
+ * @param semanticElement
+ * The renamed semantic element.
+ * @return The editor configuration, if it exists.
+ */
+ public static IDirectEditorConfiguration getConfigurationSuperType(final EClass basedEClass, final EObject semanticElement) {
+ IDirectEditorConfiguration configuration = null;
+ List<EClass> eClasses = basedEClass.getESuperTypes();
+
+ if (null != eClasses && !eClasses.isEmpty()) {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ int i = 0;
+ while (i < eClasses.size() && null == configuration) {
+ EClass eClass = eClasses.get(i);
+ String semanticClassName = eClass.getInstanceClassName();
+ String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT + semanticClassName;
+ String languagePreferred = store.getString(key);
+
+ // If language has found, get the corresponding configuration.
+ if (languagePreferred != null && !languagePreferred.isEmpty()) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, semanticElement, semanticElement);
+ if (!configuration.isSuperType()) {
+ configuration = getConfigurationSuperType(eClass, semanticElement);
+ }
+ } else {
+ configuration = getConfigurationSuperType(eClass, semanticElement);
+ }
+
+ i++;
+ }
+ }
+
+ return configuration;
+ }
}
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 92720e236dc..2b73a827912 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
@@ -11,6 +11,7 @@
* Christian W. Damus (CEA) - post refreshes for transaction commit asynchronously (CDO)
* Christian W. Damus (CEA) - bugs 429826, 434635, 437217, 441857
* Christian W. Damus - bugs 450235, 451683, 485220
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
*
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer;
@@ -63,7 +64,6 @@ import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenu;
import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
@@ -84,7 +84,6 @@ import org.eclipse.papyrus.views.modelexplorer.matching.ReferencableMatchingItem
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.graphics.Point;
@@ -1082,6 +1081,29 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
}
}
+ /**
+ * Edit an element contained on the common viewer.
+ *
+ * @param element
+ * The element to edit.
+ * @param numColumn
+ * The number of the column which contains the element to edit.
+ */
+ public void editElement(final EObject element, final int numColumn) {
+ ModelElementItemMatchingItem modelElementItemMatchingItem = new ModelElementItemMatchingItem(element);
+ if (null != modelElementItemMatchingItem) {
+ CommonViewer commonViewer = getCommonViewer();
+ if (null != commonViewer) {
+ commonViewer.getControl().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ commonViewer.editElement(modelElementItemMatchingItem, numColumn);
+ }
+ });
+ }
+ }
+ }
+
@Override
public void pageOpened(IPage page) {
refreshTree();

Back to the top