Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2010-04-15 16:18:13 +0000
committerThomas Schindl2010-04-15 16:18:13 +0000
commite368adda276c5740c120e9fa7dbfb8577f55b9c9 (patch)
tree8ac0f9050d7a4289b3207b91ce873c078b4ee5c0
parent9b481c04fd344caa4e1ff539da01fccb03eaa1a5 (diff)
downloadorg.eclipse.e4.tools-e368adda276c5740c120e9fa7dbfb8577f55b9c9.tar.gz
org.eclipse.e4.tools-e368adda276c5740c120e9fa7dbfb8577f55b9c9.tar.xz
org.eclipse.e4.tools-e368adda276c5740c120e9fa7dbfb8577f55b9c9.zip
[Bug 304584] - [Tooling] Implement Workbench-Model-Tooling
* switch back to tags as a list
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java91
1 files changed, 54 insertions, 37 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java
index c38b76c2..b918e975 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java
@@ -12,7 +12,6 @@ package org.eclipse.e4.tools.emf.ui.internal.common.component;
import java.util.Arrays;
import java.util.List;
-import java.util.Map.Entry;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
@@ -30,12 +29,10 @@ import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
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.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
@@ -178,42 +175,44 @@ public class ControlFactory {
l.setText(Messages.ControlFactory_Tags);
l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
- final TableViewer tableviewer = new TableViewer(parent);
-
- ObservableListContentProvider cp = new ObservableListContentProvider();
- tableviewer.setContentProvider(cp);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = 120;
- tableviewer.getControl().setLayoutData(gd);
-
- TableViewerColumn column = new TableViewerColumn(tableviewer, SWT.NONE);
- column.getColumn().setText(Messages.ControlFactory_Key);
- column.getColumn().setWidth(200);
- column.setLabelProvider(new ColumnLabelProvider() {
- @SuppressWarnings("unchecked")
+ final Text tagText = new Text(parent, SWT.BORDER);
+ tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ tagText.addKeyListener(new KeyAdapter() {
@Override
- public String getText(Object element) {
- Entry<String, String> entry = (Entry<String, String>) element;
- return entry.getKey();
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == SWT.CR || e.keyCode == SWT.LF) {
+ handleAddText(editor, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, tagText);
+ }
+ }
+ });
+
+ Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
+ b.setText(Messages.ControlFactory_Add);
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleAddText(editor, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, tagText);
}
- });
-
- //FIXME How can we react upon changes in the Map-Value?
- column = new TableViewerColumn(tableviewer, SWT.NONE);
- column.getColumn().setText(Messages.ControlFactory_Value);
- column.getColumn().setWidth(200);
- column.setLabelProvider(new ColumnLabelProvider() {
- @SuppressWarnings("unchecked")
+ });
+ b.setImage(editor.getImage(b.getDisplay(), AbstractComponentEditor.TABLE_ADD_IMAGE));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
+
+ l = new Label(parent, SWT.NONE);
+ final TableViewer viewer = new TableViewer(parent);
+ viewer.setContentProvider(new ObservableListContentProvider());
+ viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
- Entry<String, String> entry = (Entry<String, String>) element;
- return entry.getValue();
+ return element.toString();
}
});
-
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 120;
+ viewer.getControl().setLayoutData(gd);
+
IEMFEditListProperty prop = EMFEditProperties.list(editor.getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS);
- tableviewer.setInput(prop.observeDetail(editor.getMaster()));
-
+ viewer.setInput(prop.observeDetail(editor.getMaster()));
+
Composite buttonComp = new Composite(parent, SWT.NONE);
buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
GridLayout gl = new GridLayout();
@@ -222,16 +221,34 @@ public class ControlFactory {
gl.marginWidth = 0;
gl.marginHeight = 0;
buttonComp.setLayout(gl);
-
- Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
- b.setText(Messages.ControlFactory_Add);
- b.setImage(editor.getImage(b.getDisplay(), AbstractComponentEditor.TABLE_ADD_IMAGE));
+
+ b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
+ b.setText(Messages.ControlFactory_Up);
+ b.setImage(editor.getImage(b.getDisplay(), AbstractComponentEditor.ARROW_UP));
+ b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+
+ b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
+ b.setText(Messages.ControlFactory_Down);
+ b.setImage(editor.getImage(b.getDisplay(), AbstractComponentEditor.ARROW_DOWN));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText(Messages.ControlFactory_Remove);
b.setImage(editor.getImage(b.getDisplay(), AbstractComponentEditor.TABLE_DELETE_IMAGE));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ if( ! s.isEmpty() ) {
+ MApplicationElement appEl = (MApplicationElement) editor.getMaster().getValue();
+ Command cmd = RemoveCommand.create(editor.getEditingDomain(), appEl, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, s.toList());
+ if( cmd.canExecute() ) {
+ editor.getEditingDomain().getCommandStack().execute(cmd);
+ }
+ }
+ }
+ });
}
private static void handleAddText( AbstractComponentEditor editor, EStructuralFeature feature, Text tagText) {
@@ -249,4 +266,4 @@ public class ControlFactory {
tagText.setText(""); //$NON-NLS-1$
}
}
-}
+} \ No newline at end of file

Back to the top