Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2014-07-25 04:18:36 -0400
committerTom Schindl2014-07-25 04:18:36 -0400
commit8f11d5098da7803f2ae7129981967c3226cdcaf6 (patch)
treec7add9f9a2ab7d57179e8f1f9d814dcea3e8438a
parent68bc96c9d229c26042043cd0dde7ef78df74c5fc (diff)
downloadorg.eclipse.e4.tools-8f11d5098da7803f2ae7129981967c3226cdcaf6.tar.gz
org.eclipse.e4.tools-8f11d5098da7803f2ae7129981967c3226cdcaf6.tar.xz
org.eclipse.e4.tools-8f11d5098da7803f2ae7129981967c3226cdcaf6.zip
Bug 440417 - [ModelTooling] CompositePart editor should support to set
icon, label and tooltip
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java4
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties4
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CompositePartEditor.java50
3 files changed, 58 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
index 4a052e7a..622dfba0 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
@@ -708,4 +708,8 @@ public class Messages {
public String CompositePartEditor_SelectedElement;
public String CompositePartEditor_ContainerData;
public String CompositePartEditor_Controls;
+ public String CompositePartEditor_LabelLabel;
+ public String CompositePartEditor_Tooltip;
+ public String CompositePartEditor_IconURI;
+ public String CompositePartEditor_IconURI_Tooltip;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
index 2cda3138..f41c3c33 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
@@ -719,3 +719,7 @@ CompositePartEditor_Vertical=Vertical
CompositePartEditor_SelectedElement=Selected Element
CompositePartEditor_ContainerData=Container Data
CompositePartEditor_Controls=Controls
+CompositePartEditor_LabelLabel=Label
+CompositePartEditor_Tooltip=Tooltip
+CompositePartEditor_IconURI=Icon URI
+CompositePartEditor_IconURI_Tooltip=Choose the icon of your part here
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CompositePartEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CompositePartEditor.java
index cfd4b6ce..9974d3b6 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CompositePartEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/CompositePartEditor.java
@@ -8,24 +8,30 @@ import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.list.IListProperty;
import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.tools.emf.ui.common.IEditorFeature.FeatureClass;
+import org.eclipse.e4.tools.emf.ui.common.ImageTooltip;
import org.eclipse.e4.tools.emf.ui.common.Util;
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.ResourceProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.ControlFactory.TextPasteHandler;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.PartIconDialogEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.uistructure.UIViewer;
import org.eclipse.e4.tools.emf.ui.internal.imp.ModelImportWizard;
import org.eclipse.e4.tools.emf.ui.internal.imp.RegistryUtil;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.model.application.ui.MUILabel;
import org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl;
import org.eclipse.e4.ui.model.application.ui.basic.MCompositePart;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.FeaturePath;
@@ -67,6 +73,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
public class CompositePartEditor extends AbstractComponentEditor {
@@ -86,6 +93,9 @@ public class CompositePartEditor extends AbstractComponentEditor {
private Shell shell;
@Inject
+ IEclipseContext eclipseContext;
+
+ @Inject
public CompositePartEditor() {
super();
}
@@ -239,6 +249,46 @@ public class CompositePartEditor extends AbstractComponentEditor {
ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID));
ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE));
+ ControlFactory.createTextField(parent, Messages.CompositePartEditor_LabelLabel, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL));
+ ControlFactory.createTextField(parent, Messages.CompositePartEditor_Tooltip, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP));
+
+ // ------------------------------------------------------------
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText(Messages.CompositePartEditor_IconURI);
+ l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+ l.setToolTipText(Messages.CompositePartEditor_IconURI_Tooltip);
+
+ final Text t = new Text(parent, SWT.BORDER);
+ TextPasteHandler.createFor(t);
+ 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, Messages) {
+
+ @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.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
+ b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom));
+ b.setText(Messages.ModelTooling_Common_FindEllipsis);
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ PartIconDialogEditor dialog = new PartIconDialogEditor(b.getShell(), eclipseContext, project, getEditingDomain(), (MPart) getMaster().getValue(), Messages);
+ dialog.open();
+ }
+ });
+ }
// ------------------------------------------------------------
{

Back to the top