Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/META-INF/MANIFEST.MF2
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/build.properties3
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml2
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/examples/InteractionComponent_Example.zipbin0 -> 10332 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_1.jpgbin0 -> 14138 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_empty.jpgbin0 -> 11377 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/example_xwt.pngbin0 -> 26554 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_false.jpgbin0 -> 10862 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_true.jpgbin0 -> 11184 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_private.jpgbin0 -> 13972 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_public.JPGbin0 -> 13959 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/properties-view.mediawiki72
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/META-INF/MANIFEST.MF67
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/pom.xml20
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/listeners/IPropertiesListener.java40
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/AbstractPropertyEditor.java236
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/listeners/ReadOnlyStringPropertiesListener.java52
17 files changed, 438 insertions, 56 deletions
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/META-INF/MANIFEST.MF b/plugins/doc/org.eclipse.papyrus.views.properties.doc/META-INF/MANIFEST.MF
index 137495bd603..75436b2b92f 100644
--- a/plugins/doc/org.eclipse.papyrus.views.properties.doc/META-INF/MANIFEST.MF
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Require-Bundle: org.eclipse.help;bundle-version="[3.7.0,4.0.0)",
org.eclipse.papyrus.infra.doc;bundle-version="[1.2.0,2.0.0)"
Bundle-Vendor: Eclipse Modeling Project
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Name: Properties view Documentation
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.views.properties.doc;singleton:=true
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/build.properties b/plugins/doc/org.eclipse.papyrus.views.properties.doc/build.properties
index 064e816b187..47844d4d1b7 100644
--- a/plugins/doc/org.eclipse.papyrus.views.properties.doc/build.properties
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/build.properties
@@ -1,6 +1,7 @@
bin.includes = META-INF/,\
about.html,\
plugin.xml,\
- target/generated-eclipse-help/**
+ target/generated-eclipse-help/**,\
+ resource/examples/
src.includes = about.html,\
resource/
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml b/plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml
index 40bef8e9820..4b8cc842c16 100644
--- a/plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml
@@ -8,7 +8,7 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.views.properties.doc</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>
<plugins>
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/examples/InteractionComponent_Example.zip b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/examples/InteractionComponent_Example.zip
new file mode 100644
index 00000000000..0abc5876282
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/examples/InteractionComponent_Example.zip
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_1.jpg b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_1.jpg
new file mode 100644
index 00000000000..31eadba8b4f
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_1.jpg
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_empty.jpg b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_empty.jpg
new file mode 100644
index 00000000000..36929c11678
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/className_empty.jpg
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/example_xwt.png b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/example_xwt.png
new file mode 100644
index 00000000000..37634f1cba3
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/example_xwt.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_false.jpg b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_false.jpg
new file mode 100644
index 00000000000..1fed2de5c84
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_false.jpg
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_true.jpg b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_true.jpg
new file mode 100644
index 00000000000..3eba0119514
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/isAbstract_true.jpg
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_private.jpg b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_private.jpg
new file mode 100644
index 00000000000..6f45b84bb44
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_private.jpg
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_public.JPG b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_public.JPG
new file mode 100644
index 00000000000..dbdbb6d1fb7
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/images/visibility_public.JPG
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/properties-view.mediawiki b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/properties-view.mediawiki
index f60a07c2faa..1f42b2a86c0 100644
--- a/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/properties-view.mediawiki
+++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/resource/properties-view.mediawiki
@@ -329,7 +329,77 @@ You can now open the *.ctx file and customize your property view.
Papyrus provides a simple tool to deploy a property view locally (Right click on a CTX file -> Deploy/Undeploy)
-==Multipllicity Editor==
+
+===Interaction between Components===
+
+Papyrus provides a way to synchronize several widgets between them. Indeed, this is possible by modifying the XWT files corresponding to the desired components.
+
+====How to use it ?====
+
+To set up the interaction between several components, two global variables were created in "AbstractPropertyEditor":
+* '''listeningPropertyPaths''': list of properties to listen,
+* '''listenerClasses''': list of classes used to define the behaviors to be adopted when modifying the values of the properties.
+ A class is defined as: 'bundle name'/'path of the class'
+
+So we need to use these names as attributes in the desired XWT files.
+
+Next, create a class that inherits from "IPropertiesListener" or use an existing class such as "ReadOnlyStringPropertiesListener". The purpose of this class is to define the behavior of the chosen editor according to the associated input.
+
+It is at the ListenerClasses attribute that will be defined this class. The link will be made between the editor and the "PropertiesListener".
+
+Here is an example of adding attributes to an XWT file:
+
+[[File:images/example_xwt.png|Adding of attributes to an XWT file]]
+
+====Examples====
+
+An example "InteractionComponent_Example.zip" is provided in the plugin '''org.eclipse.papyrus.views.properties.doc''', in the folder '''resource.examples'''. it is intended to show how the mechanism should be used.
+
+There are 3 examples of interaction between components.
+
+=====First example=====
+For this example, create and select a class. In the 'Properties' view, a new 'tab' is present "InteractionComponent".
+In this tab, if the name is not empty it is not possible to modify the label. This property is readOnly.
+This is the listener "ReadOnlyStringPropertiesListener" that is used.
+
+When the 'Name' is empty, the 'Label' can be modified:
+
+[[File:images/className_empty.jpg|'Label' can be modified]]
+
+Otherwise it is read-only:
+
+[[File:images/className_1.jpg|'Label' set to read-only]]
+
+=====Second example=====
+It is still necessary to use a class, this time the modification is done on a boolean. Modifying the 'isAbstract' property activates/deactivates the 'isActive' property.
+This is the listener "ReadOnlyBooleanPropertiesListener" that is used.
+
+When 'isAbstract' is 'true', 'isActive' can be changed:
+
+[[File:images/isAbstract_true.jpg|'Is active' can be modified]]
+
+Otherwise it is read-only:
+
+[[File:images/isAbstract_false.jpg|'Is active' set to read only]]
+
+=====Third example=====
+Here you have to create a constraint and select it.
+
+The enumerated 'Visibility' activates/deactivates the property 'Context'.
+
+If the value is 'Public', the modification is possible, otherwise the property is read-only.
+The listener used is "ReadOnlyVisibilityPropertiesListener".
+
+When 'Visibility' is 'Public', 'Context' can be changed:
+
+[[File:images/visibility_public.jpg|'Context' can be modified]]
+
+Otherwise it is read-only:
+
+[[File:images/visibility_private.jpg|'Context' set to read only]]
+
+
+==Multiplicity Editor==
===Description===
The multiplicity editor contains two modes of edition:
* The '''simple''' mode which allows to edit the lower and the upper values from a unique editor
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 7ca7fc840f0..3a27044e588 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
@@ -1,33 +1,34 @@
-Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.infra.properties.internal.ui;x-internal:=true,
- org.eclipse.papyrus.infra.properties.internal.ui.extensions;x-friends:="org.eclipse.papyrus.views.properties",
- org.eclipse.papyrus.infra.properties.internal.ui.messages;x-internal:=true,
- org.eclipse.papyrus.infra.properties.internal.ui.observable;x-internal:=true,
- org.eclipse.papyrus.infra.properties.internal.ui.runtime;x-friends:="org.eclipse.papyrus.views.properties.toolsmiths,org.eclipse.papyrus.views.properties",
- org.eclipse.papyrus.infra.properties.ui.creation,
- org.eclipse.papyrus.infra.properties.ui.modelelement,
- org.eclipse.papyrus.infra.properties.ui.preferences,
- org.eclipse.papyrus.infra.properties.ui.providers,
- org.eclipse.papyrus.infra.properties.ui.runtime,
- org.eclipse.papyrus.infra.properties.ui.util,
- org.eclipse.papyrus.infra.properties.ui.widgets,
- org.eclipse.papyrus.infra.properties.ui.widgets.layout,
- org.eclipse.papyrus.infra.properties.ui.xwt
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.papyrus.infra.properties;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.widgets;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.xwt;bundle-version="[1.2.0,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.0.0.qualifier
-Eclipse-BuddyPolicy: dependent
-Bundle-Activator: org.eclipse.papyrus.infra.properties.internal.ui.Activator
-Bundle-ManifestVersion: 2
-Bundle-Description: %pluginDescription
-Bundle-SymbolicName: org.eclipse.papyrus.infra.properties.ui;singleton:=true
+Manifest-Version: 1.0
+Export-Package: org.eclipse.papyrus.infra.properties.internal.ui;x-internal:=true,
+ org.eclipse.papyrus.infra.properties.internal.ui.extensions;x-friends:="org.eclipse.papyrus.views.properties",
+ org.eclipse.papyrus.infra.properties.internal.ui.messages;x-internal:=true,
+ org.eclipse.papyrus.infra.properties.internal.ui.observable;x-internal:=true,
+ org.eclipse.papyrus.infra.properties.internal.ui.runtime;x-friends:="org.eclipse.papyrus.views.properties.toolsmiths,org.eclipse.papyrus.views.properties",
+ org.eclipse.papyrus.infra.properties.ui.creation,
+ org.eclipse.papyrus.infra.properties.ui.listeners,
+ org.eclipse.papyrus.infra.properties.ui.modelelement,
+ org.eclipse.papyrus.infra.properties.ui.preferences,
+ org.eclipse.papyrus.infra.properties.ui.providers,
+ org.eclipse.papyrus.infra.properties.ui.runtime,
+ org.eclipse.papyrus.infra.properties.ui.util,
+ org.eclipse.papyrus.infra.properties.ui.widgets,
+ org.eclipse.papyrus.infra.properties.ui.widgets.layout,
+ org.eclipse.papyrus.infra.properties.ui.xwt
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.papyrus.infra.properties;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.widgets;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.xwt;bundle-version="[1.2.0,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.1.0.qualifier
+Eclipse-BuddyPolicy: dependent
+Bundle-Activator: org.eclipse.papyrus.infra.properties.internal.ui.Activator
+Bundle-ManifestVersion: 2
+Bundle-Description: %pluginDescription
+Bundle-SymbolicName: org.eclipse.papyrus.infra.properties.ui;singleton:=true
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 f403af2a073..03496be8fdf 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
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-properties</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.properties.ui</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-properties</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.properties.ui</artifactId>
+ <version>3.1.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/listeners/IPropertiesListener.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/listeners/IPropertiesListener.java
new file mode 100644
index 00000000000..9d6c8b9c2fd
--- /dev/null
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/listeners/IPropertiesListener.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * 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.infra.properties.ui.listeners;
+
+import java.util.Set;
+
+import org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource;
+import org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor;
+
+/**
+ * Interface that handles behavior for a specific editor.
+ *
+ * @since 3.1
+ */
+public interface IPropertiesListener {
+
+ /**
+ * Handle the behavior required for a editor according to the input and property paths.
+ *
+ * @param editor
+ * the property editor.
+ * @param input
+ * the current input.
+ * @param listeningPropertyPaths
+ * list of properties listened by the editor.
+ */
+ public void handle(final AbstractPropertyEditor editor, final DataSource input, final Set<String> listeningPropertyPaths);
+
+}
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 0724726d7dd..d644486d241 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
@@ -16,10 +16,16 @@
* Sebastien Gabel (Esterel Technologies SAS) - bug 497367
* Sebastien Gabel (Esterel Technologies SAS) - bug 497461
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 515650
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 522124
*
*****************************************************************************/
package org.eclipse.papyrus.infra.properties.ui.widgets;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
@@ -27,9 +33,11 @@ import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.contexts.Property;
import org.eclipse.papyrus.infra.properties.internal.ui.Activator;
+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.modelelement.DataSourceChangedEvent;
import org.eclipse.papyrus.infra.properties.ui.modelelement.IDataSourceListener;
@@ -45,6 +53,7 @@ import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
+import org.osgi.framework.Bundle;
/**
@@ -115,6 +124,44 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
public static int descriptionMaxCharPerLine = 200;
/**
+ * List separator for listenerClasses and listeningPropertyPaths.
+ */
+ private static final String LIST_SEPARATOR = ","; //$NON-NLS-1$
+
+ /**
+ * Separator for bundle and class on the listenerClasses value.
+ */
+ private static final String BUNDLE_SEPARATOR = "/"; //$NON-NLS-1$
+
+ /**
+ * List of properties to listen.
+ *
+ * @since 3.1
+ */
+ protected String listeningPropertyPaths;
+
+ /**
+ * HashSet of Listening property paths.
+ *
+ * @since 3.1
+ */
+ protected Set<String> listeningPropertyPathsSet;
+
+ /**
+ * List of classes used to define the behaviors to be adopted when modifying the values of the properties.
+ *
+ * @since 3.1
+ */
+ protected String listenerClasses;
+
+ /**
+ * HashSet of listener classes.
+ *
+ * @since 3.1
+ */
+ protected Set<IPropertiesListener> listenerClassesSet;
+
+ /**
* Constructor.
* When using this constructor, you should explicitly call the #setEditor method.
*/
@@ -280,6 +327,8 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
checkInput();
updateLabel();
updateDescription();
+
+ manageObservableListeners();
}
/**
@@ -337,6 +386,8 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
// Only do this after attaching our listener so that it will be ahead of
// any ModelElements created for properties
checkInput();
+
+ manageObservableListeners();
}
}
@@ -363,12 +414,12 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
if (customLabel != null) {
return customLabel;
}
-
- if(null != getInput()) {
+
+ 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()) {
+ if (modelElement instanceof ILabeledModelElement) {
+ final String label = ((ILabeledModelElement) modelElement).getLabel(getLocalPropertyPath());
+ if (null != label && !label.isEmpty()) {
return label;
}
}
@@ -555,7 +606,7 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
/**
* Sets the editor's Layout
- *
+ *
* @param layout
*/
public void setLayout(Layout layout) {
@@ -566,15 +617,15 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
/**
* Returns the editor's Layout
- *
+ *
* @return
- * The editor's layout
+ * The editor's layout
*/
public Layout getLayout() {
return getEditor() == null ? null : getEditor().getLayout();
}
- /**
+ /**
* Indicates whether the editor's label should be displayed or not
*
* @param showLabel
@@ -695,4 +746,171 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
return dataSourceListener;
}
+
+ /**
+ * Return the listening property paths.
+ *
+ * @return the listeningPropertyPaths The listening property paths.
+ * @since 3.1
+ */
+ public String getListeningPropertyPaths() {
+ return listeningPropertyPaths;
+ }
+
+ /**
+ * Return the HashSet of listening property paths.
+ *
+ * @return the listeningPropertyPathsSet The HashSet of listening property paths.
+ * @since 3.1
+ */
+ public Set<String> getListeningPropertyPathsSet() {
+ return listeningPropertyPathsSet;
+ }
+
+ /**
+ * Return the listener classes.
+ *
+ * @return the listenerClasses The listener classes.
+ * @since 3.1
+ */
+ public String getListenerClasses() {
+ return listenerClasses;
+ }
+
+ /**
+ * Return the HashSet of listener classes.
+ *
+ * @return the listenerClassesSet HashSet of listener classes.
+ * @since 3.1
+ */
+ public Set<IPropertiesListener> getListenerClassesSet() {
+ return listenerClassesSet;
+ }
+
+ /**
+ * Set the HashSet of listening property paths.
+ *
+ * @param listeningPropertyPaths
+ * @since 3.1
+ */
+ public void setListeningPropertyPaths(final String listeningPropertyPaths) {
+ this.listeningPropertyPaths = listeningPropertyPaths;
+
+ if (listeningPropertyPaths.isEmpty()) {
+ this.listeningPropertyPathsSet = null;
+ } else {
+ final String[] propertyPaths = listeningPropertyPaths.trim().split(LIST_SEPARATOR);
+
+ if (null == this.listeningPropertyPathsSet) {
+ this.listeningPropertyPathsSet = new HashSet<>();
+ }
+
+ for (int i = 0; i < propertyPaths.length; i++) {
+ if (!propertyPaths[i].isEmpty()) {
+ this.listeningPropertyPathsSet.add(propertyPaths[i]);
+ }
+ }
+
+ manageObservableListeners();
+ }
+ }
+
+ /**
+ * Set the HashSet of listener classes.
+ *
+ * @param listenerClasses
+ * The list of listener classes.
+ * @since 3.1
+ */
+ public void setListenerClasses(final String listenerClasses) {
+ this.listenerClasses = listenerClasses;
+ if (listenerClasses.isEmpty()) {
+ this.listenerClassesSet = null;
+ } else {
+ final String[] propertyPaths = listenerClasses.trim().split(LIST_SEPARATOR);
+
+ if (null == this.listenerClassesSet) {
+ this.listenerClassesSet = new HashSet<>();
+ }
+
+ for (int i = 0; i < propertyPaths.length; i++) {
+ final String listenerMethodPath = propertyPaths[i];
+ if (!listenerMethodPath.isEmpty()) {
+ try {
+ final String[] splittedListenerMethodPath = listenerMethodPath.split(BUNDLE_SEPARATOR);
+ final Class<?> listenerClass;
+ if (splittedListenerMethodPath.length > 1) {
+ Bundle bundle = Platform.getBundle(splittedListenerMethodPath[0]);
+ listenerClass = bundle.loadClass(splittedListenerMethodPath[1]);
+ } else {
+
+ listenerClass = Class.forName(listenerMethodPath);
+ }
+ final List<Class<?>> interfacesImplemented = Arrays.asList(listenerClass.getInterfaces());
+ if (interfacesImplemented.contains(IPropertiesListener.class)) {
+ this.listenerClassesSet.add((IPropertiesListener) listenerClass.newInstance());
+ } else {
+ Activator.log.error("The listener classes defined in listenerClasses must implement 'IPropertiesListener' interface.", null); //$NON-NLS-1$
+ }
+
+ } catch (ClassNotFoundException e) {
+ Activator.log.error("The listener classes defined in listenerClasses are not correct.", e); //$NON-NLS-1$
+ } catch (InstantiationException e) {
+ Activator.log.error(e);
+ } catch (IllegalAccessException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+
+ manageObservableListeners();
+ }
+ }
+
+ /**
+ * Add listeners for observables corresponding to property paths.
+ *
+ * @since 3.1
+ */
+ public void manageObservableListeners() {
+ final String property = getProperty();
+ final DataSource input = getInput();
+ if (null != property && !property.isEmpty() && null != input) {
+ Set<String> propertyPathsSet = getListeningPropertyPathsSet();
+ Set<IPropertiesListener> classesSet = getListenerClassesSet();
+
+ if (null != propertyPathsSet && !propertyPathsSet.isEmpty() && null != classesSet && !classesSet.isEmpty()) {
+ for (String listeningPropertyPath : propertyPathsSet) {
+ final IObservable observable = input.getObservable(listeningPropertyPath);
+ if (null != observable) {
+ observable.addChangeListener(new IChangeListener() {
+
+ @Override
+ public void handleChange(final ChangeEvent event) {
+ handlePropertiesListener(classesSet, propertyPathsSet);
+ }
+ });
+
+ handlePropertiesListener(classesSet, propertyPathsSet);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Handle the listenerClasses.
+ *
+ * @param classesSet
+ * The HashSet of listener classes.
+ * @param propertyPathsSet
+ * The HashSet of property paths.
+ * @since 3.1
+ *
+ */
+ private void handlePropertiesListener(final Set<IPropertiesListener> classesSet, final Set<String> propertyPathsSet) {
+ for (IPropertiesListener iPropertiesListener : classesSet) {
+ iPropertiesListener.handle(AbstractPropertyEditor.this, input, propertyPathsSet);
+ }
+ }
}
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);
+ }
+
+}

Back to the top