Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-10-12 09:12:58 +0000
committercletavernie2011-10-12 09:12:58 +0000
commitecb0117810e622566f5164e2f7e3e17491eb0a57 (patch)
treeaa56dd74906a4df6aae370a562dedb0f44a6daf1
parent3be41055defbd464a97ae9dbd961db29c72005b9 (diff)
downloadorg.eclipse.papyrus-ecb0117810e622566f5164e2f7e3e17491eb0a57.tar.gz
org.eclipse.papyrus-ecb0117810e622566f5164e2f7e3e17491eb0a57.tar.xz
org.eclipse.papyrus-ecb0117810e622566f5164e2f7e3e17491eb0a57.zip
360123: [Activity Diagram] Property View of OpaqueAction : problems with body attribute
https://bugs.eclipse.org/bugs/show_bug.cgi?id=360123
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/AbstractPropertyEditor.java27
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/DynamicBodyEditor.java20
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/ExpressionEditor.java24
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NaturalLanguageEditor.java2
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NullBodyEditor.java66
5 files changed, 132 insertions, 7 deletions
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/AbstractPropertyEditor.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/AbstractPropertyEditor.java
index 36c764b37af..607391d99d6 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/AbstractPropertyEditor.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/AbstractPropertyEditor.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.properties.widgets;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
+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.papyrus.properties.Activator;
@@ -204,7 +205,15 @@ public abstract class AbstractPropertyEditor implements IChangeListener {
}
}
- public void handleChange(ChangeEvent event) {
+ /**
+ * {@inheritDoc}
+ */
+ //TODO : This method handles a change on the DataSource. This should not be a ChangeEvent, as the DataSource is not an IObservable
+ //This method should be changed, and the source of the event should be checked (Otherwise, it cannot be extended).
+ //TODO : Remove the "final" modifier to let subclasses extend this behavior,
+ //when the source of the event is checked. Until then, it is not safe to override this method
+ public final void handleChange(ChangeEvent event) {
+ //Handle the "forceRefresh" behavior when the input DataSource sends a ChangeEvent
AbstractEditor editor = getEditor();
if(editor != null) {
editor.refreshValue();
@@ -391,6 +400,22 @@ public abstract class AbstractPropertyEditor implements IChangeListener {
}
/**
+ * Returns the IObservable for this propertyEditor, or null if it is
+ * not available
+ *
+ * @return The IObservable associated to this propertyEditor
+ */
+ protected IObservable getInputObservable() {
+ if(listEditor != null) {
+ return getInputObservableList();
+ }
+ if(valueEditor != null) {
+ return getInputObservableValue();
+ }
+ return null;
+ }
+
+ /**
* @return the last segment of the property path (Which is the property name)
*/
protected String getLocalPropertyPath() {
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/DynamicBodyEditor.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/DynamicBodyEditor.java
index 14e1b02c100..c37d2beb9dc 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/DynamicBodyEditor.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/DynamicBodyEditor.java
@@ -62,6 +62,9 @@ public class DynamicBodyEditor extends AbstractValueEditor implements Listener {
bodyEditorContainer = new Composite(this, style);
bodyEditorContainer.setLayout(new FillLayout());
bodyEditorContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ currentEditor = new NullBodyEditor();
+ currentEditor.createWidget(bodyEditorContainer, SWT.NONE);
}
/**
@@ -72,14 +75,23 @@ public class DynamicBodyEditor extends AbstractValueEditor implements Listener {
* the expression to edit
*/
public void display(Expression expression) {
- String language = expression.getLanguage();
- String initialText = expression.getBody();
-
if(currentEditor != null) {
disposeBodyEditor();
}
- BodyEditor editor = getEditor(language);
+ BodyEditor editor;
+
+ if(expression == null) {
+ editor = new NullBodyEditor();
+ editor.createWidget(bodyEditorContainer, SWT.NONE);
+ bodyEditorContainer.layout();
+ return;
+ }
+
+ String language = expression.getLanguage();
+ String initialText = expression.getBody();
+
+ editor = getEditor(language);
editor.createWidget(bodyEditorContainer, SWT.NONE);
if(context != null) {
editor.setContext(context);
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/ExpressionEditor.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/ExpressionEditor.java
index 69ba1362acb..dc70086547e 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/ExpressionEditor.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/ExpressionEditor.java
@@ -22,6 +22,8 @@ import org.eclipse.papyrus.properties.uml.expression.ExpressionList;
import org.eclipse.papyrus.properties.uml.expression.ExpressionList.Expression;
import org.eclipse.papyrus.properties.uml.messages.Messages;
import org.eclipse.papyrus.properties.widgets.AbstractPropertyEditor;
+import org.eclipse.papyrus.widgets.editors.AbstractEditor;
+import org.eclipse.papyrus.widgets.editors.ICommitListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
@@ -42,7 +44,7 @@ import org.eclipse.swt.widgets.Listener;
*/
//TODO : Check support for Ctrl+Z (Is there one single command executed ?)
//TODO : Check listeners on observables (If there is an external modification, is the value correctly refreshed ?)
-public class ExpressionEditor extends AbstractPropertyEditor implements Listener, ISelectionChangedListener {
+public class ExpressionEditor extends AbstractPropertyEditor implements Listener, ISelectionChangedListener, ICommitListener {
private final ExpressionLanguageEditor languageEditor;
@@ -74,6 +76,7 @@ public class ExpressionEditor extends AbstractPropertyEditor implements Listener
bodyEditor.addChangeListener(this);
languageEditor.getViewer().addSelectionChangedListener(this);
+ languageEditor.addCommitListener(this);
setEditor(languageEditor);
}
@@ -123,12 +126,17 @@ public class ExpressionEditor extends AbstractPropertyEditor implements Listener
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
- if(!selection.isEmpty() && selection instanceof IStructuredSelection) {
+ if(selection.isEmpty()) {
+ bodyEditor.display(null);
+ } else if(selection instanceof IStructuredSelection) {
IStructuredSelection sSelection = (IStructuredSelection)selection;
currentExpression = (Expression)sSelection.getFirstElement();
bodyEditor.display(currentExpression);
}
+
+ //Force the layout of the widget after the new widget has been displayed
+ bodyEditorContainer.getParent().layout();
}
@Override
@@ -136,4 +144,16 @@ public class ExpressionEditor extends AbstractPropertyEditor implements Listener
languageEditor.setReadOnly(readOnly);
bodyEditor.setReadOnly(readOnly);
}
+
+ public void commit(AbstractEditor editor) {
+ //If the viewer has no selection, or if there is only one element,
+ //automatically set the selection to the first element
+ if(editor == languageEditor && observableList != null) {
+ if(observableList.size() == 0) {
+ languageEditor.getViewer().setSelection(StructuredSelection.EMPTY);
+ } else if(observableList.size() == 1 || languageEditor.getViewer().getSelection().isEmpty()) {
+ languageEditor.getViewer().setSelection(new StructuredSelection(observableList.get(0)));
+ }
+ }
+ }
}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NaturalLanguageEditor.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NaturalLanguageEditor.java
index 62f1dd7ef56..e5aa5af8225 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NaturalLanguageEditor.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NaturalLanguageEditor.java
@@ -64,6 +64,8 @@ public class NaturalLanguageEditor implements BodyEditor {
}
});
+
+ editor.layout();
}
public void setInput(String value) {
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NullBodyEditor.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NullBodyEditor.java
new file mode 100644
index 00000000000..aa085fa1670
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/NullBodyEditor.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.properties.uml.widgets;
+
+import org.eclipse.papyrus.properties.modelelement.ModelElement;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * A "Null" implementation of the BodyEditor
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class NullBodyEditor implements BodyEditor {
+
+ private Label messageLabel;
+
+ public void createWidget(Composite parent, int style) {
+ messageLabel = new Label(parent, style | SWT.WRAP);
+ messageLabel.setText("Please select a language first.");
+ }
+
+ public void setInput(String value) {
+ //Ignore
+ }
+
+ public void dispose() {
+ if(messageLabel != null) {
+ messageLabel.dispose();
+ messageLabel = null;
+ }
+ }
+
+ public void addChangeListener(Listener listener) {
+ //Ignore
+ }
+
+ public void removeChangeListener(Listener listener) {
+ //Ignore
+ }
+
+ public String getValue() {
+ return null; //Ignore
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ //Ignore
+ }
+
+ public void setContext(ModelElement context) {
+ //Ignore
+ }
+
+}

Back to the top