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/infra/nattable
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/infra/nattable')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.classpath2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF6
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/plugin.xml254
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorConfiguration.java44
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorParser.java129
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java40
7 files changed, 348 insertions, 133 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.classpath b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.classpath
index ad32c83a788..eca7bdba8f0 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.classpath
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.settings/org.eclipse.jdt.core.prefs
index 94d61f00da6..b3aa6d60f94 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
index 8c6e273480e..44cb4466d48 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable.modelexplorer,
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Name: %Bundle-Name
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)",
@@ -15,7 +15,9 @@ Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,
org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.ui;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.views.modelexplorer;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.papyrus.infra.nattable.modelexplorer.Activator
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/plugin.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/plugin.xml
index 0746ee37722..647b0add2cf 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/plugin.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/plugin.xml
@@ -1,120 +1,134 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension point="org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration">
- <modeldeclaration file="resources/PapyrusTable.custom"/>
- </extension>
- <extension point="org.eclipse.ui.handlers">
- <handler class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.RenameTableHandler" commandId="org.eclipse.ui.edit.rename">
- <activeWhen>
-
- <with variable="selection">
- <test forcePluginActivation="true" property="org.eclipse.papyrus.infra.nattable.modelexplorer.tablepropertytester.isTable" value="true">
- </test>
- </with>
-
- </activeWhen>
- </handler>
- </extension>
- <extension
- point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.papyrus.infra.nattable.modelexplorer.providers.TablePropertyTester"
- id="org.eclipse.papyrus.infra.nattable.modelexplorer.tablepropertytester"
- namespace="org.eclipse.papyrus.infra.nattable.modelexplorer.tablepropertytester"
- properties="isTable"
- type="org.eclipse.jface.viewers.IStructuredSelection">
- </propertyTester>
- </extension>
-
- <extension
- id="PapyrusQuickFormatHandler"
- name="QuickFormatHandler"
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
- commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingUpperCaseCommand">
- <activeWhen>
- <and>
- <with
- variable="selection">
- <test
- property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
- value="true">
- </test>
- </with>
- </and>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
- commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingLowerCaseCommand">
- <activeWhen>
- <and>
- <with
- variable="selection">
- <test
- property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
- value="true">
- </test>
- </with>
- </and>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
- commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingSwitchSpace2UnderscoreCommand">
- <activeWhen>
- <and>
- <with
- variable="selection">
- <test
- property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
- value="true">
- </test>
- </with>
- </and>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
- commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingCapitalizeFirstLetterCommand">
- <activeWhen>
- <and>
- <with
- variable="selection">
- <test
- property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
- value="true">
- </test>
- </with>
- </and>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
- commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingRemoveSpaceCommand">
- <activeWhen>
- <and>
- <with
- variable="selection">
- <test
- property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
- value="true">
- </test>
- </with>
- </and>
- </activeWhen>
- </handler>
-</extension>
- <extension
- point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableNamePropertyTester"
- id="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester"
- namespace="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester"
- properties="isNameChangeable"
- type="org.eclipse.jface.viewers.IStructuredSelection">
- </propertyTester>
- </extension>
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension point="org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration">
+ <modeldeclaration file="resources/PapyrusTable.custom"/>
+ </extension>
+ <extension point="org.eclipse.ui.handlers">
+ <handler class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.RenameTableHandler" commandId="org.eclipse.ui.edit.rename">
+ <activeWhen>
+
+ <with variable="selection">
+ <test forcePluginActivation="true" property="org.eclipse.papyrus.infra.nattable.modelexplorer.tablepropertytester.isTable" value="true">
+ </test>
+ </with>
+
+ </activeWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.infra.nattable.modelexplorer.providers.TablePropertyTester"
+ id="org.eclipse.papyrus.infra.nattable.modelexplorer.tablepropertytester"
+ namespace="org.eclipse.papyrus.infra.nattable.modelexplorer.tablepropertytester"
+ properties="isTable"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
+ </extension>
+
+ <extension
+ id="PapyrusQuickFormatHandler"
+ name="QuickFormatHandler"
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
+ commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingUpperCaseCommand">
+ <activeWhen>
+ <and>
+ <with
+ variable="selection">
+ <test
+ property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
+ commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingLowerCaseCommand">
+ <activeWhen>
+ <and>
+ <with
+ variable="selection">
+ <test
+ property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
+ commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingSwitchSpace2UnderscoreCommand">
+ <activeWhen>
+ <and>
+ <with
+ variable="selection">
+ <test
+ property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
+ commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingCapitalizeFirstLetterCommand">
+ <activeWhen>
+ <and>
+ <with
+ variable="selection">
+ <test
+ property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableQuickFormatHandler"
+ commandId="org.eclipse.papyrus.infra.ui.menu.commands.QuickFormattingRemoveSpaceCommand">
+ <activeWhen>
+ <and>
+ <with
+ variable="selection">
+ <test
+ property="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester.isNameChangeable"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+ </handler>
+</extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.infra.nattable.modelexplorer.handlers.NattableNamePropertyTester"
+ id="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester"
+ namespace="org.eclipse.papyrus.infra.nattable.modelexplorer.menu.quickformatpropertytester"
+ properties="isNameChangeable"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
+ <DirectEditor
+ contributor="All4Tec"
+ language="Table Direct Editor"
+ objectToEdit="org.eclipse.papyrus.infra.nattable.model.nattable.Table">
+ <popupeditor
+ editorConfiguration="org.eclipse.papyrus.infra.nattable.modelexplorer.directeditor.TableDirectEditorConfiguration">
+ </popupeditor>
+ <Priority
+ name="Medium">
+ </Priority>
+ </DirectEditor>
+ </extension>
+</plugin>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorConfiguration.java
new file mode 100644
index 00000000000..8cd32ae3bd4
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorConfiguration.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * 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.infra.nattable.modelexplorer.directeditor;
+
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.AbstractBasicDirectEditorConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ * Specific direct editor configuration to rename Table.
+ */
+public class TableDirectEditorConfiguration extends AbstractBasicDirectEditorConfiguration {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTextToEdit(final Object objectToEdit) {
+ if (objectToEdit instanceof Table) {
+ return ((Table) objectToEdit).getName();
+ }
+
+ return super.getTextToEdit(objectToEdit);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IParser createDirectEditorParser() {
+ return new TableDirectEditorParser(getTextToEdit(objectToEdit));
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorParser.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorParser.java
new file mode 100644
index 00000000000..74e2d73fcef
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/directeditor/TableDirectEditorParser.java
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * 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.infra.nattable.modelexplorer.directeditor;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ * Specific Parser for the Table.
+ */
+public class TableDirectEditorParser implements IParser {
+
+ /**
+ * Name of the current Table.
+ */
+ private String textToEdit;
+
+ /**
+ * Constructor.
+ *
+ */
+ public TableDirectEditorParser(final String textToEdit) {
+ this.textToEdit = textToEdit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getEditString(final IAdaptable element, final int flags) {
+ return this.textToEdit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getParseCommand(final IAdaptable element, final String newString, final int flags) {
+ CompositeCommand result = new CompositeCommand("Rename"); //$NON-NLS-1$
+
+ EObject eObjectElement = element.getAdapter(EObject.class);
+
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(eObjectElement);
+
+ AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "RenameCommand", null) { //$NON-NLS-1$
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param monitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (eObjectElement instanceof Table) {
+ if (null != newString && !newString.isEmpty()) {
+ ((Table) eObjectElement).setName(newString);
+ return CommandResult.newOKCommandResult();
+ }
+ }
+
+ return CommandResult.newCancelledCommandResult();
+ }
+ };
+
+ result.add(cmd);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(final IAdaptable element, final int flags) {
+ return this.textToEdit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(final Object event, final int flags) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IContentAssistProcessor getCompletionProcessor(final IAdaptable element) {
+ // Not used
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IParserEditStatus isValidEditString(final IAdaptable element, final String editString) {
+ // Not used
+ return null;
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java
index 79f69725e2d..a1623c64850 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java
@@ -8,6 +8,8 @@
*
* Contributors:
* Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.modelexplorer.handlers;
@@ -18,29 +20,26 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.modelexplorer.messages.Messages;
+import org.eclipse.papyrus.views.modelexplorer.DirectEditorEditingSupport;
import org.eclipse.swt.widgets.Display;
/**
* This handler provides the method to rename a Table
- *
- *
- *
*/
public class RenameTableHandler extends AbstractTableCommandHandler {
/**
- *
- * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#getCommand()
- *
- * @return
+ * {@inheritDoc}
*/
@Override
protected Command getCommand(IEvaluationContext context) {
@@ -73,4 +72,31 @@ public class RenameTableHandler extends AbstractTableCommandHandler {
}
return UnexecutableCommand.INSTANCE;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean computeEnabled(final IEvaluationContext context) {
+ boolean computeEnabled = super.computeEnabled(context);
+ if (computeEnabled) {
+ List<EObject> selectedElements = getSelectedElements();
+ EObject selection = selectedElements.get(0);
+ computeEnabled = !EMFHelper.isReadOnly(selection) && !isHandledByDirectEditor(selection);
+ }
+
+ return computeEnabled;
+ }
+
+ /**
+ * Check whether the editing of an element is handled by a direct editor. In this case, we do
+ * not want to open the rename pop-up.
+ *
+ * @param element
+ * an element that should be edited.
+ * @return true, if handled by a direct editor
+ */
+ protected boolean isHandledByDirectEditor(final EObject element) {
+ return null != DirectEditorEditingSupport.getConfiguration(element);
+ }
}

Back to the top