diff options
author | Nicolas FAUVERGUE | 2018-11-07 10:33:34 +0000 |
---|---|---|
committer | Patrick Tessier | 2018-11-09 17:11:51 +0000 |
commit | 2dd5ffbff80f4d6c903a812301479b786507e81f (patch) | |
tree | 1d48ba5fd5d7f8b65b82d3ccdf1c0301590d0cbc /plugins/infra/properties | |
parent | 2d38e814846af71469560d5081d66876c4db5cc9 (diff) | |
download | org.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>
Diffstat (limited to 'plugins/infra/properties')
4 files changed, 103 insertions, 2 deletions
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; + } + } |