Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Activator.java52
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Messages.java37
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialog.java168
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialogFactory.java105
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialog.java184
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialogFactory.java32
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/composite/IFilteredElementSelectionComposite.java34
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialog.java51
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallback.java28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallbackWithPreCommit.java59
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogWithoutResultCallback.java33
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialog.java32
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialogFactory.java52
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialog.java43
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialogFactory.java49
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IWithResultDialogCallback.java34
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractExceptionFreeRunnable.java20
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidExceptionFreeRunnable.java22
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidRunnable.java22
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/DisplaySyncRuntimeException.java34
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/IRunnable.java16
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedComposite.java38
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedObject.java115
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/handler/HandlerUtils.java90
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/tree/menu/ITreeMenu.java44
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/FilteredElementSelectionComposite.java174
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/SynchronizedFilteredElementSelectionComposite.java89
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialog.java169
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialogWithCallback.java58
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractMainDialog.java62
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/SynchronizedAbstractDialog.java94
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/handler/AbstractSelectionExpectedTypeHandler.java51
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/ExtendedTree.java174
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/item/AbstractTreeItem.java210
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenu.java205
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenuItem.java213
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeSubMenu.java128
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/ExtendedTreeMenu.java341
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/AbstractWidget.java155
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractCommandWidget.java86
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractGetOrCreateFilteredElementCommandWidget.java147
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/ICommandWidget.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/IGetOrCreateFilteredElementCommmandWidget.java33
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/CreateElementWidget.java132
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWidget.java168
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithButtonWidget.java120
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithDialogButtonWidget.java89
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithWizardButtonWidget.java82
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/AbstractGetPropertyWidget.java159
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/bounds/AbstractGetBoundsWidget.java127
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractGetElementNameWidget.java86
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractPrintElementWidget.java59
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/query/AbstractQueryWidget.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/wizard/SynchronizedWizard.java314
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/IAbstractWidget.java56
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWidget.java43
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWithButtonWidget.java41
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/wizard/IExtendedWizard.java56
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/messages.properties23
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWidget.java92
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWithButtonWidget.java112
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedGetOrCreateFilteredElementCommmandWidget.java142
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedOkDialog.java64
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/widget/metaclass/FilteredElementSelectionWidget.java150
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement.java113
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement2.java54
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/UIUtils.java248
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/WidgetProperties.java67
68 files changed, 6460 insertions, 0 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Activator.java
new file mode 100644
index 00000000000..78ea2cb7f82
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Activator.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+@SuppressWarnings("PMD.UseSingleton")
+// @SuppressWarnings("PMD.UseSingleton") We cannot conforms to this rule because
+// this class is an Eclipse plug-in activator which will be instantiated by the
+// Eclipse framework.
+public class Activator extends Plugin {
+
+ private static Activator plugin;
+
+ @Override
+ @SuppressWarnings("PMD.SignatureDeclareThrowsException")
+ // @SuppressWarnings("PMD.SignatureDeclareThrowsException") We have to use
+ // this signature because this is an override of an Eclipse framework's
+ // method.
+ public void start(final BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ Activator.plugin = this;
+ }
+
+ @Override
+ @SuppressWarnings({ "PMD.SignatureDeclareThrowsException",
+ "PMD.NullAssignment" })
+ // @SuppressWarnings("PMD.SignatureDeclareThrowsException") We have to use
+ // this signature because this is an override of an Eclipse framework's
+ // method.
+ // @SuppressWarnings("PMD.NullAssignment")
+ // No choice to right it in another way : this is an Eclipse pattern.
+ public void stop(final BundleContext bundleContext) throws Exception {
+ Activator.plugin = null;
+ super.stop(bundleContext);
+ }
+
+ public static Plugin getDefault() {
+ return Activator.plugin;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Messages.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Messages.java
new file mode 100644
index 00000000000..3491bf39f6b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/Messages.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Thomas Cicognani (Soft-Maint) - Bug 406565 - Ok Dialog
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.emf.facet.util.ui.internal.messages"; //$NON-NLS-1$
+ public static String FilteredElementSelectionControl_type_filter_text;
+ public static String QuestionDialog_yes;
+ public static String QuestionDialog_no;
+ public static String OK;
+
+ public static String item_todo;
+ public static String Type;
+ public static String Select;
+ public static String New;
+
+ public static String Select_Facet;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialog.java
new file mode 100644
index 00000000000..26d9b707e71
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialog.java
@@ -0,0 +1,168 @@
+/**
+ * Copyright (c) Soft-Maint.
+ *
+ * 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:
+ * Thomas Cicognani (Soft-Maint) - Bug 406565 - Ok Dialog
+ */
+package org.eclipse.emf.facet.util.ui.internal.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.facet.util.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IOkDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class OkDialog implements IOkDialog {
+ private static final int SHELL_WIDTH = 450;
+ private static final int SHELL_HEIGHT = 170;
+ private static final int BUTTON_WIDTH_HINT = 80;
+ private static final int MARGIN_LEFT = 5;
+ private static final int MARGIN_TOP = 8;
+ private static final int VERTICAL_SPACING = 10;
+ private static final int HORIZONT_SPACING = 15;
+ private static final int BUTTONS_COMP_COL = 3;
+
+ private final List<Runnable> listeners = new ArrayList<Runnable>();
+
+ private final Shell parentShell;
+ private final String title;
+ private final String message;
+ private final IDialogCallback<Void> callback;
+ private Shell shell;
+ private final int kind;
+
+ public OkDialog(final Shell parentShell, final int kind,
+ final String title, final String message,
+ final IDialogCallback<Void> iDialogCallback) {
+ this.parentShell = parentShell;
+ this.title = title;
+ this.message = message;
+ this.callback = iDialogCallback;
+ this.kind = kind;
+ createContents();
+ }
+
+ private void createContents() {
+ this.shell = new Shell(this.parentShell, SWT.BORDER | SWT.RESIZE
+ | SWT.TITLE | SWT.APPLICATION_MODAL);
+ this.shell.setSize(OkDialog.SHELL_WIDTH, OkDialog.SHELL_HEIGHT);
+ this.shell.setText(this.title);
+ final GridLayout shellLayout = new GridLayout(2, false);
+
+ // constants to make checkstyle happy
+ shellLayout.marginLeft = OkDialog.MARGIN_LEFT;
+ shellLayout.marginTop = OkDialog.MARGIN_TOP;
+ shellLayout.verticalSpacing = OkDialog.VERTICAL_SPACING;
+ shellLayout.horizontalSpacing = OkDialog.HORIZONT_SPACING;
+
+ this.shell.setLayout(shellLayout);
+
+ final Label image = new Label(this.shell, SWT.NONE);
+ image.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
+ image.setImage(Display.getDefault().getSystemImage(this.kind));
+
+ final Text labelMessage = new Text(this.shell, SWT.WRAP | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.READ_ONLY);
+ labelMessage.setText(this.message);
+ labelMessage
+ .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ final Composite buttonsComposite = new Composite(this.shell, SWT.NONE);
+ buttonsComposite.setLayout(new GridLayout(OkDialog.BUTTONS_COMP_COL,
+ false));
+ buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+ false, 2, 1));
+
+ final Composite paddingComposite = new Composite(buttonsComposite,
+ SWT.NONE);
+ final GridData paddCompGridData = new GridData(SWT.FILL, SWT.CENTER,
+ true, false, 1, 1);
+ paddCompGridData.heightHint = 0;
+ paddingComposite.setLayoutData(paddCompGridData);
+
+ final Button btnOk = new Button(buttonsComposite, SWT.NONE);
+ final GridData button1GridData = new GridData(SWT.LEFT, SWT.BOTTOM,
+ false, false, 1, 1);
+ button1GridData.widthHint = OkDialog.BUTTON_WIDTH_HINT;
+ btnOk.setLayoutData(button1GridData);
+ btnOk.setText(Messages.OK);
+ btnOk.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent event) {
+ commit();
+ }
+ });
+ }
+
+ public void open() {
+ this.shell.layout();
+ // center the shell on its parent (if not parent shell then it will not
+ // be centered)
+ if (this.parentShell != null) {
+ final Rectangle parentShellBounds = this.parentShell.getBounds();
+ final Point shellSize = this.shell.getSize();
+ this.shell.setLocation(parentShellBounds.x
+ + (parentShellBounds.width - shellSize.x) / 2,
+ parentShellBounds.y
+ + (parentShellBounds.height - shellSize.y) / 2);
+ }
+ this.shell.open();
+ }
+
+ public final void commit() {
+ if (this.shell.isDisposed()) {
+ throw new UnsupportedOperationException("Dialog is disposed"); //$NON-NLS-1$
+ }
+ this.shell.dispose();
+ notifyListeners();
+ }
+
+ private void notifyListeners() {
+ if (this.callback != null) {
+ this.callback.committed(null);
+ }
+ for (final Runnable listener : this.listeners) {
+ listener.run();
+ }
+ }
+
+ public void addCloseListener(final Runnable paramRunnable) {
+ this.listeners.add(paramRunnable);
+ }
+
+ public Shell getShell() {
+ return this.shell;
+ }
+
+ public boolean isInformation() {
+ return this.kind == SWT.ICON_INFORMATION;
+ }
+
+ public boolean isWarning() {
+ return this.kind == SWT.ICON_WARNING;
+ }
+
+ public boolean isError() {
+ return this.kind == SWT.ICON_ERROR;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialogFactory.java
new file mode 100644
index 00000000000..c00fef055f4
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/OkDialogFactory.java
@@ -0,0 +1,105 @@
+/**
+ * Copyright (c) Soft-Maint.
+ *
+ * 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:
+ * Thomas Cicognani (Soft-Maint) - Bug 406565 - Ok Dialog
+ */
+package org.eclipse.emf.facet.util.ui.internal.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IOkDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IOkDialogFactory;
+import org.eclipse.emf.facet.util.ui.internal.sync.generated.SynchronizedOkDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class OkDialogFactory implements IOkDialogFactory {
+
+ private final IDialogCallback<Void> noDialogCallback = new IDialogCallback<Void>() {
+ public void committed(final Void paramT) {
+ // Nothing to do
+ }
+ };
+
+ public IOkDialog openDialog(final Shell parentShell, final int kind,
+ final String title, final String message,
+ final IDialogCallback<Void> iDialogCallback) {
+ final OkDialog okDialog = new OkDialog(parentShell, kind, title,
+ message, iDialogCallback);
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ okDialog.open();
+ }
+ });
+
+ return new SynchronizedOkDialog(okDialog, Display.getDefault());
+ }
+
+ public IOkDialog openDialog(final Shell parentShell, final int kind,
+ final String title, final String message) {
+ return openDialog(parentShell, kind, title, message,
+ this.noDialogCallback);
+ }
+
+ public IOkDialog openInformationDialog(final Shell parentShell,
+ final String title, final String message,
+ final IDialogCallback<Void> iDialogCallback) {
+ return openDialog(parentShell, SWT.ICON_INFORMATION, title, message,
+ iDialogCallback);
+ }
+
+ public IOkDialog openInformationDialog(final Shell parentShell,
+ final String title, final String message) {
+ return openInformationDialog(parentShell, title, message,
+ this.noDialogCallback);
+ }
+
+ public IOkDialog openWarningDialog(final Shell parentShell,
+ final String title, final String message,
+ final IDialogCallback<Void> iDialogCallback) {
+ return openDialog(parentShell, SWT.ICON_WARNING, title, message,
+ iDialogCallback);
+ }
+
+ public IOkDialog openWarningDialog(final Shell parentShell,
+ final String title, final String message) {
+ return openWarningDialog(parentShell, title, message,
+ this.noDialogCallback);
+ }
+
+ public IOkDialog openErrorDialog(final Shell parentShell,
+ final String title, final String message,
+ final IDialogCallback<Void> iDialogCallback) {
+ return openDialog(parentShell, SWT.ICON_ERROR, title, message,
+ iDialogCallback);
+ }
+
+ public IOkDialog openErrorDialog(final Shell parentShell,
+ final String title, final String message) {
+ return openErrorDialog(parentShell, title, message,
+ this.noDialogCallback);
+ }
+
+ public IOkDialog openErrorDialog(final Shell parentShell,
+ final Exception exception, final String message) {
+ final StringBuffer strBuffer = new StringBuffer();
+ strBuffer.append(message);
+ strBuffer.append("\n\n"); //$NON-NLS-1$
+ strBuffer.append(exception.getMessage());
+ strBuffer.append("\n\n"); //$NON-NLS-1$
+ for (StackTraceElement stkElt : exception.getStackTrace()) {
+ strBuffer.append(stkElt.toString());
+ strBuffer.append('\n');
+ }
+ return openErrorDialog(parentShell, exception.getClass().getName(),
+ strBuffer.toString(), this.noDialogCallback);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialog.java
new file mode 100644
index 00000000000..5ff97dda59c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialog.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
+ * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
+ * Gregoire Dupe (Mia-Software) - Bug 374903 - [Table] ITableWidget.setLoadedFacetSets
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.facet.util.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IQuestionDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A yes/no dialog, that replicates the JFace MessageDialog#openQuestion, but is designed to be easily testable with JUnit
+ *
+ * @since 0.2
+ */
+public class QuestionDialog implements IQuestionDialog {
+
+ private static final int SHELL_WIDTH = 450;
+ private static final int SHELL_HEIGHT = 170;
+
+ private final Shell parentShell;
+ private final List<Runnable> listeners = new ArrayList<Runnable>();
+ private Boolean result = null;
+ private Shell shell;
+ private Button btnYes;
+ private Button btnNo;
+ private final String title;
+ private final String message;
+ private IDialogCallback<Boolean> callback;
+
+ public QuestionDialog(final Shell parent, final String title,
+ final String message, final IDialogCallback<Boolean> callback) {
+ this.parentShell = parent;
+ this.title = title;
+ this.message = message;
+ this.callback = callback;
+ createContents();
+ }
+
+ /**
+ * Open the dialog.
+ *
+ * @return the result
+ */
+ public final void open() {
+ this.shell.layout();
+ // center the shell on its parent (if not parent shell then it will not be centered)
+ if (this.parentShell != null) {
+ final Rectangle parentShellBounds = this.parentShell.getBounds();
+ final Point shellSize = this.shell.getSize();
+ this.shell.setLocation(
+ parentShellBounds.x + (parentShellBounds.width - shellSize.x) / 2,
+ parentShellBounds.y + (parentShellBounds.height - shellSize.y) / 2);
+ }
+ this.shell.open();
+ }
+
+ /** Create the contents of the dialog. */
+ private void createContents() {
+ final int buttonWidthHint = 80;
+ this.shell = new Shell(this.parentShell, SWT.BORDER | SWT.RESIZE | SWT.TITLE
+ | SWT.APPLICATION_MODAL);
+ this.shell.setSize(QuestionDialog.SHELL_WIDTH,
+ QuestionDialog.SHELL_HEIGHT);
+ this.shell.setText(this.title);
+ final GridLayout shellLayout = new GridLayout(2, false);
+
+ // constants to make checkstyle happy
+ final int marginLeft = 5;
+ final int marginTop = 8;
+ final int verticalSpacing = 10;
+ final int horizontalSpacing = 15;
+ shellLayout.marginLeft = marginLeft;
+ shellLayout.marginTop = marginTop;
+ shellLayout.verticalSpacing = verticalSpacing;
+ shellLayout.horizontalSpacing = horizontalSpacing;
+
+ this.shell.setLayout(shellLayout);
+
+ final Label image = new Label(this.shell, SWT.NONE);
+ image.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
+ image.setImage(Display.getDefault().getSystemImage(SWT.ICON_QUESTION));
+
+ final Label labelMessage = new Label(this.shell, SWT.WRAP);
+ labelMessage.setText(this.message);
+ labelMessage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ final Composite buttonsComposite = new Composite(this.shell, SWT.NONE);
+ final int buttonsCompositeColumns = 3;
+ buttonsComposite.setLayout(new GridLayout(buttonsCompositeColumns, false));
+ buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+
+ final Composite paddingComposite = new Composite(buttonsComposite, SWT.NONE);
+ final GridData paddingCompositeGridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
+ paddingCompositeGridData.heightHint = 0;
+ paddingComposite.setLayoutData(paddingCompositeGridData);
+
+ this.btnYes = new Button(buttonsComposite, SWT.NONE);
+ final GridData button1GridData = new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1);
+ button1GridData.widthHint = buttonWidthHint;
+ this.btnYes.setLayoutData(button1GridData);
+ this.btnYes.setText(Messages.QuestionDialog_yes);
+ this.btnYes.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ pressYes();
+ }
+ });
+
+ this.btnNo = new Button(buttonsComposite, SWT.NONE);
+ final GridData button2GridData = new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1);
+ button2GridData.widthHint = buttonWidthHint;
+ this.btnNo.setLayoutData(button2GridData);
+ this.btnNo.setText(Messages.QuestionDialog_no);
+ this.btnNo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ pressNo();
+ }
+ });
+ }
+
+ public final void pressYes() {
+ if (this.shell.isDisposed()) {
+ throw new UnsupportedOperationException("Dialog is disposed"); //$NON-NLS-1$
+ }
+ this.result = Boolean.TRUE;
+ this.shell.dispose();
+ notifyListeners();
+ }
+
+ public final void pressNo() {
+ if (this.shell.isDisposed()) {
+ throw new UnsupportedOperationException("Dialog is disposed"); //$NON-NLS-1$
+ }
+ this.result = Boolean.FALSE;
+ this.shell.dispose();
+ notifyListeners();
+ }
+
+ private synchronized void notifyListeners() {
+ if (this.callback != null) {
+ this.callback.committed(getResult());
+ }
+ for (final Runnable listener : new ArrayList<Runnable>(this.listeners)) {
+ listener.run();
+ }
+ }
+
+ public synchronized void addCloseListener(final Runnable runnable) {
+ this.listeners.add(runnable);
+ }
+
+ public final Boolean getResult() {
+ return this.result;
+ }
+
+ public final Shell getShell() {
+ return this.shell;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialogFactory.java
new file mode 100644
index 00000000000..5fbd5d4e28a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/dialog/QuestionDialogFactory.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
+ * Gregoire Dupe (Mia-Software) - Bug 374903 - [Table] ITableWidget.setLoadedFacetSets
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IQuestionDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IQuestionDialogFactory;
+import org.eclipse.swt.widgets.Shell;
+
+public class QuestionDialogFactory implements IQuestionDialogFactory {
+
+ public IQuestionDialog createQuestionDialog(final Shell parent, final String title, final String message) {
+ return new QuestionDialog(parent, title, message, null);
+ }
+
+ public IQuestionDialog createQuestionDialog(final Shell parent,
+ final String title, final String message,
+ final IDialogCallback<Boolean> callback) {
+ return new QuestionDialog(parent, title, message, callback);
+ }
+
+}
+
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/composite/IFilteredElementSelectionComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/composite/IFilteredElementSelectionComposite.java
new file mode 100644
index 00000000000..0221177038c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/composite/IFilteredElementSelectionComposite.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.composite;
+
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.FilteredList;
+
+/**
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IFilteredElementSelectionComposite {
+
+ void setElements(final Object[] elements);
+
+ Object getFirstSelectedElement();
+
+ Object[] getSelectedElements();
+
+ FilteredList getFilteredList();
+
+ Text getFilterText();
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialog.java
new file mode 100644
index 00000000000..33e36c54d8e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialog.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.dialog.AbstractDialog;
+
+/**
+ * @see AbstractDialog
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IDialog<W extends Object> {
+
+ /**
+ * Press the "Ok" button.
+ */
+ void commit();
+
+ /**
+ * Press the "Cancel" button.
+ */
+ void cancel();
+
+ /**
+ * Open the dialog. This method is used for to open the dialog into the
+ * thread UI. So, this method has no to be called into the constructor.
+ *
+ * @return the result of the dialog (OK or CANCEL).
+ */
+ int open();
+
+ /**
+ * Return if the dialog is valid or not.
+ *
+ * @return true if all the necessaries properties are set.
+ */
+ boolean isDialogValid();
+
+ W getWidget();
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallback.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallback.java
new file mode 100644
index 00000000000..34e56f47245
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallback.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Gregoire Dupe (Mia-Software) - Initial API
+ * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+/**
+ * A callback used to return a dialog's result asynchronously.
+ *
+ * @param <T>
+ * the type of the result
+ */
+public interface IDialogCallback<T> {
+ /**
+ * The user committed their selection in the dialog.
+ *
+ * @param result
+ * the result
+ */
+ void committed(T result);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallbackWithPreCommit.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallbackWithPreCommit.java
new file mode 100644
index 00000000000..b53f3b1ba03
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogCallbackWithPreCommit.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Gregoire Dupe (Mia-Software) - Initial API
+ * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+/**
+ * A callback used to return a dialog's result asynchronously. This interface makes it possible to open a second
+ * "pre-commit" dialog when the user commits their selection in the first dialog. This second dialog is given the
+ * opportunity to open before the first dialog closes. This can be useful to ask the user for confirmation for example.
+ * <p>
+ * The second dialog should either:
+ * <ul>
+ * <li>call {@link IDialogCallback#committed(Object) committed} on the callback passed to
+ * {@link IDialogCallbackWithPreCommit#openPrecommitDialog(Object, IDialogCallback) openPrecommitDialog} with the
+ * definitive result
+ * <li>do nothing if the pre-commit dialog was canceled
+ * </ul>
+ *
+ * @param <T1>
+ * the type of the result for the first dialog
+ * @param <T2>
+ * the type of the result for the pre-commit dialog
+ * @param <D>
+ * the type of the pre-commit dialog
+ */
+public interface IDialogCallbackWithPreCommit<T1, T2, D> {
+ /**
+ * The user confirmed their choice in the pre-commit dialog.
+ *
+ * @param result
+ * the result of the first dialog
+ * @param precommitResult
+ * the result of the pre-commit dialog
+ */
+ void committed(T1 result, T2 precommitResult);
+
+ /**
+ * The user committed their selection in the first dialog. This method is called to let you open a second
+ * "pre-commit" dialog, that can prompt the user for confirmation.
+ *
+ * @param result
+ * the result from the first dialog
+ * @param precommitCallback
+ * you must call {@link IDialogCallback#committed(Object) committed} on this callback if the user
+ * confirms their choice in the second (pre-commit) dialog, and pass the result of the pre-commit dialog.
+ * Or do nothing if the user chose to cancel. If you return <code>null</code> from this method, you
+ * mustn't call {@link IDialogCallback#committed(Object)} or the commit will be done twice
+ * @return the pre-commit dialog (for unit tests), or <code>null</code> if no pre-commit callback is needed
+ */
+ D openPrecommitDialog(T1 result, IDialogCallback<T2> precommitCallback);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogWithoutResultCallback.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogWithoutResultCallback.java
new file mode 100644
index 00000000000..c2f44779394
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IDialogWithoutResultCallback.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+
+/**
+ * A callback used to return a dialog's result asynchronously.
+ *
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IDialogWithoutResultCallback {
+
+ /**
+ * The user commit his action.
+ */
+ void commited();
+
+ /**
+ * The user cancel his action.
+ */
+ void canceled();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialog.java
new file mode 100644
index 00000000000..c578bdde60d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialog.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) Soft-Maint.
+ *
+ * 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:
+ * Thomas Cicognani (Soft-Maint) - Bug 406565 - Ok Dialog
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+
+/**
+ *
+ * @author tcicognani
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 0.4
+ */
+public interface IOkDialog {
+
+ void commit();
+
+ boolean isInformation();
+
+ boolean isWarning();
+
+ boolean isError();
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialogFactory.java
new file mode 100644
index 00000000000..030c54a0a26
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IOkDialogFactory.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) Soft-Maint.
+ *
+ * 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:
+ * Thomas Cicognani (Soft-Maint) - Bug 406565 - Ok Dialog
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.dialog.OkDialogFactory;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ *
+ * @author tcicognani
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 0.4
+ */
+public interface IOkDialogFactory {
+ IOkDialogFactory DEFAULT = new OkDialogFactory();
+
+ IOkDialog openDialog(Shell parentShell, int kind, String title,
+ String message, IDialogCallback<Void> iDialogCallback);
+
+ IOkDialog openDialog(Shell parentShell, int kind, String title,
+ String message);
+
+ IOkDialog openInformationDialog(Shell parentShell, String title,
+ String message, IDialogCallback<Void> iDialogCallback);
+
+ IOkDialog openInformationDialog(Shell parentShell, String title,
+ String message);
+
+ IOkDialog openWarningDialog(Shell parentShell, String title,
+ String message, IDialogCallback<Void> iDialogCallback);
+
+ IOkDialog openWarningDialog(Shell parentShell, String title, String message);
+
+ IOkDialog openErrorDialog(Shell parentShell, String title, String message,
+ IDialogCallback<Void> iDialogCallback);
+
+ IOkDialog openErrorDialog(Shell parentShell, String title, String message);
+
+ IOkDialog openErrorDialog(Shell parentShell, Exception exception,
+ String message);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialog.java
new file mode 100644
index 00000000000..d336f8977f2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialog.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+import org.eclipse.swt.widgets.Shell;
+
+/** A simple dialog with a title, a message, and "yes" and "no" buttons */
+public interface IQuestionDialog {
+
+ /** Opens the dialog */
+ void open();
+
+ /** Programmatically emulate a press on the "Yes" button */
+ void pressYes();
+
+ /** Programmatically emulate a press on the "No" button */
+ void pressNo();
+
+ /** Add a listener that will be modified when the dialog closes */
+ void addCloseListener(final Runnable runnable);
+
+ /**
+ * Get the user's answer
+ *
+ * @return <ul>
+ * <li><code>true</code> if the user clicked "Yes"
+ * <li><code>false</code> if the user clicked "No"
+ * <li><code>null</code> if the user closed the dialog without clicking either on "Yes" or "No"
+ * </ul>
+ */
+ Boolean getResult();
+
+ /** @return the dialog's shell */
+ Shell getShell();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialogFactory.java
new file mode 100644
index 00000000000..f43e2632424
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IQuestionDialogFactory.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
+ * Gregoire Dupe (Mia-Software) - Bug 374903 - [Table] ITableWidget.setLoadedFacetSets
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.dialog.QuestionDialogFactory;
+import org.eclipse.swt.widgets.Shell;
+
+/** A factory to instantiate {@link IQuestionDialog} */
+public interface IQuestionDialogFactory {
+ static IQuestionDialogFactory INSTANCE = new QuestionDialogFactory();
+
+ /**
+ * Instantiates a question dialog (without opening it)
+ *
+ * @param parent
+ * the parent shell for the new dialog
+ * @param title
+ * the text that appears in the title of the dialog
+ * @param message
+ * the text that appears in the message area of the dialog
+ * @return the dialog, ready to be {@link IQuestionDialog#open() opened}
+ */
+ @Deprecated
+ IQuestionDialog createQuestionDialog(Shell parent, String title, String message);
+
+ /**
+ * Instantiates a question dialog (without opening it)
+ *
+ * @param parent
+ * the parent shell for the new dialog
+ * @param title
+ * the text that appears in the title of the dialog
+ * @param message
+ * the text that appears in the message area of the dialog
+ * @return the dialog, ready to be {@link IQuestionDialog#open() opened}
+ * @since 0.2
+ */
+ IQuestionDialog createQuestionDialog(Shell parent, String title,
+ String message, IDialogCallback<Boolean> callback);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IWithResultDialogCallback.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IWithResultDialogCallback.java
new file mode 100644
index 00000000000..e6110141109
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/dialog/IWithResultDialogCallback.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.dialog;
+
+
+/**
+ * A callback used to return a dialog's result asynchronously.
+ *
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface IWithResultDialogCallback<T> {
+
+ /**
+ * The user commit his action.
+ */
+ void commited(T result);
+
+ /**
+ * The user cancel his action.
+ */
+ void canceled(T result);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractExceptionFreeRunnable.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractExceptionFreeRunnable.java
new file mode 100644
index 00000000000..ced86df33a9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractExceptionFreeRunnable.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 365808 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.NatTableAPITests
+ * Grégoire Dupé (Mia-Software) - Bug 367153 - synchronization utilities
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.displaysync;
+
+public abstract class AbstractExceptionFreeRunnable<T> implements IRunnable<T, Exception> {
+ public abstract T safeRun();
+
+ public T run() throws Exception {
+ return this.safeRun();
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidExceptionFreeRunnable.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidExceptionFreeRunnable.java
new file mode 100644
index 00000000000..1d86484a72d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidExceptionFreeRunnable.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 365808 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.NatTableAPITests
+ * Grégoire Dupé (Mia-Software) - Bug 367153 - synchronization utilities
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.displaysync;
+
+public abstract class AbstractVoidExceptionFreeRunnable implements
+ IRunnable<Object, Exception> {
+ public abstract void voidSafeRun();
+
+ public Object run() throws Exception {
+ voidSafeRun();
+ return null;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidRunnable.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidRunnable.java
new file mode 100644
index 00000000000..df769c3ff9e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/AbstractVoidRunnable.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 365808 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.NatTableAPITests
+ * Grégoire Dupé (Mia-Software) - Bug 367153 - synchronization utilities
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.displaysync;
+
+public abstract class AbstractVoidRunnable<E extends Exception> implements
+ IRunnable<Object, E> {
+ public abstract void voidRun() throws E;
+
+ public Object run() throws E {
+ this.voidRun();
+ return null;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/DisplaySyncRuntimeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/DisplaySyncRuntimeException.java
new file mode 100644
index 00000000000..095c38e41e4
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/DisplaySyncRuntimeException.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 365808 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.NatTableAPITests
+ * Grégoire Dupé (Mia-Software) - Bug 367153 - synchronization utilities
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.displaysync;
+
+class DisplaySyncRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = -4424355632936609905L;
+
+ public DisplaySyncRuntimeException() {
+ super();
+ }
+
+ public DisplaySyncRuntimeException(final String message) {
+ super(message);
+ }
+
+ public DisplaySyncRuntimeException(final Throwable cause) {
+ super(cause);
+ }
+
+ public DisplaySyncRuntimeException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/IRunnable.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/IRunnable.java
new file mode 100644
index 00000000000..fdc86d5322a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/IRunnable.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 365808 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.NatTableAPITests
+ * Grégoire Dupé (Mia-Software) - Bug 367153 - synchronization utilities
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.displaysync;
+
+public interface IRunnable<T extends Object, E extends Exception> {
+ T run() throws E;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedComposite.java
new file mode 100644
index 00000000000..2e9f7ae6ca5
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedComposite.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2012 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 365808 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.NatTableAPITests
+ * Grégoire Dupé (Mia-Software) - Bug 367153 - synchronization utilities
+ * Nicolas Bros (Mia-Software) - Bug 370442 - rewrite the Facet loading dialog for v0.2
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.displaysync;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * <ul>
+ * <li>syncExecWithResult (has return type, throws exception)
+ * <li>safeSyncExec (has return type, no exception)
+ * <li>voidSyncExec (no return type, throws exception)
+ * <li>voidExceptionFreeRunnable (no return type, no exception)
+ * </ul>
+ */
+public class SynchronizedComposite<C extends Composite> extends SynchronizedObject<C> {
+
+ public SynchronizedComposite(final C composite) {
+ super(composite, composite.getDisplay());
+ }
+
+ @Deprecated
+ protected C getSynchronizedComposite() {
+ return getSynchronizedObject();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedObject.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedObject.java
new file mode 100644
index 00000000000..6302ad4defe
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/displaysync/SynchronizedObject.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 365808 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.NatTableAPITests
+ * Grégoire Dupé (Mia-Software) - Bug 367153 - synchronization utilities
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.displaysync;
+
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * <ul>
+ * <li>syncExecWithResult (has return type, throws exception)
+ * <li>safeSyncExec (has return type, no exception)
+ * <li>voidSyncExec (no return type, throws exception)
+ * <li>voidExceptionFreeRunnable (no return type, no exception)
+ * </ul>
+ */
+public class SynchronizedObject<O extends Object> {
+
+ private final O object;
+ private final Thread widgetThread;
+ private final Display display;
+
+ public SynchronizedObject(final O object, final Display display) {
+ this.object = object;
+ this.display = display;
+ this.widgetThread = this.display.getThread();
+ }
+
+ protected final <T, E extends Exception> T syncExecWithResult(
+ final IRunnable<T, E> runnable) throws E {
+ T result;
+ if (this.widgetThread == Thread.currentThread()) {
+ result = runnable.run();
+ } else {
+ final ExceptionHandler exceptionHandler = new ExceptionHandler();
+ final Object[] resultHandler = new Object[1];
+ this.display.syncExec(new java.lang.Runnable() {
+ public void run() {
+ try {
+ resultHandler[0] = runnable.run();
+ } catch (final Exception e) {
+ exceptionHandler.setException(e);
+ }
+
+ }
+ });
+ if (exceptionHandler.getException() != null) {
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") This cast is safe because
+ // "exceptionHandler" contains an exception thrown by "runnable"
+ // and
+ // "runnable" throws by definition a instance of E
+ final E castException = (E) exceptionHandler.getException();
+ throw castException;
+ }
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") This cast is safe because
+ // "resultHandler" contains a value returned by "runnable" and
+ // "runnable" returns by definition a instance of T
+ final T tmpResult = (T) resultHandler[0];
+ result = tmpResult;
+ }
+ return result;
+ }
+
+ protected class ExceptionHandler {
+
+ private Exception exception;
+
+ public Exception getException() {
+ return this.exception;
+ }
+
+ public void setException(final Exception exception) {
+ this.exception = exception;
+ }
+ }
+
+ protected final <E extends Exception> void voidSyncExec(
+ final AbstractVoidRunnable<E> runnable) throws E {
+ this.syncExecWithResult(runnable);
+ }
+
+ protected final <T> T safeSyncExec(
+ final AbstractExceptionFreeRunnable<T> runnable) {
+ try {
+ return this.syncExecWithResult(runnable);
+ } catch (final Exception e) {
+ throw new DisplaySyncRuntimeException(e);
+ }
+ }
+
+ protected final void voidExceptionFreeRunnable(
+ final AbstractVoidExceptionFreeRunnable runnable) {
+ try {
+ this.syncExecWithResult(runnable);
+ } catch (final Exception e) {
+ throw new DisplaySyncRuntimeException(e);
+ }
+ }
+
+ public O getSynchronizedObject() {
+ return this.object;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/handler/HandlerUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/handler/HandlerUtils.java
new file mode 100644
index 00000000000..500e9f77991
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/handler/HandlerUtils.java
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 423181 - Unchecked cast in HandlerUtils.getStructuredSelection()
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.handler;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Util class for Handlers.
+ *
+ * @since 0.3
+ */
+public final class HandlerUtils {
+
+ private HandlerUtils() {
+ // Hidden constructor.
+ }
+
+ /**
+ * Return the tree selection of the user's selection.
+ *
+ * @return the current tree selection.
+ */
+ public static IStructuredSelection getStructuredSelection() {
+ ISelection selection = null;
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ final IWorkbenchWindow[] workbenchWindows = workbench
+ .getWorkbenchWindows();
+ if ((workbenchWindows.length > 0)
+ && (workbenchWindows[0].getSelectionService() != null)) {
+ selection = workbenchWindows[0].getSelectionService()
+ .getSelection();
+ }
+ }
+ IStructuredSelection result = null;
+ if (selection instanceof IStructuredSelection) {
+ result = (IStructuredSelection) selection;
+ }
+ return result;
+ }
+
+ /**
+ * Return the current selection.
+ *
+ * @return the current selection.
+ */
+ public static Object getSelection() {
+ Object result = null;
+ // on a facet model, the selection is obviously a TreeSelection
+ final IStructuredSelection structSelection = getStructuredSelection();
+ if (structSelection != null) {
+ result = structSelection.getFirstElement();
+ }
+ return result;
+ }
+
+ /**
+ * Return the active workbench window.
+ *
+ * @return the active workbench window.
+ */
+ public static Shell getWorkbenchWindowShell() {
+ final IWorkbenchWindow iWorkbenchWindow = PlatformUI.getWorkbench()
+ .getWorkbenchWindows()[0];
+ final IWorkbenchPage iWorkbenchPage = iWorkbenchWindow.getPages()[0];
+ final IWorkbenchPart activePart = iWorkbenchPage.getActivePart();
+ final IWorkbenchPartSite site = activePart.getSite();
+
+ return site.getShell();
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/tree/menu/ITreeMenu.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/tree/menu/ITreeMenu.java
new file mode 100644
index 00000000000..7c3ff453162
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/tree/menu/ITreeMenu.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.tree.menu;
+
+import java.util.List;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.item.AbstractTreeItem;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu.AbstractTreeMenuItem;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu.ExtendedTreeMenu;
+
+/**
+ * @see ExtendedTreeMenu
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ITreeMenu<T extends Object> {
+
+ /**
+ * Select a menu item in the tree menu.
+ *
+ * @param menuItemType
+ * @return an instance of T.
+ */
+ T selectMenuItem(Class<? extends AbstractTreeMenuItem<T>> menuItemType);
+
+ /**
+ * Select all the items of the tree with the name <code>treeItemName</code>
+ *
+ * @param treeItemName
+ * the name of the item to select.
+ * @return the list of all the tree item with the name in parameter.
+ */
+ List<AbstractTreeItem<T>> getTreeItems(String treeItemName);
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/FilteredElementSelectionComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/FilteredElementSelectionComposite.java
new file mode 100644
index 00000000000..11f0e556f15
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/FilteredElementSelectionComposite.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011, 2012 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.ui.internal.exported.util.composite;
+
+import org.eclipse.emf.facet.util.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.composite.IFilteredElementSelectionComposite;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.FilteredList;
+
+/**
+ * A control for selecting an element from a list of elements, that can be
+ * filtered using the associated text field.
+ *
+ * @since 0.3
+ */
+public class FilteredElementSelectionComposite extends Composite implements
+ IFilteredElementSelectionComposite {
+
+ private final Text filterText;
+ private final FilteredList fFilteredList;
+ private String matchPrefix;
+
+ public FilteredElementSelectionComposite(final Composite parent,
+ final boolean matchAnywhere, final boolean multiSelection) {
+ super(parent, SWT.BORDER);
+ setLayout(new GridLayout());
+
+ this.filterText = createFilterText(this);
+ this.fFilteredList = createFilteredList(this, multiSelection);
+
+ this.filterText.addModifyListener(new ModifyListener() {
+ public void modifyText(final ModifyEvent event) {
+ getfFilteredList().setFilter(
+ getMatchPrefix(matchAnywhere)
+ + getFilterText().getText());
+ }
+ });
+
+ this.filterText.addKeyListener(new KeyListener() {
+ public void keyPressed(final KeyEvent event) {
+ if (event.keyCode == SWT.ARROW_DOWN) {
+ getfFilteredList().setFocus();
+ }
+ }
+
+ public void keyReleased(final KeyEvent event) {
+ // nothing
+ }
+ });
+ }
+
+ protected String getMatchPrefix(final boolean matchAnywhere) {
+ if (matchAnywhere) {
+ this.matchPrefix = "*"; //$NON-NLS-1$
+ } else {
+ this.matchPrefix = ""; //$NON-NLS-1$
+ }
+ return this.matchPrefix;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.composite.
+ * IFilteredElementSelectionComposite#setElements(java.lang.Object[])
+ */
+ public void setElements(final Object[] elements) {
+ this.fFilteredList.setElements(elements);
+ }
+
+ protected static FilteredList createFilteredList(final Composite parent,
+ final boolean multiSelection) {
+ int multi;
+ if (multiSelection) {
+ multi = SWT.MULTI;
+ } else {
+ multi = SWT.SINGLE;
+ }
+ final FilteredList filteredList = new FilteredList(parent, SWT.BORDER
+ | SWT.V_SCROLL | SWT.H_SCROLL | multi, new LabelProvider(),
+ true, false, true);
+ final GridData data = new GridData();
+ data.grabExcessVerticalSpace = true;
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ data.verticalAlignment = GridData.FILL;
+ filteredList.setLayoutData(data);
+ filteredList.setFilter(""); //$NON-NLS-1$
+ return filteredList;
+ }
+
+ protected static Text createFilterText(final Composite parent) {
+ final Text text = new Text(parent, SWT.BORDER);
+ text.setMessage(Messages.FilteredElementSelectionControl_type_filter_text);
+ final GridData data = new GridData();
+ data.grabExcessVerticalSpace = false;
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ data.verticalAlignment = GridData.BEGINNING;
+ text.setLayoutData(data);
+ return text;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.composite.
+ * IFilteredElementSelectionComposite#getFirstSelectedElement()
+ */
+ public Object getFirstSelectedElement() {
+ Object result = null;
+ final Object[] selection = this.fFilteredList.getSelection();
+ if (selection.length > 0) {
+ result = selection[0];
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.composite.
+ * IFilteredElementSelectionComposite#getSelectedElements()
+ */
+ public Object[] getSelectedElements() {
+ Object[] result = null;
+ if (this.fFilteredList.getSelection().length > 0) {
+ result = this.fFilteredList.getSelection();
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.composite.
+ * IFilteredElementSelectionComposite#getFilteredList()
+ */
+ public FilteredList getFilteredList() {
+ return this.fFilteredList;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.composite.
+ * IFilteredElementSelectionComposite#getFilterText()
+ */
+ public Text getFilterText() {
+ return this.filterText;
+ }
+
+ protected FilteredList getfFilteredList() {
+ return this.fFilteredList;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/SynchronizedFilteredElementSelectionComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/SynchronizedFilteredElementSelectionComposite.java
new file mode 100644
index 00000000000..a889860d9a4
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/composite/SynchronizedFilteredElementSelectionComposite.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.composite;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.composite.IFilteredElementSelectionComposite;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.FilteredList;
+
+/**
+ * @since 0.3
+ */
+public class SynchronizedFilteredElementSelectionComposite<T extends IFilteredElementSelectionComposite>
+ extends SynchronizedObject<T> implements
+ IFilteredElementSelectionComposite {
+
+ /**
+ * @param object
+ * @param display
+ */
+ public SynchronizedFilteredElementSelectionComposite(final T object,
+ final Display display) {
+ super(object, display);
+ }
+
+ public void setElements(final Object[] elements) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedFilteredElementSelectionComposite.this
+ .getSynchronizedObject().setElements(elements);
+ }
+ });
+ }
+
+ public Object getFirstSelectedElement() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Object>() {
+ @Override
+ public Object safeRun() {
+ return SynchronizedFilteredElementSelectionComposite.this
+ .getSynchronizedObject().getFirstSelectedElement();
+ }
+ });
+ }
+
+ public Object[] getSelectedElements() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Object[]>() {
+ @Override
+ public Object[] safeRun() {
+ return SynchronizedFilteredElementSelectionComposite.this
+ .getSynchronizedObject().getSelectedElements();
+ }
+ });
+ }
+
+ public FilteredList getFilteredList() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<FilteredList>() {
+ @Override
+ public FilteredList safeRun() {
+ return SynchronizedFilteredElementSelectionComposite.this
+ .getSynchronizedObject().getFilteredList();
+ }
+ });
+ }
+
+ public Text getFilterText() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Text>() {
+ @Override
+ public Text safeRun() {
+ return SynchronizedFilteredElementSelectionComposite.this
+ .getSynchronizedObject().getFilterText();
+ }
+ });
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialog.java
new file mode 100644
index 00000000000..aabdba6e8d9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialog.java
@@ -0,0 +1,169 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.dialog;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.ICommandWidget;
+import org.eclipse.emf.facet.util.ui.utils.WidgetProperties;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Monitor;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Abstract class representing a dialog. Some methods are implemented to avoid
+ * unnecessary duplication code.
+ *
+ * @param <CB>
+ * The type of the callback.
+ * @param <P>
+ * The type of the key of the {@link WidgetProperties}
+ * @since 0.3
+ */
+public abstract class AbstractDialog<CB extends Object, W extends ICommandWidget>
+ extends TitleAreaDialog implements IDialog<W> {
+
+ // Attributes.
+ private W widget;
+ private Composite dialogComposite;
+ private CB callback;
+
+ /**
+ * Constructor.
+ *
+ * @param callback
+ * the callback
+ * @param properties
+ * the properties that the widget needs
+ */
+ protected AbstractDialog(final CB callback) {
+ this();
+ this.callback = callback;
+ }
+
+ /**
+ * Constructor.
+ */
+ protected AbstractDialog() {
+ super(createDisplayedShell());
+ }
+
+ private static Shell createDisplayedShell() {
+ final Display display = Display.getDefault();
+ final Shell shell = new Shell(display);
+ final Monitor primary = display.getPrimaryMonitor();
+ final Rectangle bounds = primary.getBounds();
+ final Rectangle rect = shell.getBounds();
+ final int xLocation = bounds.x + ((bounds.width - rect.width) / 2);
+ final int yLocation = bounds.y + ((bounds.height - rect.height) / 2);
+ shell.setLocation(xLocation, yLocation);
+ return shell;
+ }
+
+ /**
+ * Execute the widget {@link Command}.
+ */
+ protected abstract void execute();
+
+ /**
+ * Check if all the required attributes are setted ({@link #isDialogValid()}
+ * and call the method {@link #execute()} to get and execute the widget
+ * command. If the dialog is not valid, this method display the errors with
+ * the method {@link #setErrorMessage(String)}.
+ */
+ @Override
+ protected void okPressed() {
+ if (isDialogValid()) {
+ getWidget().onDialogValidation();
+ execute();
+ super.okPressed();
+ } else {
+ setErrorMessage(getWidget().getError());
+ }
+ }
+
+ /**
+ * Set the title and the message dialog. Create the associated widget and
+ * all sub widgets of this widget.
+ */
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ setTitle(getDialogTitle());
+ setMessage(getDialogMessage());
+ // Composite is a subtype of Control.
+ this.dialogComposite = (Composite) super.createDialogArea(parent);
+ this.widget = createWidget();
+ this.widget.createWidgetContent();
+ return this.widget.adapt(Control.class);
+ }
+
+ public Composite getDialogComposite() {
+ return this.dialogComposite;
+ }
+
+ /**
+ * Create the associated widget to the dialog.
+ *
+ * @return an instance of the widget.
+ */
+ protected abstract W createWidget();
+
+ /**
+ * Return the message at the top of the dialog.
+ *
+ * @return the message.
+ */
+ protected abstract String getDialogMessage();
+
+ /**
+ * Return the title of the dialog.
+ *
+ * @return the title.
+ */
+ protected abstract String getDialogTitle();
+
+
+ public boolean isDialogValid() {
+ boolean result = true;
+ final String error = getWidget().getError();
+ if (error != null) {
+ result = false;
+ }
+
+ return result;
+ }
+
+ public W getWidget() {
+ return this.widget;
+ }
+
+ public void commit() {
+ okPressed();
+ }
+
+ public void cancel() {
+ cancelPressed();
+ }
+
+ /**
+ * @return the callback
+ */
+ public CB getCallback() {
+ return this.callback;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialogWithCallback.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialogWithCallback.java
new file mode 100644
index 00000000000..1ce1301892c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractDialogWithCallback.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialogWithoutResultCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IWithResultDialogCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.ICommandWidget;
+
+/**
+ * Abstract dialog with an {@link IDialogWithoutResultCallback} in parameter.
+ *
+ * @since 0.3
+ */
+public abstract class AbstractDialogWithCallback<T extends Object, W extends ICommandWidget>
+ extends AbstractDialog<IWithResultDialogCallback<T>, W> {
+
+ /**
+ * Constructor.
+ *
+ * @param editingDomain
+ * the current editing domain
+ * @param properties
+ * the properties that the widget needs
+ */
+ protected AbstractDialogWithCallback(
+ final IWithResultDialogCallback<T> callback) {
+ super(callback);
+ }
+
+ @Override
+ protected void okPressed() {
+ if (isDialogValid() && (getCallback() != null)) {
+ getCallback().commited(getResult());
+ }
+ super.okPressed();
+ }
+
+ protected abstract T getResult();
+
+ @Override
+ protected void cancelPressed() {
+ if (getCallback() != null) {
+ getCallback().canceled(getResult());
+ }
+ super.cancelPressed();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractMainDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractMainDialog.java
new file mode 100644
index 00000000000..6d0eee1f483
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/AbstractMainDialog.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.AbstractCommandWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.ICommandWidget;
+import org.eclipse.emf.facet.util.ui.utils.WidgetProperties;
+
+/**
+ * This abstract class will create a dialog. All the action's dialog must
+ * extends this class. It provides a simple way to create a standard dialog for
+ * this ui.</p>
+ *
+ * A single {@link AbstractCommandWidget} is created by the dialog wich will
+ * contain all the subwidgets {@link AbstractWidget}.
+ *
+ * The dialog have to create all the properties {@link WidgetProperties} that
+ * the widgets {@link AbstractCommandWidget} will need.
+ *
+ * @see AbstractCommandWidget
+ * @see AbstractWidget
+ * @see AbstractAddElementDialog
+ * @since 0.3
+ */
+public abstract class AbstractMainDialog<W extends ICommandWidget>
+ extends AbstractDialog<Object, W> {
+
+ private final Object selection;
+
+ /**
+ * Constructor.
+ *
+ * @param callback
+ * the callback.
+ * @param editedElement
+ * the selection in the model (ecore file).
+ */
+ protected AbstractMainDialog(final Object editedElement) {
+ super();
+ this.selection = editedElement;
+ }
+
+ /**
+ * @return the selection in the model.
+ */
+ protected Object getSelection() {
+ return this.selection;
+ }
+
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/SynchronizedAbstractDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/SynchronizedAbstractDialog.java
new file mode 100644
index 00000000000..165391fb1c1
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/dialog/SynchronizedAbstractDialog.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.dialog;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Synchronized class for safe run.
+ *
+ * @see AbstractDialog
+ * @since 0.3
+ *
+ */
+public class SynchronizedAbstractDialog<W extends Object> extends
+ SynchronizedObject<IDialog<W>> implements IDialog<W> {
+
+ /**
+ * Constructor.
+ *
+ * @param object
+ * the to synchronized.
+ * @param display
+ * the display.
+ */
+ public SynchronizedAbstractDialog(final IDialog<W> object,
+ final Display display) {
+ super(object, display);
+ }
+
+ public void commit() {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractDialog.this.getSynchronizedObject()
+ .commit();
+ }
+ });
+ }
+
+ public void cancel() {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractDialog.this.getSynchronizedObject()
+ .cancel();
+ }
+ });
+ }
+
+ public int open() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Integer>() {
+ @Override
+ public Integer safeRun() {
+ return Integer.valueOf(SynchronizedAbstractDialog.this
+ .getSynchronizedObject().open());
+ }
+ }).intValue();
+ }
+
+ public boolean isDialogValid() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedAbstractDialog.this
+ .getSynchronizedObject().isDialogValid());
+ }
+ }).booleanValue();
+ }
+
+ public W getWidget() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<W>() {
+ @Override
+ public W safeRun() {
+ return SynchronizedAbstractDialog.this.getSynchronizedObject()
+ .getWidget();
+ }
+ });
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/handler/AbstractSelectionExpectedTypeHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/handler/AbstractSelectionExpectedTypeHandler.java
new file mode 100644
index 00000000000..dddd61c21ca
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/handler/AbstractSelectionExpectedTypeHandler.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.emf.facet.util.ui.internal.exported.handler.HandlerUtils;
+
+/**
+ * Abstract handler. All handlers must extends this class.
+ *
+ * @see IFunctionDialogFactory
+ *
+ * @see CreateFacetInFacetSetHandler
+ * @see CreateFacetSetInFacetSetHandler
+ * @see AddAttributeInFacetHandler
+ * @see AddOperationInFacetHandler
+ * @see AddReferenceInFacetHandler
+ * @see AddParameterInOperationHandler
+ * @since 0.3
+ */
+public abstract class AbstractSelectionExpectedTypeHandler extends AbstractHandler {
+
+ @Override
+ public boolean isEnabled() {
+ boolean result = false;
+ if ((HandlerUtils.getStructuredSelection() != null && HandlerUtils
+ .getStructuredSelection().size() == 1)
+ && getSelectionExpectedType().isInstance(
+ HandlerUtils.getSelection())) {
+ result = true;
+ }
+ return result;
+ }
+
+ /**
+ * Return the expected type of the selection.
+ *
+ * @return the type expected.
+ */
+ protected abstract Class<?> getSelectionExpectedType();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/ExtendedTree.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/ExtendedTree.java
new file mode 100644
index 00000000000..427cb705c4e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/ExtendedTree.java
@@ -0,0 +1,174 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.tree;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.item.AbstractTreeItem;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu.AbstractTreeMenu;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu.ExtendedTreeMenu;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Tree;
+
+/**
+ * This class provides the creation of a {@link Tree} but with extended
+ * elements.</p>
+ *
+ * This tree creates its menu {@link ExtendedTreeMenu} and had the list of all the items
+ * of the tree accessible with the method {@link #getTreeItems()}.
+ *
+ * </p> Only one element of the tree can be selected at the same time.
+ *
+ * @since 0.3
+ */
+public class ExtendedTree {
+
+ private static final int TREE_HEIGHT = 250;
+ private final Tree tree;
+ private final ExtendedTreeMenu<IDialog> treeMenu;
+ private Listener listener;
+
+ /**
+ * Constructor.
+ *
+ * Create a new instance of a {@link Tree} and create the {@link ExtendedTreeMenu}
+ * with the <code>menuItems</code> in parameter.
+ *
+ * @param parent
+ * the parent of the TreeExtended.
+ * @param menuItems
+ * the items of the menu.
+ *
+ * @see ExtendedTreeMenu
+ * @see AbstractTreeMenu
+ */
+ public ExtendedTree(final Composite parent,
+ final List<AbstractTreeMenu<IDialog>> menuItems) {
+
+ // SWT.SINGLE -> a unique selection on the tree possible
+ this.tree = new Tree(parent, SWT.SINGLE | SWT.NONE);
+ final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.heightHint = TREE_HEIGHT;
+ this.tree.setLayoutData(gridData);
+ this.tree.addMouseListener(new MouseListener() {
+
+ public void mouseUp(final MouseEvent mouseEvent) {
+ // Nothing.
+ }
+
+ public void mouseDown(final MouseEvent mouseEvent) {
+ // Nothing.
+ }
+
+ public void mouseDoubleClick(final MouseEvent mouseEvent) {
+ onMouseDoubleClick();
+ }
+ });
+ this.tree.addKeyListener(new KeyListener() {
+
+ public void keyReleased(final KeyEvent event) {
+ // Nothing.
+ }
+
+ public void keyPressed(final KeyEvent event) {
+ onKeyPressed(event);
+ }
+ });
+ this.treeMenu = new ExtendedTreeMenu<IDialog>(parent, this, menuItems);
+ this.getTreeMenu().createMenu();
+ this.tree.setMenu(this.getTreeMenu().getMenu());
+ }
+
+ /**
+ * This method is called when a key is pressed on the tree.
+ */
+ protected void onKeyPressed(final KeyEvent event) {
+ if (event.keyCode == SWT.DEL) {
+ this.getTreeMenu().removeCurrentItemSelected();
+ }
+ }
+
+ /**
+ * When the mouse does a double click on an element of the tree.
+ */
+ protected void onMouseDoubleClick() {
+ if (getTree().getSelection().length > 0) {
+ // new Tree(parent, SWT.SINGLE | SWT.NONE) -> the tree can only had
+ // one selection at the same time.
+ this.getTreeMenu().onMouseSelection();
+ }
+ }
+
+ /**
+ * @return the {@link Tree} created by this class.
+ */
+ public Tree getTree() {
+ return this.tree;
+ }
+
+ /**
+ * Add a {@link ModificationListener} to the list of listeners of the tree.
+ *
+ * @param listener
+ */
+ public void setListener(final Listener listener) {
+ this.listener = listener;
+ }
+
+ /**
+ * When a modification appends, this method has to be called and the method
+ * {@link #notifyChanged()} is called for the listener of this Tree.
+ */
+ public void fireChanged() {
+ this.listener.handleEvent(null);
+ }
+
+ /**
+ * @return a map of properties to pass to the {@link AbstractTreeItem}. Each
+ * items add to override the method
+ * {@link AbstractTreeItem#getExtraProperties(Map)} to get this
+ * properties.
+ */
+ public void putExtraPropertiesToItems(final Map<String, Object> properties) {
+ this.getTreeMenu().putExtraProperties(properties);
+ }
+
+ /**
+ * Return the first {@link AbstractTreeItem} of the tree.
+ *
+ * @return the first item of the tree.
+ */
+ public AbstractTreeItem<IDialog> getFirstTreeItem() {
+ AbstractTreeItem<IDialog> result = null;
+ if (this.tree.getItemCount() > 0) {
+ result = this.getTreeMenu().getTreeItemExtended(this.tree.getItem(0));
+ }
+ return result;
+ }
+
+ /**
+ * @return the treeMenu of this tree.
+ */
+ public ExtendedTreeMenu<IDialog> getTreeMenu() {
+ return this.treeMenu;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/item/AbstractTreeItem.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/item/AbstractTreeItem.java
new file mode 100644
index 00000000000..d2f69206c14
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/item/AbstractTreeItem.java
@@ -0,0 +1,210 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.tree.item;
+
+import java.util.Map;
+
+import org.eclipse.emf.facet.util.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.ExtendedTree;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu.AbstractTreeMenuItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * This abstract class represent an item of the tree. All the item types of the
+ * tree must extend this abstract class.
+ *
+ * @since 0.3
+ */
+public abstract class AbstractTreeItem<T extends Object> {
+
+ private AbstractTreeMenuItem<T> menuItem;
+ private TreeItem treeItem;
+ private Map<String, Object> extraProperties;
+
+ /**
+ * Create a new item {@link TreeItem} into the parent.
+ *
+ * @param parent
+ * the parent of the item to create.
+ */
+ public TreeItem createItem(final AbstractTreeMenuItem<T> itemMenu,
+ final Tree parent) {
+ this.menuItem = itemMenu;
+ final TreeItem item = new TreeItem(parent, SWT.NONE);
+ initialize(item);
+ return item;
+ }
+
+ /**
+ * Create a new item {@link TreeItem} into the parent.
+ *
+ * @param parent
+ * the parent of the item to create.
+ */
+ public TreeItem createItem(final AbstractTreeMenuItem<T> itemMenu,
+ final TreeItem parent) {
+ this.menuItem = itemMenu;
+ final TreeItem item = new TreeItem(parent, SWT.NONE);
+ // Open the parent of the item on the tree.
+ parent.setExpanded(true);
+ initialize(item);
+ return item;
+ }
+
+ /**
+ * Initialize the tree item with the text and call the method
+ * {@link #onItemCreation()} if the user wants an extra action.
+ */
+ private void initialize(final TreeItem item) {
+ item.setChecked(true);
+ if ((getItemText() == null) || "".equals(getItemText())) { //$NON-NLS-1$
+ item.setText(getDefaultItemText());
+ } else {
+ item.setText(getItemText());
+ }
+ fireChanged();
+ this.setTreeItem(item);
+ }
+
+ /**
+ * Return the default message when the item is created.
+ *
+ * @return the default message.
+ */
+ public static String getDefaultItemText() {
+ return Messages.item_todo;
+ }
+
+ /**
+ * Return the text to display for the item. This text can be null or an
+ * empty string (the value of the string will be {@link Messages#item_todo}
+ * ). The item text can be setted later with {@link #setItemText(String)}.
+ *
+ * @return the text of the item in the tree.
+ */
+ public abstract String getItemText();
+
+ /**
+ * Called when this object will be instantiate.
+ */
+ public abstract T onItemCreation();
+
+ /**
+ * This method is called when the item of the tree is selected.
+ */
+ public abstract IDialog onItemMouseSelection();
+
+ /**
+ * Return the value of this item.
+ *
+ * @return the value.
+ */
+ public abstract Object returnValue();
+
+ /**
+ * Delete the item and all his children of the tree.
+ */
+ public void removeItem() {
+ for (final TreeItem item : getChildren()) {
+ findTreeItemExtended(item).removeItem();
+ }
+ this.getTreeItem().dispose();
+ fireChanged();
+ }
+
+ /**
+ * Return the children of this item in the tree.
+ *
+ * @return the list of the children.
+ */
+ public TreeItem[] getChildren() {
+ return this.getTreeItem().getItems();
+ }
+
+ /**
+ * Return the parent of this item on the tree.
+ *
+ * @return the parent of the item or null if the item is root.
+ */
+ public AbstractTreeItem<T> getParent() {
+ return findTreeItemExtended(getTreeItem().getParentItem());
+ }
+
+ /**
+ * Edit the text of the item into the tree.
+ *
+ * @param newText
+ * the new text.
+ */
+ public void setTreeItemText(final String newText) {
+ this.getTreeItem().setText(newText);
+ }
+
+ /**
+ * When a modification append, this method has to be called and the method
+ * {@link #notifyChanged()} is called for the listener of this Tree.
+ */
+ protected void fireChanged() {
+ this.getMenuItem().fireChanged();
+ }
+
+ /**
+ * @return the treeItem
+ */
+ public TreeItem getTreeItem() {
+ return this.treeItem;
+ }
+
+ /**
+ * @param treeItem
+ * the treeItem to set
+ */
+ private void setTreeItem(final TreeItem treeItem) {
+ this.treeItem = treeItem;
+ }
+
+ /**
+ * @return the menuItem
+ */
+ public AbstractTreeMenuItem<T> getMenuItem() {
+ return this.menuItem;
+ }
+
+ /**
+ * @param item
+ * @return
+ */
+ public AbstractTreeItem<T> findTreeItemExtended(final TreeItem item) {
+ return getMenuItem().findTreeItemExtended(item);
+ }
+
+ /**
+ * This method gets the <code>properties</code> passed by the
+ * {@link #treeExtended} via the method
+ * {@link ExtendedTree#putExtraPropertiesToItems(Map)}.
+ *
+ * @return the extraProperties
+ */
+ public Map<String, Object> getExtraProperties() {
+ return this.extraProperties;
+ }
+
+ /**
+ * @param extraProperties the extraProperties to set
+ */
+ public void setExtraProperties(final Map<String, Object> extraProperties) {
+ this.extraProperties = extraProperties;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenu.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenu.java
new file mode 100644
index 00000000000..4f3f0d576fe
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenu.java
@@ -0,0 +1,205 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu;
+
+import java.util.Map;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.item.AbstractTreeItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Abstract class providing the creation of any item into the menu.
+ *
+ * @see AbstractTreeMenuItem
+ * @see AbstractTreeSubMenu
+ * @since 0.3
+ */
+public abstract class AbstractTreeMenu<T extends Object> {
+
+ private ExtendedTreeMenu<T> treeMenu;
+ private MenuItem menuItem;
+ private boolean menuItemCreated;
+ private Map<String, Object> properties;
+
+ /**
+ * Refresh the the menu according to the actual context.
+ */
+ public void refresh(final ExtendedTreeMenu<T> menu) {
+ this.treeMenu = menu;
+ refreshMenu(this.treeMenu.getMenu());
+ }
+
+ /**
+ * Refresh the the menu according to the actual context.
+ */
+ public void refresh(final ExtendedTreeMenu<T> menuTree, final Menu menu) {
+ this.treeMenu = menuTree;
+ refreshMenu(menu);
+ }
+
+ /**
+ * Refresh the the menu according to the actual context.
+ */
+ private void refreshMenu(final Menu menu) {
+ if (isEnabled()) {
+ if (this.isMenuItemCreated()) {
+ deleteMenuItem();
+ }
+ this.setMenuItemCreated(true);
+ this.menuItem = createMenuItem(menu);
+ } else {
+ deleteMenuItem();
+ this.setMenuItemCreated(false);
+ }
+ }
+
+ /**
+ * Return if the menu item has to be enabled or not (by checking if the
+ * associated AbstractTreeItem is enabled or not).
+ *
+ * @return if the menu item has to be enabled or not.
+ */
+ public boolean isEnabled(final ExtendedTreeMenu<T> menuTree) {
+ this.treeMenu = menuTree;
+ return isEnabled();
+ }
+
+ /**
+ * Return if the menu item has to be enabled or not (by checking if the
+ * associated AbstractTreeItem is enabled or not).
+ *
+ * @return if the menu item has to be enabled or not.
+ */
+ public abstract boolean isEnabled();
+
+ /**
+ * Create the concrete item. Has to be overrided by the classes extending
+ * this abstract class.
+ *
+ * @param parent
+ * the parent of the item.
+ * @return the item created.
+ */
+ protected MenuItem createMenuItem(final Menu parent) {
+ final MenuItem item = new MenuItem(parent, SWT.NONE);
+ item.setText(getMenuName());
+ item.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(final SelectionEvent selectionEvent) {
+ onMenuItemSelection();
+ }
+
+ public void widgetDefaultSelected(
+ final SelectionEvent selectionEvent) {
+ // Nothing.
+ }
+ });
+ return item;
+ }
+
+ /**
+ * @return the menu item name.
+ */
+ public abstract String getMenuName();
+
+ /**
+ * This method is called when the menu item is selected.
+ *
+ * @return can return an instance of T.
+ */
+ public abstract T onMenuItemSelection();
+
+ /**
+ * Delete the item of the menu.
+ */
+ public void deleteMenuItem() {
+ if (this.isMenuItemCreated() && (this.menuItem != null)
+ && !this.menuItem.isDisposed()) {
+ if (this.menuItem.getMenu() != null) {
+ this.menuItem.getMenu().dispose();
+ }
+ this.menuItem.dispose();
+ }
+ }
+
+ /**
+ * @return the treeMenu of the tree.
+ */
+ public ExtendedTreeMenu<T> getTreeMenu() {
+ return this.treeMenu;
+ }
+
+ /**
+ * Set the properties to pass to the new items.
+ *
+ * @param extraProperties
+ * the properties to pass.
+ *
+ */
+ public void setExtraProperties(final Map<String, Object> extraProperties) {
+ this.properties = extraProperties;
+ }
+
+ /**
+ * @return the {@link Tree}.
+ */
+ public Tree getTree() {
+ return this.treeMenu.getTree();
+ }
+
+ /**
+ * @return the properties.
+ */
+ public Map<String, Object> getProperties() {
+ return this.properties;
+ }
+
+ /**
+ * @return true if the menu for this concrete item is created or not.
+ */
+ public boolean isMenuItemCreated() {
+ return this.menuItemCreated;
+ }
+
+ /**
+ * @param menuItemCreated
+ * the menuItemCreated to set.
+ */
+ public void setMenuItemCreated(final boolean menuItemCreated) {
+ this.menuItemCreated = menuItemCreated;
+ }
+
+ /**
+ * Return the {@link AbstractTreeItem} according to the {@link TreeItem}.
+ *
+ * @param treeItem
+ * the treeItem related.
+ * @return the {@link AbstractTreeItem} related to the <code>treeItem</code>
+ * .
+ */
+ public abstract AbstractTreeItem<T> getTreeItemExtended(
+ final TreeItem treeItem);
+
+ /**
+ * Remove the item in parameter of the tree.
+ *
+ * @param item
+ * the item to remove.
+ */
+ public abstract boolean removeItem(final TreeItem item);
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenuItem.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenuItem.java
new file mode 100644
index 00000000000..1be61eb48cc
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeMenuItem.java
@@ -0,0 +1,213 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.ui.internal.Activator;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.item.AbstractTreeItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Abstract class for the tree menu item. Each Menu Item had an handler which
+ * provide the methods: <li>{@link #isEnabled()} : return if the menu item has
+ * to be displayed.</li> <li>{@link #onMenuItemSelection()} : this method will
+ * be execute when the item is selected.</li> <li>
+ * {@link #getAssociatedTreeItemClass()} : links this class with an
+ * {@link AbstractTreeItem}. This item will be instantiate when the user select
+ * this element on the tree menu.</li>
+ *
+ * @see AbstractTreeItem
+ * @see AbstractTreeMenu
+ * @since 0.3
+ */
+public abstract class AbstractTreeMenuItem<T extends Object> extends
+ AbstractTreeMenu<T> {
+
+ private final List<AbstractTreeItem<T>> items;
+
+ /**
+ * Constructor.
+ */
+ public AbstractTreeMenuItem() {
+ super();
+ this.items = new LinkedList<AbstractTreeItem<T>>();
+ }
+
+ /**
+ * This method creates the associated item and set the extra properties to
+ * it.
+ */
+ @Override
+ public T onMenuItemSelection() {
+ AbstractTreeItem<T> item = null;
+ if (getCurrentItemSelected() == null) {
+ item = createItem(getTree());
+ } else {
+ item = createItem(getCurrentItemSelected());
+ }
+ this.getItems().add(item);
+ item.setExtraProperties(getProperties());
+ fireChanged();
+ return item.onItemCreation();
+ }
+
+ /**
+ * Create a new item {@link TreeItem} into the parent.
+ *
+ * @param parent
+ * the parent of the item to create.
+ */
+ public AbstractTreeItem<T> createItem(final Tree parent) {
+ return createTreeItem(parent);
+ }
+
+ /**
+ * Create a new item {@link TreeItem} into the parent.
+ *
+ * @param parent
+ * the parent of the item to create.
+ */
+ public AbstractTreeItem<T> createItem(final TreeItem parent) {
+ return createTreeItem(parent);
+ }
+
+ /**
+ * Create a new item {@link TreeItem} into the parent.
+ *
+ * @param parent
+ * the parent of the item to create.
+ */
+ protected AbstractTreeItem<T> createTreeItem(final Object parent) {
+ AbstractTreeItem<T> newTreeItem = null;
+ try {
+ newTreeItem = getAssociatedTreeItemClass().newInstance();
+ if (parent instanceof Tree) {
+ newTreeItem.createItem(this, (Tree) parent);
+ } else if (parent instanceof TreeItem) {
+ newTreeItem.createItem(this, (TreeItem) parent);
+ }
+ } catch (final SecurityException e) {
+ Logger.logError(e, Activator.getDefault());
+ } catch (final IllegalArgumentException e) {
+ Logger.logError(e, Activator.getDefault());
+ } catch (final InstantiationException e) {
+ Logger.logError(e, Activator.getDefault());
+ } catch (final IllegalAccessException e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+
+ return newTreeItem;
+ }
+
+ /**
+ * Find the treeItem searching into the all tree.
+ *
+ * @param treeItem
+ * the treeItem to find.
+ * @return the corresponding {@link AbstractTreeItem}. Null if not.
+ */
+ public AbstractTreeItem<T> findTreeItemExtended(final TreeItem treeItem) {
+ return this.getTreeMenu().getTreeItemExtended(treeItem);
+ }
+
+ /**
+ * This method only find the item into the corresponding element of this
+ * menu item. To find an element searching it into the all tree, use the
+ * method {@link #findTreeItemExtended(TreeItem)}.
+ */
+ @Override
+ public AbstractTreeItem<T> getTreeItemExtended(final TreeItem item) {
+ AbstractTreeItem<T> result = null;
+ for (final AbstractTreeItem<T> itemExtended : this.getItems()) {
+ if (itemExtended.getTreeItem().equals(item)) {
+ result = itemExtended;
+ break;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean removeItem(final TreeItem item) {
+ boolean removed = false;
+ final AbstractTreeItem<T> itemExtended = findTreeItemExtended(item);
+ if (itemExtended != null) {
+ this.getItems().remove(itemExtended);
+ itemExtended.removeItem();
+ removed = true;
+ fireChanged();
+ }
+ return removed;
+ }
+
+ /**
+ * @return get the current selection of the tree.
+ */
+ public TreeItem getCurrentItemSelected() {
+ return getTreeMenu().getCurrentItemSelected();
+ }
+
+ /**
+ * Remove the last item created.
+ */
+ protected void removeLastItem() {
+ // The list created is a LinkedList<AbstractTreeItem>
+ ((LinkedList<AbstractTreeItem<T>>) this.getItems()).getLast()
+ .removeItem();
+ fireChanged();
+ }
+
+ /**
+ * Set a new text to the last item created.
+ *
+ * @param newText
+ * the new text to set.
+ */
+ protected void setLastItemText(final String newText) {
+ // The list created is a LinkedList<AbstractTreeItem>
+ ((LinkedList<AbstractTreeItem<T>>) this.getItems()).getLast()
+ .setTreeItemText(newText);
+ fireChanged();
+ }
+
+ /**
+ * When a modification append, this method has to be called and the method
+ * {@link #notifyChanged()} is called for the listener of this Tree.
+ */
+ public void fireChanged() {
+ final ExtendedTreeMenu<T> treeMenu = getTreeMenu();
+ if (treeMenu != null) {
+ treeMenu.fireChanged();
+ }
+ }
+
+ /**
+ * Return the class associated with this menu item. When this menu item will
+ * be selected, a new instance of this associated {@link AbstractTreeItem}
+ * will be created.
+ *
+ * @return the associated class.
+ */
+ public abstract Class<? extends AbstractTreeItem<T>> getAssociatedTreeItemClass();
+
+
+ /**
+ * @return the items created by this menu item.
+ */
+ public List<AbstractTreeItem<T>> getItems() {
+ return this.items;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeSubMenu.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeSubMenu.java
new file mode 100644
index 00000000000..9cd8a720710
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/AbstractTreeSubMenu.java
@@ -0,0 +1,128 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.item.AbstractTreeItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Class for the creation of a sub-menu in the menu. The sub-menu is not
+ * selectable and own a list of sub-items (declared by the contributor with the
+ * extension point).
+ *
+ * @since 0.3
+ */
+public abstract class AbstractTreeSubMenu<T extends Object> extends
+ AbstractTreeMenu<T> {
+
+ private final List<AbstractTreeMenu<T>> items;
+
+ /**
+ * Constructor.
+ */
+ public AbstractTreeSubMenu() {
+ super();
+ this.items = new LinkedList<AbstractTreeMenu<T>>();
+ }
+
+ /**
+ * Add an item to the list of the sub-menu items.
+ *
+ * @param item
+ * the item to add.
+ */
+ public void addItem(final AbstractTreeMenu<T> item) {
+ this.getItems().add(item);
+ }
+
+ /**
+ * Creation of the sub-menu and all his children.
+ */
+ @Override
+ protected MenuItem createMenuItem(final Menu parent) {
+ MenuItem menuItem = null;
+ for (final AbstractTreeMenu<T> item : this.getItems()) {
+ if (item.isEnabled(getTreeMenu())) {
+ if (menuItem == null) {
+ menuItem = createConcreteMenu(parent);
+ }
+ item.setExtraProperties(getProperties());
+ item.refresh(getTreeMenu(), menuItem.getMenu());
+ }
+ }
+ return menuItem;
+ }
+
+ /**
+ * Create the concrete sub menu into the tree menu.
+ *
+ * @param parent
+ * the menu parent of this sub menu.
+ * @return the new item into the menu.
+ */
+ protected MenuItem createConcreteMenu(final Menu parent) {
+ final MenuItem menuItem = new MenuItem(parent, SWT.CASCADE);
+ menuItem.setText(getMenuName());
+ menuItem.setMenu(new Menu(parent));
+ return menuItem;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ boolean result = false;
+ for (final AbstractTreeMenu<T> item : this.getItems()) {
+ if (item.isEnabled(getTreeMenu())) {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public AbstractTreeItem<T> getTreeItemExtended(final TreeItem treeItem) {
+ AbstractTreeItem<T> result = null;
+ for (final AbstractTreeMenu<T> menuItem : this.getItems()) {
+ final AbstractTreeItem<T> itemExtended = menuItem
+ .getTreeItemExtended(treeItem);
+ if (itemExtended != null) {
+ result = itemExtended;
+ break;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean removeItem(final TreeItem item) {
+ boolean removed = false;
+ for (final AbstractTreeMenu<T> menuItem : this.getItems()) {
+ removed = menuItem.removeItem(item);
+ if (removed) {
+ break;
+ }
+ }
+ return removed;
+ }
+
+ /**
+ * @return the items
+ */
+ public List<AbstractTreeMenu<T>> getItems() {
+ return this.items;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/ExtendedTreeMenu.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/ExtendedTreeMenu.java
new file mode 100644
index 00000000000..aebaed0ca52
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/tree/menu/ExtendedTreeMenu.java
@@ -0,0 +1,341 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.tree.menu;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.tree.menu.ITreeMenu;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.ExtendedTree;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.tree.item.AbstractTreeItem;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.MenuListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * This class provide the creation of the menu {@link Menu} of the tree (
+ * {@link #createMenu(Control, ExtendedTree)}. The menu add a list of
+ * {@link AbstractTreeItem} and for each an {@link AbstractTreeItem} which will
+ * be instantiate when the menu item is selected.
+ *
+ * @since 0.3
+ */
+public class ExtendedTreeMenu<IDialog> implements ITreeMenu<IDialog> {
+
+ private final Control parent;
+ private final ExtendedTree treeExtended;
+ private final List<AbstractTreeMenu<IDialog>> menuItems;
+ private Menu menu;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of the menu.
+ * @param treeExtended
+ * the tree to which the menu will be linked.
+ * @param menuItems
+ */
+ public ExtendedTreeMenu(final Control parent, final ExtendedTree treeExtended,
+ final List<AbstractTreeMenu<IDialog>> menuItems) {
+ this.parent = parent;
+ this.treeExtended = treeExtended;
+ this.menuItems = menuItems;
+ }
+
+ /**
+ * This method creates the tree menu, add put the listener into the menu.
+ *
+ * @param parent
+ * the parent of the menu.
+ * @param treeExtended
+ * the associated {@link ExtendedTree} of the menu.
+ */
+ public void createMenu() {
+ this.menu = new Menu(this.parent);
+ this.menu.addMenuListener(new MenuListener() {
+
+ public void menuShown(final MenuEvent menuEvent) {
+ onMenuShown();
+ }
+
+ public void menuHidden(final MenuEvent menuEvent) {
+ // Nothing.
+ }
+ });
+ }
+
+ /**
+ * This method is called when the menu is displayed. It calls all the
+ * {@link AbstractTreeMenu#refresh(TreeMenu)} method of each element of the
+ * menu.
+ */
+ public void onMenuShown() {
+ for (final AbstractTreeMenu<IDialog> menuItem : this.getMenuItems()) {
+ menuItem.refresh(this);
+ }
+ }
+
+ /**
+ * Return the list of all the items of this menu.
+ *
+ * @return the list of the {@link AbstractTreeMenu} of this menu.
+ */
+ public List<AbstractTreeMenu<IDialog>> getTreeMenuItems() {
+ return this.getMenuItems();
+ }
+
+ /**
+ * Return the {@link Menu} of this TreeMenu.
+ *
+ * @return the menu.
+ */
+ public Menu getMenu() {
+ return this.menu;
+ }
+
+ /**
+ * Put this <code>properties</code> to each items created.
+ *
+ * @param properties
+ * the list of properties to pass.
+ */
+ public void putExtraProperties(final Map<String, Object> properties) {
+ for (final AbstractTreeMenu<IDialog> menuItem : this.getMenuItems()) {
+ menuItem.setExtraProperties(properties);
+ }
+ }
+
+ /**
+ * @return the current {@link TreeItem} selected on the tree.
+ */
+ public TreeItem getCurrentItemSelected() {
+ TreeItem result = null;
+ final TreeItem[] items = this.treeExtended.getTree().getSelection();
+ if (items.length > 0) {
+ result = this.treeExtended.getTree().getSelection()[0];
+ }
+ return result;
+ }
+
+ /**
+ * @return the {@link AbstractTreeItem} selected on the tree. Can be null.
+ */
+ public AbstractTreeItem<IDialog> getTreeItemExtended(final TreeItem treeItem) {
+ AbstractTreeItem<IDialog> result = null;
+ for (final AbstractTreeMenu<IDialog> menuItem : this.getMenuItems()) {
+ final AbstractTreeItem<IDialog> itemExtended = menuItem
+ .getTreeItemExtended(treeItem);
+ if (itemExtended != null) {
+ result = itemExtended;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @return the {@link AbstractTreeMenu} selected on the tree. Can be null.
+ */
+ public AbstractTreeMenu<IDialog> getTreeMenu(final TreeItem treeItem) {
+ AbstractTreeMenu<IDialog> result = null;
+
+ for (final AbstractTreeMenu<IDialog> menuItem : this.getMenuItems()) {
+ final AbstractTreeItem<IDialog> itemExtended = menuItem
+ .getTreeItemExtended(treeItem);
+ if (itemExtended != null) {
+ result = menuItem;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Remove the current item selected of the tree.
+ */
+ public void removeCurrentItemSelected() {
+ final AbstractTreeMenu<IDialog> treeMenu = getTreeMenu(getCurrentItemSelected());
+ if (treeMenu != null) {
+ treeMenu.removeItem(getCurrentItemSelected());
+ }
+ }
+
+ /**
+ * @return the {@link Tree}.
+ */
+ public Tree getTree() {
+ return this.treeExtended.getTree();
+ }
+
+ /**
+ * This method call the method
+ * {@link AbstractTreeItem#onItemMouseSelection()} of the current selection.
+ */
+ public void onMouseSelection() {
+ final AbstractTreeItem<IDialog> treeMenu = getTreeItemExtended(getCurrentItemSelected());
+ if (treeMenu != null) {
+ treeMenu.onItemMouseSelection();
+ fireChanged();
+ }
+ }
+
+ /**
+ * When a modification append, this method has to be called and the method
+ * {@link #notifyChanged()} is called for the listener of this Tree.
+ */
+ public void fireChanged() {
+ this.treeExtended.fireChanged();
+ }
+
+ /**
+ * @return the all the items of the menu.
+ */
+ private List<AbstractTreeMenu<IDialog>> getMenuItems() {
+ return this.menuItems;
+ }
+
+ /**
+ * Select the item into the menu (if the item exist).
+ *
+ * @return can return a {@link IDialog}. Can be null.
+ */
+ public IDialog selectMenuItem(
+ final Class<? extends AbstractTreeMenuItem<IDialog>> menuItemType) {
+ IDialog result = null;
+ final AbstractTreeMenu<IDialog> treeMenu = findMenuItem(menuItemType);
+ if (treeMenu != null) {
+ result = treeMenu.onMenuItemSelection();
+ }
+ return result;
+ }
+
+ /**
+ * Return (if exist) the {@link AbstractTreeMenu} with the name
+ * <code>menuItemName</code> into the items of the tree menu.
+ *
+ * @param menuItemType
+ * the name of the element to find.
+ * @return the item menu with the name in parameter (can be null).
+ */
+ private AbstractTreeMenuItem<IDialog> findMenuItem(
+ final Class<? extends AbstractTreeMenuItem<IDialog>> menuItemType) {
+ AbstractTreeMenuItem<IDialog> result = null;
+ for (final AbstractTreeMenuItem<IDialog> item : getAllTreeMenuItems()) {
+ if (item.getClass().isInstance(menuItemType)) {
+ result = item;
+ }
+ }
+ return result;
+ }
+
+ private List<AbstractTreeMenuItem<IDialog>> getAllTreeMenuItems() {
+ final List<AbstractTreeMenuItem<IDialog>> result = new LinkedList<AbstractTreeMenuItem<IDialog>>();
+ for (final AbstractTreeMenu<IDialog> menuItem : getMenuItems()) {
+ if (menuItem instanceof AbstractTreeSubMenu) {
+ result.addAll(getAllTreeMenuItems((AbstractTreeSubMenu<IDialog>) menuItem));
+ } else {
+ result.add((AbstractTreeMenuItem<IDialog>) menuItem);
+ }
+ }
+ return result;
+ }
+
+ private List<AbstractTreeMenuItem<IDialog>> getAllTreeMenuItems(
+ final AbstractTreeSubMenu<IDialog> subMenu) {
+ final List<AbstractTreeMenuItem<IDialog>> result = new LinkedList<AbstractTreeMenuItem<IDialog>>();
+ for (final AbstractTreeMenu<IDialog> menuItem : subMenu.getItems()) {
+ if (menuItem instanceof AbstractTreeSubMenu) {
+ result.addAll(getAllTreeMenuItems((AbstractTreeSubMenu<IDialog>) menuItem));
+ } else {
+ result.add((AbstractTreeMenuItem<IDialog>) menuItem);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @return the treeMenuItem into the menu with is an instance of the type in
+ * parameter.
+ */
+ public AbstractTreeMenu<IDialog> getTreeMenuItem(final Class<?> treeMenuType) {
+ AbstractTreeMenu<IDialog> result = null;
+ final List<AbstractTreeMenu<IDialog>> treeMenuItems = getTreeMenuItems();
+ for (final AbstractTreeMenu<IDialog> item : treeMenuItems) {
+ result = getTreeMenuItem(item, treeMenuType);
+ if (result != null) {
+ break;
+ }
+ }
+ return result;
+ }
+
+ private AbstractTreeMenu<IDialog> getTreeMenuItem(
+ final AbstractTreeSubMenu<IDialog> item,
+ final Class<?> treeMenuType) {
+ AbstractTreeMenu<IDialog> result = null;
+ for (final AbstractTreeMenu<IDialog> subItem : item.getItems()) {
+ result = getTreeMenuItem(subItem, treeMenuType);
+ if (result != null) {
+ break;
+ }
+ }
+ return result;
+ }
+
+ private AbstractTreeMenu<IDialog> getTreeMenuItem(
+ final AbstractTreeMenu<IDialog> item,
+ final Class<?> treeMenuType) {
+ AbstractTreeMenu<IDialog> result = null;
+ if (treeMenuType.isInstance(item)) {
+ result = item;
+ } else if (item instanceof AbstractTreeSubMenu) {
+ result = getTreeMenuItem((AbstractTreeSubMenu<IDialog>) item,
+ treeMenuType);
+ }
+ return result;
+ }
+
+ /**
+ * get all the items of the tree with the name <code>treeItemName</code>
+ *
+ * @param treeItemName
+ * the name of the item to select.
+ * @return the list of all the tree item with the name in parameter.
+ */
+ public List<AbstractTreeItem<IDialog>> getTreeItems(
+ final String treeItemName) {
+ final List<AbstractTreeItem<IDialog>> result = new LinkedList<AbstractTreeItem<IDialog>>();
+ for (final AbstractTreeMenuItem<IDialog> menuItem : getAllTreeMenuItems()) {
+ for (final AbstractTreeItem<IDialog> treeItem : menuItem.getItems()) {
+ if (treeItemName.equals(treeItem.getItemText())) {
+ result.add(treeItem);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Select a item into the tree.
+ *
+ * @param treeItem
+ * the {@link AbstractTreeItem} to select
+ */
+ public void selectTreeItem(final AbstractTreeItem<IDialog> treeItem) {
+ this.treeExtended.getTree().setSelection(treeItem.getTreeItem());
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/AbstractWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/AbstractWidget.java
new file mode 100644
index 00000000000..278fd861de8
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/AbstractWidget.java
@@ -0,0 +1,155 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.AbstractCommandWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.AbstractGetOrCreateFilteredElementCommandWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.properties.AbstractGetPropertyWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.properties.bounds.AbstractGetBoundsWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+import org.eclipse.emf.facet.util.ui.internal.widget.metaclass.FilteredElementSelectionWidget;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * An abstract class providing the creation of a specific action widget.</p>
+ *
+ * The listener provided by the {@link #getWidgetListener()} is applied on the
+ * widget and called when the mouse move into the dialog.
+ *
+ * @see AbstractCommandWidget
+ * @see AbstractGetOrCreateFilteredElementCommandWidget
+ * @see FilteredElementSelectionWidget
+ * @see SelectSubTypingTypeWidget
+ * @see AbstractGetBoundsWidget
+ * @see AbstractGetPropertyWidget
+ * @see GetQueryWidgetComposite
+ * @see SelectQueryTypeWidget
+ * @since 0.3
+ */
+public abstract class AbstractWidget extends Composite implements IAbstractWidget {
+
+ protected static final int VERTICAL_SPACING = 2;
+ protected static final int WIDTH_HINT = 110;
+ private final Composite widgetParent;
+ private final List<IAbstractWidget> subWidgets;
+ private final List<IAbstractWidget> listeners;
+
+ /**
+ * The constructor.
+ *
+ * @param parent
+ * the parent of the widget.
+ * @param editingDomain
+ * the editing domain.
+ */
+ public AbstractWidget(final Composite parent) {
+ super(parent, SWT.NONE);
+ this.widgetParent = parent;
+ this.subWidgets = new LinkedList<IAbstractWidget>();
+ this.setLayout(new GridLayout());
+ this.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.listeners = new LinkedList<IAbstractWidget>();
+ }
+
+ /**
+ * Add the widget to the list of sub widgets.
+ *
+ * @param widget
+ * the widget to add.
+ */
+ protected void addSubWidget(final IAbstractWidget widget) {
+ this.subWidgets.add(widget);
+ }
+
+ /**
+ * This method add all the sub widgets of this widget.
+ * <p/>
+ * Use the method {@link #addSubWidget(AbstractCommandWidget)}
+ */
+ protected abstract void addSubWidgets();
+
+ /**
+ * @return the widget parent.
+ */
+ protected Composite getWidgetParent() {
+ return this.widgetParent;
+ }
+
+ /**
+ * Return the string containing the error for this widget.
+ *
+ * @return null if there is no error. The string containing the error if
+ * there is an error.
+ */
+ public abstract String getError();
+
+ /**
+ * Create the content of the widget (call {@link #addSubWidgets()}) and
+ * sub-widgets.
+ */
+ public void createWidgetContent() {
+ addSubWidgets();
+ for (final IAbstractWidget widget : this.subWidgets) {
+ widget.createWidgetContent();
+ widget.addListener(this);
+ }
+ }
+
+ /**
+ * Add the abstractWidget in parameter to the list of listeners of the
+ * widget.
+ *
+ * @param abstractWidget
+ * the abstractWidget to listen.
+ */
+ public void addListener(final AbstractWidget abstractWidget) {
+ // This method is public because PMD doesn't want it to be private...
+ // This is due to the fact that this method is used on the method
+ // 'createWidgetContent' but it is called on the same object type but
+ // not on the same instance. So, programatly, put the method private is
+ // correct because the object type is the same that the owner but not on
+ // the same instance.
+ this.listeners.add(abstractWidget);
+ }
+
+ /**
+ * When a modification append, this method is called and the method
+ * {@link #notifyChanged()} is called for each listeners of this widget.
+ */
+ protected void fireChanged() {
+ for (final IAbstractWidget listener : this.listeners) {
+ listener.notifyChanged();
+ }
+ }
+
+ /**
+ * When a change in a sub-widget append, this method is execute. If no
+ * action has to be done when a modification append, this method has to be
+ * void.
+ */
+ public abstract void notifyChanged();
+
+ /**
+ * @return the subWidgets
+ */
+ public List<IAbstractWidget> getSubWidgets() {
+ return this.subWidgets;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractCommandWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractCommandWidget.java
new file mode 100644
index 00000000000..13bb384c75c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractCommandWidget.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.dialog.AbstractDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.dialog.AbstractMainDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+import org.eclipse.emf.facet.util.ui.utils.WidgetProperties;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This abstract class provides all the necessary methods for the creation of a
+ * widget. The widget must return a {@link Command} (with the method
+ * {@link #getCommand()}) that will be executed when the "ok" button of the
+ * dialog will be pressed.</p>
+ *
+ * The widget have to get all the necessary properties for the creation of the
+ * element (with the command). To get all the properties, the widget have to add
+ * all the subwidgets he needs for the edition of the command. Each subwidget
+ * {@link AbstractWidget} will edit a specific property of the
+ * {@link WidgetProperties}.
+ *
+ * @since 0.3
+ */
+public abstract class AbstractCommandWidget extends AbstractWidget implements ICommandWidget {
+
+ /**
+ * Constructor. Initialize the {@link IFacetCommandFactory} for the creation
+ * of the command.
+ *
+ * @param parent
+ * the parent {@link AbstractDialog} of this widget.
+ * @param editingDomain
+ * the current editing domain.
+ * @param properties
+ * The {@link WidgetProperties} provided by the
+ * {@link AbstractMainDialog} that the widget had to edit.
+ */
+ public AbstractCommandWidget(final Composite parent) {
+ super(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.ICommandWidget#getCommand()
+ */
+ public abstract Object getCommand();
+
+ @Override
+ public String getError() {
+ String result = null;
+ for (final IAbstractWidget widgets : this.getSubWidgets()) {
+ final String error = widgets.getError();
+ if (error != null) {
+ result = error;
+ break;
+ }
+ }
+ return result;
+ }
+
+
+ public abstract void onDialogValidation();
+
+ public <A> A adapt(final Class<A> adapterType) {
+ A result = null;
+ if (adapterType.isInstance(this)) {
+ @SuppressWarnings("unchecked")
+ final A adapted = (A) this;
+ result = adapted;
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractGetOrCreateFilteredElementCommandWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractGetOrCreateFilteredElementCommandWidget.java
new file mode 100644
index 00000000000..f03aacfb5a1
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/AbstractGetOrCreateFilteredElementCommandWidget.java
@@ -0,0 +1,147 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command;
+
+import java.util.Map;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.dialog.AbstractDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.dialog.SynchronizedAbstractDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.CreateElementWidget;
+import org.eclipse.emf.facet.util.ui.internal.widget.metaclass.FilteredElementSelectionWidget;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This abstract class allows the user to select or create an element (the
+ * concretes classes extending this abstract class will specify the type for
+ * this elements).</p>
+ *
+ * The widget contains two composite:
+ * <nl>
+ * <li> {@link FilteredElementSelectionWidget} : display a filtered list with the
+ * elements returned by {@link #getElements()}</li>
+ * <li> {@link CreateElementWidget} : create a "new..." button, and display the
+ * dialog returned by {@link #createDialog()} when clicked</li>
+ * </nl>
+ *
+ * @see GetOrCreateFacetSetWidget
+ * @see GetOrCreateFacetWidget
+ * @see GetOrCreateOperationWidget
+ * @see FilteredElementSelectionWidget
+ * @see CreateElementWidget
+ * @since 0.3
+ */
+public abstract class AbstractGetOrCreateFilteredElementCommandWidget<T extends Object, W extends Object>
+ extends AbstractCommandWidget implements IGetOrCreateFilteredElementCommmandWidget<T, W> {
+
+ private static final int COLUMNS_NUMBER = 2;
+ private FilteredElementSelectionWidget elementSelection;
+ private CreateElementWidget<W> createElementW;
+
+ /**
+ * Constructor. Initialize a new layout containing {@value #COLUMN_NUMBER}
+ * columns.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param editingDomain
+ * the current editing domain.
+ * @param properties
+ * the properties.
+ */
+ protected AbstractGetOrCreateFilteredElementCommandWidget(
+ final Composite parent) {
+ super(parent);
+ this.setLayout(new GridLayout(COLUMNS_NUMBER, false));
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ final Object[] array = getElements().keySet().toArray();
+ this.elementSelection = new FilteredElementSelectionWidget(this, array);
+ addSubWidget(this.elementSelection);
+ final IDialog<W> dialog = createDialog();
+ if (dialog != null) {
+ this.createElementW = new CreateElementWidget<W>(this, dialog);
+ addSubWidget(this.createElementW);
+ }
+ }
+
+ /**
+ * This method must return the all the elements that the user can choose
+ * (with the name to display has the key to the map). The method
+ * {@link #getSuperFacetSet(Object)} can be useful.
+ *
+ * @return a map of the elements to display.
+ */
+ protected abstract Map<String, T> getElements();
+
+ /**
+ * @return the dialog that the "New..." button of this widget will open.
+ * Null if you want no "New..." button.
+ *
+ * @see AbstractDialog
+ */
+ protected abstract IDialog<W> createDialog();
+
+ /**
+ * Update the filtered list. The list will be updated with the elements
+ * returned by {@link #getElements()}.
+ */
+ public void updateFilteredList() {
+ this.elementSelection.setElements(getElements().keySet().toArray());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.IGetOrCreateFilteredElementCommmandWidget#getElementSelected()
+ */
+ public T getElementSelected() {
+ T result = null;
+ final Object selectedElement = this.elementSelection
+ .getFirstSelectedElement();
+ if (selectedElement != null) {
+ final String elementName = selectedElement.toString();
+ result = getElements().get(elementName);
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.IGetOrCreateFilteredElementCommmandWidget#selectElement(T)
+ */
+ public void selectElement(final T element) {
+ Object[] selectionsParam = new Object[1];
+ for (String key : getElements().keySet()) {
+ if (getElements().get(key) == element) {
+ selectionsParam[0] = key;
+ this.elementSelection.getFilteredList().setSelection(
+ selectionsParam);
+ break;
+ }
+ }
+ }
+
+ public void selectElementByName(final String name) {
+ final T element = this.getElements().get(name);
+ selectElement(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.IGetOrCreateFilteredElementCommmandWidget#pressNewButton()
+ */
+ public IDialog<W> pressNewButton() {
+ return new SynchronizedAbstractDialog<W>(
+ this.createElementW.pressNewButton(), this.getDisplay());
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/ICommandWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/ICommandWidget.java
new file mode 100644
index 00000000000..d1ea42c4975
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/ICommandWidget.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+
+/**
+ * @since 0.3
+ */
+public interface ICommandWidget extends IAbstractWidget {
+
+ /**
+ * Return the command for the widget specific action. The factory can be
+ * used for the creation of the {@link Command}.
+ *
+ * @see IFacetCommandFactory
+ *
+ * @return the command.
+ */
+ Object getCommand();
+
+ /**
+ * This method is execute when the "OK" button of the {@link #parent} is
+ * pressed.
+ */
+ void onDialogValidation();
+
+ <A> A adapt(Class<A> adapterType);
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/IGetOrCreateFilteredElementCommmandWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/IGetOrCreateFilteredElementCommmandWidget.java
new file mode 100644
index 00000000000..c40efb7dc88
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/command/IGetOrCreateFilteredElementCommmandWidget.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+
+/**
+ * @since 0.3
+ */
+public interface IGetOrCreateFilteredElementCommmandWidget<T extends Object, W extends Object>
+ extends ICommandWidget {
+
+ /**
+ * @return the selected element in the filtredList.
+ */
+ T getElementSelected();
+
+ void selectElement(T element);
+
+ void selectElementByName(String name);
+
+ IDialog<W> pressNewButton();
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/CreateElementWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/CreateElementWidget.java
new file mode 100644
index 00000000000..15a9cdb71a8
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/CreateElementWidget.java
@@ -0,0 +1,132 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component;
+
+import org.eclipse.emf.facet.util.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.AbstractGetOrCreateFilteredElementCommandWidget;
+import org.eclipse.jface.viewers.CellEditor.LayoutData;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * WidgetComposite for the creation of the "New..." button. This widget will
+ * open the dialog passed in the constructor.
+ *
+ * @since 0.3
+ */
+public class CreateElementWidget<W extends Object> extends AbstractWidget {
+
+ private final IDialog<W> dialog;
+ private final AbstractGetOrCreateFilteredElementCommandWidget<?, ?> typedParent;
+
+ /**
+ * Constructor. Initialize the {@link LayoutData} with the
+ * {@link AbstractWidget} attribute 'fillGridData'.
+ *
+ * @param parent
+ * the parent of this composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param dialog
+ * the dialog displayed when the "new.." is pressed.
+ */
+ public CreateElementWidget(
+ final AbstractGetOrCreateFilteredElementCommandWidget<?, ?> parent,
+ final IDialog<W> dialog) {
+ super(parent);
+ // Set the new button at the TOP.
+ setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, true, false));
+ this.typedParent = parent;
+ this.dialog = dialog;
+ }
+
+ /**
+ * @return the dialog
+ */
+ public IDialog<W> getDialog() {
+ return this.dialog;
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ createButton();
+ }
+
+ /**
+ * Creation of the 'new...' button. When pressed, the {@link #dialog} will
+ * be displayed.
+ */
+ private void createButton() {
+ final Button button = new Button(this, SWT.NONE);
+ button.setText(Messages.New);
+ button.addListener(SWT.Selection, new Listener() {
+
+ public void handleEvent(final Event event) {
+ onWidgetSelected();
+ }
+
+ });
+ }
+
+ public IDialog<W> onWidgetSelected() {
+ final IDialog<W> newDialog = getDialog();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ final int result = newDialog.open();
+ if (result == Window.OK) {
+ onCommited();
+ } else {
+ onCanceled();
+ }
+ }
+ });
+ return newDialog;
+ }
+
+ /**
+ * Action to do when the dialog opened with the button "..." is closed with
+ * the "Ok" button.
+ */
+ protected void onCommited() {
+ this.typedParent.updateFilteredList();
+ }
+
+ /**
+ * Action to do when the dialog opened with the button "..." is closed with
+ * the "Cancel" button.
+ */
+ protected void onCanceled() {
+ // Nothing
+ }
+
+ @Override
+ public String getError() {
+ return null;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // No action has to be done if a change appends.
+ }
+
+ public IDialog<W> pressNewButton() {
+ return onWidgetSelected();
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWidget.java
new file mode 100644
index 00000000000..a80b9ff723a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWidget.java
@@ -0,0 +1,168 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.properties.name.AbstractGetElementNameWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWidget;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.emf.facet.util.ui.utils.UIUtils;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Abstract class for the creation of a composite that allows the selection or
+ * creation of an element. Classes implementing this class must overrides
+ * {@link #getSubWidgets()} method. This class prepare the composite for
+ * {@link #COLUMN_NUMBER} subComposites and provide the method
+ * {@link #createTextField(boolean)} for the creation of a textField area.
+ *
+ * @see AbstractGetOrCreateElementWithButtonWidget
+ * @see AbstractGetElementNameWidget
+ * @since 0.3
+ */
+public abstract class AbstractGetOrCreateElementWidget<T extends Object>
+ extends AbstractWidget
+ implements IAbstractGetOrCreateElementWidget {
+
+ /**
+ * The number of columns of this composite.
+ */
+ public static final int COLUMN_NUMBER = 3;
+ private PropertyElement2<T> propertyElement;
+ private Text text;
+
+ /**
+ * Constructor. Initialize the composite with a layout of
+ * {@value #COLUMN_NUMBER} columns.
+ *
+ * @param parent
+ * the parent containing this composite.
+ * @param style
+ * the style of the composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param propertyElement
+ * the property element that this composite will edit.
+ */
+ protected AbstractGetOrCreateElementWidget(final Composite parent,
+ final PropertyElement2<T> propertyElement) {
+ super(parent);
+ this.propertyElement = propertyElement;
+ this.setLayout(new GridLayout(COLUMN_NUMBER, false));
+ }
+
+ /**
+ * @return the property element.
+ */
+ public final PropertyElement2<T> getPropertyElement() {
+ return this.propertyElement;
+ }
+
+ public Text getTextField() {
+ return this.text;
+ }
+
+ /**
+ * Create the text field in the composite.</p> If the property
+ * {@link #propertyElement} has a value, the field is not editable.
+ *
+ * @param enabled
+ * set if the field must be editable or not.
+ */
+ protected void createTextField(final boolean enabled) {
+ ModifyListener modifyListener = null;
+ if (enabled) {
+ modifyListener = new ModifyListener() {
+
+ public void modifyText(final ModifyEvent event) {
+ onTextModfified();
+ }
+ };
+ }
+ String initialText = ""; //$NON-NLS-1$
+ if ((this.propertyElement.getValue() != null)
+ && (getTextFieldInitialText() != null)) {
+ initialText = getTextFieldInitialText();
+ }
+ this.text = UIUtils.createTextField(this, initialText, enabled,
+ modifyListener);
+ fireChanged();
+ }
+
+ protected void onTextModfified() {
+ this.propertyElement.setValue(this.text.getText().toString());
+ onFieldEdited();
+ }
+
+ /**
+ * Execute an action when the text field is edited. If not override, nothing
+ * appends. Can be override if needed.
+ */
+ protected void onFieldEdited() {
+ fireChanged();
+ }
+
+ /**
+ * @return the initial text of the textField of this composite. Null or void
+ * if no text has to be displayed.
+ */
+ protected String getTextFieldInitialText() {
+ String result = ""; //$NON-NLS-1$
+ final Object value = this.getPropertyElement().getValue();
+ if (value != null) {
+ result = value.toString();
+ }
+ return result;
+ }
+
+ @Override
+ public String getError() {
+ String error = null;
+ final Object value = this.propertyElement.getValue();
+ if (value == null && !this.propertyElement.isCanBeNull()) {
+ error = getErrorMessage();
+ }
+ return error;
+ }
+
+ /**
+ * @return the error message if the {@link #propertyElement} is not edited.
+ * Return 'null' if no error can be returned.
+ */
+ protected abstract String getErrorMessage();
+
+ /**
+ * @param propertyElement
+ * the propertyElement to set
+ */
+ public void setPropertyElement(final PropertyElement2<T> propertyElement) {
+ this.propertyElement = propertyElement;
+ }
+
+ public T getElement() {
+ return getPropertyElement().getValue2();
+ }
+
+ public String getText() {
+ return this.text.getText();
+ }
+
+ public void setText(final String text) {
+ this.text.setText(text);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithButtonWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithButtonWidget.java
new file mode 100644
index 00000000000..a176d1b7f56
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithButtonWidget.java
@@ -0,0 +1,120 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWithButtonWidget;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.emf.facet.util.ui.utils.UIUtils;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Provide all the necessary for the creation of a composite that have: </p>
+ *
+ * Label : [ textField ][...] </p>
+ *
+ * The button will execute {@link #openDialog()} method when pressed. </p>
+ *
+ * The {@link #getLabel()} method have to be override and provide the label of
+ * the 'Label'.
+ *
+ * @see GetOrCreateFacetSetWidget
+ * @see GetOrCreateFacetWidget
+ * @see GetOrCreateOperationWidget
+ * @since 0.3
+ */
+public abstract class AbstractGetOrCreateElementWithButtonWidget<T extends Object, D extends Object>
+ extends AbstractGetOrCreateElementWidget<T> implements
+ IAbstractGetOrCreateElementWithButtonWidget<D> {
+
+ private Button button;
+ private boolean buttonEnabled;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param propertyElement
+ * the property element that be edited with this composite.
+ */
+ protected AbstractGetOrCreateElementWithButtonWidget(
+ final Composite parent,
+ final PropertyElement2<T> propertyElement) {
+ super(parent, propertyElement);
+ this.setPropertyElement(propertyElement);
+ this.setLayout(new GridLayout(COLUMN_NUMBER, false));
+ this.buttonEnabled = propertyElement.isChangeable();
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ if ((getLabel() != null) && !"".equals(getLabel())) { //$NON-NLS-1$
+ UIUtils.createLabel(this, getLabel());
+ }
+ createTextField(false);
+ createButton();
+ }
+
+ public void setButtonEnabled(final boolean buttonEnabled) {
+ this.buttonEnabled = buttonEnabled;
+ this.button.setEnabled(this.buttonEnabled);
+ }
+
+ /**
+ * Create a button [...]. When pressed, the {@link #openDialog()} method is
+ * called.
+ */
+ private void createButton() {
+ final SelectionListener selectionListener = new SelectionListener() {
+
+ public void widgetSelected(final SelectionEvent selectionEvent) {
+ onButtonPressed();
+ }
+
+ public void widgetDefaultSelected(
+ final SelectionEvent selectionEvent) {
+ // Nothing.
+ }
+ };
+ this.button = UIUtils.createButton(this, "...", this.buttonEnabled, //$NON-NLS-1$
+ selectionListener);
+ }
+
+ /**
+ * The method will be called when the button "..." is pressed.
+ */
+ public abstract D onButtonPressed();
+
+ /**
+ * @return the label for this composite. If no label has to be displayed,
+ * null or void must be returned.
+ */
+ protected abstract String getLabel();
+
+ /**
+ * @return the button
+ */
+ public Button getButton() {
+ return this.button;
+ }
+
+ public D pressButton() {
+ return onButtonPressed();
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithDialogButtonWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithDialogButtonWidget.java
new file mode 100644
index 00000000000..c4a3ce220f7
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithDialogButtonWidget.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate;
+
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IWithResultDialogCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.dialog.SynchronizedAbstractDialog;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Has the same goal than {@link AbstractGetOrCreateElementWithButtonWidget} but
+ * especially for dialogs.
+ *
+ * @since 0.3
+ */
+public abstract class AbstractGetOrCreateElementWithDialogButtonWidget<T extends ENamedElement, W extends Object>
+ extends AbstractGetOrCreateElementWithButtonWidget<T, IDialog<W>> {
+
+ protected AbstractGetOrCreateElementWithDialogButtonWidget(
+ final Composite parent,
+ final PropertyElement2<T> propertyElement) {
+ super(parent, propertyElement);
+ }
+
+ @Override
+ public IDialog<W> onButtonPressed() {
+ final IWithResultDialogCallback<T> callback = new IWithResultDialogCallback<T>() {
+ public void commited(final T result) {
+ onCommited(result);
+ }
+ public void canceled(final T result) {
+ onCanceled();
+ }
+ };
+ final IDialog<W> dialog = getCreationDialog(callback);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ dialog.open();
+ }
+ });
+ return createSynchronizedDialog(dialog);
+ }
+
+ protected final void onCommited(final T result) {
+ this.getPropertyElement().setValue2(result);
+ final String name = result.getName();
+ final Text textField = this.getTextField();
+ textField.setText(name);
+ }
+
+ /**
+ * Action to do when the dialog opened with the button "..." is closed with
+ * the "Cancel" button.
+ */
+ protected abstract void onCanceled();
+
+ /**
+ * Create and return the dialog that will be display when the [...] button
+ * is pressed.
+ *
+ * @return the dialog.
+ */
+ protected abstract IDialog<W> getCreationDialog(
+ final IWithResultDialogCallback<T> callback);
+
+ /**
+ * Create the synchronized dialog for the selection of the type.
+ *
+ * @return the dialog.
+ */
+ private IDialog<W> createSynchronizedDialog(final IDialog<W> dialog) {
+ return new SynchronizedAbstractDialog<W>(dialog, this.getDisplay());
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithWizardButtonWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithWizardButtonWidget.java
new file mode 100644
index 00000000000..6e8bd5af912
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/getorcreate/AbstractGetOrCreateElementWithWizardButtonWidget.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.wizard.IExtendedWizard;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Has the same goal than {@link AbstractGetOrCreateElementWithButtonWidget} but
+ * especially for dialogs.
+ *
+ * @since 0.3
+ */
+public abstract class AbstractGetOrCreateElementWithWizardButtonWidget<T extends Object, W extends IExtendedWizard>
+ extends AbstractGetOrCreateElementWithButtonWidget<T, W> {
+
+ protected AbstractGetOrCreateElementWithWizardButtonWidget(
+ final Composite parent,
+ final PropertyElement2<T> propertyElement) {
+ super(parent, propertyElement);
+ }
+
+ @Override
+ public W onButtonPressed() {
+ final W wizard = createIWizard();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ final int openResult = wizard.open();
+ // TODO The wizard closing events must be cached by the use of
+ // call back pattern. The use of this pattern must be done in
+ // the subclass of this class, like in
+ // org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWithWizardButtonWidget<ETypedElement>
+ // The following if statement and the methods 'onWizardCommited'
+ // 'onWizardCanceled' must be removed (replaced by the use of
+ // call backs)
+ if (openResult == Window.OK) {
+ onWizardCommited(wizard);
+ } else {
+ onWizardCanceled();
+ }
+ }
+ });
+ return createSynchronizedWizard(wizard);
+ }
+
+ /**
+ * Create the wizard for the selection of the type.
+ *
+ * @return the wizard.
+ */
+ protected abstract W createIWizard();
+
+ /**
+ * Action to do when the dialog opened with the button "..." is closed with
+ * the "Ok" button.
+ *
+ * @param selectETypeDialog
+ */
+ protected abstract void onWizardCommited(W wizard);
+
+ /**
+ * Action to do when the dialog opened with the button "..." is closed with
+ * the "Cancel" button.
+ */
+ protected abstract void onWizardCanceled();
+
+ protected abstract W createSynchronizedWizard(final W wizard);
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/AbstractGetPropertyWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/AbstractGetPropertyWidget.java
new file mode 100644
index 00000000000..e4aa8ba53b2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/AbstractGetPropertyWidget.java
@@ -0,0 +1,159 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.properties;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.emf.facet.util.ui.utils.UIUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * This Abstract class provides all the elements to create:</p>
+ *
+ * Label : [x]</p>
+ *
+ * The label is set by {@link #getLabel()}. The checkbox is initialized with the
+ * {@link PropertyElement} attributes
+ * <nl>
+ * <li>{@link PropertyElement#getValue()} (the value of the property must be a
+ * boolean)</li>
+ * <li>{@link PropertyElement#isChangeable()}</li>
+ * </nl>
+ *
+ * The {@link #getError()} method return 'null' because no error can be returned
+ * (the value of the checkbox is 'true' or 'false').
+ *
+ * @see GetChangeableWidget
+ * @see GetOrderedWidget
+ * @see GetDerivedWidget
+ * @see GetTransientWidget
+ * @see GetUniqueWidget
+ * @see GetVolatileWidget
+ * @since 0.3
+ */
+public abstract class AbstractGetPropertyWidget extends AbstractWidget {
+
+ private static final int COLUMN_NUMBER = 2;
+ private static final int WIDTH_HINT_DEF = 65;
+ private int labelWidthHint;
+ private final PropertyElement propertyElement;
+ private Button propertyButton;
+
+ /**
+ * Constructor. Initialize the composite with a layout of
+ * {@value #COLUMN_NUMBER} columns and the layoutData with the
+ * 'fillGridData' attribute of {@link AbstractWidget}.
+ *
+ * @param parent
+ * the parent containing this composite.
+ * @param style
+ * the style of the composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param propertyElement
+ * the property element that this composite will edit.
+ *
+ * @see AbstractWidget
+ */
+ protected AbstractGetPropertyWidget(final Composite parent,
+ final PropertyElement propertyElement) {
+ super(parent);
+ this.propertyElement = propertyElement;
+ this.labelWidthHint = WIDTH_HINT_DEF;
+ this.setLayout(new GridLayout(COLUMN_NUMBER, false));
+ this.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ if ((getLabel() != null) && !"".equals(getLabel())) { //$NON-NLS-1$
+ final Label label = UIUtils.createLabel(this, getLabel());
+ final GridData layoutData = new GridData(SWT.FILL);
+ layoutData.widthHint = this.labelWidthHint;
+ label.setLayoutData(layoutData);
+ label.setEnabled(this.propertyElement.isChangeable());
+ }
+ createCheckbox();
+ }
+
+ public void setPropertyEnabled(final boolean enabled) {
+ this.propertyButton.setSelection(enabled);
+ }
+
+ /**
+ * Create a checkbox initialized with the {@link PropertyElement} attributes
+ * <nl>
+ * <li>Default value : {@link PropertyElement#getValue()} (the value of the
+ * property must be a boolean)</li>
+ * <li>Enabled : {@link PropertyElement#isChangeable()}</li>
+ * </nl>
+ */
+ private void createCheckbox() {
+ if (this.propertyElement.getValue() == null) {
+ this.propertyElement.setValue(Boolean.TRUE);
+ }
+ SelectionListener selectionListener = null;
+ if (this.propertyElement.isChangeable()) {
+ selectionListener = new SelectionListener() {
+
+ public void widgetSelected(final SelectionEvent event) {
+ onSelection((Button) event.getSource());
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent event) {
+ // Nothing.
+ }
+ };
+ }
+ this.propertyButton = UIUtils.createCheckbox(this,
+ this.propertyElement.isChangeable(),
+ ((Boolean) this.propertyElement.getValue()).booleanValue(),
+ selectionListener);
+ }
+
+ /**
+ * @param source
+ */
+ protected void onSelection(final Button source) {
+ this.propertyElement.setValue(Boolean.valueOf(source.getSelection()));
+ }
+
+ /**
+ * @return the label of the label field. If no label has to be displayed,
+ * null or void must be returned.
+ */
+ protected abstract String getLabel();
+
+ /**
+ * Method to change the distance between the label and the checkbox.
+ *
+ * @param lABEL_WIDTH_HINT
+ * the lABEL_WIDTH_HINT to set
+ */
+ public void setLabelWidthHint(final int labelWidthHint) {
+ this.labelWidthHint = labelWidthHint;
+ }
+
+ /**
+ * @return the value of the property.
+ */
+ public boolean isSelected() {
+ return this.propertyButton.getSelection();
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/bounds/AbstractGetBoundsWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/bounds/AbstractGetBoundsWidget.java
new file mode 100644
index 00000000000..5395a580799
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/bounds/AbstractGetBoundsWidget.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.properties.bounds;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.emf.facet.util.ui.utils.UIUtils;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Spinner;
+
+/**
+ * This abstract class provide a simple way to create a composite for the
+ * edition of bounds. The {@link Spinner} composite is used for the edition of
+ * number.</p>
+ *
+ * No error is return because the default value is 0.
+ *
+ * @see Spinner
+ * @see GetUpperBoundWidget
+ * @see GetLowerBoundWidget
+ * @since 0.3
+ */
+public abstract class AbstractGetBoundsWidget extends AbstractWidget {
+
+ private static final int COLUMN_NUMBER = 3;
+ private static final int MAX_VALUE = Integer.MAX_VALUE;
+ private static final int MIN_VALUE = Integer.MIN_VALUE;
+ private static final int INCREMENT = 1;
+
+ private final PropertyElement2<Integer> propertyElement;
+ private Spinner spinner;
+
+ /**
+ * Constructor. Initialize the composite with a layout of
+ * {@value #COLUMN_NUMBER} columns.
+ *
+ * @param parent
+ * the parent containing this composite.
+ * @param style
+ * the style of the composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param propertyElement
+ * the property element that this composite will edit.
+ */
+ protected AbstractGetBoundsWidget(final Composite parent,
+ final PropertyElement2<Integer> propertyElement) {
+ super(parent);
+ this.propertyElement = propertyElement;
+ this.setLayout(new GridLayout(COLUMN_NUMBER, false));
+ }
+
+ /**
+ * @return the propertyElement
+ */
+ public PropertyElement getPropertyElement() {
+ return this.propertyElement;
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ if ((getLabel() != null) && !"".equals(getLabel())) { //$NON-NLS-1$
+ UIUtils.createLabel(this, getLabel());
+ }
+ createSpinner();
+ }
+
+ /**
+ * Creation of a spinner.
+ */
+ private void createSpinner() {
+ // SPINNER
+ final ModifyListener modifyListener = new ModifyListener() {
+ public void modifyText(final ModifyEvent event) {
+ textModified();
+ }
+ };
+ this.spinner = UIUtils.createSpinner(this, MAX_VALUE, MIN_VALUE,
+ INCREMENT, this.propertyElement.isChangeable(), modifyListener);
+ final Integer value = this.propertyElement.getValue2();
+ if (value != null) {
+ setBoundValue(value.intValue());
+ }
+ }
+
+ /**
+ * Method called when the text is modified.
+ */
+ protected void textModified() {
+ getPropertyElement().setValue(Integer.valueOf(this.spinner.getText()));
+ }
+
+ /**
+ * @return the label. If no label has to be displayed, null or void must be
+ * returned.
+ */
+ protected abstract String getLabel();
+
+ /**
+ * Set the bound value.
+ *
+ * @param value
+ * the value to set.
+ */
+ public void setBoundValue(final int value) {
+ this.spinner.setSelection(value);
+ }
+
+ public int getBoundValue() {
+ final String text = this.spinner.getText();
+ return Integer.parseInt(text);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractGetElementNameWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractGetElementNameWidget.java
new file mode 100644
index 00000000000..7af5a298291
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractGetElementNameWidget.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.properties.name;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWidget;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.emf.facet.util.ui.utils.UIUtils;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This abstract class provide the creation of:</p>
+ *
+ * Label : [ TextFiled ]</p>
+ *
+ * Where the label is getted by {@link #getLabel()}. The TextField will set the
+ * value of the {@link PropertyElement} when edited. If the field is not setted,
+ * an error will be displayed at the top of the dialog when the 'ok' button is
+ * pressed.
+ *
+ * @see GetAttributeNameWidget
+ * @see GetFacetNameWidget
+ * @see GetFacetSetNameWidget
+ * @see GetOperationNameWidget
+ * @see GetReferenceNameWidget
+ * @see GetQueryNameWidget
+ * @since 0.3
+ */
+public abstract class AbstractGetElementNameWidget extends
+ AbstractGetOrCreateElementWidget<String> {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param propertyElement
+ * the property element that be edited with this composite.
+ */
+ protected AbstractGetElementNameWidget(final Composite parent,
+ final PropertyElement2<String> propertyElement) {
+ super(parent, propertyElement);
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ if ((getLabel() != null) && !"".equals(getLabel())) { //$NON-NLS-1$
+ UIUtils.createLabel(this, getLabel());
+ }
+ createTextField(this.getPropertyElement().isChangeable());
+ }
+
+ /**
+ * @return the label for this composite. If no label has to be displayed,
+ * null or empty string must be returned.
+ */
+ protected abstract String getLabel();
+
+ @Override
+ public String getError() {
+ String result = null;
+ final String elementName = this.getPropertyElement().getValue2();
+ if ((elementName == null) || "".equals(elementName)) { //$NON-NLS-1$
+ result = getErrorMessage();
+ }
+ return result;
+ }
+
+ /**
+ * @return the error message.
+ */
+ @Override
+ protected abstract String getErrorMessage();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractPrintElementWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractPrintElementWidget.java
new file mode 100644
index 00000000000..e1b8a97165b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/component/properties/name/AbstractPrintElementWidget.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.properties.name;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWidget;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.emf.facet.util.ui.utils.UIUtils;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This abstract class provide the creation of:</p>
+ *
+ * Label : [//TextFiled//]</p>
+ *
+ * Where the label is getted by {@link #getLabel()}. The textField is disabled
+ * an initializated with the value of the {@link #getTextFieldInitialText()}.
+ *
+ * @since 0.3
+ */
+public abstract class AbstractPrintElementWidget<T extends Object> extends
+ AbstractGetOrCreateElementWidget<T> {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this composite.
+ * @param editingDomain
+ * the current editing domain.
+ */
+ protected AbstractPrintElementWidget(final Composite parent,
+ final PropertyElement2<T> propertyElement) {
+ super(parent, propertyElement);
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ if ((getLabel() != null) && !"".equals(getLabel())) { //$NON-NLS-1$
+ UIUtils.createLabel(this, getLabel());
+ }
+ createTextField(false);
+ }
+
+ /**
+ * @return the label for this composite. If no label has to be displayed,
+ * null or void must be returned.
+ */
+ protected abstract String getLabel();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/query/AbstractQueryWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/query/AbstractQueryWidget.java
new file mode 100644
index 00000000000..6115a9eae67
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/widget/query/AbstractQueryWidget.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.widget.query;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.AbstractCommandWidget;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This abstract class must be used by the plug-ins extending this plug-in. It
+ * provides a simple way to create the widget for the edition of the query.
+ *
+ * @since 0.3
+ */
+public abstract class AbstractQueryWidget<P extends Object> extends
+ AbstractCommandWidget {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param editingDomain
+ * the current editing domain.
+ * @param properties
+ * the properties.
+ */
+ protected AbstractQueryWidget(final Composite parent) {
+ super(parent);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/wizard/SynchronizedWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/wizard/SynchronizedWizard.java
new file mode 100644
index 00000000000..5e51c80f200
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/util/wizard/SynchronizedWizard.java
@@ -0,0 +1,314 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.util.wizard;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.emf.facet.util.ui.internal.exported.wizard.IExtendedWizard;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Synchronized class for safe run.
+ *
+ * @see WizardFactoryImpl
+ * @since 0.3
+ */
+public class SynchronizedWizard<T extends IExtendedWizard> extends
+ SynchronizedObject<T> implements IExtendedWizard {
+
+ /**
+ * Constructor.
+ *
+ * @param object
+ * the to synchronized.
+ * @param display
+ * the display.
+ */
+ public SynchronizedWizard(final T object, final Display display) {
+ super(object, display);
+ }
+
+ public int open() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Integer>() {
+ @Override
+ public Integer safeRun() {
+ return Integer.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().open());
+ }
+ }).intValue();
+ }
+
+ public IWizardPage getCurrentPage() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getCurrentPage();
+ }
+ });
+ }
+
+ public IWizardPage next() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .next();
+ }
+ });
+ }
+
+ public IWizardPage previous() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .previous();
+ }
+ });
+ }
+
+ public boolean finish() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().finish());
+ }
+ }).booleanValue();
+ }
+
+ public void addPages() {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizard.this.getSynchronizedObject().addPages();
+ }
+ });
+ }
+
+ public boolean canFinish() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().canFinish());
+ }
+ }).booleanValue();
+ }
+
+ public void createPageControls(final Composite pageContainer) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizard.this.getSynchronizedObject()
+ .createPageControls(pageContainer);
+ }
+ });
+ }
+
+ public void dispose() {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizard.this.getSynchronizedObject().dispose();
+ }
+ });
+ }
+
+ public IWizardContainer getContainer() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardContainer>() {
+ @Override
+ public IWizardContainer safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getContainer();
+ }
+ });
+ }
+
+ public Image getDefaultPageImage() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Image>() {
+ @Override
+ public Image safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getDefaultPageImage();
+ }
+ });
+ }
+
+ public IDialogSettings getDialogSettings() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IDialogSettings>() {
+ @Override
+ public IDialogSettings safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getDialogSettings();
+ }
+ });
+ }
+
+ public IWizardPage getNextPage(final IWizardPage page) {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getNextPage(page);
+ }
+ });
+ }
+
+ public IWizardPage getPage(final String pageName) {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getPage(pageName);
+ }
+ });
+ }
+
+ public int getPageCount() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Integer>() {
+ @Override
+ public Integer safeRun() {
+ return Integer.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().getPageCount());
+ }
+ }).intValue();
+ }
+
+ public IWizardPage[] getPages() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage[]>() {
+ @Override
+ public IWizardPage[] safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getPages();
+ }
+ });
+ }
+
+ public IWizardPage getPreviousPage(final IWizardPage page) {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getPreviousPage(page);
+ }
+ });
+ }
+
+ public IWizardPage getStartingPage() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getStartingPage();
+ }
+ });
+ }
+
+ public RGB getTitleBarColor() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<RGB>() {
+ @Override
+ public RGB safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getTitleBarColor();
+ }
+ });
+ }
+
+ public String getWindowTitle() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<String>() {
+ @Override
+ public String safeRun() {
+ return SynchronizedWizard.this.getSynchronizedObject()
+ .getWindowTitle();
+ }
+ });
+ }
+
+ public boolean isHelpAvailable() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().isHelpAvailable());
+ }
+ }).booleanValue();
+ }
+
+ public boolean needsPreviousAndNextButtons() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().needsPreviousAndNextButtons());
+ }
+ }).booleanValue();
+ }
+
+ public boolean needsProgressMonitor() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().needsProgressMonitor());
+ }
+ }).booleanValue();
+ }
+
+ public boolean performCancel() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().performCancel());
+ }
+ }).booleanValue();
+ }
+
+ public boolean performFinish() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizard.this
+ .getSynchronizedObject().performFinish());
+ }
+ }).booleanValue();
+ }
+
+ public void setContainer(final IWizardContainer wizardContainer) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizard.this.getSynchronizedObject().setContainer(
+ wizardContainer);
+ }
+ });
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/IAbstractWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/IAbstractWidget.java
new file mode 100644
index 00000000000..078f8db3a26
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/IAbstractWidget.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.widget;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+
+/**
+ *
+ * @see AbstractWidget
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IAbstractWidget {
+
+ /**
+ * Add the abstractWidget in parameter to the list of listeners of the
+ * widget.
+ *
+ * @param abstractWidget
+ * the abstractWidget to listen.
+ */
+ void addListener(final AbstractWidget abstractWidget);
+
+ /**
+ * When a change in a sub-widget append, this method is execute. If no
+ * action has to be done when a modification append, this method has to be
+ * void.
+ */
+ void notifyChanged();
+
+ /**
+ * Create the content of the widget (call {@link #addSubWidgets()}) and
+ * sub-widgets.
+ */
+ void createWidgetContent();
+
+ /**
+ * Return the string containing the error for this widget.
+ *
+ * @return null if there is no error. The string containing the error if
+ * there is an error.
+ */
+ String getError();
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWidget.java
new file mode 100644
index 00000000000..3f786c1293a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWidget.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWidget;
+import org.eclipse.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+
+
+/**
+ * Interface.
+ *
+ *
+ * @see AbstractGetOrCreateElementWidget
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IAbstractGetOrCreateElementWidget extends IAbstractWidget {
+
+ /**
+ * @return the text field.
+ */
+ String getText();
+
+ /**
+ * Set the text field.
+ *
+ * @param text
+ * the new text.
+ */
+ void setText(String text);
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWithButtonWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWithButtonWidget.java
new file mode 100644
index 00000000000..3fc0533118d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/widget/getorcreate/IAbstractGetOrCreateElementWithButtonWidget.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWithButtonWidget;
+
+/**
+ * @see AbstractGetOrCreateElementWithButtonWidget
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IAbstractGetOrCreateElementWithButtonWidget<D>
+ extends
+ IAbstractGetOrCreateElementWidget {
+
+ /**
+ * @param buttonEnabled
+ * the buttonEnabled to set
+ */
+ void setButtonEnabled(final boolean buttonEnabled);
+
+ /**
+ * Press the button.
+ *
+ * @return the potential object return when the button is pressed. Can be
+ * null.
+ */
+ D pressButton();
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/wizard/IExtendedWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/wizard/IExtendedWizard.java
new file mode 100644
index 00000000000..3f3e6bb0ace
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/exported/wizard/IExtendedWizard.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.exported.wizard;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * Interface for the facets wizards.
+ *
+ * @since 0.3
+ */
+public interface IExtendedWizard extends IWizard {
+
+ /**
+ * @return the current page of the wizard.
+ */
+ IWizardPage getCurrentPage();
+
+ /**
+ * Simulate the action of pressing the next button.
+ *
+ * @return the next page.
+ */
+ IWizardPage next();
+
+ /**
+ * Simulate the action of pressing the previous button.
+ *
+ * @return the previous page.
+ */
+ IWizardPage previous();
+
+ /**
+ * Simulate the action of pressing the finish button.
+ *
+ * @return true if the wizard finish correctly.
+ */
+ boolean finish();
+
+ /**
+ * Open the wizard.
+ *
+ * @return the return code when the wizard closes.
+ */
+ int open();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/messages.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/messages.properties
new file mode 100644
index 00000000000..feca399c98c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/messages.properties
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2011 Mia-Software.
+# 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:
+# Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
+# Alban M?nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+# Thomas Cicognani (Soft-Maint) - Bug 406565 - Ok Dialog
+###############################################################################
+QuestionDialog_yes=Yes
+QuestionDialog_no=No
+
+item_todo= == TODO ==
+
+FilteredElementSelectionControl_type_filter_text=type filter text
+Select=Select
+Type=Type :
+New=New...
+Select_Facet= Select a Facet
+OK=Ok
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWidget.java
new file mode 100644
index 00000000000..32dba136476
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWidget.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.sync.generated;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+
+public class SynchronizedAbstractGetOrCreateElementWidget
+ extends
+ SynchronizedObject<org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWidget>
+ implements
+ org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWidget {
+
+ public SynchronizedAbstractGetOrCreateElementWidget(
+ final org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWidget object,
+ final Display display) {
+ super(object, display);
+ }
+
+ public final void addListener(
+ final org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWidget.this
+ .getSynchronizedObject().addListener(parm0);
+ }
+ });
+ }
+
+ public final void createWidgetContent() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWidget.this
+ .getSynchronizedObject().createWidgetContent();
+ }
+ });
+ }
+
+ public final java.lang.String getError() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<java.lang.String>() {
+ @Override
+ public java.lang.String safeRun() {
+ return SynchronizedAbstractGetOrCreateElementWidget.this
+ .getSynchronizedObject().getError();
+ }
+ });
+ }
+
+ public final void notifyChanged() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWidget.this
+ .getSynchronizedObject().notifyChanged();
+ }
+ });
+ }
+
+ public final java.lang.String getText() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<java.lang.String>() {
+ @Override
+ public java.lang.String safeRun() {
+ return SynchronizedAbstractGetOrCreateElementWidget.this
+ .getSynchronizedObject().getText();
+ }
+ });
+ }
+
+ public final void setText(final java.lang.String parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWidget.this
+ .getSynchronizedObject().setText(parm0);
+ }
+ });
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWithButtonWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWithButtonWidget.java
new file mode 100644
index 00000000000..502af8c254b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedAbstractGetOrCreateElementWithButtonWidget.java
@@ -0,0 +1,112 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.sync.generated;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+
+public class SynchronizedAbstractGetOrCreateElementWithButtonWidget<D extends java.lang.Object>
+ extends
+ SynchronizedObject<org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWithButtonWidget<D>>
+ implements
+ org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWithButtonWidget<D> {
+
+ public SynchronizedAbstractGetOrCreateElementWithButtonWidget(
+ final org.eclipse.emf.facet.util.ui.internal.exported.widget.getorcreate.IAbstractGetOrCreateElementWithButtonWidget<D> object,
+ final Display display) {
+ super(object, display);
+ }
+
+ public final void addListener(
+ final org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().addListener(parm0);
+ }
+ });
+ }
+
+ public final void createWidgetContent() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().createWidgetContent();
+ }
+ });
+ }
+
+ public final java.lang.String getError() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<java.lang.String>() {
+ @Override
+ public java.lang.String safeRun() {
+ return SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().getError();
+ }
+ });
+ }
+
+ public final void notifyChanged() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().notifyChanged();
+ }
+ });
+ }
+
+ public final java.lang.String getText() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<java.lang.String>() {
+ @Override
+ public java.lang.String safeRun() {
+ return SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().getText();
+ }
+ });
+ }
+
+ public final void setText(final java.lang.String parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().setText(parm0);
+ }
+ });
+ }
+
+ public final D pressButton() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<D>() {
+ @Override
+ public D safeRun() {
+ return SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().pressButton();
+ }
+ });
+ }
+
+ public final void setButtonEnabled(final boolean parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedAbstractGetOrCreateElementWithButtonWidget.this
+ .getSynchronizedObject().setButtonEnabled(parm0);
+ }
+ });
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedGetOrCreateFilteredElementCommmandWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedGetOrCreateFilteredElementCommmandWidget.java
new file mode 100644
index 00000000000..1544ea3c50e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedGetOrCreateFilteredElementCommmandWidget.java
@@ -0,0 +1,142 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.sync.generated;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+
+public class SynchronizedGetOrCreateFilteredElementCommmandWidget<T extends java.lang.Object, W extends java.lang.Object>
+ extends
+ SynchronizedObject<org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.IGetOrCreateFilteredElementCommmandWidget<T, W>>
+ implements
+ org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.IGetOrCreateFilteredElementCommmandWidget<T, W> {
+
+ public SynchronizedGetOrCreateFilteredElementCommmandWidget(
+ final org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.IGetOrCreateFilteredElementCommmandWidget<T, W> object,
+ final Display display) {
+ super(object, display);
+ }
+
+ public final void addListener(
+ final org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().addListener(parm0);
+ }
+ });
+ }
+
+ public final void createWidgetContent() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().createWidgetContent();
+ }
+ });
+ }
+
+ public final java.lang.String getError() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<java.lang.String>() {
+ @Override
+ public java.lang.String safeRun() {
+ return SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().getError();
+ }
+ });
+ }
+
+ public final void notifyChanged() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().notifyChanged();
+ }
+ });
+ }
+
+ public final <A> A adapt(final java.lang.Class<A> parm0) {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<A>() {
+ @Override
+ public A safeRun() {
+ return SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().adapt(parm0);
+ }
+ });
+ }
+
+ public final java.lang.Object getCommand() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<java.lang.Object>() {
+ @Override
+ public java.lang.Object safeRun() {
+ return SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().getCommand();
+ }
+ });
+ }
+
+ public final void onDialogValidation() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().onDialogValidation();
+ }
+ });
+ }
+
+ public final T getElementSelected() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<T>() {
+ @Override
+ public T safeRun() {
+ return SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().getElementSelected();
+ }
+ });
+ }
+
+ public final org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog<W> pressNewButton() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog<W>>() {
+ @Override
+ public org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog<W> safeRun() {
+ return SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().pressNewButton();
+ }
+ });
+ }
+
+ public final void selectElement(final T parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().selectElement(parm0);
+ }
+ });
+ }
+
+ public final void selectElementByName(final java.lang.String parm0) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedGetOrCreateFilteredElementCommmandWidget.this
+ .getSynchronizedObject().selectElementByName(parm0);
+ }
+ });
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedOkDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedOkDialog.java
new file mode 100644
index 00000000000..261d006756b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/sync/generated/SynchronizedOkDialog.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) Soft-Maint.
+ *
+ * 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:
+ * Thomas Cicognani (Soft-Maint) - Bug 406565 - Ok Dialog
+ */
+
+package org.eclipse.emf.facet.util.ui.internal.sync.generated;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IOkDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.swt.widgets.Display;
+
+@SuppressWarnings("PMD.ExcessivePublicCount")
+public class SynchronizedOkDialog extends SynchronizedObject<IOkDialog>
+ implements IOkDialog {
+
+ public SynchronizedOkDialog(final IOkDialog object, final Display display) {
+ super(object, display);
+ }
+ public final void commit() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedOkDialog.this.getSynchronizedObject().commit();
+ }
+ });
+ }
+
+ public final boolean isError() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedOkDialog.this.getSynchronizedObject().isError());
+ }
+ }).booleanValue();
+ }
+
+ public final boolean isInformation() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedOkDialog.this.getSynchronizedObject().isInformation());
+ }
+ }).booleanValue();
+ }
+
+ public final boolean isWarning() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedOkDialog.this.getSynchronizedObject().isWarning());
+ }
+ }).booleanValue();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/widget/metaclass/FilteredElementSelectionWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/widget/metaclass/FilteredElementSelectionWidget.java
new file mode 100644
index 00000000000..1326f16bfd8
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/internal/widget/metaclass/FilteredElementSelectionWidget.java
@@ -0,0 +1,150 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.internal.widget.metaclass;
+
+import org.eclipse.emf.facet.util.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.FilteredList;
+
+/**
+ * A control for selecting an element from a list of elements, that can be
+ * filtered using the associated text field.
+ */
+public class FilteredElementSelectionWidget extends
+ AbstractWidget {
+
+ private static final String MATCH_PREFIX = "*"; //$NON-NLS-1$
+ private static final int FILTER_WIDTH_HINT = 350;
+
+ private Text filterText;
+ private FilteredList fFilteredList;
+ private final Object[] elements;
+ private static final boolean MULTISELECTION = false;
+
+ public FilteredElementSelectionWidget(final Composite parent,
+ final Object[] elements) {
+ super(parent);
+ this.elements = elements.clone();
+ final GridData gridData = new GridData(SWT.FILL);
+ gridData.widthHint = FILTER_WIDTH_HINT;
+ setLayoutData(gridData);
+ }
+
+ public void setElements(final Object[] elements) {
+ this.fFilteredList.setElements(elements);
+ }
+
+ private void createFilteredList(final Composite parent) {
+ int multi;
+ if (MULTISELECTION) {
+ multi = SWT.MULTI;
+ } else {
+ multi = SWT.SINGLE;
+ }
+ this.fFilteredList = new FilteredList(parent, SWT.BORDER | SWT.V_SCROLL
+ | SWT.H_SCROLL | multi, new LabelProvider(), true, false, true);
+
+ final GridData data = new GridData();
+ data.grabExcessVerticalSpace = true;
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ data.verticalAlignment = GridData.FILL;
+ this.fFilteredList.setLayoutData(data);
+ this.fFilteredList.setFilter(""); //$NON-NLS-1$
+ this.fFilteredList.setElements(this.elements);
+ }
+
+ private void createFilterText(final Composite parent) {
+ this.filterText = new Text(parent, SWT.BORDER);
+ this.filterText
+ .setMessage(Messages.FilteredElementSelectionControl_type_filter_text);
+ final GridData data = new GridData();
+ data.grabExcessVerticalSpace = false;
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ data.verticalAlignment = GridData.BEGINNING;
+ this.filterText.setLayoutData(data);
+ this.filterText.addModifyListener(new ModifyListener() {
+ public void modifyText(final ModifyEvent event) {
+ getfFilteredList().setFilter(
+ MATCH_PREFIX + getFilterText().getText());
+ }
+ });
+ this.filterText.addKeyListener(new KeyListener() {
+
+ public void keyPressed(final KeyEvent event) {
+ if (event.keyCode == SWT.ARROW_DOWN) {
+ getfFilteredList().setFocus();
+ }
+ }
+
+ public void keyReleased(final KeyEvent event) {
+ // nothing
+ }
+ });
+ }
+
+ public Object getFirstSelectedElement() {
+ Object result = null;
+ final Object[] selection = this.fFilteredList.getSelection();
+ if (selection.length > 0) {
+ result = selection[0];
+ }
+ return result;
+ }
+
+ public Object[] getSelectedElements() {
+ Object[] result = null;
+ final Object[] selection = this.fFilteredList.getSelection();
+ if (selection.length != 0) {
+ result = selection;
+ }
+ return result;
+ }
+
+ public FilteredList getFilteredList() {
+ return this.fFilteredList;
+ }
+
+ public Text getFilterText() {
+ return this.filterText;
+ }
+
+ protected FilteredList getfFilteredList() {
+ return this.fFilteredList;
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ createFilterText(this);
+ createFilteredList(this);
+ }
+
+ @Override
+ public String getError() {
+ return null;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // No action has to be done if a change appends.
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement.java
new file mode 100644
index 00000000000..c36cd7a29df
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.utils;
+
+/**
+ * Generic class representing all the properties like:
+ * <ol>
+ * <li>facetName</li>
+ * <li>upperBound</li>
+ * <li>unique</li>
+ * <li>...</li>
+ * </ol>
+ *
+ * @since 0.3
+ */
+public class PropertyElement {
+
+ // TODO This class must not be exposed.
+
+ private final String name;
+ private final Class<?> type;
+ private boolean changeable;
+ private Object value;
+
+ /**
+ * Constructor
+ *
+ * @param name
+ * the name of the property.
+ * @param type
+ * the type of the property.
+ * @param changeable
+ * if the property can be changed (edited) or not.
+ */
+ public PropertyElement(final String name, final Class<?> type,
+ final boolean changeable) {
+ this(name, type, changeable, null);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param name
+ * the name of the property.
+ * @param type
+ * the type of the property.
+ * @param changeable
+ * if the property can be changed (edited) or not.
+ * @param value
+ * the initial value of the property.
+ */
+ public PropertyElement(final String name, final Class<?> type,
+ final boolean changeable, final Object value) {
+ super();
+ this.name = name;
+ this.type = type;
+ this.changeable = changeable;
+ this.value = value;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the changeable
+ */
+ public boolean isChangeable() {
+ return this.changeable;
+ }
+
+ /**
+ * @return the type
+ */
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ /**
+ * @return the value
+ */
+ public Object getValue() {
+ return this.value;
+ }
+
+ /**
+ * set the value.
+ */
+ public void setValue(final Object value) {
+ this.value = value;
+ }
+
+ /**
+ * @param changeable
+ * the changeable to set
+ */
+ public void setChangeable(final boolean changeable) {
+ this.changeable = changeable;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement2.java
new file mode 100644
index 00000000000..4adb661da1c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/PropertyElement2.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved.
+ *
+ * Contributors:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Integration into ITM-Factory
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.utils;
+
+
+/**
+ * @since 0.3
+ */
+public class PropertyElement2<T extends Object> extends PropertyElement {
+
+ private final boolean canBeNull;
+
+ public PropertyElement2(final boolean changeable) {
+ super("", Object.class, changeable); //$NON-NLS-1$
+ this.canBeNull = false;
+ }
+
+ public PropertyElement2(final boolean changeable, final T value) {
+ super("", Object.class, changeable, value); //$NON-NLS-1$
+ this.canBeNull = false;
+ }
+
+ public PropertyElement2(final boolean changeable, final boolean canBeNull) {
+ super("", Object.class, changeable); //$NON-NLS-1$
+ this.canBeNull = canBeNull;
+ }
+
+ public T getValue2() {
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") This cast is safe because the value
+ // has to be a instance of T.
+ // PropertyElement a refactoring of PropertyElement is expected.
+ final T result = (T) this.getValue();
+ return result; // NOPMD by gdupe on 19/10/12 16:59
+ // NOPMD to isolate @SuppressWarnings("unchecked")
+ }
+
+ public void setValue2(final T value) {
+ this.setValue(value);
+ }
+
+ public boolean isCanBeNull() {
+ return this.canBeNull;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/UIUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/UIUtils.java
new file mode 100644
index 00000000000..00c34cd49df
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/UIUtils.java
@@ -0,0 +1,248 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.utils;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This util class provides methods for the creation of basics ui components
+ * like buttons or text field.
+ *
+ * @since 0.3
+ */
+public final class UIUtils {
+
+ private static final int WIDTH_HINT = 110;
+
+ private UIUtils() {
+ // Private constructor.
+ }
+
+ /**
+ * Create the label (with the given labelName) in the given composite. The
+ * layoutData of the label is {@link #getLabelGridData()}.
+ *
+ * @param parent
+ * the composite parent.
+ * @param labelName
+ * the label name.
+ */
+ public static Label createLabel(final Composite parent,
+ final String labelName) {
+ final Label label = new Label(parent, SWT.NONE);
+ label.setText(labelName);
+ label.setLayoutData(getLabelGridData());
+ return label;
+ }
+
+ /**
+ * Create and return a new button.
+ *
+ * @param parent
+ * the button parent.
+ * @param text
+ * the text to display on the button.
+ * @param enabled
+ * set if the button can be pressed or not.
+ * @param selectionListener
+ * the listener when the button is pressed (can be null).
+ * @return the new button.
+ */
+ public static Button createButton(final Composite parent,
+ final String text, final boolean enabled,
+ final SelectionListener selectionListener) {
+ final Button button = new Button(parent, SWT.NONE);
+ button.setText(text);
+ button.setEnabled(enabled);
+ if (selectionListener != null) {
+ button.addSelectionListener(selectionListener);
+ }
+ return button;
+ }
+
+ /**
+ * Create and return a new text field.
+ *
+ * @param parent
+ * the text field parent.
+ * @param text
+ * the text to display on the text field.
+ * @param enabled
+ * set if the text field can be edit or not.
+ * @param selectListener
+ * the listener when the text field is edited (can be null).
+ * @return the new text field.
+ */
+ public static Text createTextField(final Composite parent,
+ final String text, final boolean enabled,
+ final ModifyListener modifyListener) {
+ final Text textField = new Text(parent, SWT.BORDER);
+ textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ textField.setEnabled(enabled);
+ if (text != null) {
+ textField.setText(text);
+ }
+ if (modifyListener != null) {
+ textField.addModifyListener(modifyListener);
+ }
+ return textField;
+ }
+
+ /**
+ * Create a combobox with a label.
+ *
+ * @param parent
+ * the parent of the combobox.
+ * @param enabled
+ * if the combobox is enabled.
+ * @param elements
+ * the elements of the combobox
+ * @param listener
+ * the listener of the combobox (can be null)
+ * @return the combobox created.
+ */
+ public static Combo createCombobox(final Composite parent,
+ final boolean enabled, final List<String> elements,
+ final String label, final SelectionListener listener) {
+ final Composite composite = new Composite(parent, SWT.NONE);
+ final GridLayout gridLayout = new GridLayout(2, false);
+ gridLayout.marginWidth = 0;
+ composite.setLayout(gridLayout);
+ final Label comboboxLabel = new Label(composite, SWT.NONE);
+ comboboxLabel.setText(label);
+ final GridData gridData = new GridData(SWT.FILL);
+ comboboxLabel.setLayoutData(gridData);
+ final Combo combobox = new Combo(composite, SWT.DROP_DOWN
+ | SWT.READ_ONLY);
+ combobox.setLayoutData(new GridData(SWT.FILL));
+ combobox.setEnabled(enabled);
+ for (final String element : elements) {
+ combobox.add(element);
+ }
+ combobox.select(0);
+ if (listener != null) {
+ combobox.addSelectionListener(listener);
+ }
+ return combobox;
+ }
+
+ /**
+ * Create and return a new text field.
+ *
+ * @param parent
+ * the text field parent.
+ * @param text
+ * the text to display on the text field.
+ * @param enabled
+ * set if the text field can be edit or not.
+ * @param selectListener
+ * the listener when the text field is edited (can be null).
+ * @return the new text field.
+ */
+ public static Text createTextArea(final Composite parent,
+ final String text, final boolean enabled,
+ final ModifyListener modifyListener) {
+ final Text textArea = new Text(parent, SWT.MULTI | SWT.BORDER
+ | SWT.WRAP | SWT.V_SCROLL);
+ textArea.setLayoutData(new GridData(GridData.FILL_BOTH));
+ textArea.setEnabled(enabled);
+ if (text != null) {
+ textArea.setText(text);
+ }
+ if (modifyListener != null) {
+ textArea.addModifyListener(modifyListener);
+ }
+ return textArea;
+ }
+
+ /**
+ * @return the labelGridData
+ */
+ public static GridData getLabelGridData() {
+ final GridData labelGridData = new GridData(SWT.FILL);
+ labelGridData.widthHint = WIDTH_HINT;
+ return labelGridData;
+ }
+
+ /**
+ * Create and return a new checkbox.
+ *
+ * @param parent
+ * the checkbox parent.
+ * @param enabled
+ * set if the checkbox can be checked or not.
+ * @param selected
+ * set if the checkbox is initially selected or not.
+ * @param selectionListener
+ * the listener when the checkbox is selected (can be null).
+ * @return the new checkbox.
+ */
+ public static Button createCheckbox(final Composite composite,
+ final boolean enabled, final boolean selected,
+ final SelectionListener selectionListener) {
+ final Button checkbox = new Button(composite, SWT.CHECK);
+ checkbox.setEnabled(enabled);
+ checkbox.setSelection(selected);
+ checkbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ if (selectionListener != null) {
+ checkbox.addSelectionListener(selectionListener);
+ }
+ return checkbox;
+ }
+
+ /**
+ * Create and return a new spinner.
+ *
+ * @param parent
+ * the parent of the spinner.
+ * @param maxValue
+ * the max value the spinner can reach.
+ * @param minValue
+ * the min value the spinner can reach.
+ * @param increment
+ * the increment of the spinner.
+ * @param changeable
+ * if the spinner is changeable or not.
+ * @param modifyListener
+ * the listener when the spinner is changed (can be null).
+ * @return the new spinner.
+ *
+ * @see Spinner
+ */
+ public static Spinner createSpinner(final Composite parent,
+ final int maxValue, final int minValue, final int increment,
+ final boolean changeable, final ModifyListener modifyListener) {
+ final Spinner spinner = new Spinner(parent, SWT.BORDER);
+ spinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ spinner.setMaximum(maxValue);
+ spinner.setMinimum(minValue);
+ spinner.setIncrement(increment);
+ spinner.setEnabled(changeable);
+ if (modifyListener != null) {
+ spinner.addModifyListener(modifyListener);
+ }
+ return spinner;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/WidgetProperties.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/WidgetProperties.java
new file mode 100644
index 00000000000..dd4cfc1645f
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.ui/src/org/eclipse/emf/facet/util/ui/utils/WidgetProperties.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * 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:
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.ui.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.ETypedElement;
+
+/**
+ * This class contain all the possible properties for the facets creations.
+ *
+ * @since 0.3
+ */
+public class WidgetProperties<T extends Object> {
+
+ // TODO This class must not be exposed.
+
+ private final Map<T, PropertyElement> properties;
+
+ public WidgetProperties() {
+ this.properties = new HashMap<T, PropertyElement>();
+ }
+
+ /**
+ * Add a new property in the map.
+ *
+ * @param element
+ * the key, the {@link ETypedElement} of the property.
+ * @param property
+ * the property.
+ */
+ public void addProperty(final T element,
+ final PropertyElement property) {
+ getProperties().put(element, property);
+ }
+
+ /**
+ * Get the list of properties.
+ *
+ * @return a map of the properties.
+ */
+ private Map<T, PropertyElement> getProperties() {
+ return this.properties;
+ }
+
+ /**
+ * Return the {@link PropertyElement} for the given element.
+ *
+ * @param element
+ * the element.
+ * @return the property.
+ */
+ public PropertyElement getProperty(final T element) {
+ return getProperties().get(element);
+ }
+}

Back to the top