diff options
author | Thomas Schindl | 2010-06-26 13:03:44 +0000 |
---|---|---|
committer | Thomas Schindl | 2010-06-26 13:03:44 +0000 |
commit | 33e5c7f031dc98fe185ce0e38e6fd765be1ccd44 (patch) | |
tree | e1dc2bc78d7705c69f0ee277b50615ce96681d69 /bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools | |
parent | b5bb9511fd46b6d5ea3d25d8a5fc77a86bc57fa0 (diff) | |
download | org.eclipse.e4.tools-33e5c7f031dc98fe185ce0e38e6fd765be1ccd44.tar.gz org.eclipse.e4.tools-33e5c7f031dc98fe185ce0e38e6fd765be1ccd44.tar.xz org.eclipse.e4.tools-33e5c7f031dc98fe185ce0e38e6fd765be1ccd44.zip |
Bug 304584 - [Tooling] Implement Workbench-Model-Tooling
* fixing problem with fragments (treats everything as import)
* some minor layout improvements (everything right aligned)
Diffstat (limited to 'bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools')
38 files changed, 1506 insertions, 319 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/ImageTooltip.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/ImageTooltip.java new file mode 100644 index 00000000..87251ca5 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/ImageTooltip.java @@ -0,0 +1,192 @@ +package org.eclipse.e4.tools.emf.ui.common; + +import java.io.FileNotFoundException; + +import java.text.DecimalFormat; + +import java.text.NumberFormat; + +import java.io.ByteArrayInputStream; + +import org.eclipse.swt.graphics.ImageData; + +import java.io.ByteArrayOutputStream; + +import org.eclipse.swt.layout.GridLayout; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.jface.resource.JFaceResources; + +import org.eclipse.swt.graphics.Image; + +import org.eclipse.swt.graphics.Font; + +import org.eclipse.swt.widgets.Label; + +import org.eclipse.swt.SWT; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; + +import org.eclipse.swt.widgets.Control; + +import org.eclipse.jface.window.ToolTip; + +public abstract class ImageTooltip extends ToolTip { + private Image image; + + public ImageTooltip(Control control) { + super(control); + + } + + @Override + protected boolean shouldCreateToolTip(Event event) { + if( getImageURI() != null ) { + return super.shouldCreateToolTip(event); + } + return false; + } + + @Override + protected Composite createToolTipContentArea(Event event, Composite parent) { + clearResources(); + parent = new Composite(parent, SWT.NONE); + parent.setBackground(event.widget.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + parent.setBackgroundMode(SWT.INHERIT_DEFAULT); + parent.setLayout(new GridLayout(2, false)); + + URI uri = getImageURI(); + + if( uri != null ) { + int fileSize = -1; + ByteArrayOutputStream out = null; + InputStream stream = null; + InputStream bStream = null; + String errorMessage = "<Unknow Error>"; + try { + URL url = new URL(uri.toString()); + stream = url.openStream(); + + if( stream != null ) { + out = new ByteArrayOutputStream(); + byte[] buf = new byte[1024]; + int length; + while( ( length = stream.read(buf)) != -1 ) { + out.write(buf,0,length); + } + fileSize = out.size(); + bStream = new ByteArrayInputStream(out.toByteArray()); + image = new Image(parent.getDisplay(),bStream); + } + } catch (MalformedURLException e) { + errorMessage = e.getMessage(); + } catch (FileNotFoundException e) { + if( uri.isPlatform() ) { + errorMessage = "File '" + e.getMessage() + "' not found in bundle '"+uri.segment(1)+"'"; + } else { + errorMessage = e.getMessage(); + } + } catch (IOException e) { + errorMessage = e.getMessage(); + } catch(Exception e) { + errorMessage = e.getMessage(); + }finally { + if(out != null) { + try { + out.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + if( bStream != null ) { + try { + bStream.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + if( stream != null ) { + try { + stream.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + // --------------------------------- + Label l = new Label(parent, SWT.NONE); + l.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); + l.setText("Icon:"); + + l = new Label(parent,SWT.NONE); + if( image == null ) { + System.err.println(errorMessage); + l.setText(errorMessage); + } else { + l.setImage(image); + } + + // --------------------------------- + + l = new Label(parent, SWT.NONE); + l.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); + l.setText("Name:"); + + l = new Label(parent,SWT.NONE); + l.setText(uri.lastSegment()); + + // --------------------------------- + + l = new Label(parent, SWT.NONE); + l.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); + l.setText("Dimensions:"); + + l = new Label(parent,SWT.NONE); + if( image != null ) { + l.setText(image.getBounds().width + "x" + image.getBounds().height+" px"); + } else { + l.setText("0x0 px"); + } + + + // --------------------------------- + + l = new Label(parent, SWT.NONE); + l.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); + l.setText("File-Size:"); + + l = new Label(parent,SWT.NONE); + l.setText( new DecimalFormat("#,##0.00").format((fileSize / 1024.0)) + "KB" ); + } + + return parent; + } + + @Override + protected void afterHideToolTip(Event event) { + super.afterHideToolTip(event); + clearResources(); + } + + protected abstract URI getImageURI(); + + private void clearResources() { + if( image != null ) { + image.dispose(); + image = null; + } + } +} diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/Util.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/Util.java index 06bdb506..19d535ce 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/Util.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/Util.java @@ -1,7 +1,15 @@ package org.eclipse.e4.tools.emf.ui.common; +import org.eclipse.e4.ui.model.fragment.impl.FragmentPackageImpl; + +import org.eclipse.emf.ecore.EObject; + public class Util { public static final boolean isNullOrEmpty(String element) { return element == null || element.trim().length() == 0; } + + public static final boolean isImport(EObject object) { + return object.eContainingFeature() == FragmentPackageImpl.Literals.MODEL_FRAGMENTS__IMPORTS; + } } 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 278aca83..0874d5b5 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 @@ -10,51 +10,20 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common; -import org.eclipse.e4.ui.model.fragment.MModelFragments; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VModelImportsEditor; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VModelFragmentsEditor; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.swt.widgets.ToolItem; - -import org.eclipse.swt.widgets.ToolBar; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.TrimContributionEditor; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VTrimContributionsEditor; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VToolBarContributionsEditor; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.ToolBarContributionEditor; +import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VWindowSharedElementsEditor; - -import org.eclipse.e4.tools.emf.ui.common.IEditorFeature.FeatureClass; - -import org.eclipse.emf.ecore.EStructuralFeature; - -import org.eclipse.e4.tools.emf.ui.common.IEditorFeature; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.StringModelFragment; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.ModelFragmentsEditor; - -import org.eclipse.e4.ui.model.fragment.impl.FragmentPackageImpl; - -import org.eclipse.e4.tools.emf.ui.internal.common.component.MenuContributionEditor; +import javax.annotation.PostConstruct; -import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VMenuContributionsEditor; +import org.eclipse.e4.ui.internal.workbench.E4XMIResource; -import org.eclipse.e4.ui.di.Focus; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.PreDestroy; import javax.inject.Inject; import org.eclipse.core.databinding.observable.IObservable; import org.eclipse.core.databinding.observable.list.IObservableList; @@ -76,6 +45,8 @@ import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.services.contributions.IContributionFactory; import org.eclipse.e4.tools.emf.ui.common.IEditorDescriptor; +import org.eclipse.e4.tools.emf.ui.common.IEditorFeature; +import org.eclipse.e4.tools.emf.ui.common.IEditorFeature.FeatureClass; import org.eclipse.e4.tools.emf.ui.common.IModelResource; import org.eclipse.e4.tools.emf.ui.common.ISelectionProviderService; import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; @@ -91,8 +62,10 @@ import org.eclipse.e4.tools.emf.ui.internal.common.component.HandledToolItemEdit import org.eclipse.e4.tools.emf.ui.internal.common.component.HandlerEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.InputPartEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.KeyBindingEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.MenuContributionEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.MenuEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.MenuSeparatorEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.ModelFragmentsEditor; 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.tools.emf.ui.internal.common.component.PartSashContainerEditor; @@ -100,31 +73,44 @@ import org.eclipse.e4.tools.emf.ui.internal.common.component.PartStackEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.PerspectiveEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.PerspectiveStackEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.PlaceholderEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.StringModelFragment; +import org.eclipse.e4.tools.emf.ui.internal.common.component.ToolBarContributionEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.ToolBarEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.ToolBarSeparatorEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.ToolControlEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.TrimBarEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.TrimContributionEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.TrimmedWindowEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.WindowEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VApplicationAddons; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VBindingTableEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VCommandEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VHandlerEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VMenuContributionsEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VMenuEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VModelFragmentsEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VModelImportsEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VPartDescriptor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VToolBarContributionsEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VTrimContributionsEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VWindowControlEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VWindowEditor; +import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VWindowSharedElementsEditor; import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VWindowTrimEditor; +import org.eclipse.e4.ui.di.Focus; import org.eclipse.e4.ui.di.Persist; 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.advanced.impl.AdvancedPackageImpl; import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl; import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl; +import org.eclipse.e4.ui.model.fragment.MModelFragments; +import org.eclipse.e4.ui.model.fragment.impl.FragmentPackageImpl; import org.eclipse.emf.databinding.EMFProperties; import org.eclipse.emf.databinding.FeaturePath; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -182,15 +168,17 @@ public class ModelEditor { private IProject project; private ISelectionProviderService selectionService; private IEclipseContext context; - private Image toolmenuIcon; private boolean fragment; + @Inject + @Optional + private MPart editorPart; + public ModelEditor(Composite composite, IEclipseContext context, IModelResource modelProvider, IProject project) { this.modelProvider = modelProvider; this.project = project; this.context = context; this.context.set(ModelEditor.class, this); - this.toolmenuIcon = new Image(composite.getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/full/obj16/headermenu.png")); registerDefaultEditors(); registerVirtualEditors(); @@ -234,15 +222,12 @@ public class ModelEditor { final Label textLabel = new Label(headerContainer, SWT.NONE); textLabel.setData(CSS_CLASS_KEY, "sectionHeader"); //$NON-NLS-1$ textLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - -// ToolBar toolbar = new ToolBar(headerContainer, SWT.NONE); -// ToolItem item = new ToolItem(toolbar, SWT.PUSH); -// item.setImage(toolmenuIcon); - + final ScrolledComposite scrolling = new ScrolledComposite(editingArea, SWT.H_SCROLL | SWT.V_SCROLL); scrolling.setBackgroundMode(SWT.INHERIT_DEFAULT); scrolling.setData(CSS_CLASS_KEY, "formContainer"); //$NON-NLS-1$ + final StackLayout layout = new StackLayout(); final Composite contentContainer = new Composite(scrolling, SWT.NONE); contentContainer.setData(CSS_CLASS_KEY, "formContainer"); //$NON-NLS-1$ scrolling.setExpandHorizontal(true); @@ -251,13 +236,14 @@ public class ModelEditor { scrolling.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { - Rectangle r = scrolling.getClientArea(); - scrolling.setMinSize(contentContainer.computeSize(r.width, SWT.DEFAULT)); + if( layout.topControl != null ) { + Rectangle r = scrolling.getClientArea(); + scrolling.setMinSize(layout.topControl.computeSize(r.width, SWT.DEFAULT)); + } } }); scrolling.setLayoutData(new GridData(GridData.FILL_BOTH)); - final StackLayout layout = new StackLayout(); contentContainer.setLayout(layout); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @@ -290,7 +276,9 @@ public class ModelEditor { } Rectangle r = scrolling.getClientArea(); - scrolling.setMinSize(contentContainer.computeSize(r.width, SWT.DEFAULT)); + scrolling.setMinSize(layout.topControl.computeSize(r.width, SWT.DEFAULT)); + scrolling.setOrigin(0, 0); + scrolling.layout(true,true); if (selectionService != null) { selectionService.setSelection(s.getFirstElement()); @@ -354,6 +342,10 @@ public class ModelEditor { return fragment; } + public boolean isLiveModel() { + return ! modelProvider.isSaveable(); + } + public List<FeatureClass> getFeatureClasses(EClass eClass, EStructuralFeature feature) { List<FeatureClass> list = new ArrayList<IEditorFeature.FeatureClass>(); @@ -365,11 +357,10 @@ public class ModelEditor { } @Inject - @Optional - public void setSelectionService(ISelectionProviderService selectionService) { + public void setSelectionService(@Optional ISelectionProviderService selectionService) { this.selectionService = selectionService; if (viewer != null && !viewer.getControl().isDisposed()) { - if (!viewer.getSelection().isEmpty()) { + if (!viewer.getSelection().isEmpty() && selectionService != null) { selectionService.setSelection(((IStructuredSelection) viewer.getSelection()).getFirstElement()); } } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/AddonsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/AddonsEditor.java index 71789db0..f6f381cf 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/AddonsEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/AddonsEditor.java @@ -10,6 +10,14 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component; +import org.eclipse.core.databinding.observable.value.IObservableValue; + +import org.eclipse.e4.ui.model.application.ui.basic.MPart; +import org.eclipse.swt.custom.StackLayout; +import org.eclipse.swt.widgets.Control; + +import org.eclipse.e4.tools.emf.ui.common.Util; + import org.eclipse.emf.ecore.EObject; import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog; @@ -47,6 +55,7 @@ public class AddonsEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private IProject project; private Image image; + private StackLayout stackLayout; public AddonsEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) { super(editingDomain,editor); @@ -88,22 +97,45 @@ public class AddonsEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context); - } + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + getMaster().setValue(object); return composite; } - protected Composite createForm(Composite parent, EMFDataBindingContext context) { + protected Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( getEditor().isModelFragment() && isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -111,6 +143,7 @@ public class AddonsEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.AddonsEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -123,6 +156,7 @@ public class AddonsEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.AddonsEditor_ClassURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 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 index 437ffc19..abdf9143 100644 --- 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 @@ -103,6 +103,7 @@ public class ApplicationEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ApplicationEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/BindingTableEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/BindingTableEditor.java index 37f11bcb..bc935054 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/BindingTableEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/BindingTableEditor.java @@ -10,6 +10,12 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component; +import org.eclipse.core.databinding.observable.value.IObservableValue; + +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; @@ -65,6 +71,7 @@ public class BindingTableEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private IListProperty BINDING_TABLE__BINDINGS = EMFProperties.list(CommandsPackageImpl.Literals.BINDING_TABLE__BINDINGS); + private StackLayout stackLayout; public BindingTableEditor(EditingDomain editingDomain, ModelEditor editor) { @@ -99,28 +106,50 @@ public class BindingTableEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context) { + private Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } - { Label l = new Label(parent, SWT.NONE); l.setText(Messages.BindingTableEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -132,6 +161,7 @@ public class BindingTableEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.BindingTableEditor_ContextId); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -145,7 +175,7 @@ public class BindingTableEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.BindingTableEditor_Keybindings); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + 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/CommandEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CommandEditor.java index af5c12ab..5dabe393 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 @@ -10,6 +10,12 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component; +import org.eclipse.core.databinding.observable.value.IObservableValue; + +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; @@ -67,6 +73,7 @@ public class CommandEditor extends AbstractComponentEditor { private Composite composite; private Image image; private EMFDataBindingContext context; + private StackLayout stackLayout; public CommandEditor(EditingDomain editingDomain, ModelEditor editor) { super(editingDomain,editor); @@ -100,19 +107,42 @@ public class CommandEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context) { + private Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; @@ -121,6 +151,7 @@ public class CommandEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.CommandEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -133,6 +164,7 @@ public class CommandEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.CommandEditor_Name); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -145,7 +177,7 @@ public class CommandEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.CommandEditor_LabelDescription); - l.setLayoutData(new GridData(GridData.BEGINNING,GridData.BEGINNING,false,false)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); Text t = new Text(parent, SWT.BORDER|SWT.H_SCROLL|SWT.V_SCROLL); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -159,7 +191,7 @@ public class CommandEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.CommandEditor_Parameters); - l.setLayoutData(new GridData(GridData.BEGINNING,GridData.BEGINNING,false,false)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent,SWT.FULL_SELECTION|SWT.MULTI|SWT.BORDER); ObservableListContentProvider cp = new ObservableListContentProvider(); 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 a8f99174..782a1f73 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 @@ -87,38 +87,41 @@ import org.eclipse.swt.widgets.Text; public class ControlFactory { public static void createFindImport(Composite parent, final AbstractComponentEditor editor, EMFDataBindingContext context) { IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - + Label l = new Label(parent, SWT.NONE); - l.setText("Reference-Id"); - - Text t = new Text(parent, SWT.BORDER); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - t.setLayoutData(gd); - context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(editor.getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(editor.getMaster())); - - final Button b = new Button(parent, SWT.PUSH|SWT.FLAT); - b.setText("Find ..."); - b.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - FindImportElementDialog dialog = new FindImportElementDialog(b.getShell(), editor.getEditingDomain(), (EObject) editor.getMaster().getValue()); - dialog.open(); - } - }); + l.setText("Reference-Id"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + Text t = new Text(parent, SWT.BORDER); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + t.setLayoutData(gd); + context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(editor.getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(editor.getMaster())); + + final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); + b.setText("Find ..."); + b.setImage(editor.getImage(t.getDisplay(), AbstractComponentEditor.SEARCH_IMAGE)); + b.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + FindImportElementDialog dialog = new FindImportElementDialog(b.getShell(), editor.getEditingDomain(), (EObject) editor.getMaster().getValue()); + dialog.open(); + } + }); } - + public static void createSelectedElement(Composite parent, final AbstractComponentEditor editor, final EMFDataBindingContext context, String label) { Label l = new Label(parent, SWT.NONE); l.setText(label); + 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); IEMFEditListProperty listProp = EMFEditProperties.list(editor.getEditingDomain(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); IEMFEditValueProperty labelProp = EMFEditProperties.value(editor.getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL); IEMFEditValueProperty idProp = EMFEditProperties.value(editor.getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID); - + IViewerValueProperty vProp = ViewerProperties.singleSelection(); final Binding[] binding = new Binding[1]; @@ -127,7 +130,7 @@ public class ControlFactory { editor.getMaster().addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { - if( binding[0] != null ) { + if (binding[0] != null) { binding[0].dispose(); } @@ -137,36 +140,33 @@ public class ControlFactory { final IObservableList list = listProp.observeDetail(editor.getMaster()); ObservableListContentProvider cp = new ObservableListContentProvider(); viewer.setContentProvider(cp); - IObservableMap[] attributeMaps = { - labelProp.observeDetail(cp.getKnownElements()), - idProp.observeDetail(cp.getKnownElements()) - }; + IObservableMap[] attributeMaps = { labelProp.observeDetail(cp.getKnownElements()), idProp.observeDetail(cp.getKnownElements()) }; viewer.setLabelProvider(new ObservableMapLabelProvider(attributeMaps) { @Override public String getText(Object element) { EObject o = (EObject) element; String rv = o.eClass().getName(); - - if( element instanceof MUILabel ) { + + if (element instanceof MUILabel) { MUILabel label = (MUILabel) element; - if( ! Util.isNullOrEmpty(label.getLabel()) ) { - return rv + " - " + label.getLabel().trim(); + if (!Util.isNullOrEmpty(label.getLabel())) { + return rv + " - " + label.getLabel().trim(); } - + } - - if(element instanceof MApplicationElement) { + + if (element instanceof MApplicationElement) { MApplicationElement appEl = (MApplicationElement) element; - if( ! Util.isNullOrEmpty(appEl.getElementId()) ) { + if (!Util.isNullOrEmpty(appEl.getElementId())) { return rv + " - " + appEl.getElementId(); } } - - return rv + "["+list.indexOf(element)+"]"; + + return rv + "[" + list.indexOf(element) + "]"; } }); viewer.setInput(list); - + editor.getMaster().addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { @@ -174,11 +174,11 @@ public class ControlFactory { } }); } - + public static void createStringListWidget(Composite parent, final AbstractComponentEditor editor, String label, final EStructuralFeature feature) { Label l = new Label(parent, SWT.NONE); l.setText(label); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -298,12 +298,11 @@ public class ControlFactory { } }); } - - + public static void createVariablesWidget(Composite parent, final AbstractComponentEditor editor) { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ControlFactory_ContextVariables); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); final Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -427,7 +426,7 @@ public class ControlFactory { public static void createBindingsWidget(Composite parent, final AbstractComponentEditor editor) { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ControlFactory_BindingContexts); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); final Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -551,7 +550,7 @@ public class ControlFactory { public static void createTagsWidget(Composite parent, final AbstractComponentEditor editor) { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ControlFactory_Tags); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); final Text tagText = new Text(parent, SWT.BORDER); tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectMenuItemEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectMenuItemEditor.java index fd3b6644..7ebc2b32 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectMenuItemEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectMenuItemEditor.java @@ -74,6 +74,7 @@ public class DirectMenuItemEditor extends MenuItemEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.DirectMenuItemEditor_ClassURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectToolItemEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectToolItemEditor.java index 6e465145..43f64ed3 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectToolItemEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/DirectToolItemEditor.java @@ -64,6 +64,7 @@ public class DirectToolItemEditor extends ToolItemEditor { Label l = new Label(parent, SWT.NONE); l.setText(Messages.DirectToolItemEditor_ClassURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledMenuItemEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledMenuItemEditor.java index a8ef32c7..8ed2596d 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledMenuItemEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledMenuItemEditor.java @@ -103,6 +103,7 @@ public class HandledMenuItemEditor extends MenuItemEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.HandledMenuItemEditor_Command); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -126,7 +127,7 @@ public class HandledMenuItemEditor extends MenuItemEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.HandledMenuItemEditor_Parameters); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); final TableViewer tableviewer = new TableViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledToolItemEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledToolItemEditor.java index 5f3d845c..e0eb7458 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledToolItemEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandledToolItemEditor.java @@ -92,6 +92,7 @@ public class HandledToolItemEditor extends ToolItemEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.HandledToolItemEditor_Command); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -115,7 +116,7 @@ public class HandledToolItemEditor extends ToolItemEditor { Label l = new Label(parent, SWT.NONE); l.setText(Messages.HandledToolItemEditor_Parameters); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); final TableViewer tableviewer = new TableViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandlerEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandlerEditor.java index dce8bfc6..d0e07976 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandlerEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/HandlerEditor.java @@ -10,6 +10,12 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component; +import org.eclipse.core.databinding.observable.value.IObservableValue; + +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; @@ -52,6 +58,7 @@ public class HandlerEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private IModelResource resource; private IProject project; + private StackLayout stackLayout; public HandlerEditor(EditingDomain editingDomain, ModelEditor editor, IModelResource resource, IProject project) { super(editingDomain,editor); @@ -86,20 +93,42 @@ public class HandlerEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context) { + private Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -108,7 +137,8 @@ public class HandlerEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.HandlerEditor_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; @@ -120,6 +150,7 @@ public class HandlerEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.HandlerEditor_Command); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -143,6 +174,7 @@ public class HandlerEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.HandlerEditor_ClassURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/InputPartEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/InputPartEditor.java index 7119cc4e..b1164d29 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/InputPartEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/InputPartEditor.java @@ -47,6 +47,7 @@ public class InputPartEditor extends PartEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.InputPartEditor_InputURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); 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 4cdf045e..f72445c7 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 @@ -10,6 +10,12 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component; +import org.eclipse.core.databinding.observable.value.IObservableValue; + +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; @@ -69,6 +75,7 @@ public class KeyBindingEditor extends AbstractComponentEditor { private Image image; private EMFDataBindingContext context; private IModelResource resource; + private StackLayout stackLayout; public KeyBindingEditor(EditingDomain editingDomain, ModelEditor editor, IModelResource resource) { super(editingDomain,editor); @@ -103,20 +110,42 @@ public class KeyBindingEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context) { + private Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -125,6 +154,7 @@ public class KeyBindingEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.KeyBindingEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -137,6 +167,7 @@ public class KeyBindingEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.KeyBindingEditor_Sequence); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -149,6 +180,7 @@ public class KeyBindingEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.KeyBindingEditor_Command); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -170,7 +202,7 @@ public class KeyBindingEditor extends AbstractComponentEditor { Label l = new Label(parent, SWT.NONE); l.setText(Messages.KeyBindingEditor_Parameters); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); final TableViewer tableviewer = new TableViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuContributionEditor.java index 9629abd0..d4f8ea5f 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuContributionEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuContributionEditor.java @@ -10,6 +10,10 @@ ******************************************************************************/ 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; @@ -83,6 +87,7 @@ public class MenuContributionEditor extends AbstractComponentEditor { private IProject project; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; private static class Struct { private final String label; @@ -132,22 +137,44 @@ public class MenuContributionEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context2, WritableValue master) { + 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( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -156,6 +183,7 @@ public class MenuContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -168,6 +196,7 @@ public class MenuContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_ParentId); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -180,6 +209,7 @@ public class MenuContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_Position); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -193,7 +223,7 @@ public class MenuContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_MenuItems); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + 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/MenuEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuEditor.java index a4958d5b..266b9ff1 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuEditor.java @@ -10,6 +10,12 @@ ******************************************************************************/ 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.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog; import java.net.MalformedURLException; @@ -124,12 +130,17 @@ public class MenuEditor extends AbstractComponentEditor { stackLayout = new StackLayout(); composite.setLayout(stackLayout); - createForm(composite, context, getMaster(),false); - createForm(composite, context, getMaster(),true); + createForm(composite, context, getMaster(),false,false); + createForm(composite, context, getMaster(),true,false); + if( getEditor().isModelFragment() ) { + createForm(composite, context, getMaster(),false,true); + } } EObject o = (EObject) object; Control topControl; - if( o.eContainer() instanceof MWindow || o.eContainer() == null ) { + if( Util.isImport(o) && getEditor().isModelFragment() ) { + topControl = composite.getChildren()[2]; + } else if( o.eContainer() instanceof MWindow || o.eContainer() == null ) { topControl = composite.getChildren()[1]; } else { topControl = composite.getChildren()[0]; @@ -144,14 +155,13 @@ public class MenuEditor extends AbstractComponentEditor { return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean rootMenu) { + private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean rootMenu, boolean isImport) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -160,6 +170,7 @@ public class MenuEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -173,6 +184,7 @@ public class MenuEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuEditor_LabelLabel); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -186,6 +198,7 @@ public class MenuEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuEditor_Tooltip); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -199,11 +212,26 @@ public class MenuEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuEditor_IconURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 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)); + new ImageTooltip(t) { + + @Override + protected URI getImageURI() { + MUILabel part = (MUILabel) getMaster().getValue(); + String uri = part.getIconURI(); + 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.setImage(getImage(t.getDisplay(), SEARCH_IMAGE)); b.setText(Messages.MenuItemEditor_Find); @@ -220,7 +248,7 @@ public class MenuEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuEditor_MenuItems); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + 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/MenuItemEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuItemEditor.java index a8b4c89f..6a187ede 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuItemEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuItemEditor.java @@ -10,6 +10,14 @@ ******************************************************************************/ 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.basic.MPart; +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.conversion.Converter; import org.eclipse.core.databinding.UpdateValueStrategy; @@ -61,6 +69,7 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { private Image menuImage; private EMFDataBindingContext context; protected IProject project; + private StackLayout stackLayout; public MenuItemEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) { super(editingDomain,editor); @@ -85,13 +94,36 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); @@ -99,7 +131,7 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { IWidgetValueProperty checkProp = WidgetProperties.selection(); IWidgetValueProperty enabled = WidgetProperties.enabled(); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -108,6 +140,7 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -121,6 +154,7 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_Type); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); ComboViewer viewer = new ComboViewer(parent); viewer.setContentProvider(new ArrayContentProvider()); @@ -137,6 +171,7 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_Label); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -149,6 +184,7 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_Tooltip); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -161,11 +197,25 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_IconURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 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)); + new ImageTooltip(t) { + + @Override + protected URI getImageURI() { + MUILabel part = (MUILabel) getMaster().getValue(); + String uri = part.getIconURI(); + 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.setImage(getImage(t.getDisplay(), SEARCH_IMAGE)); b.setText(Messages.MenuItemEditor_Find); @@ -181,6 +231,7 @@ public abstract class MenuItemEditor extends AbstractComponentEditor { { 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)); @@ -190,6 +241,7 @@ public abstract class MenuItemEditor 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)); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuSeparatorEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuSeparatorEditor.java index 4040f05f..dbc90e44 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuSeparatorEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuSeparatorEditor.java @@ -10,6 +10,10 @@ ******************************************************************************/ 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; @@ -43,6 +47,7 @@ public class MenuSeparatorEditor extends AbstractComponentEditor { private Image separatorImage; private Composite composite; private EMFDataBindingContext context; + private StackLayout stackLayout; public MenuSeparatorEditor(EditingDomain editingDomain, ModelEditor editor) { super(editingDomain,editor); @@ -81,19 +86,42 @@ public class MenuSeparatorEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + 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( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -102,6 +130,7 @@ public class MenuSeparatorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuSeparatorEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelFragmentsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelFragmentsEditor.java index dd21635a..708cd12b 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelFragmentsEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ModelFragmentsEditor.java @@ -122,7 +122,7 @@ public class ModelFragmentsEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Imports"); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); viewer.setContentProvider(new ObservableListContentProvider()); @@ -263,7 +263,7 @@ public class ModelFragmentsEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ModelFragmentsEditor_ModelFragments); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); viewer.setContentProvider(new ObservableListContentProvider()); 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 index 9b569d15..fe587978 100644 --- 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 @@ -10,6 +10,16 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component; +import org.eclipse.e4.ui.model.application.ui.MUILabel; + +import org.eclipse.e4.tools.emf.ui.common.ImageTooltip; +import org.eclipse.emf.common.util.URI; + +import org.eclipse.e4.tools.emf.ui.common.Util; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; +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; @@ -79,6 +89,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { private IListProperty HANDLER_CONTAINER__HANDLERS = EMFProperties.list(CommandsPackageImpl.Literals.HANDLER_CONTAINER__HANDLERS); private IValueProperty PART__TOOLBAR = EMFProperties.value(BasicPackageImpl.Literals.PART_DESCRIPTOR__TOOLBAR); private Button createRemoveToolBar; + private StackLayout stackLayout; public PartDescriptorEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) { super(editingDomain,editor); @@ -111,23 +122,49 @@ public class PartDescriptorEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + + if (createRemoveToolBar != null) { + createRemoveToolBar.setSelection(((MPartDescriptor) object).getToolbar() != null); } + getMaster().setValue(object); - createRemoveToolBar.setSelection(((MPartDescriptor)object).getToolbar() != null); return composite; } - protected Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master) { + protected Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { parent = new Composite(parent,SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -137,6 +174,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -149,6 +187,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_LabelLabel); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -161,7 +200,8 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Tooltip); - + 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; @@ -173,11 +213,25 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_IconURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 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)); + new ImageTooltip(t) { + + @Override + protected URI getImageURI() { + MUILabel part = (MUILabel) getMaster().getValue(); + String uri = part.getIconURI(); + 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.setImage(getImage(t.getDisplay(), SEARCH_IMAGE)); b.setText(Messages.PartDescriptorEditor_Find); @@ -194,6 +248,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_ClassURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -215,6 +270,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_ToolBar); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); createRemoveToolBar = new Button(parent, SWT.CHECK); createRemoveToolBar.addSelectionListener(new SelectionAdapter() { @@ -235,6 +291,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_ContainerData); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -247,6 +304,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Dirtyable); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); @@ -262,6 +320,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Closeable); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); @@ -276,6 +335,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Multiple); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); @@ -290,6 +350,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Category); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL,GridData.BEGINNING, true, false, 2, 1)); @@ -300,7 +361,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_PersitedState); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); TableViewer tableviewer = new TableViewer(parent); tableviewer.getTable().setHeaderVisible(true); @@ -362,7 +423,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Variables); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); ListViewer viewer = new ListViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -375,7 +436,7 @@ public class PartDescriptorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Properties); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); TableViewer tableviewer = new TableViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -418,6 +479,11 @@ public class PartDescriptorEditor extends AbstractComponentEditor { @Override public IObservableList getChildList(final Object element) { final WritableList list = new WritableList(); + + if( getEditor().isModelFragment() && Util.isImport((EObject) element) ) { + return list; + } + list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_PARTDESCRIPTOR_MENU, PART__MENUS, element, Messages.PartDescriptorEditor_Menus) { @Override 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 f3d49c0a..d5f54996 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 @@ -10,6 +10,26 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component; +import org.eclipse.e4.ui.model.application.ui.MUILabel; + +import org.eclipse.e4.tools.emf.ui.common.ImageTooltip; + +import java.io.InputStream; + +import java.io.IOException; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.swt.widgets.Event; + +import org.eclipse.jface.window.DefaultToolTip; + +import org.eclipse.swt.widgets.Control; + +import org.eclipse.e4.tools.emf.ui.common.Util; + +import org.eclipse.swt.custom.StackLayout; + import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.FindImportElementDialog; import org.eclipse.emf.ecore.EObject; @@ -84,16 +104,16 @@ public class PartEditor extends AbstractComponentEditor { private IListProperty HANDLER_CONTAINER__HANDLERS = EMFProperties.list(CommandsPackageImpl.Literals.HANDLER_CONTAINER__HANDLERS); private IValueProperty PART__TOOLBAR = EMFProperties.value(BasicPackageImpl.Literals.PART__TOOLBAR); private Button createRemoveToolBar; - + private StackLayout stackLayout; public PartEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) { - 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/Part.gif")); //$NON-NLS-1$ } catch (MalformedURLException e) { @@ -117,78 +137,122 @@ public class PartEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + + if (createRemoveToolBar != null) { + createRemoveToolBar.setSelection(((MPart) object).getToolbar() != null); } + getMaster().setValue(object); - createRemoveToolBar.setSelection(((MPart)object).getToolbar() != null); + return composite; } - protected Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master) { - parent = new Composite(parent,SWT.NONE); + protected Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { + parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { - ControlFactory.createFindImport(parent, this, context); - return parent; - } - + if( isImport ) { + ControlFactory.createFindImport(parent, this, context); + return parent; + } + // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_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(master)); + context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID).observeDetail(master)); } - + // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_LabelLabel); + 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(), UiPackageImpl.Literals.UI_LABEL__LABEL).observeDetail(master)); + context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL).observeDetail(master)); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_Tooltip); - + 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(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP).observeDetail(master)); + context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP).observeDetail(master)); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_IconURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - Text t = new Text(parent, SWT.BORDER); + final 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)); - final Button b = new Button(parent, SWT.PUSH|SWT.FLAT); + new ImageTooltip(t) { + + @Override + protected URI getImageURI() { + MUILabel part = (MUILabel) getMaster().getValue(); + String uri = part.getIconURI(); + 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.setImage(getImage(t.getDisplay(), SEARCH_IMAGE)); b.setText(Messages.PartEditor_Find); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - PartIconDialogEditor dialog = new PartIconDialogEditor(b.getShell(), project,getEditingDomain(),(MPart) getMaster().getValue()); + PartIconDialogEditor dialog = new PartIconDialogEditor(b.getShell(), project, getEditingDomain(), (MPart) getMaster().getValue()); dialog.open(); } }); @@ -198,115 +262,122 @@ public class PartEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_ClassURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - context.bindValue(textProp.observeDelayed(200,t), EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI).observeDetail(master)); + 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); + final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setImage(getImage(t.getDisplay(), SEARCH_IMAGE)); b.setText(Messages.PartEditor_Find); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - ContributionClassDialog dialog = new ContributionClassDialog(b.getShell(),project,getEditingDomain(),(MContribution) getMaster().getValue(), ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI); + ContributionClassDialog dialog = new ContributionClassDialog(b.getShell(), project, getEditingDomain(), (MContribution) getMaster().getValue(), ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI); dialog.open(); } }); } - + // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_ToolBar); - + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + createRemoveToolBar = new Button(parent, SWT.CHECK); createRemoveToolBar.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MPart window = (MPart) getMaster().getValue(); - if( window.getToolbar() == null ) { + if (window.getToolbar() == null) { addToolBar(); } else { removeToolBar(); } } }); - createRemoveToolBar.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER,false,false,2,1)); + createRemoveToolBar.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); } - + // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_ContainerData); + 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(), 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)); } - + createSubformElements(parent, context, master); - + // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_Closeable); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); - + IEMFEditValueProperty mprop = EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.PART__CLOSEABLE); IWidgetValueProperty uiProp = WidgetProperties.selection(); - + context.bindValue(uiProp.observe(checkbox), mprop.observeDetail(master)); } // ------------------------------------------------------------ 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); -// } + // 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); l.setText(Messages.PartEditor_PersitedState); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); TableViewer tableviewer = new TableViewer(parent); tableviewer.getTable().setHeaderVisible(true); @@ -315,7 +386,7 @@ public class PartEditor 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(Messages.PartEditor_PersitedStateKey); column.getColumn().setWidth(200); @@ -326,9 +397,9 @@ public class PartEditor 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(Messages.PartEditor_PersitedStateValue); column.getColumn().setWidth(200); @@ -340,17 +411,17 @@ public class PartEditor 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); @@ -369,30 +440,35 @@ public class PartEditor extends AbstractComponentEditor { return parent; } - + private void addToolBar() { MToolBar menu = MMenuFactory.INSTANCE.createToolBar(); Command cmd = SetCommand.create(getEditingDomain(), getMaster().getValue(), BasicPackageImpl.Literals.PART__TOOLBAR, menu); - if( cmd.canExecute() ) { + if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); } } - + private void removeToolBar() { Command cmd = SetCommand.create(getEditingDomain(), getMaster().getValue(), BasicPackageImpl.Literals.PART__TOOLBAR, null); - if( cmd.canExecute() ) { + if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); } } - + protected void createSubformElements(Composite parent, EMFDataBindingContext context, IObservableValue master) { - + } @Override public IObservableList getChildList(Object element) { final WritableList list = new WritableList(); - list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_PART_MENU, PART__MENUS, element, Messages.PartEditor_Menus) { + + if( getEditor().isModelFragment() && Util.isImport((EObject) element) ) { + return list; + } + + list.add(new VirtualEntry<Object>(ModelEditor.VIRTUAL_PART_MENU, PART__MENUS, element, Messages.PartEditor_Menus) { @Override protected boolean accepted(Object o) { @@ -401,7 +477,7 @@ public class PartEditor extends AbstractComponentEditor { }); - list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_HANDLER, HANDLER_CONTAINER__HANDLERS, element, Messages.PartEditor_Handlers) { + list.add(new VirtualEntry<Object>(ModelEditor.VIRTUAL_HANDLER, HANDLER_CONTAINER__HANDLERS, element, Messages.PartEditor_Handlers) { @Override protected boolean accepted(Object o) { @@ -409,22 +485,22 @@ public class PartEditor extends AbstractComponentEditor { } }); - + MPart window = (MPart) element; - if( window.getToolbar() != null ) { - list.add(0,window.getToolbar()); + if (window.getToolbar() != null) { + list.add(0, window.getToolbar()); } - + PART__TOOLBAR.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()); createRemoveToolBar.setSelection(false); } - - if( event.diff.getNewValue() != null ) { - list.add(0,event.diff.getNewValue()); + + if (event.diff.getNewValue() != null) { + list.add(0, event.diff.getNewValue()); createRemoveToolBar.setSelection(true); } } @@ -441,8 +517,6 @@ public class PartEditor 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) }; } } 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 f1384ba7..a5b691fb 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -80,6 +84,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; public PartSashContainerEditor(EditingDomain editingDomain, ModelEditor editor) { super(editingDomain,editor); @@ -126,22 +131,45 @@ public class PartSashContainerEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + WritableValue master, boolean isImport) { parent = new Composite(parent,SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -150,6 +178,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartSashContainerEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -162,7 +191,8 @@ public class PartSashContainerEditor extends AbstractComponentEditor { { 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; @@ -185,6 +215,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartSashContainerEditor_ContainerData); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -198,7 +229,7 @@ public class PartSashContainerEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartSashContainerEditor_Controls); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -342,7 +373,6 @@ public class PartSashContainerEditor extends AbstractComponentEditor { @Override public String getDetailLabel(Object element) { - // TODO Auto-generated method stub return null; } 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 43567b2b..7d66d1ef 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -77,6 +81,7 @@ public class PartStackEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; public PartStackEditor(EditingDomain editingDomain, ModelEditor editor) { super(editingDomain,editor); @@ -108,22 +113,45 @@ public class PartStackEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + WritableValue master, boolean isImport) { parent = new Composite(parent,SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -132,6 +160,7 @@ public class PartStackEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartStackEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -146,6 +175,7 @@ public class PartStackEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartStackEditor_ContainerData); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -158,6 +188,7 @@ public class PartStackEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartStackEditor_Parts); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); viewer.setContentProvider(new ObservableListContentProvider()); 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 3a2798ef..19385e28 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,6 +10,14 @@ ******************************************************************************/ 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; @@ -80,6 +88,7 @@ public class PerspectiveEditor extends AbstractComponentEditor { private IProject project; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; public PerspectiveEditor(EditingDomain editingDomain, IProject project, ModelEditor editor) { super(editingDomain,editor); @@ -131,19 +140,42 @@ public class PerspectiveEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + 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( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -152,6 +184,7 @@ public class PerspectiveEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PerspectiveEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -166,6 +199,7 @@ public class PerspectiveEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PerspectiveEditor_LabelLabel); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -178,6 +212,7 @@ public class PerspectiveEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PerspectiveEditor_Tooltip); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -190,11 +225,25 @@ public class PerspectiveEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PerspectiveEditor_IconURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 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)); + new ImageTooltip(t) { + + @Override + protected URI getImageURI() { + MUILabel part = (MUILabel) getMaster().getValue(); + String uri = part.getIconURI(); + 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() { @@ -209,7 +258,7 @@ public class PerspectiveEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PerspectiveEditor_Controls); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); 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 a133dd15..fc674650 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -71,6 +75,7 @@ public class PerspectiveStackEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; public PerspectiveStackEditor(EditingDomain editingDomain, ModelEditor editor) { super(editingDomain,editor); @@ -107,22 +112,45 @@ public class PerspectiveStackEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + WritableValue master, boolean isImport) { parent = new Composite(parent,SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -131,6 +159,7 @@ public class PerspectiveStackEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PerspectiveStackEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -145,6 +174,7 @@ public class PerspectiveStackEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PerspectiveStackEditor_Perspectives); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); viewer.setContentProvider(new ObservableListContentProvider()); 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 d721775c..57ee751b 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,6 +10,9 @@ ******************************************************************************/ 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; @@ -69,6 +72,7 @@ public class PlaceholderEditor extends AbstractComponentEditor { private Image image; private EMFDataBindingContext context; private IModelResource resource; + private StackLayout stackLayout; public PlaceholderEditor(EditingDomain editingDomain, ModelEditor editor, IModelResource resource) { super(editingDomain,editor); @@ -133,19 +137,42 @@ public class PlaceholderEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + 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( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -154,6 +181,7 @@ public class PlaceholderEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PlaceholderEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -166,6 +194,7 @@ public class PlaceholderEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Reference"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setEditable(false); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/StringModelFragment.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/StringModelFragment.java index 363b9218..0bc7185b 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/StringModelFragment.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/StringModelFragment.java @@ -142,6 +142,7 @@ public class StringModelFragment extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.StringModelFragment_ParentId); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -153,6 +154,7 @@ public class StringModelFragment extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.StringModelFragment_Featurename); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Composite comp = new Composite(parent, SWT.NONE); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -184,6 +186,7 @@ public class StringModelFragment extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.StringModelFragment_PositionInList); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -196,7 +199,7 @@ public class StringModelFragment extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.StringModelFragment_Elements); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); viewer.setContentProvider(new ObservableListContentProvider()); 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 c8ab8ba3..4887cdf1 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -85,6 +89,7 @@ public class ToolBarContributionEditor extends AbstractComponentEditor { private IProject project; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; private static class Struct { private final String label; @@ -134,21 +139,44 @@ public class ToolBarContributionEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context2, WritableValue master) { + 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( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -157,6 +185,7 @@ public class ToolBarContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -169,6 +198,7 @@ public class ToolBarContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_ParentId); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -181,6 +211,7 @@ public class ToolBarContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_Position); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -194,7 +225,7 @@ public class ToolBarContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ToolBarEditor_ToolbarItems); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + 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/ToolBarEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ToolBarEditor.java index 99c10786..41e114f6 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -71,6 +75,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 static class Struct { private final String label; @@ -114,21 +119,44 @@ public class ToolBarEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + 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( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -137,6 +165,7 @@ public class ToolBarEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ToolBarEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -149,7 +178,7 @@ public class ToolBarEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ToolBarEditor_ToolbarItems); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + 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 84d95705..47a639ef 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -43,6 +47,7 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor { private Image separatorImage; private Composite composite; private EMFDataBindingContext context; + private StackLayout stackLayout; public ToolBarSeparatorEditor(EditingDomain editingDomain, ModelEditor editor) { super(editingDomain,editor); @@ -81,19 +86,42 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + 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( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -102,6 +130,7 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ToolBarSeparatorEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -115,7 +144,6 @@ public class ToolBarSeparatorEditor extends AbstractComponentEditor { @Override public IObservableList getChildList(Object element) { - // TODO Auto-generated method stub return null; } 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 7f9674c2..dcc8a364 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -53,6 +57,7 @@ public class ToolControlEditor extends AbstractComponentEditor { private EMFDataBindingContext context; private Composite composite; private IProject project; + private StackLayout stackLayout; public ToolControlEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) { super(editingDomain,editor); @@ -93,18 +98,42 @@ public class ToolControlEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context2, WritableValue master) { + 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( getEditor().isModelFragment() ) { + + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -113,6 +142,7 @@ public class ToolControlEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ToolControlEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -125,6 +155,7 @@ public class ToolControlEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ToolControlEditor_ClassURI); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -146,7 +177,7 @@ public class ToolControlEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Persited State"); - l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); + l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); TableViewer tableviewer = new TableViewer(parent); tableviewer.getTable().setHeaderVisible(true); 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 0abd550d..8376509a 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,6 +10,14 @@ ******************************************************************************/ 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; @@ -53,6 +61,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor { private Composite composite; private EMFDataBindingContext context; protected IProject project; + private StackLayout stackLayout; public ToolItemEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) { super(editingDomain, editor); @@ -63,25 +72,49 @@ public abstract class ToolItemEditor extends AbstractComponentEditor { public Composite getEditor(Composite parent, Object object) { if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent, context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + 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( getEditor().isModelFragment() ) { + 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); @@ -103,6 +136,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Type"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); ComboViewer viewer = new ComboViewer(parent); viewer.setContentProvider(new ArrayContentProvider()); @@ -118,6 +152,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Label"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -130,6 +165,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Tooltip"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -142,11 +178,25 @@ public abstract class ToolItemEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Icon URI"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 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 ) { + 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)); @@ -163,6 +213,7 @@ public abstract class ToolItemEditor extends AbstractComponentEditor { { 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)); @@ -172,6 +223,7 @@ 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)); 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 8b9c1af9..21a5ad73 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -78,6 +82,7 @@ public class TrimBarEditor extends AbstractComponentEditor { private ModelEditor editor; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; public TrimBarEditor(EditingDomain editingDomain, ModelEditor editor) { super(editingDomain,editor); @@ -110,22 +115,45 @@ public class TrimBarEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + 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) { + WritableValue master, boolean isImport) { parent = new Composite(parent,SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -134,7 +162,8 @@ public class TrimBarEditor extends AbstractComponentEditor { { 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; @@ -146,6 +175,7 @@ public class TrimBarEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Side"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); ComboViewer viewer = new ComboViewer(parent); viewer.setContentProvider(new ArrayContentProvider()); @@ -161,7 +191,7 @@ public class TrimBarEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Controls"); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); viewer.setLabelProvider(new ComponentLabelProvider(editor)); 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 3f1cf15d..55bbf9d6 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,6 +10,10 @@ ******************************************************************************/ 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; @@ -89,6 +93,7 @@ public class TrimContributionEditor extends AbstractComponentEditor { private IProject project; private IListProperty ELEMENT_CONTAINER__CHILDREN = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); + private StackLayout stackLayout; private static class Struct { private final String label; @@ -138,20 +143,44 @@ public class TrimContributionEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + getMaster().setValue(object); return composite; } - private Composite createForm(Composite parent, EMFDataBindingContext context2, WritableValue master) { + 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( getEditor().isModelFragment() ) { + + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -160,6 +189,7 @@ public class TrimContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_Id); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -172,6 +202,7 @@ public class TrimContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_ParentId); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -184,6 +215,7 @@ public class TrimContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_Position); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -197,7 +229,7 @@ public class TrimContributionEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Controls"); - l.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + l.setLayoutData(new GridData(GridData.END,GridData.BEGINNING,false,false)); final TableViewer viewer = new TableViewer(parent); viewer.setLabelProvider(new ComponentLabelProvider(getEditor())); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimmedWindowEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimmedWindowEditor.java index 9e81ea8c..b00e589e 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimmedWindowEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/TrimmedWindowEditor.java @@ -1,5 +1,18 @@ +/******************************************************************************* + * 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.e4.tools.emf.ui.common.Util; +import org.eclipse.emf.ecore.EObject; + import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.property.list.IListProperty; import org.eclipse.core.resources.IProject; @@ -19,6 +32,10 @@ public class TrimmedWindowEditor extends WindowEditor { public IObservableList getChildList(Object element) { IObservableList list = super.getChildList(element); + if( getEditor().isModelFragment() && Util.isImport((EObject) element) ) { + return list; + } + list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_TRIMMED_WINDOW_TRIMS, TRIMMED_WINDOW__TRIM_BARS, element, "TrimBars") { @Override 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 795032b3..44363b33 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,6 +10,14 @@ ******************************************************************************/ 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; @@ -76,7 +84,8 @@ public class WindowEditor extends AbstractComponentEditor { private IValueProperty WINDOW__MAIN_MENU = EMFProperties.value(BasicPackageImpl.Literals.WINDOW__MAIN_MENU); private Action addMainMenu; - private Button createRemoveMainMenu; + private Button createRemoveMainMenu; + private StackLayout stackLayout; public WindowEditor(EditingDomain editingDomain, ModelEditor editor, IProject project) { super(editingDomain,editor); @@ -115,23 +124,50 @@ public class WindowEditor extends AbstractComponentEditor { @Override public Composite getEditor(Composite parent, Object object) { - if( composite == null ) { + if (composite == null) { context = new EMFDataBindingContext(); - composite = createForm(parent,context, getMaster()); + if (getEditor().isModelFragment()) { + composite = new Composite(parent, SWT.NONE); + stackLayout = new StackLayout(); + composite.setLayout(stackLayout); + createForm(composite, context, getMaster(), false); + createForm(composite, context, getMaster(), true); + } else { + composite = createForm(parent, context, getMaster(), false); + } + } + + if( getEditor().isModelFragment() ) { + Control topControl; + if( Util.isImport((EObject) object) ) { + topControl = composite.getChildren()[1]; + } else { + topControl = composite.getChildren()[0]; + } + + if( stackLayout.topControl != topControl ) { + stackLayout.topControl = topControl; + composite.layout(true, true); + } + } + + if( createRemoveMainMenu != null ) { + createRemoveMainMenu.setSelection(((MWindow)object).getMainMenu() != null); } + getMaster().setValue(object); - createRemoveMainMenu.setSelection(((MWindow)object).getMainMenu() != null); + return composite; } private Composite createForm(Composite parent, EMFDataBindingContext context, - WritableValue master) { + WritableValue master, boolean isImport) { parent = new Composite(parent,SWT.NONE); parent.setLayout(new GridLayout(3, false)); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); - if( getEditor().isModelFragment() ) { + if( isImport ) { ControlFactory.createFindImport(parent, this, context); return parent; } @@ -140,6 +176,7 @@ public class WindowEditor extends AbstractComponentEditor { { 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); @@ -152,6 +189,7 @@ public class WindowEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("X"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -164,6 +202,7 @@ public class WindowEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Y"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -176,6 +215,7 @@ public class WindowEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Width"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -188,6 +228,7 @@ public class WindowEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Height"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -200,6 +241,7 @@ public class WindowEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Label"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -212,6 +254,7 @@ public class WindowEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Tooltip"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -224,11 +267,25 @@ public class WindowEditor extends AbstractComponentEditor { { Label l = new Label(parent, SWT.NONE); l.setText("Icon URI"); + l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 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)); + new ImageTooltip(t) { + + @Override + protected URI getImageURI() { + MUILabel part = (MUILabel) getMaster().getValue(); + String uri = part.getIconURI(); + 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)); @@ -245,6 +302,7 @@ public class WindowEditor extends AbstractComponentEditor { { 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() { @@ -287,6 +345,10 @@ public class WindowEditor extends AbstractComponentEditor { @Override public IObservableList getChildList(final Object element) { final WritableList list = new WritableList(); + if( getEditor().isModelFragment() && Util.isImport((EObject) element) ) { + return list; + } + list.add(new VirtualEntry<Object>( ModelEditor.VIRTUAL_HANDLER, HANDLER_CONTAINER__HANDLERS, element, "Handlers") { @Override diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindImportElementDialog.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindImportElementDialog.java index 5ad34a97..9a508b92 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindImportElementDialog.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindImportElementDialog.java @@ -1,5 +1,29 @@ package org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs; +import org.eclipse.jface.viewers.TableViewer; + +import org.eclipse.e4.ui.model.application.MApplication; + +import org.eclipse.swt.widgets.Button; + +import org.eclipse.swt.widgets.Text; + +import org.eclipse.swt.layout.GridLayout; + +import org.eclipse.swt.widgets.Label; + +import org.eclipse.swt.layout.GridData; + +import org.eclipse.swt.SWT; + +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; + +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; + +import org.eclipse.swt.graphics.Image; + import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -12,15 +36,59 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.TitleAreaDialog; public class FindImportElementDialog extends TitleAreaDialog { + private MApplication runningApp; - public FindImportElementDialog(Shell parentShell, EditingDomain domain, EObject element) { + public FindImportElementDialog(Shell parentShell, EditingDomain domain, EObject element/*, MApplication runningApp*/) { super(parentShell); + this.runningApp = runningApp; } @Override protected Control createDialogArea(Composite parent) { Composite comp = (Composite) super.createDialogArea(parent); + final Image titleImage = new Image(parent.getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/full/wizban/import_wiz.png")); + setTitleImage(titleImage); + getShell().addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent e) { + titleImage.dispose(); + } + }); + + getShell().setText("Find Import Elements"); + setTitle("Find Import Elements"); + setMessage("Search for an elements whose ID you'd like to import"); + + Composite container = new Composite(comp,SWT.NONE); + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + container.setLayout(new GridLayout(3, false)); + + + Label l = new Label(container, SWT.NONE); + l.setText("Search"); + + final Text searchText = new Text(container, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + searchText.setLayoutData(gd); + + new Label(container, SWT.NONE); + + l = new Label(container, SWT.NONE); + l.setText("File"); + + Text t = new Text(container, SWT.BORDER); + t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + t.setText("memory://running-model"); + + Button b = new Button(container, SWT.PUSH); + b.setText("Browse"); + + l = new Label(container, SWT.PUSH); + + TableViewer viewer = new TableViewer(container); + viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); + return comp; } }
\ No newline at end of file |