Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2010-03-14 10:53:16 +0000
committerThomas Schindl2010-03-14 10:53:16 +0000
commit649a809a977d62b3204ad2f642e4a5347e9ec4bd (patch)
tree60806094bd3459f2f7fa54ed9b22421126ecf571 /bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4
parent70a30f7263dcba92a344f4d642129a13edeff426 (diff)
downloadorg.eclipse.e4.tools-649a809a977d62b3204ad2f642e4a5347e9ec4bd.tar.gz
org.eclipse.e4.tools-649a809a977d62b3204ad2f642e4a5347e9ec4bd.tar.xz
org.eclipse.e4.tools-649a809a977d62b3204ad2f642e4a5347e9ec4bd.zip
[Bug 304584] - [Tooling] Implement Workbench-Model-Tooling
* doing adds with a dropdown
Diffstat (limited to 'bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4')
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java2
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CommandEditor.java1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartSashContainerEditor.java113
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VControlEditor.java104
4 files changed, 150 insertions, 70 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
index 5503557b..a2f28595 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -258,7 +258,7 @@ public class ModelEditor {
registerEditor( MApplicationPackage.Literals.HANDLER, new HandlerEditor(modelProvider.getEditingDomain()));
registerEditor( MApplicationPackage.Literals.COMMAND,new CommandEditor(modelProvider.getEditingDomain()));
registerEditor( MApplicationPackage.Literals.WINDOW, new WindowEditor(modelProvider.getEditingDomain()));
- registerEditor( MApplicationPackage.Literals.PART_SASH_CONTAINER, new PartSashContainerEditor(modelProvider.getEditingDomain()));
+ registerEditor( MApplicationPackage.Literals.PART_SASH_CONTAINER, new PartSashContainerEditor(modelProvider.getEditingDomain(), this));
registerEditor( MApplicationPackage.Literals.PART_STACK, new PartStackEditor(modelProvider.getEditingDomain()));
registerEditor( MApplicationPackage.Literals.WINDOW_TRIM, new WindowTrimEditor(modelProvider.getEditingDomain()));
registerEditor( MApplicationPackage.Literals.TOOL_BAR, new ToolBarEditor(modelProvider.getEditingDomain()));
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CommandEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CommandEditor.java
index e418a4cf..85b70bb6 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CommandEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CommandEditor.java
@@ -20,7 +20,6 @@ import org.eclipse.e4.ui.model.application.MApplicationFactory;
import org.eclipse.e4.ui.model.application.MApplicationPackage;
import org.eclipse.e4.ui.model.application.MCommand;
import org.eclipse.e4.ui.model.application.MCommandParameter;
-import org.eclipse.e4.ui.model.application.MParameter;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.FeaturePath;
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 7336c2be..349e9f58 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
@@ -12,6 +12,7 @@ package org.eclipse.e4.tools.emf.ui.internal.common.component;
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;
@@ -21,27 +22,43 @@ 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.component.AbstractComponentEditor;
+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.MApplicationFactory;
import org.eclipse.e4.ui.model.application.MApplicationPackage;
import org.eclipse.e4.ui.model.application.MPartSashContainer;
+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.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.edit.command.AddCommand;
+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;
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.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.Display;
import org.eclipse.swt.widgets.Label;
@@ -53,12 +70,13 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
private Image vImage;
private Image hImage;
private EMFDataBindingContext context;
+ private ModelEditor editor;
private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN);
- public PartSashContainerEditor(EditingDomain editingDomain) {
+ public PartSashContainerEditor(EditingDomain editingDomain, ModelEditor editor) {
super(editingDomain);
- // TODO Auto-generated constructor stub
+ this.editor = editor;
}
@Override
@@ -188,6 +206,97 @@ public class PartSashContainerEditor extends AbstractComponentEditor {
ControlFactory.createTagsWidget(parent, this);
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Controls");
+ l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+ final TableViewer viewer = new TableViewer(parent);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 200;
+ viewer.getControl().setLayoutData(gd);
+ ObservableListContentProvider cp = new ObservableListContentProvider();
+ viewer.setContentProvider(cp);
+ viewer.setLabelProvider(new ComponentLabelProvider(editor));
+
+ IEMFListProperty prop = EMFProperties.list(MApplicationPackage.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.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 = 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));
+
+ final ComboViewer childrenDropDown = new ComboViewer(buttonComp);
+ childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+ childrenDropDown.setContentProvider(new ArrayContentProvider());
+ childrenDropDown.setLabelProvider(new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ EClass eclass = (EClass) element;
+ return eclass.getName();
+ }
+ });
+ childrenDropDown.setInput(new EClass[] {
+ MApplicationPackage.Literals.PART_SASH_CONTAINER,
+ MApplicationPackage.Literals.PART_STACK,
+ MApplicationPackage.Literals.PART
+ });
+ childrenDropDown.setSelection(new StructuredSelection(MApplicationPackage.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();
+ EObject eObject = MApplicationFactory.eINSTANCE.create(eClass);
+
+ Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, eObject);
+
+ if( cmd.canExecute() ) {
+ getEditingDomain().getCommandStack().execute(cmd);
+ editor.setSelection(eObject);
+ }
+ }
+ }
+ });
+
+ 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.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if( ! viewer.getSelection().isEmpty() ) {
+ List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
+
+ Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
+ if( cmd.canExecute() ) {
+ getEditingDomain().getCommandStack().execute(cmd);
+ }
+ }
+ }
+ });
+ }
+
return parent;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VControlEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VControlEditor.java
index af30d970..5cd4a5a9 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VControlEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VControlEditor.java
@@ -20,19 +20,21 @@ import org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.VirtualEntry;
import org.eclipse.e4.ui.model.application.MApplicationFactory;
import org.eclipse.e4.ui.model.application.MApplicationPackage;
-import org.eclipse.e4.ui.model.application.MPart;
-import org.eclipse.e4.ui.model.application.MPartSashContainer;
-import org.eclipse.e4.ui.model.application.MPartStack;
-import org.eclipse.e4.ui.model.application.MPerspectiveStack;
import org.eclipse.emf.common.command.Command;
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.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
+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;
import org.eclipse.swt.events.SelectionAdapter;
@@ -113,7 +115,7 @@ public class VControlEditor extends AbstractComponentEditor {
Composite buttonComp = new Composite(parent, SWT.NONE);
buttonComp.setLayoutData(new GridData(GridData.FILL,GridData.END,false,false));
- GridLayout gl = new GridLayout();
+ GridLayout gl = new GridLayout(2,false);
gl.marginLeft=0;
gl.marginRight=0;
gl.marginWidth=0;
@@ -123,92 +125,62 @@ public class VControlEditor extends AbstractComponentEditor {
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));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
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));
-
- b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
- b.setText("Add Sash");
- 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) {
- MPartSashContainer handler = MApplicationFactory.eINSTANCE.createPartSashContainer();
- Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, handler);
-
- if( cmd.canExecute() ) {
- getEditingDomain().getCommandStack().execute(cmd);
- editor.setSelection(handler);
- }
- }
- });
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false,2,1));
- b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
- b.setText("Add PartStack");
- b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- b.addSelectionListener(new SelectionAdapter() {
+ final ComboViewer childrenDropDown = new ComboViewer(buttonComp);
+ childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+ childrenDropDown.setContentProvider(new ArrayContentProvider());
+ childrenDropDown.setLabelProvider(new LabelProvider() {
@Override
- public void widgetSelected(SelectionEvent e) {
- MPartStack handler = MApplicationFactory.eINSTANCE.createPartStack();
- Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, handler);
-
- if( cmd.canExecute() ) {
- getEditingDomain().getCommandStack().execute(cmd);
- editor.setSelection(handler);
- }
+ public String getText(Object element) {
+ EClass eclass = (EClass) element;
+ return eclass.getName();
}
});
-
-
- b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
- b.setText("Add PerspectiveStack");
- 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) {
- MPerspectiveStack handler = MApplicationFactory.eINSTANCE.createPerspectiveStack();
- Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, handler);
-
- if( cmd.canExecute() ) {
- getEditingDomain().getCommandStack().execute(cmd);
- editor.setSelection(handler);
- }
- }
+ childrenDropDown.setInput(new EClass[] {
+ MApplicationPackage.Literals.PERSPECTIVE_STACK,
+ MApplicationPackage.Literals.PART_SASH_CONTAINER,
+ MApplicationPackage.Literals.PART_STACK,
+ MApplicationPackage.Literals.PART
});
+ childrenDropDown.setSelection(new StructuredSelection(MApplicationPackage.Literals.PERSPECTIVE_STACK));
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
- b.setText("Add Part");
b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
- b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- MPart handler = MApplicationFactory.eINSTANCE.createPart();
- Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, handler);
-
- if( cmd.canExecute() ) {
- getEditingDomain().getCommandStack().execute(cmd);
- editor.setSelection(handler);
+ if( ! childrenDropDown.getSelection().isEmpty() ) {
+ EClass eClass = (EClass) ((IStructuredSelection)childrenDropDown.getSelection()).getFirstElement();
+ EObject eObject = MApplicationFactory.eINSTANCE.create(eClass);
+
+ Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, eObject);
+
+ if( cmd.canExecute() ) {
+ getEditingDomain().getCommandStack().execute(cmd);
+ editor.setSelection(eObject);
+ }
}
}
});
-
+
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));
+ 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<?> controls = ((IStructuredSelection)viewer.getSelection()).toList();
- Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, controls);
+ List<?> elements = ((IStructuredSelection)viewer.getSelection()).toList();
+
+ Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), MApplicationPackage.Literals.ELEMENT_CONTAINER__CHILDREN, elements);
if( cmd.canExecute() ) {
getEditingDomain().getCommandStack().execute(cmd);
}

Back to the top