aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFanch BONNABESSE2017-10-03 10:44:44 -0400
committervincent lorenzo2017-10-08 15:29:19 -0400
commit9f153a33d292f3140f1abf460c848e3e4514b4ec (patch)
treeab17debcefaad14ae95f51dd8cdb78c183d17ca6
parent93a0b6a6dd740d264f8015cb38f1921894d3b734 (diff)
downloadorg.eclipse.papyrus-9f153a33d292f3140f1abf460c848e3e4514b4ec.zip
org.eclipse.papyrus-9f153a33d292f3140f1abf460c848e3e4514b4ec.tar.gz
org.eclipse.papyrus-9f153a33d292f3140f1abf460c848e3e4514b4ec.tar.xz
Bug 521902: [Property View][Profile] In-line edition for PrimitiveTypes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=521902 Add the "directCreation" to edit value directly in the TreeViewer. Change-Id: I9eea3816304a1f4c886ae2cf92a63f8eb3a5e7b3 Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractMultipleValueEditor.java54
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleBooleanEditor.java76
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleDoubleEditor.java88
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleIntegerEditor.java72
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java224
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TypedMultipleStringEditor.java20
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/Constants.java5
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java18
8 files changed, 517 insertions, 40 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractMultipleValueEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractMultipleValueEditor.java
index ea1d84c..9fda0a5 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractMultipleValueEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractMultipleValueEditor.java
@@ -12,6 +12,7 @@
* Christian W. Damus - bugs 399859, 516526
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - manage buttons visibility and enable.
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 515808
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
@@ -416,21 +417,7 @@ public abstract class AbstractMultipleValueEditor<T extends IElementSelector> ex
final Object context = getContextElement();
if (directCreation) {
- if (referenceFactory != null && referenceFactory.canCreateObject()) {
- getOperationExecutor(context).execute(new Callable<Object>() {
-
- @Override
- public Object call() {
- Object result = referenceFactory.createObject(AbstractMultipleValueEditor.this, context);
- if (result != null) {
- modelProperty.add(result);
- commit();
- }
- return result;
- }
- }, NLS.bind(Messages.MultipleValueEditor_addOperation, labelText));
- }
-
+ directCreateObject(context);
return;
}
@@ -731,6 +718,17 @@ public abstract class AbstractMultipleValueEditor<T extends IElementSelector> ex
}
/**
+ * Returns the boolean for the direct creation.
+ *
+ * @return the directCreation value.
+ *
+ * @since 3.1
+ */
+ public boolean isDirectCreation() {
+ return directCreation;
+ }
+
+ /**
* Adds a ISelectionChangedListener to this widget
*
* @param listener
@@ -811,6 +809,32 @@ public abstract class AbstractMultipleValueEditor<T extends IElementSelector> ex
return getSelection().getFirstElement();
}
+ /**
+ * Create an object with the direct creation.
+ *
+ * @param context
+ * The context element.
+ *
+ * @since 3.1
+ *
+ */
+ protected void directCreateObject(final Object context) {
+ if (referenceFactory != null && referenceFactory.canCreateObject()) {
+ getOperationExecutor(context).execute(new Callable<Object>() {
+
+ @Override
+ public Object call() {
+ Object result = referenceFactory.createObject(AbstractMultipleValueEditor.this, context);
+ if (result != null) {
+ modelProperty.add(result);
+ commit();
+ }
+ return result;
+ }
+ }, NLS.bind(Messages.MultipleValueEditor_addOperation, labelText));
+ }
+ }
+
@Override
public void changeColorField() {
// nothing to do here
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleBooleanEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleBooleanEditor.java
index 9337e8b..9f44835 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleBooleanEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleBooleanEditor.java
@@ -8,11 +8,19 @@
*
* Contributors:
* Pierre GAUTIER (CEA LIST) - Initial API and implementation
- *
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.papyrus.infra.widgets.selectors.BooleanSelector;
+import org.eclipse.papyrus.infra.widgets.util.Constants;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
/**
@@ -22,6 +30,9 @@ import org.eclipse.swt.widgets.Composite;
*/
public class MultipleBooleanEditor extends MultipleStringEditor<BooleanSelector> {
+ /** Proposals for boolean */
+ private final String[] booleanProposals = new String[] { "true", "false" }; //$NON-NLS-1$ //$NON-NLS-2$
+
/**
* Constructs an Editor for multiple boolean values.
* The widget is a List, with controls to move values up/down, add values and remove values.
@@ -35,4 +46,67 @@ public class MultipleBooleanEditor extends MultipleStringEditor<BooleanSelector>
super(parent, style, new BooleanSelector());
}
+ /**
+ * Constructs an Editor for multiple boolean values.
+ * The widget is a List, with controls to move values up/down, add values and remove values.
+ *
+ * @param parent
+ * The Composite in which this editor is created
+ * @param directCreation
+ * Indicates if the creation and modification are directed.
+ * @param style
+ * The List's style
+ *
+ * @since 3.1
+ */
+ public MultipleBooleanEditor(final Composite parent, final boolean directCreation, final int style) {
+ super(parent, style, new BooleanSelector(), directCreation);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CellEditor createCellEditor(Object element) {
+ return new ComboBoxCellEditor(((TreeViewer) getViewer()).getTree(), booleanProposals, SWT.READ_ONLY);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getEditingValue(Object object) {
+ List<String> booleans = Arrays.asList(booleanProposals);
+ if (object == null || object.equals(Constants.EMPTY_STRING)) {
+ return 0;
+ }
+ return booleans.indexOf(object.toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getValueToSet(Object element, Object value) {
+ Object newValue = value;
+
+ if (element instanceof Boolean) {
+ if (value.equals(0)) {
+ newValue = true;
+ } else {
+ newValue = false;
+ }
+ }
+
+ return newValue;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getDefaultValue() {
+ return true;
+ }
+
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleDoubleEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleDoubleEditor.java
index 7629b33..6e32bf3 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleDoubleEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleDoubleEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2017 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -7,10 +7,14 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.papyrus.infra.widgets.selectors.RealSelector;
import org.eclipse.swt.widgets.Composite;
@@ -18,9 +22,8 @@ import org.eclipse.swt.widgets.Composite;
public class MultipleDoubleEditor extends MultipleStringEditor<RealSelector> {
/**
- * Constructs an Editor for multiple double values
- * The widget is a List, with controls to move values up/down, add values
- * and remove values.
+ * Constructs an Editor for multiple double values.
+ * The widget is a List, with controls to move values up/down, add values and remove values.
*
* @param parent
* The Composite in which this editor is created
@@ -32,9 +35,8 @@ public class MultipleDoubleEditor extends MultipleStringEditor<RealSelector> {
}
/**
- * Constructs an Editor for multiple double values
- * The widget is a List, with controls to move values up/down, add values
- * and remove values.
+ * Constructs an Editor for multiple double values.
+ * The widget is a List, with controls to move values up/down, add values and remove values.
*
* @param parent
* The Composite in which this editor is created
@@ -48,9 +50,8 @@ public class MultipleDoubleEditor extends MultipleStringEditor<RealSelector> {
}
/**
- * Constructs an Editor for multiple double values
- * The widget is a List, with controls to move values up/down, add values
- * and remove values.
+ * Constructs an Editor for multiple double values.
+ * The widget is a List, with controls to move values up/down, add values and remove values.
*
* @param parent
* The Composite in which this editor is created
@@ -67,4 +68,71 @@ public class MultipleDoubleEditor extends MultipleStringEditor<RealSelector> {
super(parent, style, new RealSelector(), ordered, unique, label);
}
+ /**
+ * Constructs an Editor for multiple double values.
+ * The widget is a List, with controls to move values up/down, add values and remove values.
+ *
+ * @param parent
+ * The Composite in which this editor is created
+ * @param directCreation
+ * Indicates if the creation and modification are directed.
+ * @param style
+ * The List's style
+ *
+ * @since 3.1
+ */
+ public MultipleDoubleEditor(Composite parent, boolean directCreation, int style) {
+ super(parent, style, new RealSelector(), directCreation);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CellEditor createCellEditor(Object element) {
+ return new DoubleCellEditor(tree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getDefaultValue() {
+ return new Double(0);
+ }
+
+ /**
+ * This cell editor ensures that only Double values are supported.
+ */
+ private static class DoubleCellEditor extends TextCellEditor {
+ public DoubleCellEditor(Composite composite) {
+ super(composite);
+ setValidator(new ICellEditorValidator() {
+ public String isValid(Object object) {
+ if (object instanceof Double) {
+ return null;
+ } else {
+ String string = (String) object;
+ try {
+ Double.parseDouble(string);
+ return null;
+ } catch (NumberFormatException exception) {
+ return exception.getMessage();
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ public Object doGetValue() {
+ return Double.parseDouble((String) super.doGetValue());
+ }
+
+ @Override
+ public void doSetValue(Object value) {
+ super.doSetValue(value.toString());
+ }
+ }
+
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleIntegerEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleIntegerEditor.java
index f8bb968..f7bc098 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleIntegerEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleIntegerEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2017 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,9 +8,13 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.papyrus.infra.widgets.selectors.IntegerSelector;
import org.eclipse.swt.widgets.Composite;
@@ -72,4 +76,70 @@ public class MultipleIntegerEditor extends MultipleStringEditor<IntegerSelector>
super(parent, style, new IntegerSelector(), ordered, unique, label);
}
+ /**
+ * Constructs an Editor for multiple Integer values.
+ * The widget is a List, with controls to move values up/down, add values and remove values.
+ *
+ * @param parent
+ * The Composite in which this editor is created
+ * @param directCreation
+ * Indicates if the creation and modification are directed.
+ * @param style
+ * The List's style
+ *
+ * @since 3.1
+ */
+ public MultipleIntegerEditor(Composite parent, boolean directCreation, int style) {
+ super(parent, style, new IntegerSelector(), directCreation);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CellEditor createCellEditor(Object element) {
+ return new IntegerCellEditor(tree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getDefaultValue() {
+ return new Integer(0);
+ }
+
+ /**
+ * This cell editor ensures that only Integer values are supported
+ */
+ private static class IntegerCellEditor extends TextCellEditor {
+ public IntegerCellEditor(Composite composite) {
+ super(composite);
+ setValidator(new ICellEditorValidator() {
+ public String isValid(Object object) {
+ if (object instanceof Integer) {
+ return null;
+ } else {
+ String string = (String) object;
+ try {
+ Integer.parseInt(string);
+ return null;
+ } catch (NumberFormatException exception) {
+ return exception.getMessage();
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ public Object doGetValue() {
+ return Integer.parseInt((String) super.doGetValue());
+ }
+
+ @Override
+ public void doSetValue(Object value) {
+ super.doSetValue(value.toString());
+ }
+ }
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java
index 797d4f1..4727efc 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2017 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,14 +8,33 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import org.eclipse.jface.layout.TreeColumnLayout;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.infra.widgets.creation.StringEditionFactory;
+import org.eclipse.papyrus.infra.widgets.messages.Messages;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.TreeCollectionContentProvider;
import org.eclipse.papyrus.infra.widgets.selectors.StandardSelector;
import org.eclipse.papyrus.infra.widgets.selectors.StringSelector;
+import org.eclipse.papyrus.infra.widgets.util.Constants;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
/**
@@ -42,8 +61,28 @@ public class MultipleStringEditor<T extends StringSelector> extends MultipleValu
init();
}
+ /**
+ * Constructs an Editor for multiple String values
+ * The widget is a List, with controls to move values up/down, add values
+ * and remove values.
+ *
+ * @param parent
+ * The Composite in which this editor is created
+ * @param directCreation
+ * Indicates if the creation and modification are directed.
+ * @param style
+ * The List's style
+ *
+ * @since 3.1
+ */
+ public MultipleStringEditor(Composite parent, boolean directCreation, int style) {
+ super(parent, style, new StringSelector());
+ setDirectCreation(directCreation);
+ init();
+ }
+
public MultipleStringEditor(Composite parent, int style, boolean multiline) {
- super(parent, style, new StringSelector(multiline));
+ super(parent, style, new StringSelector(multiline), true, false, null);
init();
}
@@ -130,6 +169,27 @@ public class MultipleStringEditor<T extends StringSelector> extends MultipleValu
}
/**
+ * Constructs an Editor for multiple Integer values
+ * The widget is a List, with controls to move values up/down, add values
+ * and remove values.
+ *
+ * @param parent
+ * The Composite in which this editor is created
+ * @param style
+ * The List's style
+ * @param selector
+ * The Element selector for the dialog's left-pane. Used to select values or enter new ones.
+ * @param directCreation
+ * Indicates if the creation and modification are directed.
+ * @since 3.1
+ */
+ public MultipleStringEditor(Composite parent, int style, T selector, boolean directCreation) {
+ super(parent, style, selector);
+ setDirectCreation(directCreation);
+ init();
+ }
+
+ /**
* Constructs an Editor for multiple String values
* The widget is a List, with controls to move values up/down, add values
* and remove values.
@@ -182,4 +242,164 @@ public class MultipleStringEditor<T extends StringSelector> extends MultipleValu
setSelector(selector);
}
+ /**
+ * {@inheritDoc}
+ *
+ */
+ @Override
+ public void updateButtons() {
+ super.updateButtons();
+ edit.setVisible(!isDirectCreation());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @since 3.1
+ */
+ @Override
+ protected void directCreateObject(Object context) {
+ if (referenceFactory != null && referenceFactory.canCreateObject()) {
+ getOperationExecutor(context).execute(new Callable<Object>() {
+
+ @Override
+ public Object call() {
+ Object result = getDefaultValue();
+ if (result != null) {
+ modelProperty.add(result);
+ commit();
+ }
+ return result;
+ }
+ }, NLS.bind(Messages.MultipleValueEditor_addOperation, labelText));
+
+ editNewElement();
+ }
+ }
+
+ /**
+ * Edit the latest element of the TreeViewer.
+ *
+ * @since 3.1
+ */
+ protected void editNewElement() {
+ Object data = tree.getData();
+ if (data instanceof List<?>) {
+ int size = ((List) data).size();
+ if (0 != size) {
+ Object object = ((List) data).get(size - 1);
+ if (null != object) {
+ treeViewer.editElement(object, 0);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the default value for each new String value.
+ *
+ * @since 3.1
+ */
+ protected Object getDefaultValue() {
+ return Constants.DEFAULT_STRING_VALUE;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite compositeTree = factory.createComposite(parent);
+ final TreeColumnLayout treeColumnLayout = new TreeColumnLayout();
+ compositeTree.setLayout(treeColumnLayout);
+
+ tree = new Tree(compositeTree, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
+ tree.setLinesVisible(true);
+
+ tree.addSelectionListener(this);
+
+ treeViewer = new TreeViewer(tree);
+ treeViewer.setContentProvider(TreeCollectionContentProvider.instance);
+
+ TreeViewerColumn viewerColumn = createTreeViewerColumn(treeViewer, Constants.COLUMN_NAME_VALUE);
+ treeColumnLayout.setColumnData(viewerColumn.getColumn(), new ColumnWeightData(100));
+ viewerColumn.setEditingSupport(new EditingSupport(treeViewer) {
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ Object newValue = getValueToSet(element, value);
+
+ final int index = modelProperty.indexOf(element);
+
+ if ((element != newValue) && (newValue != null)) {
+ modelProperty.set(index, newValue);
+ }
+
+ commit();
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ return getEditingValue(element);
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return createCellEditor(element);
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return isDirectCreation();
+ }
+ });
+
+ return compositeTree;
+ }
+
+ /**
+ * This allows to create a tree viewer column in the tree viewer.
+ *
+ * @param viewer
+ * the tree viewer.
+ * @param title
+ * The title of the column.
+ * @return The created tree viewer column.
+ * @since 3.1
+ */
+ protected TreeViewerColumn createTreeViewerColumn(final TreeViewer viewer, final String title) {
+ final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.BORDER);
+ final TreeColumn column = viewerColumn.getColumn();
+ column.setText(title);
+ column.setResizable(true);
+ column.setMoveable(false);
+ return viewerColumn;
+ }
+
+ /**
+ * Returns the CellEditor for the editing support.
+ *
+ * @since 3.1
+ */
+ protected CellEditor createCellEditor(final Object element) {
+ return new TextCellEditor(tree);
+ }
+
+ /**
+ * Returns the value editing on the editing support.
+ *
+ * @since 3.1
+ */
+ protected Object getEditingValue(final Object element) {
+ return element.toString();
+ }
+
+ /**
+ * Returns the value to set on the editing support.
+ *
+ * @since 3.1
+ */
+ protected Object getValueToSet(final Object element, final Object value) {
+ return value;
+ }
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TypedMultipleStringEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TypedMultipleStringEditor.java
index b208f91..ee366c6 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TypedMultipleStringEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TypedMultipleStringEditor.java
@@ -8,10 +8,11 @@
*
* Contributors:
* Pierre GAUTIER (CEA LIST) - Initial API and implementation
- *
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
+import org.eclipse.papyrus.infra.widgets.selectors.BooleanSelector;
import org.eclipse.papyrus.infra.widgets.selectors.StringSelector;
import org.eclipse.swt.widgets.Composite;
@@ -35,4 +36,21 @@ public class TypedMultipleStringEditor extends MultipleStringEditor<StringSelect
super(parent, style, true);
}
+ /**
+ * Constructs an Editor for multiple strings values.
+ * The widget is a List, with controls to move values up/down, add values and remove values.
+ *
+ * @param parent
+ * The Composite in which this editor is created
+ * @param directCreation
+ * Indicates if the creation and modification are directed.
+ * @param style
+ * The List's style
+ *
+ * @since 3.1
+ */
+ public TypedMultipleStringEditor(Composite parent, boolean directCreation, int style) {
+ super(parent, style, new BooleanSelector(), directCreation);
+ }
+
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/Constants.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/Constants.java
index 999d88c..f68f11e 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/Constants.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/Constants.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and implementation
- *
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.util;
@@ -28,4 +28,7 @@ public class Constants {
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ public static final String DEFAULT_STRING_VALUE = "New String"; //$NON-NLS-1$
+
+ public static final String COLUMN_NAME_VALUE = "Value"; //$NON-NLS-1$
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
index 7a0a6ae..c2a8124 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
@@ -11,7 +11,7 @@
* Christian W. Damus (CEA) - bug 323802
* Christian W. Damus (CEA) - bug 448139
* Pierre GAUTIER (CEA LIST) - bug 521857
- *
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -82,7 +82,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
protected ReferenceValueFactory valueFactory;
protected IChangeListener changeListener;
-
+
private static final Map<String, Class<?>> TYPE_ALIASES = new HashMap<>();
static {
@@ -206,7 +206,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
final String aliasedInstanceClassName = ((EDataType) featureType).getInstanceClassName();
final Class<?> clazz = EStructuralFeatureEditor.TYPE_ALIASES.get(aliasedInstanceClassName);
if (clazz == null) {
- throw new IllegalArgumentException("No clazz has been found for aliasedInstanceClassName '" + aliasedInstanceClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException("No clazz has been found for aliasedInstanceClassName '" + aliasedInstanceClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (feature.isMany()) {
createMultipleEditor(clazz, element, title, feature);
@@ -220,7 +220,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
}
pageBook.showPage(currentPage);
}
-
+
protected void setValueEditorProperties(final AbstractValueEditor editor, final EObject stereotypeApplication, final String title, final EStructuralFeature feature) {
final PapyrusObservableValue observable = new PapyrusObservableValue(stereotypeApplication, feature, EMFHelper.resolveEditingDomain(stereotypeApplication));
observable.addValueChangeListener(this);
@@ -228,7 +228,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
editor.setReadOnly(!isEditable(stereotypeApplication, feature));
editor.setModelObservable(observable);
}
-
+
protected void setMultipleValueEditorProperties(final MultipleValueEditor<?> editor, final List<?> initialList, final EObject stereotypeApplication, final String title, final EStructuralFeature feature) {
final PapyrusObservableList observable = new PapyrusObservableList(initialList, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotypeApplication, feature);
observable.addListChangeListener(this);
@@ -236,11 +236,11 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
editor.setUnique(feature.isUnique());
editor.setOrdered(feature.isOrdered());
editor.setUpperBound(feature.getUpperBound());
+ editor.setModelObservable(observable);
editor.setReadOnly(!isEditable(stereotypeApplication, feature));
if (feature instanceof EReference) {
editor.setDirectCreation(((EReference) feature).isContainment());
}
- editor.setModelObservable(observable);
editor.addCommitListener(observable);
}
@@ -250,8 +250,8 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
throw new IllegalArgumentException("No multiple editor has been found for class '" + typeClass + "'"); //$NON-NLS-1$ //$NON-NLS-2$
}
try {
- final Constructor<? extends MultipleStringEditor<?>> constructor = editorClazz.getConstructor(Composite.class, int.class);
- final MultipleStringEditor<?> editor = constructor.newInstance(pageBook, style);
+ final Constructor<? extends MultipleStringEditor<?>> constructor = editorClazz.getConstructor(Composite.class, boolean.class, int.class);
+ final MultipleStringEditor<?> editor = constructor.newInstance(pageBook, true, style);
setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
currentPage = editor;
} catch (final Exception e) {
@@ -281,7 +281,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
public void setLayoutData(final GridData data) {
pageBook.setLayoutData(data);
}
-
+
@Override
public void handleValueChange(final ValueChangeEvent<?> event) {
if (changeListener != null) {