diff options
author | Nicolas FAUVERGUE | 2017-07-26 15:50:48 +0000 |
---|---|---|
committer | vincent lorenzo | 2017-07-31 10:56:22 +0000 |
commit | bb96c6df3dc9b114a26a51ae850489b2a7259538 (patch) | |
tree | d944c9396d329b2ab1ae8ecdfe34f7615e45c7dc /plugins/infra/properties | |
parent | 63c76bf7bca32aa9daabd5b4e6014f5614cd78a7 (diff) | |
download | org.eclipse.papyrus-bb96c6df3dc9b114a26a51ae850489b2a7259538.tar.gz org.eclipse.papyrus-bb96c6df3dc9b114a26a51ae850489b2a7259538.tar.xz org.eclipse.papyrus-bb96c6df3dc9b114a26a51ae850489b2a7259538.zip |
Bug 515650: [Property View] Internationalization of labels presented in
property pages https://bugs.eclipse.org/bugs/show_bug.cgi?id=515650
Manage internationalization for labels in properties view only for
objects that are internationalized by a '*.properties' file.
Change-Id: I3e2762a7ef62e2988b592cc47ae0e1548165e989
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/infra/properties')
2 files changed, 43 insertions, 0 deletions
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/ILabeledModelElement.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/ILabeledModelElement.java new file mode 100644 index 00000000000..d9da82ed5d2 --- /dev/null +++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/ILabeledModelElement.java @@ -0,0 +1,31 @@ +/*****************************************************************************
+ * Copyright (c) 2017 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:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.properties.ui.modelelement;
+
+/**
+ * This allows to manage a custom label for the model elements.
+ * This will be used for the internationalization in a first step.
+ */
+public interface ILabeledModelElement {
+
+ /**
+ * Get a custom label.
+ *
+ * @param propertyPath
+ * The property path of the element to manage.
+ * @return The string to display.
+ */
+ public String getLabel(final String propertyPath);
+
+}
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/AbstractPropertyEditor.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/AbstractPropertyEditor.java index e4a40af674c..e0d3fdc795d 100644 --- a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/AbstractPropertyEditor.java +++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/AbstractPropertyEditor.java @@ -32,6 +32,8 @@ import org.eclipse.papyrus.infra.properties.internal.ui.Activator; import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource; import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSourceChangedEvent; import org.eclipse.papyrus.infra.properties.ui.modelelement.IDataSourceListener; +import org.eclipse.papyrus.infra.properties.ui.modelelement.ILabeledModelElement; +import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement; import org.eclipse.papyrus.infra.properties.ui.runtime.PropertiesRuntime; import org.eclipse.papyrus.infra.properties.ui.util.PropertiesUtil; import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor; @@ -360,6 +362,16 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi if (customLabel != null) { return customLabel; } + + if(null != getInput()) { + final ModelElement modelElement = getInput().getModelElement(propertyPath); + if(modelElement instanceof ILabeledModelElement) { + final String label = ((ILabeledModelElement)modelElement).getLabel(getLocalPropertyPath()); + if(null != label && !label.isEmpty()) { + return label; + } + } + } Property property = getModelProperty(); if (property == null || property.getLabel() == null || property.getLabel().trim().equals("")) { //$NON-NLS-1$ |