Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2010-04-11 18:29:57 +0000
committerThomas Schindl2010-04-11 18:29:57 +0000
commit98f2af40b1569c8d7f61472266b3618c89b4557f (patch)
treed0fd2ec6bc06c7a6750bd64af7241c24f2592e35
parent83a1715d6e0d3e09038161656c93e013c223c94e (diff)
downloadorg.eclipse.e4.tools-98f2af40b1569c8d7f61472266b3618c89b4557f.tar.gz
org.eclipse.e4.tools-98f2af40b1569c8d7f61472266b3618c89b4557f.tar.xz
org.eclipse.e4.tools-98f2af40b1569c8d7f61472266b3618c89b4557f.zip
[Bug 308722] - [Tooling] Align ModelEditor to changes in Workbench-Model
* fixed presentation of tags * fixed Java5 warnings from classes copied from org.eclipse.ui.ide
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PatternFilter.java6
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/StringMatcher.java2
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java91
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/KeyBindingEditor.java2
4 files changed, 42 insertions, 59 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PatternFilter.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PatternFilter.java
index 23ff9a50..6fc7603d 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PatternFilter.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PatternFilter.java
@@ -38,12 +38,12 @@ public class PatternFilter extends ViewerFilter {
/*
* Cache of filtered elements in the tree
*/
- private Map cache = new HashMap();
+ private Map<Object,Object[]> cache = new HashMap<Object,Object[]>();
/*
* Maps parent elements to TRUE or FALSE
*/
- private Map foundAnyCache = new HashMap();
+ private Map<Object,Boolean> foundAnyCache = new HashMap<Object,Boolean>();
private boolean useCache = false;
@@ -288,7 +288,7 @@ public class PatternFilter extends ViewerFilter {
* @return an array of words
*/
private String[] getWords(String text){
- List words = new ArrayList();
+ List<String> words = new ArrayList<String>();
// Break the text up into words, separating based on whitespace and
// common punctuation.
// Previously used String.split(..., "\\W"), where "\W" is a regular
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/StringMatcher.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/StringMatcher.java
index ddde765f..cfd87687 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/StringMatcher.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/StringMatcher.java
@@ -284,7 +284,7 @@ public class StringMatcher {
}
}
- Vector temp = new Vector();
+ Vector<String> temp = new Vector<String>();
int pos = 0;
StringBuffer buf = new StringBuffer();
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 1e7040c8..eeb94ed7 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
@@ -2,6 +2,7 @@ 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.ui.model.application.MApplication;
@@ -18,10 +19,12 @@ 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;
@@ -37,7 +40,7 @@ import org.eclipse.swt.widgets.Text;
public class ControlFactory {
public static void createBindingsWidget(Composite parent, final AbstractComponentEditor editor) {
Label l = new Label(parent, SWT.NONE);
- l.setText("Bindings");
+ l.setText("Binding Contexts");
l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
final Text t = new Text(parent, SWT.BORDER);
@@ -164,44 +167,42 @@ public class ControlFactory {
l.setText("Tags");
l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
- final Text tagText = new Text(parent, SWT.BORDER);
- tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- tagText.addKeyListener(new KeyAdapter() {
- @Override
- 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("Add");
- b.addSelectionListener(new SelectionAdapter() {
+ 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("Key");
+ column.getColumn().setWidth(200);
+ column.setLabelProvider(new ColumnLabelProvider() {
+ @SuppressWarnings("unchecked")
@Override
- public void widgetSelected(SelectionEvent e) {
- handleAddText(editor, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, tagText);
+ public String getText(Object element) {
+ Entry<String, String> entry = (Entry<String, String>) element;
+ return entry.getKey();
}
- });
- 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() {
+ });
+
+ //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);
+ column.setLabelProvider(new ColumnLabelProvider() {
+ @SuppressWarnings("unchecked")
@Override
public String getText(Object element) {
- return element.toString();
+ Entry<String, String> entry = (Entry<String, String>) element;
+ return entry.getValue();
}
});
- 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);
- viewer.setInput(prop.observeDetail(editor.getMaster()));
-
+ tableviewer.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();
@@ -210,34 +211,16 @@ public class ControlFactory {
gl.marginWidth = 0;
gl.marginHeight = 0;
buttonComp.setLayout(gl);
-
- b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
- b.setText("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("Down");
- b.setImage(editor.getImage(b.getDisplay(), AbstractComponentEditor.ARROW_DOWN));
+
+ Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
+ b.setText("Add ...");
+ b.setImage(editor.getImage(b.getDisplay(), AbstractComponentEditor.TABLE_ADD_IMAGE));
b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setText("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) {
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/KeyBindingEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/KeyBindingEditor.java
index 60a78718..7e0c05b4 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/KeyBindingEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/KeyBindingEditor.java
@@ -169,7 +169,7 @@ public class KeyBindingEditor extends AbstractComponentEditor {
IEMFEditListProperty prop = EMFEditProperties.list(getEditingDomain(), CommandsPackageImpl.Literals.KEY_BINDING__PARAMETERS);
TableViewerColumn column = new TableViewerColumn(tableviewer, SWT.NONE);
- column.getColumn().setText("Tag");
+ column.getColumn().setText("Key");
column.getColumn().setWidth(200);
column.setEditingSupport(new EditingSupport(tableviewer) {
private TextCellEditor cellEditor = new TextCellEditor(tableviewer.getTable());

Back to the top