Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-11-07 05:33:34 -0500
committerPatrick Tessier2018-11-09 12:11:51 -0500
commit2dd5ffbff80f4d6c903a812301479b786507e81f (patch)
tree1d48ba5fd5d7f8b65b82d3ccdf1c0301590d0cbc
parent2d38e814846af71469560d5081d66876c4db5cc9 (diff)
downloadorg.eclipse.papyrus-2dd5ffbff80f4d6c903a812301479b786507e81f.tar.gz
org.eclipse.papyrus-2dd5ffbff80f4d6c903a812301479b786507e81f.tar.xz
org.eclipse.papyrus-2dd5ffbff80f4d6c903a812301479b786507e81f.zip
Bug 515967: [Label Customization] Available label custo not always
coherent with selected element Manage the refresh of the checkboxes depending to the selection. Change-Id: Id8c7c8a25ad85e91b453248eace76f11e69c66ed Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/pom.xml2
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/XWTCompliantMaskProviderUpdater.java34
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/StringMask.java67
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringMask.java14
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LabelCustomizationMaskProvider.java17
7 files changed, 127 insertions, 11 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
index 0b071ff83ad..50c8d1c28c7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.infra.gmfdiag.properties.constraint,
org.eclipse.papyrus.infra.gmfdiag.properties.extension,
org.eclipse.papyrus.infra.gmfdiag.properties.modelelement
-Require-Bundle: org.eclipse.papyrus.infra.properties.ui;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
+Require-Bundle: org.eclipse.papyrus.infra.properties.ui;bundle-version="[3.4.0,4.0.0)";visibility:=reexport,
org.eclipse.core.databinding.beans;bundle-version="[1.3.0,2.0.0)",
org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="[2.0.0,3.0.0)",
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/META-INF/MANIFEST.MF b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/META-INF/MANIFEST.MF
index 6e4a1d4913c..99f6d65b561 100644
--- a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/META-INF/MANIFEST.MF
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/META-INF/MANIFEST.MF
@@ -26,7 +26,7 @@ Require-Bundle: org.eclipse.papyrus.infra.properties;bundle-version="[3.0.0,4.0.
org.eclipse.xwt;bundle-version="[1.3.1,2.0.0)",
org.eclipse.papyrus.infra.ui.emf;bundle-version="[2.0.0,3.0.0)";visibility:=reexport
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 3.3.0.qualifier
+Bundle-Version: 3.4.0.qualifier
Eclipse-BuddyPolicy: dependent
Bundle-Activator: org.eclipse.papyrus.infra.properties.internal.ui.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/pom.xml b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/pom.xml
index b4146c9cc69..b88fbae9a80 100644
--- a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/pom.xml
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.properties.ui</artifactId>
- <version>3.3.0-SNAPSHOT</version>
+ <version>3.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/XWTCompliantMaskProviderUpdater.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/XWTCompliantMaskProviderUpdater.java
new file mode 100644
index 00000000000..1b2900ef102
--- /dev/null
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/XWTCompliantMaskProviderUpdater.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.properties.ui.providers;
+
+import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource;
+
+/**
+ * This allows to update the data source of the XWT compliant mask provider for the properties view.
+ *
+ * @since 3.4
+ */
+public interface XWTCompliantMaskProviderUpdater {
+
+ /**
+ * This allows to update the data source depending to the observable.
+ *
+ * @param input
+ * The input to set.
+ */
+ public void setInput(final DataSource input);
+}
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/StringMask.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/StringMask.java
index c206f5a3f33..64681974f0a 100644
--- a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/StringMask.java
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/StringMask.java
@@ -10,11 +10,16 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 515967
*****************************************************************************/
package org.eclipse.papyrus.infra.properties.ui.widgets;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource;
import org.eclipse.papyrus.infra.properties.ui.providers.XWTCompliantMaskProvider;
import org.eclipse.papyrus.infra.properties.ui.providers.XWTCompliantMaskProviderListener;
+import org.eclipse.papyrus.infra.properties.ui.providers.XWTCompliantMaskProviderUpdater;
import org.eclipse.swt.widgets.Composite;
/**
@@ -33,6 +38,11 @@ public class StringMask extends AbstractPropertyEditor implements XWTCompliantMa
private boolean maskProviderReady = false;
/**
+ * The change listener to update the editor checkboxes when needed.
+ */
+ private IChangeListener changeListener;
+
+ /**
*
* Constructor.
*
@@ -58,6 +68,11 @@ public class StringMask extends AbstractPropertyEditor implements XWTCompliantMa
return new org.eclipse.papyrus.infra.widgets.editors.StringMask(parent, style);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor#checkInput()
+ */
@Override
protected void checkInput() {
if (maskProvider != null && maskProviderReady) {
@@ -107,10 +122,62 @@ public class StringMask extends AbstractPropertyEditor implements XWTCompliantMa
return maskProvider;
}
+ @Override
public void notifyReady(XWTCompliantMaskProvider provider) {
this.maskProviderReady = true;
editor.setMasks(maskProvider.getMasks());
provider.removeMaskProviderListener(this);
checkInput();
}
+
+ /**
+ * Manage the change listener for the input.
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor#setInput(org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource)
+ */
+ @Override
+ public void setInput(final DataSource input) {
+ final DataSource oldInput = this.input;
+
+ super.setInput(input);
+
+ if (input != oldInput) {
+ if (oldInput != null) {
+ oldInput.removeChangeListener(getChangeListener());
+ }
+
+ if (input != null) {
+ input.addChangeListener(getChangeListener());
+ }
+ }
+ }
+
+ /**
+ * This allows to create the change listener which allow to update the checkboxes of the editor.
+ *
+ * @return The created change listener.
+ * @since 3.4
+ */
+ protected IChangeListener getChangeListener() {
+ if (changeListener == null) {
+ changeListener = new IChangeListener() {
+
+ @Override
+ public void handleChange(ChangeEvent event) {
+ if (null != maskProvider) {
+ if (maskProvider instanceof XWTCompliantMaskProviderUpdater) {
+ ((XWTCompliantMaskProviderUpdater) maskProvider).setInput(getInput());
+ }
+
+ if (null != editor) {
+ editor.setMasks(maskProvider.getMasks());
+ }
+ }
+ }
+ };
+ }
+ return changeListener;
+ }
+
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringMask.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringMask.java
index 4c9d7e95453..c9c89b6fed6 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringMask.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringMask.java
@@ -10,6 +10,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 515967
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
@@ -68,7 +69,7 @@ public class StringMask extends AbstractListEditor implements SelectionListener,
}
public Collection<String> getValue() {
- Set<String> values = new HashSet<String>();
+ Set<String> values = new HashSet<>();
for (Button button : checkboxes) {
if (button.getSelection()) {
String value = (String) button.getData(DATA_KEY);
@@ -105,6 +106,9 @@ public class StringMask extends AbstractListEditor implements SelectionListener,
}
public void setMasks(final Map<String, String> values) {
+ if (!refreshCheckboxes) {
+ return;
+ }
if (checkboxes != null) {
disposeCheckboxes();
}
@@ -167,7 +171,7 @@ public class StringMask extends AbstractListEditor implements SelectionListener,
public void widgetSelected(final SelectionEvent e) {
Button button = (Button) e.widget;
String value = (String) button.getData(DATA_KEY);
- Collection<String> values = new HashSet<String>(getCurrentValue());
+ Collection<String> values = new HashSet<>(getCurrentValue());
if (button.getSelection()) {
values.add(value);
} else {
@@ -177,15 +181,15 @@ public class StringMask extends AbstractListEditor implements SelectionListener,
}
protected void setCurrentValue(final Collection<String> values) {
+ refreshCheckboxes = false;
if (modelProperty != null) {
- refreshCheckboxes = false;
modelProperty.clear();
modelProperty.addAll(values);
- refreshCheckboxes = true;
}
currentValue = values;
commit();
+ refreshCheckboxes = true;
}
protected Collection<String> getCurrentValue() {
@@ -217,7 +221,7 @@ public class StringMask extends AbstractListEditor implements SelectionListener,
@Override
public void changeColorField() {
-
+
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LabelCustomizationMaskProvider.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LabelCustomizationMaskProvider.java
index 3cd010d637f..22a469d873f 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LabelCustomizationMaskProvider.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LabelCustomizationMaskProvider.java
@@ -10,6 +10,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 515967
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -25,6 +26,7 @@ import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource;
import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement;
import org.eclipse.papyrus.infra.properties.ui.providers.XWTCompliantMaskProvider;
import org.eclipse.papyrus.infra.properties.ui.providers.XWTCompliantMaskProviderListener;
+import org.eclipse.papyrus.infra.properties.ui.providers.XWTCompliantMaskProviderUpdater;
import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart;
import org.eclipse.papyrus.uml.properties.modelelement.UMLNotationModelElement;
@@ -34,7 +36,7 @@ import org.eclipse.papyrus.uml.properties.modelelement.UMLNotationModelElement;
*
* @author Camille Letavernier
*/
-public class LabelCustomizationMaskProvider implements XWTCompliantMaskProvider {
+public class LabelCustomizationMaskProvider implements XWTCompliantMaskProvider, XWTCompliantMaskProviderUpdater {
private IMaskManagedLabelEditPolicy editPolicy;
@@ -42,11 +44,12 @@ public class LabelCustomizationMaskProvider implements XWTCompliantMaskProvider
private String propertyPath;
- private final Set<XWTCompliantMaskProviderListener> listeners = new HashSet<XWTCompliantMaskProviderListener>();
+ private final Set<XWTCompliantMaskProviderListener> listeners = new HashSet<>();
public LabelCustomizationMaskProvider() {
}
+ @Override
public Map<String, String> getMasks() {
return editPolicy.getMasks();
}
@@ -60,7 +63,13 @@ public class LabelCustomizationMaskProvider implements XWTCompliantMaskProvider
return propertyPath;
}
- public void setInput(DataSource input) {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.properties.ui.providers.XWTCompliantMaskProviderUpdater#setInput(org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource)
+ */
+ @Override
+ public void setInput(final DataSource input) {
this.input = input;
checkInput();
}
@@ -119,10 +128,12 @@ public class LabelCustomizationMaskProvider implements XWTCompliantMaskProvider
}
}
+ @Override
public void addMaskProviderListener(XWTCompliantMaskProviderListener listener) {
listeners.add(listener);
}
+ @Override
public void removeMaskProviderListener(XWTCompliantMaskProviderListener listener) {
listeners.remove(listener);
}

Back to the top