Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2010-06-26 15:18:20 +0000
committerThomas Schindl2010-06-26 15:18:20 +0000
commit40dcc2f416a273912ec970272e32bee798110404 (patch)
treee017f5f49a067b244165f2990f862dd1b459e76b
parent447b455ec998c6b18cd57f1a5d3167d6e415a293 (diff)
downloadorg.eclipse.e4.tools-40dcc2f416a273912ec970272e32bee798110404.tar.gz
org.eclipse.e4.tools-40dcc2f416a273912ec970272e32bee798110404.tar.xz
org.eclipse.e4.tools-40dcc2f416a273912ec970272e32bee798110404.zip
Bug 304584 - [Tooling] Implement Workbench-Model-Tooling
* fixed minor layout tweaks
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartEditor.java39
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartSashContainerEditor.java168
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartStackEditor.java154
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveEditor.java163
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveStackEditor.java131
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PlaceholderEditor.java128
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarContributionEditor.java97
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarEditor.java44
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarSeparatorEditor.java49
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolControlEditor.java67
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolItemEditor.java74
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimBarEditor.java165
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimContributionEditor.java186
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/WindowEditor.java179
14 files changed, 708 insertions, 936 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartEditor.java
index 6a8463e7..81f3b23f 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartEditor.java
@@ -312,45 +312,6 @@ public class PartEditor extends AbstractComponentEditor {
// ------------------------------------------------------------
ControlFactory.createBindingsWidget(parent, this);
- // TODO Does the user need to edit this?
- // // ------------------------------------------------------------
- // {
- // Label l = new Label(parent, SWT.NONE);
- // l.setText("Variables");
- // l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING,
- // false, false));
- //
- // ListViewer viewer = new ListViewer(parent);
- // GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- // gd.horizontalSpan=2;
- // gd.heightHint = 80;
- // viewer.getList().setLayoutData(gd);
- // }
-
- // // ------------------------------------------------------------
- // {
- // Label l = new Label(parent, SWT.NONE);
- // l.setText("Properties");
- // l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING,
- // false, false));
- //
- // TableViewer tableviewer = new TableViewer(parent);
- // GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- // gd.horizontalSpan=2;
- // gd.heightHint = 80;
- // tableviewer.getTable().setHeaderVisible(true);
- // tableviewer.getControl().setLayoutData(gd);
- //
- // TableViewerColumn column = new TableViewerColumn(tableviewer,
- // SWT.NONE);
- // column.getColumn().setText("Key");
- // column.getColumn().setWidth(200);
- //
- // column = new TableViewerColumn(tableviewer, SWT.NONE);
- // column.getColumn().setText("Value");
- // column.getColumn().setWidth(200);
- // }
-
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartSashContainerEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartSashContainerEditor.java
index a5b691fb..ed04e02e 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartSashContainerEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartSashContainerEditor.java
@@ -10,30 +10,21 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-
-import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
-import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
+import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
@@ -43,8 +34,6 @@ import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.FeaturePath;
import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.databinding.edit.IEMFEditListProperty;
-import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -57,7 +46,6 @@ import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.viewers.IViewerValueProperty;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
import org.eclipse.jface.databinding.viewers.ViewerProperties;
-import org.eclipse.jface.databinding.viewers.ViewerSupport;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -72,6 +60,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -84,17 +73,17 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
private EMFDataBindingContext context;
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
- private StackLayout stackLayout;
+ private EStackLayout stackLayout;
public PartSashContainerEditor(EditingDomain editingDomain, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
}
@Override
public Image getImage(Object element, Display display) {
- boolean horizontal = ((MPartSashContainer)element).isHorizontal();
+ boolean horizontal = ((MPartSashContainer) element).isHorizontal();
- if( vImage == null && ! horizontal ) {
+ if (vImage == null && !horizontal) {
try {
vImage = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/PartSashContainer_vertical.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -103,7 +92,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
}
}
- if( hImage == null && horizontal ) {
+ if (hImage == null && horizontal) {
try {
hImage = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/PartSashContainer.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -112,7 +101,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
}
}
- if( horizontal ) {
+ if (horizontal) {
return hImage;
} else {
return vImage;
@@ -135,7 +124,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -143,37 +132,36 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
- private Composite createForm(Composite parent, final EMFDataBindingContext context,
- WritableValue master, boolean isImport) {
- parent = new Composite(parent,SWT.NONE);
+ private Composite createForm(Composite parent, final EMFDataBindingContext context, WritableValue master, boolean isImport) {
+ parent = new Composite(parent, SWT.NONE);
parent.setLayout(new GridLayout(3, false));
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -182,26 +170,26 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
l.setText(Messages.PartSashContainerEditor_Orientation);
l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
+
ComboViewer viewer = new ComboViewer(parent);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
viewer.getControl().setLayoutData(gd);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
- return ((Boolean)element).booleanValue() ? Messages.PartSashContainerEditor_Horizontal : Messages.PartSashContainerEditor_Vertical;
+ return ((Boolean) element).booleanValue() ? Messages.PartSashContainerEditor_Horizontal : Messages.PartSashContainerEditor_Vertical;
}
});
viewer.setInput(new Boolean[] { Boolean.TRUE, Boolean.FALSE });
@@ -210,7 +198,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
}
ControlFactory.createSelectedElement(parent, this, context, Messages.PartSashContainerEditor_SelectedElement);
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -219,9 +207,9 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__CONTAINER_DATA).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__CONTAINER_DATA).observeDetail(master));
}
ControlFactory.createTagsWidget(parent, this);
@@ -229,8 +217,8 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
{
Label l = new Label(parent, SWT.NONE);
l.setText(Messages.PartSashContainerEditor_Controls);
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
-
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
+
final TableViewer viewer = new TableViewer(parent);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 200;
@@ -238,41 +226,41 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
ObservableListContentProvider cp = new ObservableListContentProvider();
viewer.setContentProvider(cp);
viewer.setLabelProvider(new ComponentLabelProvider(getEditor()));
-
+
IEMFListProperty prop = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
viewer.setInput(prop.observeDetail(getMaster()));
-
+
Composite buttonComp = new Composite(parent, SWT.NONE);
- buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
- GridLayout gl = new GridLayout(2,false);
- gl.marginLeft=0;
- gl.marginRight=0;
- gl.marginWidth=0;
- gl.marginHeight=0;
+ buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
+ GridLayout gl = new GridLayout(2, false);
+ gl.marginLeft = 0;
+ gl.marginRight = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
buttonComp.setLayout(gl);
Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartSashContainerEditor_Up);
b.setImage(getImage(b.getDisplay(), ARROW_UP));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) - 1;
- if( idx >= 0 ) {
+ if (idx >= 0) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
@@ -281,30 +269,30 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartSashContainerEditor_Down);
b.setImage(getImage(b.getDisplay(), ARROW_DOWN));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) + 1;
- if( idx < container.getChildren().size() ) {
+ if (idx < container.getChildren().size()) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
});
-
+
final ComboViewer childrenDropDown = new ComboViewer(buttonComp);
childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
childrenDropDown.setContentProvider(new ArrayContentProvider());
@@ -315,54 +303,48 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
return eclass.getName();
}
});
- childrenDropDown.setInput(new EClass[] {
- BasicPackageImpl.Literals.PART_SASH_CONTAINER,
- BasicPackageImpl.Literals.PART_STACK,
- BasicPackageImpl.Literals.PART,
- BasicPackageImpl.Literals.INPUT_PART,
- AdvancedPackageImpl.Literals.PLACEHOLDER
- });
+ childrenDropDown.setInput(new EClass[] { BasicPackageImpl.Literals.PART_SASH_CONTAINER, BasicPackageImpl.Literals.PART_STACK, BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, AdvancedPackageImpl.Literals.PLACEHOLDER });
childrenDropDown.setSelection(new StructuredSelection(BasicPackageImpl.Literals.PART_SASH_CONTAINER));
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! childrenDropDown.getSelection().isEmpty() ) {
- EClass eClass = (EClass) ((IStructuredSelection)childrenDropDown.getSelection()).getFirstElement();
+ if (!childrenDropDown.getSelection().isEmpty()) {
+ EClass eClass = (EClass) ((IStructuredSelection) childrenDropDown.getSelection()).getFirstElement();
EObject eObject = EcoreUtil.create(eClass);
-
+
Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, eObject);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
getEditor().setSelection(eObject);
}
}
}
});
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartSashContainerEditor_Remove);
b.setImage(getImage(b.getDisplay(), TABLE_DELETE_IMAGE));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
-
+ if (!viewer.getSelection().isEmpty()) {
+ List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();
+
Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
}
});
}
-
+
return parent;
}
@@ -378,8 +360,6 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
@Override
public FeaturePath[] getLabelProperties() {
- return new FeaturePath[] {
- FeaturePath.fromList(UiPackageImpl.Literals.GENERIC_TILE__HORIZONTAL)
- };
+ return new FeaturePath[] { FeaturePath.fromList(UiPackageImpl.Literals.GENERIC_TILE__HORIZONTAL) };
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartStackEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartStackEditor.java
index 7d66d1ef..690624b1 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartStackEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartStackEditor.java
@@ -10,30 +10,22 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-
-import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
-import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
+import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
import org.eclipse.emf.common.command.Command;
@@ -41,8 +33,6 @@ import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.databinding.edit.IEMFEditListProperty;
-import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -52,10 +42,7 @@ import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.IViewerValueProperty;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.databinding.viewers.ViewerProperties;
-import org.eclipse.jface.databinding.viewers.ViewerSupport;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -63,6 +50,7 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
@@ -70,6 +58,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -84,12 +73,12 @@ public class PartStackEditor extends AbstractComponentEditor {
private StackLayout stackLayout;
public PartStackEditor(EditingDomain editingDomain, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
}
@Override
public Image getImage(Object element, Display display) {
- if( image == null ) {
+ if (image == null) {
try {
image = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/PartStack.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -117,7 +106,7 @@ public class PartStackEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -125,37 +114,36 @@ public class PartStackEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
- private Composite createForm(Composite parent, final EMFDataBindingContext context,
- WritableValue master, boolean isImport) {
- parent = new Composite(parent,SWT.NONE);
+ private Composite createForm(Composite parent, final EMFDataBindingContext context, WritableValue master, boolean isImport) {
+ parent = new Composite(parent, SWT.NONE);
parent.setLayout(new GridLayout(3, false));
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -164,13 +152,13 @@ public class PartStackEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
ControlFactory.createSelectedElement(parent, this, context, Messages.PartStackEditor_SelectedElement);
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -179,59 +167,58 @@ public class PartStackEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__CONTAINER_DATA).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__CONTAINER_DATA).observeDetail(master));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
l.setText(Messages.PartStackEditor_Parts);
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
-
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
+
final TableViewer viewer = new TableViewer(parent);
viewer.setContentProvider(new ObservableListContentProvider());
viewer.setLabelProvider(new ComponentLabelProvider(getEditor()));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 300;
viewer.getControl().setLayoutData(gd);
-
-
+
IEMFListProperty prop = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
viewer.setInput(prop.observeDetail(getMaster()));
-
+
Composite buttonComp = new Composite(parent, SWT.NONE);
- buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
- GridLayout gl = new GridLayout(2,false);
- gl.marginLeft=0;
- gl.marginRight=0;
- gl.marginWidth=0;
- gl.marginHeight=0;
+ buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
+ GridLayout gl = new GridLayout(2, false);
+ gl.marginLeft = 0;
+ gl.marginRight = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
buttonComp.setLayout(gl);
Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartStackEditor_Up);
b.setImage(getImage(b.getDisplay(), ARROW_UP));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
- b.addSelectionListener(new SelectionAdapter() {
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
+ b.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ public void widgetSelected(SelectionEvent e) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) - 1;
- if( idx >= 0 ) {
+ if (idx >= 0) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
@@ -240,30 +227,30 @@ public class PartStackEditor extends AbstractComponentEditor {
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartStackEditor_Down);
b.setImage(getImage(b.getDisplay(), ARROW_DOWN));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) + 1;
- if( idx < container.getChildren().size() ) {
+ if (idx < container.getChildren().size()) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
});
-
+
final ComboViewer childrenDropDown = new ComboViewer(buttonComp);
childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
childrenDropDown.setContentProvider(new ArrayContentProvider());
@@ -274,44 +261,39 @@ public class PartStackEditor extends AbstractComponentEditor {
return eclass.getName();
}
});
- childrenDropDown.setInput(new EClass[] {
- BasicPackageImpl.Literals.PART,
- BasicPackageImpl.Literals.INPUT_PART,
- AdvancedPackageImpl.Literals.PLACEHOLDER
- });
+ childrenDropDown.setInput(new EClass[] { BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, AdvancedPackageImpl.Literals.PLACEHOLDER });
childrenDropDown.setSelection(new StructuredSelection(BasicPackageImpl.Literals.PART_SASH_CONTAINER));
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- EClass eClass = (EClass) ((IStructuredSelection)childrenDropDown.getSelection()).getFirstElement();
+ EClass eClass = (EClass) ((IStructuredSelection) childrenDropDown.getSelection()).getFirstElement();
EObject eObject = EcoreUtil.create(eClass);
-
+
Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, eObject);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
getEditor().setSelection(eObject);
}
}
});
-
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartStackEditor_Remove);
b.setImage(getImage(b.getDisplay(), TABLE_DELETE_IMAGE));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
-
+ if (!viewer.getSelection().isEmpty()) {
+ List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();
+
Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveEditor.java
index 19385e28..d20ada0a 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveEditor.java
@@ -10,27 +10,16 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.ImageTooltip;
-import org.eclipse.e4.ui.model.application.ui.MUILabel;
-import org.eclipse.emf.common.util.URI;
-
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
-import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.ImageTooltip;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
@@ -38,18 +27,18 @@ import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.PerspectiveIconDialogEditor;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
+import org.eclipse.e4.ui.model.application.ui.MUILabel;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.FeaturePath;
import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.databinding.edit.IEMFEditListProperty;
-import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -59,10 +48,7 @@ import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.IViewerValueProperty;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.databinding.viewers.ViewerProperties;
-import org.eclipse.jface.databinding.viewers.ViewerSupport;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -77,6 +63,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -88,10 +75,10 @@ public class PerspectiveEditor extends AbstractComponentEditor {
private IProject project;
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
- private StackLayout stackLayout;
+ private EStackLayout stackLayout;
public PerspectiveEditor(EditingDomain editingDomain, IProject project, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
this.project = project;
}
@@ -126,11 +113,9 @@ public class PerspectiveEditor extends AbstractComponentEditor {
@Override
public FeaturePath[] getLabelProperties() {
- return new FeaturePath[] {
- FeaturePath.fromList(UiPackageImpl.Literals.UI_LABEL__LABEL)
- };
+ return new FeaturePath[] { FeaturePath.fromList(UiPackageImpl.Literals.UI_LABEL__LABEL) };
}
-
+
@Override
public String getDescription(Object element) {
return Messages.PerspectiveEditor_Description;
@@ -142,7 +127,7 @@ public class PerspectiveEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -150,21 +135,21 @@ public class PerspectiveEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
@@ -175,11 +160,11 @@ public class PerspectiveEditor extends AbstractComponentEditor {
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -190,9 +175,9 @@ public class PerspectiveEditor extends AbstractComponentEditor {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
ControlFactory.createSelectedElement(parent, this, context, Messages.PerspectiveEditor_SelectedElement);
// ------------------------------------------------------------
@@ -205,7 +190,7 @@ public class PerspectiveEditor extends AbstractComponentEditor {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL).observeDetail(master));
}
// ------------------------------------------------------------
@@ -218,7 +203,7 @@ public class PerspectiveEditor extends AbstractComponentEditor {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP).observeDetail(master));
}
// ------------------------------------------------------------
@@ -229,27 +214,27 @@ public class PerspectiveEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master));
new ImageTooltip(t) {
-
+
@Override
protected URI getImageURI() {
MUILabel part = (MUILabel) getMaster().getValue();
String uri = part.getIconURI();
- if( uri == null || uri.trim().length() == 0 ) {
+ if (uri == null || uri.trim().length() == 0) {
return null;
}
return URI.createURI(part.getIconURI());
}
};
-
+
final Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PerspectiveEditor_Find);
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- PerspectiveIconDialogEditor dialog = new PerspectiveIconDialogEditor(b.getShell(), project,getEditingDomain(),(MPerspective) getMaster().getValue());
+ PerspectiveIconDialogEditor dialog = new PerspectiveIconDialogEditor(b.getShell(), project, getEditingDomain(), (MPerspective) getMaster().getValue());
dialog.open();
}
});
@@ -258,8 +243,8 @@ public class PerspectiveEditor extends AbstractComponentEditor {
{
Label l = new Label(parent, SWT.NONE);
l.setText(Messages.PerspectiveEditor_Controls);
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
-
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
+
final TableViewer viewer = new TableViewer(parent);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 200;
@@ -267,41 +252,41 @@ public class PerspectiveEditor extends AbstractComponentEditor {
ObservableListContentProvider cp = new ObservableListContentProvider();
viewer.setContentProvider(cp);
viewer.setLabelProvider(new ComponentLabelProvider(getEditor()));
-
+
IEMFListProperty prop = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
viewer.setInput(prop.observeDetail(getMaster()));
-
+
Composite buttonComp = new Composite(parent, SWT.NONE);
- buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
- GridLayout gl = new GridLayout(2,false);
- gl.marginLeft=0;
- gl.marginRight=0;
- gl.marginWidth=0;
- gl.marginHeight=0;
+ buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
+ GridLayout gl = new GridLayout(2, false);
+ gl.marginLeft = 0;
+ gl.marginRight = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
buttonComp.setLayout(gl);
Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PerspectiveEditor_Up);
b.setImage(getImage(b.getDisplay(), ARROW_UP));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) - 1;
- if( idx >= 0 ) {
+ if (idx >= 0) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
@@ -310,30 +295,30 @@ public class PerspectiveEditor extends AbstractComponentEditor {
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PerspectiveEditor_Down);
b.setImage(getImage(b.getDisplay(), ARROW_DOWN));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) + 1;
- if( idx < container.getChildren().size() ) {
+ if (idx < container.getChildren().size()) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
});
-
+
final ComboViewer childrenDropDown = new ComboViewer(buttonComp);
childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
childrenDropDown.setContentProvider(new ArrayContentProvider());
@@ -344,54 +329,48 @@ public class PerspectiveEditor extends AbstractComponentEditor {
return eclass.getName();
}
});
- childrenDropDown.setInput(new EClass[] {
- BasicPackageImpl.Literals.PART_SASH_CONTAINER,
- BasicPackageImpl.Literals.PART_STACK,
- BasicPackageImpl.Literals.PART,
- BasicPackageImpl.Literals.INPUT_PART,
- AdvancedPackageImpl.Literals.PLACEHOLDER
- });
+ childrenDropDown.setInput(new EClass[] { BasicPackageImpl.Literals.PART_SASH_CONTAINER, BasicPackageImpl.Literals.PART_STACK, BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, AdvancedPackageImpl.Literals.PLACEHOLDER });
childrenDropDown.setSelection(new StructuredSelection(BasicPackageImpl.Literals.PART_SASH_CONTAINER));
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! childrenDropDown.getSelection().isEmpty() ) {
- EClass eClass = (EClass) ((IStructuredSelection)childrenDropDown.getSelection()).getFirstElement();
+ if (!childrenDropDown.getSelection().isEmpty()) {
+ EClass eClass = (EClass) ((IStructuredSelection) childrenDropDown.getSelection()).getFirstElement();
EObject eObject = EcoreUtil.create(eClass);
-
+
Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, eObject);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
getEditor().setSelection(eObject);
}
}
}
});
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PerspectiveEditor_Remove);
b.setImage(getImage(b.getDisplay(), TABLE_DELETE_IMAGE));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
-
+ if (!viewer.getSelection().isEmpty()) {
+ List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();
+
Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
}
});
}
-
+
ControlFactory.createTagsWidget(parent, this);
return parent;
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveStackEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveStackEditor.java
index fc674650..11077159 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveStackEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PerspectiveStackEditor.java
@@ -10,23 +10,14 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-import org.eclipse.emf.ecore.EObject;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
-import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
@@ -41,19 +32,14 @@ import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.databinding.edit.IEMFEditListProperty;
-import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.IViewerValueProperty;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.databinding.viewers.ViewerProperties;
-import org.eclipse.jface.databinding.viewers.ViewerSupport;
-import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
@@ -65,6 +51,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -75,15 +62,15 @@ public class PerspectiveStackEditor extends AbstractComponentEditor {
private EMFDataBindingContext context;
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
- private StackLayout stackLayout;
+ private EStackLayout stackLayout;
public PerspectiveStackEditor(EditingDomain editingDomain, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
}
@Override
public Image getImage(Object element, Display display) {
- if( image == null ) {
+ if (image == null) {
try {
image = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/PerspectiveStack.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -116,7 +103,7 @@ public class PerspectiveStackEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -124,37 +111,36 @@ public class PerspectiveStackEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
- private Composite createForm(Composite parent, final EMFDataBindingContext context,
- WritableValue master, boolean isImport) {
- parent = new Composite(parent,SWT.NONE);
+ private Composite createForm(Composite parent, final EMFDataBindingContext context, WritableValue master, boolean isImport) {
+ parent = new Composite(parent, SWT.NONE);
parent.setLayout(new GridLayout(3, false));
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -163,61 +149,60 @@ public class PerspectiveStackEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
ControlFactory.createSelectedElement(parent, this, context, Messages.PerspectiveStackEditor_SelectedElement);
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
l.setText(Messages.PerspectiveStackEditor_Perspectives);
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
-
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
+
final TableViewer viewer = new TableViewer(parent);
viewer.setContentProvider(new ObservableListContentProvider());
viewer.setLabelProvider(new ComponentLabelProvider(getEditor()));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 300;
viewer.getControl().setLayoutData(gd);
-
-
+
IEMFListProperty prop = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
viewer.setInput(prop.observeDetail(getMaster()));
-
+
Composite buttonComp = new Composite(parent, SWT.NONE);
- buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
+ buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
GridLayout gl = new GridLayout();
- gl.marginLeft=0;
- gl.marginRight=0;
- gl.marginWidth=0;
- gl.marginHeight=0;
+ gl.marginLeft = 0;
+ gl.marginRight = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
buttonComp.setLayout(gl);
Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartStackEditor_Up);
b.setImage(getImage(b.getDisplay(), ARROW_UP));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- b.addSelectionListener(new SelectionAdapter() {
+ b.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ public void widgetSelected(SelectionEvent e) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) - 1;
- if( idx >= 0 ) {
+ if (idx >= 0) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
@@ -230,44 +215,44 @@ public class PerspectiveStackEditor extends AbstractComponentEditor {
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) + 1;
- if( idx < container.getChildren().size() ) {
+ if (idx < container.getChildren().size()) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
});
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
+ b.setText(Messages.PerspectiveStackEditor_Add);
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
MPerspective eObject = MAdvancedFactory.INSTANCE.createPerspective();
-
+
Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, eObject);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
getEditor().setSelection(eObject);
}
}
});
-
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.PartStackEditor_Remove);
b.setImage(getImage(b.getDisplay(), TABLE_DELETE_IMAGE));
@@ -275,11 +260,11 @@ public class PerspectiveStackEditor extends AbstractComponentEditor {
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
-
+ if (!viewer.getSelection().isEmpty()) {
+ List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();
+
Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PlaceholderEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PlaceholderEditor.java
index 57ee751b..b0571a0d 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PlaceholderEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PlaceholderEditor.java
@@ -10,48 +10,24 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.common.Util;
-
-import org.eclipse.e4.ui.workbench.UIEvents.UIElement;
-
-import org.eclipse.e4.ui.model.application.ui.MUIElement;
-
-import org.eclipse.core.databinding.conversion.Converter;
-
-import org.eclipse.core.databinding.conversion.Converter;
-
-import org.eclipse.core.databinding.UpdateValueStrategy;
-
-import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
-
-import org.eclipse.e4.tools.emf.ui.common.IModelResource;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.SharedElementsDialog;
-
-import org.eclipse.swt.events.SelectionEvent;
-
-import org.eclipse.swt.events.SelectionAdapter;
-
-import org.eclipse.swt.events.SelectionAdapter;
-
-import org.eclipse.swt.widgets.Button;
-
import java.net.MalformedURLException;
import java.net.URL;
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.IModelResource;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
+import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.SharedElementsDialog;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.MUILabel;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
+import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
import org.eclipse.emf.ecore.EObject;
@@ -59,10 +35,14 @@ import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -72,10 +52,10 @@ public class PlaceholderEditor extends AbstractComponentEditor {
private Image image;
private EMFDataBindingContext context;
private IModelResource resource;
- private StackLayout stackLayout;
-
+ private EStackLayout stackLayout;
+
public PlaceholderEditor(EditingDomain editingDomain, ModelEditor editor, IModelResource resource) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
this.resource = resource;
}
@@ -101,24 +81,24 @@ public class PlaceholderEditor extends AbstractComponentEditor {
@Override
public String getDetailLabel(Object element) {
MPlaceholder pl = (MPlaceholder) element;
- if( pl.getRef() != null ) {
+ if (pl.getRef() != null) {
StringBuilder b = new StringBuilder();
- b.append(((EObject)pl.getRef()).eClass().getName());
- if( pl.getRef() instanceof MUILabel ) {
+ b.append(((EObject) pl.getRef()).eClass().getName());
+ if (pl.getRef() instanceof MUILabel) {
MUILabel label = (MUILabel) pl.getRef();
- if( label.getLabel() != null && label.getLabel().trim().length() > 0 ) {
- b.append(" (" + label.getLabel() + ")"); //$NON-NLS-1$//$NON-NLS-2$
- } else if( label.getTooltip() != null && label.getTooltip().trim().length() > 0 ) {
+ if (label.getLabel() != null && label.getLabel().trim().length() > 0) {
+ b.append(" (" + label.getLabel() + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ } else if (label.getTooltip() != null && label.getTooltip().trim().length() > 0) {
b.append(" (" + label.getTooltip() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- if( pl.getRef().getElementId() != null && pl.getRef().getElementId().trim().length() > 0 ) {
+ if (pl.getRef().getElementId() != null && pl.getRef().getElementId().trim().length() > 0) {
b.append(pl.getRef().getElementId());
}
}
} else {
- if( pl.getRef().getElementId() != null && pl.getRef().getElementId().trim().length() > 0 ) {
- b.append(" (" + pl.getRef().getElementId() + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ if (pl.getRef().getElementId() != null && pl.getRef().getElementId().trim().length() > 0) {
+ b.append(" (" + pl.getRef().getElementId() + ")"); //$NON-NLS-1$//$NON-NLS-2$
}
}
@@ -139,7 +119,7 @@ public class PlaceholderEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -147,21 +127,21 @@ public class PlaceholderEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
@@ -172,11 +152,11 @@ public class PlaceholderEditor extends AbstractComponentEditor {
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -185,11 +165,11 @@ public class PlaceholderEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -200,47 +180,47 @@ public class PlaceholderEditor extends AbstractComponentEditor {
t.setEditable(false);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
t.setLayoutData(gd);
-
+
UpdateValueStrategy t2m = new UpdateValueStrategy();
t2m.setConverter(new Converter(String.class, MUIElement.class) {
-
+
public Object convert(Object fromObject) {
return null;
}
});
UpdateValueStrategy m2t = new UpdateValueStrategy();
- m2t.setConverter(new Converter(MUIElement.class,String.class) {
-
+ m2t.setConverter(new Converter(MUIElement.class, String.class) {
+
public Object convert(Object fromObject) {
- if( fromObject != null ) {
+ if (fromObject != null) {
EObject o = (EObject) fromObject;
- if( o instanceof MUILabel ) {
+ if (o instanceof MUILabel) {
MUILabel label = (MUILabel) o;
- if( ! Util.isNullOrEmpty(label.getLabel()) ) {
+ if (!Util.isNullOrEmpty(label.getLabel())) {
return o.eClass().getName() + " - " + label.getLabel();
}
}
-
- return o.eClass().getName() + " - "+((MUIElement)fromObject).getElementId();
+
+ return o.eClass().getName() + " - " + ((MUIElement) fromObject).getElementId();
}
return null;
}
});
-
- context.bindValue(textProp.observe(t), EMFEditProperties.value(getEditingDomain(), AdvancedPackageImpl.Literals.PLACEHOLDER__REF).observeDetail(getMaster()),t2m,m2t);
-
- final Button b = new Button(parent, SWT.PUSH|SWT.FLAT);
+
+ context.bindValue(textProp.observe(t), EMFEditProperties.value(getEditingDomain(), AdvancedPackageImpl.Literals.PLACEHOLDER__REF).observeDetail(getMaster()), t2m, m2t);
+
+ final Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
+ b.setImage(getImage(b.getDisplay(), SEARCH_IMAGE));
b.setText(Messages.PlaceholderEditor_FindReference);
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- SharedElementsDialog dialog = new SharedElementsDialog(b.getShell(),getEditor(),(MPlaceholder) getMaster().getValue(), resource);
+ SharedElementsDialog dialog = new SharedElementsDialog(b.getShell(), getEditor(), (MPlaceholder) getMaster().getValue(), resource);
dialog.open();
}
});
}
-
return parent;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarContributionEditor.java
index 4887cdf1..0b0fdf27 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarContributionEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarContributionEditor.java
@@ -10,42 +10,39 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement;
-
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
-import org.eclipse.emf.databinding.EMFProperties;
-
import org.eclipse.core.resources.IProject;
-import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
-
-import java.util.List;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
+import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.tools.emf.ui.internal.ObservableColumnLabelProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.MenuIconDialogEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.ui.model.application.commands.MHandler;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
-import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
-import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement;
import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.databinding.EMFDataBindingContext;
+import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
@@ -56,41 +53,28 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.swt.SWT;
-
-import org.eclipse.core.databinding.observable.value.WritableValue;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.emf.databinding.EMFDataBindingContext;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-
-import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
public class ToolBarContributionEditor extends AbstractComponentEditor {
private Composite composite;
private Image image;
private EMFDataBindingContext context;
private IProject project;
-
+
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
- private StackLayout stackLayout;
-
+ private EStackLayout stackLayout;
+
private static class Struct {
private final String label;
private final EClass eClass;
@@ -102,15 +86,15 @@ public class ToolBarContributionEditor extends AbstractComponentEditor {
this.separator = separator;
}
}
-
+
public ToolBarContributionEditor(EditingDomain editingDomain, IProject project, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
this.project = project;
}
@Override
public Image getImage(Object element, Display display) {
- if( image == null ) {
+ if (image == null) {
try {
image = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/ToolBarContribution.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -143,7 +127,7 @@ public class ToolBarContributionEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -151,21 +135,21 @@ public class ToolBarContributionEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
@@ -176,11 +160,11 @@ public class ToolBarContributionEditor extends AbstractComponentEditor {
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -193,7 +177,7 @@ public class ToolBarContributionEditor extends AbstractComponentEditor {
t.setLayoutData(gd);
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -220,12 +204,11 @@ public class ToolBarContributionEditor extends AbstractComponentEditor {
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.TOOL_BAR_CONTRIBUTION__POSITION_IN_PARENT).observeDetail(getMaster()));
}
-
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
l.setText(Messages.ToolBarEditor_ToolbarItems);
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
final TableViewer viewer = new TableViewer(parent);
ObservableListContentProvider cp = new ObservableListContentProvider();
@@ -373,8 +356,8 @@ public class ToolBarContributionEditor extends AbstractComponentEditor {
}
});
}
-
- ControlFactory.createTagsWidget(parent, this);
+
+ ControlFactory.createTagsWidget(parent, this);
return parent;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarEditor.java
index 41e114f6..8a644d31 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarEditor.java
@@ -10,19 +10,14 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-import org.eclipse.emf.ecore.EObject;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.tools.emf.ui.internal.ObservableColumnLabelProvider;
@@ -41,6 +36,7 @@ import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.MoveCommand;
@@ -64,6 +60,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -75,7 +72,7 @@ public class ToolBarEditor extends AbstractComponentEditor {
private EMFDataBindingContext context;
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
- private StackLayout stackLayout;
+ private EStackLayout stackLayout;
private static class Struct {
private final String label;
@@ -89,14 +86,13 @@ public class ToolBarEditor extends AbstractComponentEditor {
}
}
-
public ToolBarEditor(EditingDomain editingDomain, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
}
@Override
public Image getImage(Object element, Display display) {
- if( image == null ) {
+ if (image == null) {
try {
image = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/ToolBar.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -123,7 +119,7 @@ public class ToolBarEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -131,21 +127,21 @@ public class ToolBarEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
@@ -156,11 +152,11 @@ public class ToolBarEditor extends AbstractComponentEditor {
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -173,12 +169,12 @@ public class ToolBarEditor extends AbstractComponentEditor {
t.setLayoutData(gd);
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
l.setText(Messages.ToolBarEditor_ToolbarItems);
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
final TableViewer viewer = new TableViewer(parent);
ObservableListContentProvider cp = new ObservableListContentProvider();
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarSeparatorEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarSeparatorEditor.java
index 47a639ef..a8eeac79 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarSeparatorEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarSeparatorEditor.java
@@ -10,27 +10,19 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Button;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
-
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
+import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
@@ -39,6 +31,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -47,10 +40,10 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor {
private Image separatorImage;
private Composite composite;
private EMFDataBindingContext context;
- private StackLayout stackLayout;
-
+ private EStackLayout stackLayout;
+
public ToolBarSeparatorEditor(EditingDomain editingDomain, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
}
@Override
@@ -88,7 +81,7 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -96,36 +89,36 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
-
+
private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) {
parent = new Composite(parent, SWT.NONE);
parent.setLayout(new GridLayout(3, false));
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -138,7 +131,7 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor {
t.setLayoutData(gd);
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
return parent;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolControlEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolControlEditor.java
index dcc8a364..f1344ce3 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolControlEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolControlEditor.java
@@ -10,29 +10,24 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map.Entry;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
+import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.ContributionClassDialog;
import org.eclipse.e4.ui.model.application.MContribution;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
import org.eclipse.emf.databinding.edit.IEMFEditListProperty;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
@@ -48,6 +43,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -57,10 +53,10 @@ public class ToolControlEditor extends AbstractComponentEditor {
private EMFDataBindingContext context;
private Composite composite;
private IProject project;
- private StackLayout stackLayout;
+ private EStackLayout stackLayout;
public ToolControlEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
this.project = project;
}
@@ -100,7 +96,7 @@ public class ToolControlEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -108,21 +104,21 @@ public class ToolControlEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
@@ -132,12 +128,12 @@ public class ToolControlEditor extends AbstractComponentEditor {
parent.setLayout(new GridLayout(3, false));
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
-
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -150,7 +146,7 @@ public class ToolControlEditor extends AbstractComponentEditor {
t.setLayoutData(gd);
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(master));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -162,6 +158,7 @@ public class ToolControlEditor extends AbstractComponentEditor {
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI).observeDetail(master));
final Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
b.setImage(getImage(t.getDisplay(), SEARCH_IMAGE));
b.setText("Find ...");
b.addSelectionListener(new SelectionAdapter() {
@@ -172,7 +169,7 @@ public class ToolControlEditor extends AbstractComponentEditor {
}
});
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -186,7 +183,7 @@ public class ToolControlEditor extends AbstractComponentEditor {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 80;
tableviewer.getControl().setLayoutData(gd);
-
+
TableViewerColumn column = new TableViewerColumn(tableviewer, SWT.NONE);
column.getColumn().setText("Key");
column.getColumn().setWidth(200);
@@ -197,9 +194,9 @@ public class ToolControlEditor extends AbstractComponentEditor {
Entry<String, String> entry = (Entry<String, String>) element;
return entry.getKey();
}
- });
+ });
- //FIXME How can we react upon changes in the Map-Value?
+ // FIXME How can we react upon changes in the Map-Value?
column = new TableViewerColumn(tableviewer, SWT.NONE);
column.getColumn().setText("Value");
column.getColumn().setWidth(200);
@@ -211,17 +208,17 @@ public class ToolControlEditor extends AbstractComponentEditor {
return entry.getValue();
}
});
-
+
IEMFEditListProperty prop = EMFEditProperties.list(getEditingDomain(), ApplicationPackageImpl.Literals.CONTRIBUTION__PERSISTED_STATE);
tableviewer.setInput(prop.observeDetail(getMaster()));
-
+
Composite buttonComp = new Composite(parent, SWT.NONE);
- buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
+ buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
GridLayout gl = new GridLayout();
- gl.marginLeft=0;
- gl.marginRight=0;
- gl.marginWidth=0;
- gl.marginHeight=0;
+ gl.marginLeft = 0;
+ gl.marginRight = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
buttonComp.setLayout(gl);
Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolItemEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolItemEditor.java
index 8376509a..94256a0d 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolItemEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolItemEditor.java
@@ -10,37 +10,30 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.ImageTooltip;
-import org.eclipse.e4.ui.model.application.ui.MUILabel;
-import org.eclipse.emf.common.util.URI;
-
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.Converter;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
-
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.ImageTooltip;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.ToolItemIconDialogEditor;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
+import org.eclipse.e4.ui.model.application.ui.MUILabel;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
import org.eclipse.e4.ui.model.application.ui.menu.ItemType;
import org.eclipse.e4.ui.model.application.ui.menu.MToolItem;
import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.FeaturePath;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
@@ -54,6 +47,7 @@ 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.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -61,7 +55,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
private Composite composite;
private EMFDataBindingContext context;
protected IProject project;
- private StackLayout stackLayout;
+ private EStackLayout stackLayout;
public ToolItemEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) {
super(editingDomain, editor);
@@ -74,7 +68,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -82,21 +76,21 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
@@ -107,11 +101,11 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
Label l = new Label(parent, SWT.NONE);
l.setText("Id");
l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
@@ -121,7 +115,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
gd.horizontalSpan = 2;
t.setLayoutData(gd);
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(master));
-
+
createFormSubTypeForm(parent, context, master);
return parent;
@@ -185,18 +179,18 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
context.bindValue(textProp.observe(t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master));
new ImageTooltip(t) {
-
+
@Override
protected URI getImageURI() {
MUILabel part = (MUILabel) getMaster().getValue();
String uri = part.getIconURI();
- if( uri == null || uri.trim().length() == 0 ) {
+ if (uri == null || uri.trim().length() == 0) {
return null;
}
return URI.createURI(part.getIconURI());
}
};
-
+
final Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
b.setText("Find ...");
b.setImage(getImage(b.getDisplay(), SEARCH_IMAGE));
@@ -204,19 +198,19 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- ToolItemIconDialogEditor dialog = new ToolItemIconDialogEditor(b.getShell(), project,getEditingDomain(),(MToolItem) getMaster().getValue());
+ ToolItemIconDialogEditor dialog = new ToolItemIconDialogEditor(b.getShell(), project, getEditingDomain(), (MToolItem) getMaster().getValue());
dialog.open();
}
});
}
-
+
{
Label l = new Label(parent, SWT.NONE);
l.setText("Enabled");
l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
+
Button b = new Button(parent, SWT.CHECK);
- b.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER,false,false,2,1));
+ b.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
context.bindValue(checkProp.observe(b), EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__ENABLED).observeDetail(getMaster()));
}
@@ -224,11 +218,11 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
Label l = new Label(parent, SWT.NONE);
l.setText("Selected");
l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
+
Button b = new Button(parent, SWT.CHECK);
- b.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER,false,false,2,1));
+ b.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
context.bindValue(checkProp.observe(b), EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__SELECTED).observeDetail(getMaster()));
-
+
UpdateValueStrategy t2m = new UpdateValueStrategy();
t2m.setConverter(new Converter(boolean.class, ItemType.class) {
@@ -238,13 +232,13 @@ public abstract class ToolItemEditor extends AbstractComponentEditor {
});
UpdateValueStrategy m2t = new UpdateValueStrategy();
m2t.setConverter(new Converter(ItemType.class, boolean.class) {
-
+
public Object convert(Object fromObject) {
return fromObject == ItemType.CHECK || fromObject == ItemType.RADIO;
}
});
-
- context.bindValue(enabled.observe(b), EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__TYPE).observeDetail(getMaster()),t2m,m2t);
+
+ context.bindValue(enabled.observe(b), EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__TYPE).observeDetail(getMaster()), t2m, m2t);
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimBarEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimBarEditor.java
index 21a5ad73..cf552004 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimBarEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimBarEditor.java
@@ -10,22 +10,6 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
-
-import org.eclipse.emf.ecore.EClass;
-
-import org.eclipse.jface.viewers.LabelProvider;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
@@ -33,6 +17,8 @@ import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
@@ -41,14 +27,16 @@ import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MGenericTrimContainer;
import org.eclipse.e4.ui.model.application.ui.SideValue;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
-import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
-import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
+import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.FeaturePath;
import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
@@ -60,6 +48,7 @@ import org.eclipse.jface.databinding.viewers.ViewerProperties;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
@@ -70,6 +59,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -82,16 +72,16 @@ public class TrimBarEditor extends AbstractComponentEditor {
private ModelEditor editor;
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
- private StackLayout stackLayout;
+ private EStackLayout stackLayout;
public TrimBarEditor(EditingDomain editingDomain, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
this.editor = editor;
}
@Override
public Image getImage(Object element, Display display) {
- if( image == null ) {
+ if (image == null) {
try {
image = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/WindowTrim.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -119,7 +109,7 @@ public class TrimBarEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -127,50 +117,49 @@ public class TrimBarEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
- private Composite createForm(Composite parent, EMFDataBindingContext context,
- WritableValue master, boolean isImport) {
- parent = new Composite(parent,SWT.NONE);
+ private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) {
+ parent = new Composite(parent, SWT.NONE);
parent.setLayout(new GridLayout(3, false));
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
l.setText("Id");
l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
+
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -191,49 +180,49 @@ public class TrimBarEditor extends AbstractComponentEditor {
{
Label l = new Label(parent, SWT.NONE);
l.setText("Controls");
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
-
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
+
final TableViewer viewer = new TableViewer(parent);
viewer.setLabelProvider(new ComponentLabelProvider(editor));
viewer.setContentProvider(new ObservableListContentProvider());
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 300;
viewer.getControl().setLayoutData(gd);
-
+
IEMFListProperty prop = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
viewer.setInput(prop.observeDetail(getMaster()));
-
+
Composite buttonComp = new Composite(parent, SWT.NONE);
- buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
- GridLayout gl = new GridLayout(2,false);
- gl.marginLeft=0;
- gl.marginRight=0;
- gl.marginWidth=0;
- gl.marginHeight=0;
+ buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
+ GridLayout gl = new GridLayout(2, false);
+ gl.marginLeft = 0;
+ gl.marginRight = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
buttonComp.setLayout(gl);
Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText("Up");
b.setImage(getImage(b.getDisplay(), ARROW_UP));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) - 1;
- if( idx >= 0 ) {
+ if (idx >= 0) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
@@ -242,80 +231,76 @@ public class TrimBarEditor extends AbstractComponentEditor {
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText("Down");
b.setImage(getImage(b.getDisplay(), ARROW_DOWN));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) + 1;
- if( idx < container.getChildren().size() ) {
+ if (idx < container.getChildren().size()) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
});
-
- final ComboViewer typeViewer = new ComboViewer(buttonComp,SWT.READ_ONLY);
+
+ final ComboViewer typeViewer = new ComboViewer(buttonComp, SWT.READ_ONLY);
typeViewer.setContentProvider(new ArrayContentProvider());
typeViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
- return ((EClass)element).getName();
+ return ((EClass) element).getName();
}
});
- typeViewer.setInput(new Object[] {
- MenuPackageImpl.Literals.TOOL_BAR,
- MenuPackageImpl.Literals.TOOL_CONTROL
- });
+ typeViewer.setInput(new Object[] { MenuPackageImpl.Literals.TOOL_BAR, MenuPackageImpl.Literals.TOOL_CONTROL });
typeViewer.setSelection(new StructuredSelection(MenuPackageImpl.Literals.TOOL_BAR));
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- EObject toolbar = EcoreUtil.create((EClass) ((IStructuredSelection)typeViewer.getSelection()).getFirstElement());
+ EObject toolbar = EcoreUtil.create((EClass) ((IStructuredSelection) typeViewer.getSelection()).getFirstElement());
Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, toolbar);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
editor.setSelection(toolbar);
}
}
});
-
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText("Remove");
b.setImage(getImage(b.getDisplay(), TABLE_DELETE_IMAGE));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
-
+ if (!viewer.getSelection().isEmpty()) {
+ List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();
+
Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
}
});
}
-
+
return parent;
}
@@ -327,19 +312,17 @@ public class TrimBarEditor extends AbstractComponentEditor {
@Override
public String getDetailLabel(Object element) {
MGenericTrimContainer<?> trim = (MGenericTrimContainer<?>) element;
-
- if( trim.getSide() != null ) {
+
+ if (trim.getSide() != null) {
return trim.getSide().toString();
}
-
+
return null;
}
-
+
@Override
public FeaturePath[] getLabelProperties() {
- return new FeaturePath[] {
- FeaturePath.fromList(UiPackageImpl.Literals.GENERIC_TRIM_CONTAINER__SIDE)
- };
+ return new FeaturePath[] { FeaturePath.fromList(UiPackageImpl.Literals.GENERIC_TRIM_CONTAINER__SIDE) };
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimContributionEditor.java
index 55bbf9d6..b9fb8c60 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimContributionEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimContributionEditor.java
@@ -10,46 +10,35 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
-import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
-
-import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement;
-
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
-import org.eclipse.emf.databinding.EMFProperties;
-
import org.eclipse.core.resources.IProject;
-import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
-
-import java.util.List;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.Util;
+import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
-import org.eclipse.e4.tools.emf.ui.internal.ObservableColumnLabelProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.MenuIconDialogEditor;
-import org.eclipse.e4.ui.model.application.commands.MHandler;
+import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
-import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
-import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.databinding.EMFDataBindingContext;
+import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.IEMFListProperty;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
@@ -59,42 +48,28 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.swt.SWT;
-
-import org.eclipse.core.databinding.observable.value.WritableValue;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.emf.databinding.EMFDataBindingContext;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-
-import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
public class TrimContributionEditor extends AbstractComponentEditor {
private Composite composite;
private Image image;
private EMFDataBindingContext context;
private IProject project;
-
+
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
- private StackLayout stackLayout;
-
+ private EStackLayout stackLayout;
+
private static class Struct {
private final String label;
private final EClass eClass;
@@ -106,15 +81,15 @@ public class TrimContributionEditor extends AbstractComponentEditor {
this.separator = separator;
}
}
-
+
public TrimContributionEditor(EditingDomain editingDomain, IProject project, ModelEditor editor) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
this.project = project;
}
@Override
public Image getImage(Object element, Display display) {
- if( image == null ) {
+ if (image == null) {
try {
image = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/TrimContribution.gif")); //$NON-NLS-1$
} catch (MalformedURLException e) {
@@ -147,7 +122,7 @@ public class TrimContributionEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -155,21 +130,21 @@ public class TrimContributionEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
-
+
getMaster().setValue(object);
return composite;
}
@@ -180,11 +155,11 @@ public class TrimContributionEditor extends AbstractComponentEditor {
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -197,7 +172,7 @@ public class TrimContributionEditor extends AbstractComponentEditor {
t.setLayoutData(gd);
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -224,54 +199,53 @@ public class TrimContributionEditor extends AbstractComponentEditor {
context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.TRIM_CONTRIBUTION__POSITION_IN_PARENT).observeDetail(getMaster()));
}
-
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
l.setText("Controls");
- l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false));
-
+ l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));
+
final TableViewer viewer = new TableViewer(parent);
viewer.setLabelProvider(new ComponentLabelProvider(getEditor()));
viewer.setContentProvider(new ObservableListContentProvider());
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 300;
viewer.getControl().setLayoutData(gd);
-
+
IEMFListProperty prop = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
viewer.setInput(prop.observeDetail(getMaster()));
-
+
Composite buttonComp = new Composite(parent, SWT.NONE);
- buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
- GridLayout gl = new GridLayout(2,false);
- gl.marginLeft=0;
- gl.marginRight=0;
- gl.marginWidth=0;
- gl.marginHeight=0;
+ buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
+ GridLayout gl = new GridLayout(2, false);
+ gl.marginLeft = 0;
+ gl.marginRight = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
buttonComp.setLayout(gl);
Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText("Up");
b.setImage(getImage(b.getDisplay(), ARROW_UP));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) - 1;
- if( idx >= 0 ) {
+ if (idx >= 0) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
@@ -280,81 +254,77 @@ public class TrimContributionEditor extends AbstractComponentEditor {
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText("Down");
b.setImage(getImage(b.getDisplay(), ARROW_DOWN));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
- if( s.size() == 1 ) {
+ if (!viewer.getSelection().isEmpty()) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if (s.size() == 1) {
Object obj = s.getFirstElement();
MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
int idx = container.getChildren().indexOf(obj) + 1;
- if( idx < container.getChildren().size() ) {
+ if (idx < container.getChildren().size()) {
Command cmd = MoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, obj, idx);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
viewer.setSelection(new StructuredSelection(obj));
}
}
-
+
}
}
}
});
-
- final ComboViewer typeViewer = new ComboViewer(buttonComp,SWT.READ_ONLY);
+
+ final ComboViewer typeViewer = new ComboViewer(buttonComp, SWT.READ_ONLY);
typeViewer.setContentProvider(new ArrayContentProvider());
typeViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
- return ((EClass)element).getName();
+ return ((EClass) element).getName();
}
});
- typeViewer.setInput(new Object[] {
- MenuPackageImpl.Literals.TOOL_BAR,
- MenuPackageImpl.Literals.TOOL_CONTROL
- });
+ typeViewer.setInput(new Object[] { MenuPackageImpl.Literals.TOOL_BAR, MenuPackageImpl.Literals.TOOL_CONTROL });
typeViewer.setSelection(new StructuredSelection(MenuPackageImpl.Literals.TOOL_BAR));
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- EObject toolbar = EcoreUtil.create((EClass) ((IStructuredSelection)typeViewer.getSelection()).getFirstElement());
+ EObject toolbar = EcoreUtil.create((EClass) ((IStructuredSelection) typeViewer.getSelection()).getFirstElement());
Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, toolbar);
-
- if( cmd.canExecute() ) {
+
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
getEditor().setSelection(toolbar);
}
}
});
-
-
+
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText("Remove");
b.setImage(getImage(b.getDisplay(), TABLE_DELETE_IMAGE));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( ! viewer.getSelection().isEmpty() ) {
- List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
-
+ if (!viewer.getSelection().isEmpty()) {
+ List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();
+
Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
}
});
}
-
- ControlFactory.createTagsWidget(parent, this);
+
+ ControlFactory.createTagsWidget(parent, this);
return parent;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/WindowEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/WindowEditor.java
index 44363b33..35e393b9 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/WindowEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/WindowEditor.java
@@ -10,21 +10,6 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component;
-import org.eclipse.e4.tools.emf.ui.common.ImageTooltip;
-import org.eclipse.e4.ui.model.application.ui.MUILabel;
-import org.eclipse.emf.common.util.URI;
-
-import org.eclipse.e4.tools.emf.ui.common.Util;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog;
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.emf.edit.command.RemoveCommand;
-
-import org.eclipse.e4.tools.emf.ui.internal.Messages;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -37,22 +22,28 @@ import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
+import org.eclipse.e4.tools.emf.ui.common.ImageTooltip;
+import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.VirtualEntry;
import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.WindowIconDialogEditor;
import org.eclipse.e4.ui.model.application.commands.impl.CommandsPackageImpl;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
+import org.eclipse.e4.ui.model.application.ui.MUILabel;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.FeaturePath;
import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.action.Action;
@@ -66,6 +57,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -82,13 +74,13 @@ public class WindowEditor extends AbstractComponentEditor {
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
private IListProperty SHARED_ELEMENTS = EMFProperties.list(BasicPackageImpl.Literals.WINDOW__SHARED_ELEMENTS);
private IValueProperty WINDOW__MAIN_MENU = EMFProperties.value(BasicPackageImpl.Literals.WINDOW__MAIN_MENU);
-
+
private Action addMainMenu;
private Button createRemoveMainMenu;
- private StackLayout stackLayout;
-
+ private EStackLayout stackLayout;
+
public WindowEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) {
- super(editingDomain,editor);
+ super(editingDomain, editor);
this.project = project;
addMainMenu = new Action("Add Main Menu") {
@Override
@@ -100,7 +92,7 @@ public class WindowEditor extends AbstractComponentEditor {
@Override
public Image getImage(Object element, Display display) {
- if( image == null ) {
+ if (image == null) {
try {
image = loadSharedImage(display, new URL("platform:/plugin/org.eclipse.e4.tools.emf.ui/icons/full/modelelements/Window.gif"));
} catch (MalformedURLException e) {
@@ -128,7 +120,7 @@ public class WindowEditor extends AbstractComponentEditor {
context = new EMFDataBindingContext();
if (getEditor().isModelFragment()) {
composite = new Composite(parent, SWT.NONE);
- stackLayout = new StackLayout();
+ stackLayout = new EStackLayout();
composite.setLayout(stackLayout);
createForm(composite, context, getMaster(), false);
createForm(composite, context, getMaster(), true);
@@ -136,42 +128,41 @@ public class WindowEditor extends AbstractComponentEditor {
composite = createForm(parent, context, getMaster(), false);
}
}
-
- if( getEditor().isModelFragment() ) {
+
+ if (getEditor().isModelFragment()) {
Control topControl;
- if( Util.isImport((EObject) object) ) {
+ if (Util.isImport((EObject) object)) {
topControl = composite.getChildren()[1];
} else {
- topControl = composite.getChildren()[0];
+ topControl = composite.getChildren()[0];
}
-
- if( stackLayout.topControl != topControl ) {
+
+ if (stackLayout.topControl != topControl) {
stackLayout.topControl = topControl;
composite.layout(true, true);
}
}
- if( createRemoveMainMenu != null ) {
- createRemoveMainMenu.setSelection(((MWindow)object).getMainMenu() != null);
+ if (createRemoveMainMenu != null) {
+ createRemoveMainMenu.setSelection(((MWindow) object).getMainMenu() != null);
}
-
+
getMaster().setValue(object);
-
+
return composite;
}
- private Composite createForm(Composite parent, EMFDataBindingContext context,
- WritableValue master, boolean isImport) {
- parent = new Composite(parent,SWT.NONE);
+ private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) {
+ parent = new Composite(parent, SWT.NONE);
parent.setLayout(new GridLayout(3, false));
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
-
- if( isImport ) {
- ControlFactory.createFindImport(parent, this, context);
+
+ if (isImport) {
+ ControlFactory.createFindImport(parent, this, context);
return parent;
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -180,11 +171,11 @@ public class WindowEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(getMaster()));
}
-
+
// ------------------------------------------------------------
{
Label l = new Label(parent, SWT.NONE);
@@ -193,9 +184,9 @@ public class WindowEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__X).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__X).observeDetail(getMaster()));
}
// ------------------------------------------------------------
@@ -206,9 +197,9 @@ public class WindowEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__Y).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__Y).observeDetail(getMaster()));
}
// ------------------------------------------------------------
@@ -219,9 +210,9 @@ public class WindowEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__WIDTH).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__WIDTH).observeDetail(getMaster()));
}
// ------------------------------------------------------------
@@ -232,9 +223,9 @@ public class WindowEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
+ gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__HEIGHT).observeDetail(getMaster()));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.WINDOW__HEIGHT).observeDetail(getMaster()));
}
// ------------------------------------------------------------
@@ -247,7 +238,7 @@ public class WindowEditor extends AbstractComponentEditor {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL).observeDetail(master));
}
// ------------------------------------------------------------
@@ -260,7 +251,7 @@ public class WindowEditor extends AbstractComponentEditor {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
t.setLayoutData(gd);
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP).observeDetail(master));
}
// ------------------------------------------------------------
@@ -271,21 +262,21 @@ public class WindowEditor extends AbstractComponentEditor {
Text t = new Text(parent, SWT.BORDER);
t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master));
+ context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master));
new ImageTooltip(t) {
-
+
@Override
protected URI getImageURI() {
MUILabel part = (MUILabel) getMaster().getValue();
String uri = part.getIconURI();
- if( uri == null || uri.trim().length() == 0 ) {
+ if (uri == null || uri.trim().length() == 0) {
return null;
}
return URI.createURI(part.getIconURI());
}
};
-
+
final Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
b.setText("Find ...");
b.setImage(getImage(b.getDisplay(), SEARCH_IMAGE));
@@ -293,30 +284,30 @@ public class WindowEditor extends AbstractComponentEditor {
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- WindowIconDialogEditor dialog = new WindowIconDialogEditor(b.getShell(), project,getEditingDomain(),(MWindow) getMaster().getValue());
+ WindowIconDialogEditor dialog = new WindowIconDialogEditor(b.getShell(), project, getEditingDomain(), (MWindow) getMaster().getValue());
dialog.open();
}
});
}
-
+
{
Label l = new Label(parent, SWT.NONE);
l.setText("Main Menu");
l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
+
createRemoveMainMenu = new Button(parent, SWT.CHECK);
createRemoveMainMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
MWindow window = (MWindow) getMaster().getValue();
- if( window.getMainMenu() == null ) {
+ if (window.getMainMenu() == null) {
addMenu();
} else {
removeMenu();
}
}
});
- createRemoveMainMenu.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER,false,false,2,1));
+ createRemoveMainMenu.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
}
ControlFactory.createSelectedElement(parent, this, context, "Selected Element");
@@ -326,18 +317,18 @@ public class WindowEditor extends AbstractComponentEditor {
return parent;
}
-
+
void removeMenu() {
Command cmd = SetCommand.create(getEditingDomain(), getMaster().getValue(), BasicPackageImpl.Literals.WINDOW__MAIN_MENU, null);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
-
+
void addMenu() {
MMenu menu = MMenuFactory.INSTANCE.createMenu();
Command cmd = SetCommand.create(getEditingDomain(), getMaster().getValue(), BasicPackageImpl.Literals.WINDOW__MAIN_MENU, menu);
- if( cmd.canExecute() ) {
+ if (cmd.canExecute()) {
getEditingDomain().getCommandStack().execute(cmd);
}
}
@@ -345,11 +336,11 @@ public class WindowEditor extends AbstractComponentEditor {
@Override
public IObservableList getChildList(final Object element) {
final WritableList list = new WritableList();
- if( getEditor().isModelFragment() && Util.isImport((EObject) element) ) {
+ if (getEditor().isModelFragment() && Util.isImport((EObject) element)) {
return list;
}
-
- list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_HANDLER, HANDLER_CONTAINER__HANDLERS, element, "Handlers") {
+
+ list.add(new VirtualEntry<Object>(ModelEditor.VIRTUAL_HANDLER, HANDLER_CONTAINER__HANDLERS, element, "Handlers") {
@Override
protected boolean accepted(Object o) {
@@ -357,8 +348,8 @@ public class WindowEditor extends AbstractComponentEditor {
}
});
-
- list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_WINDOWS, WINDOW__WINDOWS, element, "Windows") {
+
+ list.add(new VirtualEntry<Object>(ModelEditor.VIRTUAL_WINDOWS, WINDOW__WINDOWS, element, "Windows") {
@Override
protected boolean accepted(Object o) {
@@ -367,7 +358,7 @@ public class WindowEditor extends AbstractComponentEditor {
});
- list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_WINDOW_CONTROLS, ELEMENT_CONTAINER__CHILDREN, element, "Controls") {
+ list.add(new VirtualEntry<Object>(ModelEditor.VIRTUAL_WINDOW_CONTROLS, ELEMENT_CONTAINER__CHILDREN, element, "Controls") {
@Override
protected boolean accepted(Object o) {
@@ -375,32 +366,32 @@ public class WindowEditor extends AbstractComponentEditor {
}
});
-
- list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_WINDOW_SHARED_ELEMENTS, SHARED_ELEMENTS, element, "Shared Elements" ) {
+
+ list.add(new VirtualEntry<Object>(ModelEditor.VIRTUAL_WINDOW_SHARED_ELEMENTS, SHARED_ELEMENTS, element, "Shared Elements") {
protected boolean accepted(Object o) {
return true;
}
});
-
+
MWindow window = (MWindow) element;
- if( window.getMainMenu() != null ) {
- list.add(0,window.getMainMenu());
+ if (window.getMainMenu() != null) {
+ list.add(0, window.getMainMenu());
}
-
+
WINDOW__MAIN_MENU.observe(element).addValueChangeListener(new IValueChangeListener() {
-
+
public void handleValueChange(ValueChangeEvent event) {
- if( event.diff.getOldValue() != null ) {
+ if (event.diff.getOldValue() != null) {
list.remove(event.diff.getOldValue());
- if( getMaster().getValue() == element ) {
- createRemoveMainMenu.setSelection(false);
+ if (getMaster().getValue() == element) {
+ createRemoveMainMenu.setSelection(false);
}
}
-
- if( event.diff.getNewValue() != null ) {
- list.add(0,event.diff.getNewValue());
- if( getMaster().getValue() == element ) {
- createRemoveMainMenu.setSelection(true);
+
+ if (event.diff.getNewValue() != null) {
+ list.add(0, event.diff.getNewValue());
+ if (getMaster().getValue() == element) {
+ createRemoveMainMenu.setSelection(true);
}
}
}
@@ -411,29 +402,27 @@ public class WindowEditor extends AbstractComponentEditor {
@Override
public String getDetailLabel(Object element) {
- MWindow window = (MWindow)element;
- if( window.getLabel() != null && window.getLabel().trim().length() > 0 ) {
+ MWindow window = (MWindow) element;
+ if (window.getLabel() != null && window.getLabel().trim().length() > 0) {
return window.getLabel();
}
return null;
}
-
+
@Override
public FeaturePath[] getLabelProperties() {
- return new FeaturePath[] {
- FeaturePath.fromList(UiPackageImpl.Literals.UI_LABEL__LABEL)
- };
+ return new FeaturePath[] { FeaturePath.fromList(UiPackageImpl.Literals.UI_LABEL__LABEL) };
}
-
+
@Override
public List<Action> getActions(Object element) {
List<Action> actions = new ArrayList<Action>();
-
+
MWindow window = (MWindow) element;
- if( window.getMainMenu() == null ) {
+ if (window.getMainMenu() == null) {
actions.add(addMainMenu);
}
-
+
return actions;
}
} \ No newline at end of file

Back to the top