Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-12-13 14:50:55 +0000
committervincent lorenzo2016-12-14 09:04:31 +0000
commitdf54f7df13da57bb2df54e21041658adc78a5694 (patch)
tree072d8ff7b37c137d6d4e5dc0159f8dad23a3485d /plugins/infra/gmfdiag
parent421a002124a0d73377fffca5a398bd1f3a90dfcd (diff)
downloadorg.eclipse.papyrus-df54f7df13da57bb2df54e21041658adc78a5694.tar.gz
org.eclipse.papyrus-df54f7df13da57bb2df54e21041658adc78a5694.tar.xz
org.eclipse.papyrus-df54f7df13da57bb2df54e21041658adc78a5694.zip
Bug 509155: [Internationalization] F2 on elements does not modify label
https://bugs.eclipse.org/bugs/show_bug.cgi?id=509155 - Modify the new DirectEditorConfiguration for NamedElements Diagrams and Tables to manage the label of internationalization Change-Id: I2a449b09ee009dcc93678a17a225221ac1fd49f4 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/infra/gmfdiag')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorConfiguration.java30
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorParser.java28
2 files changed, 54 insertions, 4 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorConfiguration.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorConfiguration.java
index 31954e4e7fc..4065cb7f572 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorConfiguration.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorConfiguration.java
@@ -16,6 +16,8 @@ package org.eclipse.papyrus.infra.gmfdiag.modelexplorer.directeditor;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.extensionpoints.editors.configuration.AbstractBasicDirectEditorConfiguration;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationPreferencesUtils;
/**
* Specific direct editor configuration to rename Diagram.
@@ -27,11 +29,33 @@ public class DiagramDirectEditorConfiguration extends AbstractBasicDirectEditorC
*/
@Override
public String getTextToEdit(final Object objectToEdit) {
+ String result = null;
if (objectToEdit instanceof Diagram) {
- return ((Diagram) objectToEdit).getName();
+ final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(((Diagram) objectToEdit));
+ if (null != diagramLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(((Diagram) objectToEdit))) {
+ result = diagramLabel;
+ } else {
+ result = ((Diagram) objectToEdit).getName();
+ }
}
- return super.getTextToEdit(objectToEdit);
+ return null != result ? result : super.getTextToEdit(objectToEdit);
+ }
+
+ /**
+ * This allows to determinate if the label is set and can be modified.
+ *
+ * @param objectToEdit
+ * The object to edit.
+ * @return <code>true</code> if this is a label modification, <code>false</code> otherwise.
+ */
+ public boolean isLabelSet(final Object objectToEdit) {
+ boolean result = false;
+ if (objectToEdit instanceof Diagram) {
+ final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(((Diagram) objectToEdit));
+ result = null != diagramLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(((Diagram) objectToEdit));
+ }
+ return result;
}
/**
@@ -39,7 +63,7 @@ public class DiagramDirectEditorConfiguration extends AbstractBasicDirectEditorC
*/
@Override
public IParser createDirectEditorParser() {
- return new DiagramDirectEditorParser(getTextToEdit(objectToEdit));
+ return new DiagramDirectEditorParser(getTextToEdit(objectToEdit), isLabelSet(objectToEdit));
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorParser.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorParser.java
index 649bc4b748c..f8a25b5fa19 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorParser.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/directeditor/DiagramDirectEditorParser.java
@@ -27,6 +27,7 @@ import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
/**
* Specific Parser for the Diagram.
@@ -39,10 +40,31 @@ public class DiagramDirectEditorParser implements IParser {
private String textToEdit;
/**
+ * Determinates if this is a label modification.
+ */
+ private boolean labelModification;
+
+ /**
* Constructor.
+ *
+ * @param textToEdit
+ * The text to edit.
*/
public DiagramDirectEditorParser(final String textToEdit) {
+ this(textToEdit, false);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param textToEdit
+ * The text to edit.
+ * @param labelModification
+ * Determinates if this is a label modification.
+ */
+ public DiagramDirectEditorParser(final String textToEdit, final boolean labelModification) {
this.textToEdit = textToEdit;
+ this.labelModification = labelModification;
}
/**
@@ -70,7 +92,11 @@ public class DiagramDirectEditorParser implements IParser {
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
if (eObjectElement instanceof Diagram) {
if (null != newString && !newString.isEmpty()) {
- ((Diagram) eObjectElement).setName(newString);
+ if (labelModification) {
+ LabelInternationalization.getInstance().setDiagramLabel(((Diagram) eObjectElement), newString, null);
+ } else {
+ ((Diagram) eObjectElement).setName(newString);
+ }
return CommandResult.newOKCommandResult();
}
}

Back to the top