Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common')
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ComponentLabelProvider.java141
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java233
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/VirtualEntry.java78
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ApplicationEditor.java53
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentEditor.java151
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentsEditor.java51
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartDescriptorEditor.java37
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartEditor.java206
8 files changed, 950 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ComponentLabelProvider.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ComponentLabelProvider.java
new file mode 100644
index 00000000..2030f986
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ComponentLabelProvider.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.tools.emf.ui.internal.common;
+
+import org.eclipse.e4.ui.model.application.MModelComponent;
+import org.eclipse.e4.ui.model.application.MModelComponents;
+import org.eclipse.e4.ui.model.application.MPart;
+import org.eclipse.e4.ui.model.application.MPartDescriptor;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.TextStyle;
+
+public class ComponentLabelProvider extends StyledCellLabelProvider {
+ private Image modelComponentsImage;
+ private Image modelComonentImage;
+ private Image partsImage;
+ private Image menusImage;
+ private Image partImage;
+ private Image partDescriptorImage;
+
+ @Override
+ public void update(final ViewerCell cell) {
+ if( cell.getElement() instanceof MModelComponents ) {
+ cell.setText("Model Components");
+ if( modelComponentsImage == null ) {
+ modelComponentsImage = new Image(cell.getControl().getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/application_view_icons.png"));
+ }
+ cell.setImage(modelComponentsImage);
+ } else if( cell.getElement() instanceof MModelComponent ) {
+ MModelComponent m = (MModelComponent) cell.getElement();
+ StyledString styledString = new StyledString("Model Component", null);
+ String decoration = " - " + m.getParentID();
+ Styler styler = new Styler() {
+
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ textStyle.foreground = cell.getControl().getDisplay().getSystemColor(SWT.COLOR_GRAY);
+ }
+ };
+
+ styledString.append(decoration, styler);
+ cell.setText(styledString.getString());
+ cell.setStyleRanges(styledString.getStyleRanges());
+ if( modelComonentImage == null ) {
+ modelComonentImage = new Image(cell.getControl().getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/package_go.png"));
+ }
+ cell.setImage(modelComonentImage);
+ } else if( cell.getElement() instanceof VirtualEntry<?> ) {
+ String s = cell.getElement().toString();
+ cell.setText(s);
+ if( "Parts".equals(s) ) {
+ if( partsImage == null ) {
+ partsImage = new Image(cell.getControl().getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/application_double.png"));
+ }
+ cell.setImage(partsImage);
+ } else if( "Menus".equals(s) ) {
+ if( menusImage == null ) {
+ menusImage = new Image(cell.getControl().getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/cog.png"));
+ }
+ cell.setImage(menusImage);
+ }
+ } else if( cell.getElement() instanceof MPart ) {
+ MPart part = (MPart) cell.getElement();
+ String label;
+ if( cell.getElement() instanceof MPartDescriptor ) {
+ label = "Part Descriptor";
+ if( partDescriptorImage == null ) {
+ partDescriptorImage = new Image(cell.getControl().getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/application_form_edit.png"));
+ }
+ cell.setImage(partImage);
+ } else {
+ label = "Part";
+ if( partImage == null ) {
+ partImage = new Image(cell.getControl().getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/application_form.png"));
+ }
+ cell.setImage(partImage);
+ }
+ StyledString styledString = new StyledString(label, null);
+ String decoration = " - " + part.getLabel();
+ Styler styler = new Styler() {
+
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ textStyle.foreground = cell.getControl().getDisplay().getSystemColor(SWT.COLOR_GRAY);
+ }
+ };
+
+ styledString.append(decoration, styler);
+ cell.setText(styledString.getString());
+ cell.setStyleRanges(styledString.getStyleRanges());
+ } else {
+ cell.setText(cell.getElement()+"");
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if( modelComponentsImage != null ) {
+ modelComponentsImage.dispose();
+ modelComponentsImage = null;
+ }
+
+ if( modelComonentImage != null ) {
+ modelComonentImage.dispose();
+ modelComonentImage = null;
+ }
+
+ if( partsImage != null ) {
+ partsImage.dispose();
+ partsImage = null;
+ }
+
+ if( menusImage != null ) {
+ menusImage.dispose();
+ menusImage = null;
+ }
+
+ if( partImage != null ) {
+ partImage.dispose();
+ partImage = null;
+ }
+
+ if( partDescriptorImage != null ) {
+ partDescriptorImage.dispose();
+ partDescriptorImage = null;
+ }
+ super.dispose();
+ }
+}
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
new file mode 100644
index 00000000..dee48397
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.tools.emf.ui.internal.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.list.WritableList;
+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
+import org.eclipse.core.databinding.property.list.IListProperty;
+import org.eclipse.e4.tools.emf.ui.common.IModelResource;
+import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.e4.tools.emf.ui.internal.ShadowComposite;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.ApplicationEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.ModelComponentEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.ModelComponentsEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.PartDescriptorEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.PartEditor;
+import org.eclipse.e4.ui.model.application.MApplicationPackage;
+import org.eclipse.e4.ui.model.application.MModelComponent;
+import org.eclipse.e4.ui.model.application.MModelComponents;
+import org.eclipse.e4.ui.model.application.MPart;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider;
+import org.eclipse.jface.databinding.viewers.TreeStructureAdvisor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+public class ModelEditor {
+ private static final int VIRTUAL_MENU = 1;
+ private static final int VIRTUAL_PART = 2;
+ private static final int VIRTUAL_HANDLER = 3;
+ private static final int VIRTUAL_BINDING = 4;
+
+ private Map<EClass, AbstractComponentEditor> editorMap = new HashMap<EClass, AbstractComponentEditor>();
+// private List<AbstractComponentEditor> editors = new ArrayList<AbstractComponentEditor>();
+
+ private TreeViewer viewer;
+ private IModelResource modelProvider;
+
+ @Inject
+ public ModelEditor(Composite composite, IModelResource modelProvider) {
+ this.modelProvider = modelProvider;
+ registerDefaultEditors();
+ SashForm form = new SashForm(composite, SWT.HORIZONTAL);
+ form.setBackground(form.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ viewer = createTreeViewerArea(form);
+
+ Composite parent = new Composite(form,SWT.NONE);
+ parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ FillLayout l = new FillLayout();
+ l.marginWidth=5;
+ parent.setLayout(l);
+
+ ShadowComposite editingArea = new ShadowComposite(parent,SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.marginTop=0;
+ gl.marginHeight=0;
+ editingArea.setLayout(gl);
+ editingArea.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ editingArea.setData("org.eclipse.e4.ui.css.CssClassName","contentContainer");
+
+ Composite headerContainer = new Composite(editingArea,SWT.NONE);
+ headerContainer.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ headerContainer.setData("org.eclipse.e4.ui.css.CssClassName", "headerSectionContainer");
+ headerContainer.setLayout(new GridLayout(2, false));
+ headerContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ final Label iconLabel = new Label(headerContainer,SWT.NONE);
+ iconLabel.setLayoutData(new GridData(20, 20));
+
+ final Label textLabel = new Label(headerContainer, SWT.NONE);
+ textLabel.setData("org.eclipse.e4.ui.css.CssClassName", "sectionHeader");
+ textLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ final Composite contentContainer = new Composite(editingArea,SWT.NONE);
+ contentContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
+ final StackLayout layout = new StackLayout();
+ contentContainer.setLayout(layout);
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ if( ! event.getSelection().isEmpty() ) {
+ IStructuredSelection s = (IStructuredSelection) event.getSelection();
+ if( s.getFirstElement() instanceof EObject ) {
+ EObject obj = (EObject) s.getFirstElement();
+ AbstractComponentEditor editor = editorMap.get(obj.eClass());
+ if( editor != null ) {
+ textLabel.setText(editor.getLabel());
+ iconLabel.setImage(editor.getImage(iconLabel.getDisplay()));
+ Composite comp = editor.getEditor(contentContainer, s.getFirstElement());
+ comp.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ layout.topControl = comp;
+ contentContainer.layout(true);
+ }
+ }
+ }
+ }
+ });
+
+ form.setWeights(new int[] { 1 , 2 });
+ }
+
+ private TreeViewer createTreeViewerArea(Composite parent) {
+ parent = new Composite(parent,SWT.NONE);
+ parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ FillLayout l = new FillLayout();
+ l.marginWidth=5;
+ parent.setLayout(l);
+ ShadowComposite editingArea = new ShadowComposite(parent,SWT.NONE);
+ editingArea.setLayout(new FillLayout());
+ TreeViewer viewer = new TreeViewer(editingArea);
+ viewer.setLabelProvider(new ComponentLabelProvider());
+ ObservableListTreeContentProvider contentProvider = new ObservableListTreeContentProvider(
+ new ObservableFactoryImpl(), new TreeStructureAdvisorImpl());
+ viewer.setContentProvider(contentProvider);
+ viewer.setInput(modelProvider.getRoot());
+
+ return viewer;
+ }
+
+ private void registerDefaultEditors() {
+ registerEditor( MApplicationPackage.Literals.APPLICATION, new ApplicationEditor());
+ registerEditor( MApplicationPackage.Literals.MODEL_COMPONENTS, new ModelComponentsEditor());
+ registerEditor( MApplicationPackage.Literals.MODEL_COMPONENT, new ModelComponentEditor());
+ registerEditor( MApplicationPackage.Literals.PART, new PartEditor());
+ registerEditor( MApplicationPackage.Literals.PART_DESCRIPTOR, new PartDescriptorEditor());
+ }
+
+ public void registerEditor(EClass eClass, AbstractComponentEditor editor) {
+ editorMap.put(eClass, editor);
+ }
+
+ private static class TreeStructureAdvisorImpl extends TreeStructureAdvisor {
+
+ }
+
+ private static class ObservableFactoryImpl implements IObservableFactory {
+ private IListProperty MODEL_COMPONENTS__COMPONENTS = EMFProperties.list(MApplicationPackage.Literals.MODEL_COMPONENTS__COMPONENTS);
+ private IListProperty MODEL_COMPONENT__CHILDREN = EMFProperties.list(MApplicationPackage.Literals.MODEL_COMPONENT__CHILDREN);
+ private IListProperty PART__MENUS = EMFProperties.list(MApplicationPackage.Literals.PART__MENUS);
+ private IListProperty HANDLER_CONTAINER__HANDLERS = EMFProperties.list(MApplicationPackage.Literals.HANDLER_CONTAINER__HANDLERS);
+ private IListProperty BINDING_CONTAINER__BINDINGS = EMFProperties.list(MApplicationPackage.Literals.BINDING_CONTAINER__BINDINGS);
+
+ public IObservable createObservable(Object target) {
+ if( target instanceof IObservableList ) {
+ return (IObservable) target;
+ } else if( target instanceof MModelComponents ) {
+ return MODEL_COMPONENTS__COMPONENTS.observe(target);
+ } else if( target instanceof MModelComponent ) {
+ WritableList list = new WritableList();
+ list.add(new VirtualEntry<Object>( VIRTUAL_MENU, MODEL_COMPONENT__CHILDREN, target, "Menus") {
+
+ @Override
+ protected boolean accepted(Object o) {
+ return false;
+ }
+
+ });
+ list.add(new VirtualEntry<Object>( VIRTUAL_PART, MODEL_COMPONENT__CHILDREN, target, "Parts") {
+
+ @Override
+ protected boolean accepted(Object o) {
+ return o instanceof MPart;
+ }
+
+ });
+ return list;
+ } else if( target instanceof VirtualEntry<?> ) {
+ return ((VirtualEntry<?>)target).getList();
+ } else if( target instanceof MPart ) {
+ WritableList list = new WritableList();
+ list.add(new VirtualEntry<Object>( VIRTUAL_MENU, PART__MENUS, target, "Menus") {
+
+ @Override
+ protected boolean accepted(Object o) {
+ return true;
+ }
+
+ });
+
+ list.add(new VirtualEntry<Object>( VIRTUAL_HANDLER, HANDLER_CONTAINER__HANDLERS, target, "Handlers") {
+
+ @Override
+ protected boolean accepted(Object o) {
+ return true;
+ }
+
+ });
+
+ list.add(new VirtualEntry<Object>( VIRTUAL_BINDING, BINDING_CONTAINER__BINDINGS, target, "Bindings") {
+
+ @Override
+ protected boolean accepted(Object o) {
+ return true;
+ }
+
+ });
+
+ return list;
+ }
+
+ // TODO Auto-generated method stub
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/VirtualEntry.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/VirtualEntry.java
new file mode 100644
index 00000000..a045a765
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/VirtualEntry.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.tools.emf.ui.internal.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.list.IListChangeListener;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.list.ListChangeEvent;
+import org.eclipse.core.databinding.observable.list.ListDiff;
+import org.eclipse.core.databinding.observable.list.WritableList;
+import org.eclipse.core.databinding.property.list.IListProperty;
+
+public abstract class VirtualEntry<M> {
+ private int id;
+ private Object originalParent;
+ private String label;
+ private IObservableList list;
+
+ public VirtualEntry(int id, IListProperty property, Object originalParent, String label) {
+ this.id = id;
+ this.originalParent = originalParent;
+ this.label = label;
+ this.list = new WritableList();
+ IObservableList origList = property.observe(originalParent);
+ list.addAll(cleanedList(origList));
+
+ origList.addListChangeListener(new IListChangeListener() {
+
+ public void handleListChange(ListChangeEvent event) {
+ List<Object> clean = cleanedList(event.getObservableList());
+ ListDiff diff = Diffs.computeListDiff(VirtualEntry.this.list, clean);
+ diff.applyTo(VirtualEntry.this.list);
+ }
+ });
+ }
+
+ private List<Object> cleanedList(IObservableList list) {
+ List<Object> l = new ArrayList<Object>(list.size());
+
+ for( Object o : list ) {
+ if( accepted((M) o) ) {
+ l.add(o);
+ }
+ }
+
+ return l;
+ }
+
+ protected abstract boolean accepted(M o);
+
+ public IObservableList getList() {
+ return list;
+ }
+
+ public Object getOriginalParent() {
+ return originalParent;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ApplicationEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ApplicationEditor.java
new file mode 100644
index 00000000..0e59ccdf
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ApplicationEditor.java
@@ -0,0 +1,53 @@
+package org.eclipse.e4.tools.emf.ui.internal.common.component;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+public class ApplicationEditor extends AbstractComponentEditor {
+ private Composite composite;
+ private WritableValue master = new WritableValue();
+ private Image image;
+ private DataBindingContext context;
+
+ @Override
+ public Image getImage(Display display) {
+ if( image == null ) {
+ image = new Image(display, getClass().getClassLoader().getResourceAsStream("/icons/application.png"));
+ }
+
+ return image;
+ }
+
+ @Override
+ public String getLabel() {
+ return "Application";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Application bla, bla, bla";
+ }
+
+ @Override
+ public Composite getEditor(Composite parent, Object object) {
+ if( composite == null ) {
+ context = new DataBindingContext();
+ composite = createForm(parent,context, master);
+ }
+ master.setValue(object);
+ return composite;
+ }
+
+ protected Composite createForm(Composite parent, DataBindingContext context, IObservableValue master) {
+ parent = new Composite(parent,SWT.NONE);
+
+ return parent;
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentEditor.java
new file mode 100644
index 00000000..0b7fe77d
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentEditor.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.tools.emf.ui.internal.common.component;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.core.databinding.property.value.IValueProperty;
+import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.e4.ui.model.application.MApplicationPackage;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.swt.SWT;
+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;
+import org.eclipse.swt.widgets.Text;
+
+public class ModelComponentEditor extends AbstractComponentEditor {
+ private Composite composite;
+ private WritableValue master = new WritableValue();
+ private Image image;
+ private DataBindingContext context;
+
+ @Override
+ public Composite getEditor(Composite parent, Object object) {
+ if( composite == null ) {
+ context = new DataBindingContext();
+ composite = createForm(parent);
+ }
+ master.setValue(object);
+ return composite;
+ }
+
+ public void dispose() {
+ if( image != null ) {
+ image.dispose();
+ image = null;
+ }
+
+ if( composite != null ) {
+ composite.dispose();
+ composite = null;
+ }
+
+ if( context != null ) {
+ context.dispose();
+ context = null;
+ }
+ }
+
+ private Composite createForm(Composite parent) {
+ parent = new Composite(parent,SWT.NONE);
+ parent.setLayout(new GridLayout(3, false));
+
+ IValueProperty textProp = WidgetProperties.text();
+
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Id");
+
+ Text t = new Text(parent, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.APPLICATION_ELEMENT__ID).observeDetail(master));
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Tags");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+
+ l = new Label(parent, SWT.NONE);
+ ListViewer viewer = new ListViewer(parent);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ gd.heightHint = 130;
+ viewer.getList().setLayoutData(gd);
+
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Parent-Id");
+
+ t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.MODEL_COMPONENT__PARENT_ID).observeDetail(master));
+
+ Button b = new Button(parent, SWT.PUSH|SWT.FLAT);
+ b.setText("Find ...");
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Position in Parent");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.MODEL_COMPONENT__POSITION_IN_PARENT).observeDetail(master));
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Processor");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.MODEL_COMPONENT__PROCESSOR).observeDetail(master));
+
+ return parent;
+ }
+
+ @Override
+ public Image getImage(Display display) {
+ if( image == null ) {
+ image = new Image(display, getClass().getClassLoader().getResourceAsStream("/icons/package_go.png"));
+ }
+ return image;
+ }
+
+ @Override
+ public String getLabel() {
+ return "Model Component";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The model component ... bla bla bla";
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentsEditor.java
new file mode 100644
index 00000000..3e036d74
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelComponentsEditor.java
@@ -0,0 +1,51 @@
+package org.eclipse.e4.tools.emf.ui.internal.common.component;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+public class ModelComponentsEditor extends AbstractComponentEditor {
+ private Composite composite;
+ private WritableValue master = new WritableValue();
+ private Image image;
+ private DataBindingContext context;
+
+ @Override
+ public Image getImage(Display display) {
+ if( image == null ) {
+ image = new Image(display, getClass().getClassLoader().getResourceAsStream("/icons/application_view_icons.png"));
+ }
+ return image;
+ }
+
+ @Override
+ public String getLabel() {
+ return "Model Components";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Some bla bla bla bla";
+ }
+
+ @Override
+ public Composite getEditor(Composite parent, Object object) {
+ if( composite == null ) {
+ context = new DataBindingContext();
+ composite = createForm(parent);
+ }
+ master.setValue(object);
+ return composite;
+ }
+
+ private Composite createForm(Composite parent) {
+ parent = new Composite(parent, SWT.NONE);
+
+ return parent;
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartDescriptorEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartDescriptorEditor.java
new file mode 100644
index 00000000..a4c5748a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartDescriptorEditor.java
@@ -0,0 +1,37 @@
+package org.eclipse.e4.tools.emf.ui.internal.common.component;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.property.value.IValueProperty;
+import org.eclipse.e4.ui.model.application.MApplicationPackage;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class PartDescriptorEditor extends PartEditor {
+
+ @Override
+ protected Composite createForm(Composite parent, DataBindingContext context, IObservableValue master) {
+ Composite comp = super.createForm(parent,context,master);
+
+ IValueProperty textProp = WidgetProperties.text();
+
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Label");
+
+ Text t = new Text(parent, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.UI_LABEL__LABEL).observeDetail(master));
+
+ // ------------------------------------------------------------
+
+
+ return comp;
+ }
+}
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
new file mode 100644
index 00000000..1dc0ae91
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/PartEditor.java
@@ -0,0 +1,206 @@
+package org.eclipse.e4.tools.emf.ui.internal.common.component;
+
+import org.eclipse.core.databinding.DataBindingContext;
+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.e4.tools.emf.ui.common.component.AbstractComponentEditor;
+import org.eclipse.e4.ui.model.application.MApplicationPackage;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+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;
+import org.eclipse.swt.widgets.Text;
+
+public class PartEditor extends AbstractComponentEditor {
+ private Composite composite;
+ private WritableValue master = new WritableValue();
+ private Image image;
+ private DataBindingContext context;
+
+ @Override
+ public Image getImage(Display display) {
+ if( image == null ) {
+ image = new Image(display, getClass().getClassLoader().getResourceAsStream("/icons/application_form.png"));
+ }
+
+ return image;
+ }
+
+ @Override
+ public String getLabel() {
+ return "Part Descriptor";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Part Descriptor Bla Bla Bla Bla";
+ }
+
+ @Override
+ public Composite getEditor(Composite parent, Object object) {
+ if( composite == null ) {
+ context = new DataBindingContext();
+ composite = createForm(parent,context, master);
+ }
+ master.setValue(object);
+ return composite;
+ }
+
+ protected Composite createForm(Composite parent, DataBindingContext context, IObservableValue master) {
+ parent = new Composite(parent,SWT.NONE);
+ parent.setLayout(new GridLayout(3, false));
+
+ IValueProperty textProp = WidgetProperties.text();
+
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Id");
+
+ Text t = new Text(parent, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.APPLICATION_ELEMENT__ID).observeDetail(master));
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Tags");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+
+ l = new Label(parent, SWT.NONE);
+ ListViewer viewer = new ListViewer(parent);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ gd.heightHint = 80;
+ viewer.getList().setLayoutData(gd);
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Label");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.UI_LABEL__LABEL).observeDetail(master));
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Tooltip");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.UI_LABEL__TOOLTIP).observeDetail(master));
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Icon URI");
+
+ t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.UI_LABEL__ICON_URI).observeDetail(master));
+
+ Button b = new Button(parent, SWT.PUSH|SWT.FLAT);
+ b.setText("Find ...");
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Class URI");
+
+ t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ context.bindValue(textProp.observe(t), EMFProperties.value(MApplicationPackage.Literals.CONTRIBUTION__URI).observeDetail(master));
+
+ b = new Button(parent, SWT.PUSH|SWT.FLAT);
+ b.setText("Find ...");
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Variables");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+
+ l = new Label(parent, SWT.NONE);
+ viewer = new ListViewer(parent);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ gd.heightHint = 80;
+ viewer.getList().setLayoutData(gd);
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("Properties");
+
+ t = new Text(parent, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ t.setLayoutData(gd);
+
+ l = new Label(parent, SWT.NONE);
+ TableViewer tableviewer = new TableViewer(parent);
+ 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);
+
+ // ------------------------------------------------------------
+
+ l = new Label(parent, SWT.NONE);
+ l.setText("");
+
+ Composite booleanContainer = new Composite(parent,SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ booleanContainer.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ booleanContainer.setLayoutData(gd);
+ booleanContainer.setLayout(new GridLayout(4,false));
+
+ Button checkbox = new Button(booleanContainer, SWT.CHECK);
+ checkbox.setText("to render");
+
+ checkbox = new Button(booleanContainer, SWT.CHECK);
+ checkbox.setText("on Top");
+
+ checkbox = new Button(booleanContainer, SWT.CHECK);
+ checkbox.setText("visible");
+
+ checkbox = new Button(booleanContainer, SWT.CHECK);
+ checkbox.setText("closeable");
+
+ return parent;
+ }
+}

Back to the top