diff options
author | Fanch BONNABESSE | 2017-09-12 08:57:55 +0000 |
---|---|---|
committer | vincent lorenzo | 2017-09-26 10:52:49 +0000 |
commit | b4cc83e670703e491cd3d2365910519660ea8347 (patch) | |
tree | a1000094f8221abd0538654d1bba5393756a8296 /plugins/uml/properties | |
parent | 8c13243f02fe2048026380ce9812664495333d0d (diff) | |
download | org.eclipse.papyrus-b4cc83e670703e491cd3d2365910519660ea8347.tar.gz org.eclipse.papyrus-b4cc83e670703e491cd3d2365910519660ea8347.tar.xz org.eclipse.papyrus-b4cc83e670703e491cd3d2365910519660ea8347.zip |
Bug 522124: [Property View] Interaction between Component of the
Property View must be easier to do
https://bugs.eclipse.org/bugs/show_bug.cgi?id=522124
- Modify AbstractPropertyEditor to take create two properties and
manage observable listeners.
- Add an interface to handle properties listener.
- Export new package
"org.eclipse.papyrus.infra.properties.ui.listeners".
- Add an example "ReadOnlyStringPropertiesListener".
- Add of the documentation and an example.
Change-Id: Ia93d13ac84219fad09cb53cc68117f8c1077335e
Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
Diffstat (limited to 'plugins/uml/properties')
-rw-r--r-- | plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/listeners/ReadOnlyStringPropertiesListener.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/listeners/ReadOnlyStringPropertiesListener.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/listeners/ReadOnlyStringPropertiesListener.java new file mode 100644 index 00000000000..7816319d9da --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/listeners/ReadOnlyStringPropertiesListener.java @@ -0,0 +1,52 @@ +/***************************************************************************** + * 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: + * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation, Bug 522124 + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.properties.listeners; + +import java.util.Set; + +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.papyrus.infra.properties.ui.listeners.IPropertiesListener; +import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource; +import org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor; + +/** + * PropertiesListener to set readonly an editor based on the value of a String input. + * + * @since 3.0 + */ +public class ReadOnlyStringPropertiesListener implements IPropertiesListener { + + /** + * {@inheritDoc} + */ + @Override + public void handle(final AbstractPropertyEditor editor, final DataSource input, final Set<String> listeningPropertyPaths) { + boolean isReadOnly = false; + for (String propertyPath : listeningPropertyPaths) { + IObservable observable = input.getObservable(propertyPath); + + if (observable instanceof IObservableValue<?>) { + Object value = ((IObservableValue) observable).getValue(); + + if (value instanceof String && !((String) value).isEmpty()) { + isReadOnly = true; + } + } + } + + editor.setReadOnly(isReadOnly); + } + +} |