Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2011-02-18 23:27:34 +0000
committerThomas Schindl2011-02-18 23:27:34 +0000
commitc8ce4775cddeed4cb19c17cea6c45c15e9f91128 (patch)
tree969ad738d9d023a8d64d80526665601ab73a50b8
parentc0ab3a06f29a6cca8d474da0deaa1ecf5b438b97 (diff)
downloadorg.eclipse.e4.tools-c8ce4775cddeed4cb19c17cea6c45c15e9f91128.tar.gz
org.eclipse.e4.tools-c8ce4775cddeed4cb19c17cea6c45c15e9f91128.tar.xz
org.eclipse.e4.tools-c8ce4775cddeed4cb19c17cea6c45c15e9f91128.zip
Bug 337560 - [ModelTooling] Split form area in tabs
* fixed context menus
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java3
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties113
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java33
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuEditor.java17
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuItemEditor.java30
5 files changed, 135 insertions, 61 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 89b4f168..14b4a2c9 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
@@ -22,6 +22,7 @@ public class Messages {
public String ModelTooling_Common_FindEllipsis;
public String ModelTooling_Common_TabDefault;
public String ModelTooling_Common_TabSupplementary;
+ public String ModelEditor_AddChild;
public String ModelTooling_UIElement_ToBeRendered;
public String ModelTooling_UIElement_Visible;
@@ -134,6 +135,7 @@ public class Messages {
public String MenuEditor_AddMenu;
public String MenuEditor_AddDirectMenuItem;
public String MenuEditor_AddSeparator;
+ public String MenuEditor_AddCoreExpression;
public String MenuItemEditor_Type;
public String MenuItemEditor_Label;
@@ -144,6 +146,7 @@ public class Messages {
public String MenuItemEditor_Selected;
public String MenuItemEditor_Mnemonics;
public String MenuItemEditor_NoExpression;
+ public String MenuItemEditor_AddCoreExpression;
public String MenuSeparatorEditor_Label;
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 bfb745ad..f21c4840 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
@@ -18,6 +18,7 @@ ModelTooling_Common_RefId=Reference-Id
ModelTooling_Common_FindEllipsis=Find ...
ModelTooling_Common_TabDefault=Default
ModelTooling_Common_TabSupplementary=Supplementary
+ModelEditor_AddChild=Add child
ModelTooling_UIElement_ToBeRendered=To Be Rendered
ModelTooling_UIElement_Visible=Visible
@@ -54,7 +55,7 @@ BindingTableEditor_ContextId=Context Id
BindingTableEditor_Keybindings=Keybindings
BindingTableEditor_KeySequence=KeySequence
BindingTableEditor_Command=Command
-BindingTableEditor_AddKeyBinding=Add Keybinding
+BindingTableEditor_AddKeyBinding=Keybinding
CommandEditor_Label=Command
CommandEditor_Description=Command bla bla bla
@@ -68,7 +69,7 @@ CommandEditor_ParameterOptional_Yes=yes
CommandEditor_ParameterOptional_No=no
CommandEditor_ParameterId=Id
CommandEditor_Category=Category
-CommandEditor_AddCommandParameter=Add Command Parameter
+CommandEditor_AddCommandParameter=Command Parameter
DirectMenuItemEditor_Label=DirectMenuItem
DirectMenuItemEditor_Description=DirectMenuItem bla bla bla
@@ -111,7 +112,7 @@ KeyBindingEditor_Command=Command
KeyBindingEditor_Parameters=Parameters
KeyBindingEditor_SequenceNotComplete=Keysequence is not complete
KeyBindingEditor_SequenceEmpty=Keysequence must not be empty!
-KeyBindingEditor_AddParameter=Add Parameter
+KeyBindingEditor_AddParameter=Parameter
MenuEditor_Label=Menu
MenuEditor_Description=Menu bla bla bla
@@ -128,10 +129,11 @@ MenuEditor_IconURI=Icon URI
MenuEditor_MainMenu=Main Menu
MenuEditor_Children=Children
MenuEditor_Mnemonics=Mnemonics
-MenuEditor_AddHandledMenuItem=Add HandledMenuItem
-MenuEditor_AddMenu=Add Menu
-MenuEditor_AddDirectMenuItem=Add DirectMenuItem
-MenuEditor_AddSeparator=Add Separator
+MenuEditor_AddHandledMenuItem=HandledMenuItem
+MenuEditor_AddMenu=Menu
+MenuEditor_AddDirectMenuItem=DirectMenuItem
+MenuEditor_AddSeparator=Separator
+MenuEditor_AddCoreExpression=VisibleWhen Core Expression
MenuItemEditor_Type=Type
@@ -142,6 +144,7 @@ MenuItemEditor_Enabled=Enabled
MenuItemEditor_Selected=Selected
MenuItemEditor_Mnemonics=Mnemonics
MenuItemEditor_NoExpression=<None>
+MenuItemEditor_AddCoreExpression=VisibleWhen Core Expression
MenuSeparatorEditor_Label=Separator
@@ -184,21 +187,21 @@ PartSashContainerEditor_Horizontal=Horizontal
PartSashContainerEditor_SelectedElement=Selected Element
PartSashContainerEditor_Controls=Controls
PartSashContainerEditor_ContainerData=Container Data
-PartSashContainerEditor_AddPartSashContainer=Add PartSashContainer
-PartSashContainerEditor_AddPartStack=Add PartStack
-PartSashContainerEditor_AddPart=Add Part
-PartSashContainerEditor_AddInputPart=Add Input Part
-PartSashContainerEditor_AddArea=Add Area
-PartSashContainerEditor_AddPlaceholder=Add Placeholder
+PartSashContainerEditor_AddPartSashContainer=PartSashContainer
+PartSashContainerEditor_AddPartStack=PartStack
+PartSashContainerEditor_AddPart=Part
+PartSashContainerEditor_AddInputPart=Input Part
+PartSashContainerEditor_AddArea=Area
+PartSashContainerEditor_AddPlaceholder=Placeholder
PartStackEditor_Label=Part Stack
PartStackEditor_Description=Stack bla bla bla
PartStackEditor_SelectedElement=Selected Element
PartStackEditor_Parts=Parts
PartStackEditor_ContainerData=Container Data
-PartStackEditor_AddPart=Add Part
-PartStackEditor_AddInputPart=Add Input Part
-PartStackEditor_AddPlaceholder=Add Placeholder
+PartStackEditor_AddPart=Part
+PartStackEditor_AddInputPart=Input Part
+PartStackEditor_AddPlaceholder=Placeholder
PerspectiveEditor_Label=Perspective
PerspectiveEditor_Description=Perspective Bla Bla Bla
@@ -208,19 +211,19 @@ PerspectiveEditor_Label=Label
PerspectiveEditor_Tooltip=Tooltip
PerspectiveEditor_IconURI=Icon URI
PerspectiveEditor_Controls=Controls
-PerspectiveEditor_AddPartSashContainer=Add PartSashContainer
-PerspectiveEditor_AddPartStack=Add PartStack
-PerspectiveEditor_AddPart=Add Part
-PerspectiveEditor_AddInputPart=Add InputPart
-PerspectiveEditor_AddArea=Add Area
-PerspectiveEditor_AddPlaceholder=Add Placeholder
+PerspectiveEditor_AddPartSashContainer=PartSashContainer
+PerspectiveEditor_AddPartStack=PartStack
+PerspectiveEditor_AddPart=Part
+PerspectiveEditor_AddInputPart=InputPart
+PerspectiveEditor_AddArea=Area
+PerspectiveEditor_AddPlaceholder=Placeholder
PerspectiveStackEditor_Label=Perspective Stack
PerspectiveStackEditor_Description=Perspective Stack Bla Bla Bla
PerspectiveStackEditor_SelectedElement=Selected Element
PerspectiveStackEditor_Perspectives=Perspectives
-PerspectiveStackEditor_AddPerspective=Add Perspective
+PerspectiveStackEditor_AddPerspective=Perspective
PlaceholderEditor_Label=Placeholder
PlaceholderEditor_Descriptor=Placeholder Bla Bla Bla Bla
@@ -236,10 +239,10 @@ ToolBarEditor_HandledToolItem=Handled ToolItem
ToolBarEditor_DirectToolItem=Direct ToolItem
ToolBarEditor_ToolControl=Tool Control
ToolBarEditor_Separator=Separator
-ToolBarEditor_AddHandledToolItem=Add Handled ToolItem
-ToolBarEditor_AddDirectToolItem=Add Direct ToolItem
-ToolBarEditor_AddToolControl=Add Toolcontrol
-ToolBarEditor_AddToolBarSeparator=Add Sepatator
+ToolBarEditor_AddHandledToolItem=Handled ToolItem
+ToolBarEditor_AddDirectToolItem=Direct ToolItem
+ToolBarEditor_AddToolControl=Toolcontrol
+ToolBarEditor_AddToolBarSeparator=Sepatator
ToolBarSeparatorEditor_Label=Separator
@@ -253,7 +256,7 @@ VBindingTableEditor_Contexts=Contexts
VBindingTableEditor_Name=Name
VBindingTableEditor_LabelDescription=Description
VBindingTableEditor_BindingTables=Binding Tables
-VBindingTableEditor_AddBindingTable=Add Binding Table
+VBindingTableEditor_AddBindingTable=Binding Table
AddonsEditor_ClassURI=Class URI
AddonsEditor_TreeLabel=Addon
@@ -311,7 +314,7 @@ BindingContextEditor_TreeLabelDescription=Binding Context Bla Bla Bla
BindingContextEditor_Name=Name
BindingContextEditor_Description=Description
BindingContextEditor_Subcontexts=Subcontexts
-BindingContextEditor_AddContext=Add Binding Context
+BindingContextEditor_AddContext=Binding Context
CommandParameterEditor_TreeLabel=Command Parameter
CommandParameterEditor_TreeLabelDescritpion=Command Parameter Bla Bla Bla
@@ -349,8 +352,8 @@ TrimBarEditor_TreeLabel=Window Trim
TrimBarEditor_TreeLabelDescription=Window Trim bla bla bla
TrimBarEditor_Side=Side
TrimBarEditor_Controls=Controls
-TrimBarEditor_AddToolBar=Add Toolbar
-TrimBarEditor_AddToolControl=Add Toolcontrol
+TrimBarEditor_AddToolBar=Toolbar
+TrimBarEditor_AddToolControl=Toolcontrol
TrimContributionEditor_TreeLabel=Trim Contribution
@@ -362,7 +365,7 @@ TrimContributionEditor_Controls=Controls
TrimmedWindowEditor_TrimBars=TrimBars
TrimmedWindowEditor_TreeLabel=Trimmed Window
-WindowEditor_AddMainMenu=Add Main Menu
+WindowEditor_AddMainMenu=Main Menu
WindowEditor_TreeLabel=Window
WindowEditor_TreeLabelDescription=Window bla bla bla
WindowEditor_Bounds=Bounds(x,y,w,h)
@@ -377,7 +380,7 @@ WindowEditor_Windows=Windows
WindowEditor_Controls=Controls
WindowEditor_SharedElements=Shared Elements
-VApplicationAddons_AddAddon=Add Addon
+VApplicationAddons_AddAddon=Addon
VApplicationAddons_TreeLabel=Addons
VApplicationAddons_TreeLabelDescription=Addons bla bla bla bla
VApplicationAddons_Commands=Commands
@@ -385,27 +388,27 @@ VApplicationAddons_Commands=Commands
VApplicationCategoriesEditor_TreeLabel=Command Categories
VApplicationCategoriesEditor_TreeLabelDescription=Command Categories bla bla bla bla
VApplicationCategoriesEditor_Categories=Categories
-VApplicationCategoriesEditor_AddCategory=Add Category
+VApplicationCategoriesEditor_AddCategory=Category
VCommandEditor_TreeLabel=Commands
VCommandEditor_TreeLabelDescription=Commands Bla Bla Bla Bla Bla
VCommandEditor_Commands=Commands
-VCommandEditor_AddCommand=Add Command
+VCommandEditor_AddCommand=Command
VHandlerEditor_TreeLabel=Handlers
VHandlerEditor_TreeLabelDescription=Handlers Bla Bla Bla Bla Bla
VHandlerEditor_Handlers=Handlers
-VHandlerEditor_AddHandler=Add Handler
+VHandlerEditor_AddHandler=Handler
VMenuContributionsEditor_TreeLabel=Menu Contributions
VMenuContributionsEditor_TreeLabelDescription=Menu Contributions Bla Bla Bla Bla Bla
VMenuContributionsEditor_MenuContributions=Menu Contributions
-VMenuContributionsEditor_AddMenuContribution=Add Menu Contribution
+VMenuContributionsEditor_AddMenuContribution=Menu Contribution
VMenuEditor_TreeLabel=Menus
VMenuEditor_TreeLabelDescription=Menus Bla Bla Bla Bla Bla
VMenuEditor_Menus=Menus
-VMenuEditor_AddMenuContribution=Add Menu
+VMenuEditor_AddMenuContribution=Menu
VModelFragmentsEditor_TreeLabel=Fragments
VModelFragmentsEditor_TreeLabelDescription=Fragments Bla Bla Bla Bla Bla
@@ -418,45 +421,45 @@ VModelImportsEditor_Imports=Imports
VPartDescriptor_TreeLabel=Part Descriptors
VPartDescriptor_TreeLabelDescription=Part Descriptors Bla Bla Bla Bla Bla
VPartDescriptor_Descriptors=Descriptors
-VPartDescriptor_AddPartDescriptor=Add Descriptor
+VPartDescriptor_AddPartDescriptor=Descriptor
VToolBarContributionsEditor_TreeLabel=ToolBar Contributions
VToolBarContributionsEditor_TreeLabelDescription=ToolBar Contributions Bla Bla Bla Bla Bla
VToolBarContributionsEditor_Contributions=ToolBar Contributions
-VToolBarContributionsEditor_AddToolBarContribution=Add ToolBar Contribution
+VToolBarContributionsEditor_AddToolBarContribution=ToolBar Contribution
VTrimContributionsEditor_TreeLabel=Trim Contributions
VTrimContributionsEditor_TreeLabelDescription=Trim Contributions Bla Bla Bla Bla Bla
VTrimContributionsEditor_Contributions=Trim Contributions
-VTrimContributionsEditor_AddTrimContribution=Add Trim Contribution
+VTrimContributionsEditor_AddTrimContribution=Trim Contribution
VWindowControlEditor_TreeLabel=Controls
VWindowControlEditor_TreeLabelDescription=Controls Bla Bla Bla Bla Bla
VWindowControlEditor_Controls=Controls
-VWindowControlEditor_AddPerspectiveStack=Add Perspective Stack
-VWindowControlEditor_AddPartSashContainer=Add Part Sash Container
-VWindowControlEditor_AddPartStack=Add Part Stack
-VWindowControlEditor_AddPart=Add Part
-VWindowControlEditor_AddInputPart=Add Input Part
-VWindowControlEditor_AddArea=Add Area
+VWindowControlEditor_AddPerspectiveStack=Perspective Stack
+VWindowControlEditor_AddPartSashContainer=Part Sash Container
+VWindowControlEditor_AddPartStack=Part Stack
+VWindowControlEditor_AddPart=Part
+VWindowControlEditor_AddInputPart=Input Part
+VWindowControlEditor_AddArea=Area
VWindowEditor_TreeLabel=Windows
VWindowEditor_TreeLabelDescription=Windows Bla Bla Bla Bla Bla
VWindowEditor_Windows=Windows
-VWindowEditor_AddTrimmedWindow=Add Trimmed Window
-VWindowEditor_AddWindow=Add Window
+VWindowEditor_AddTrimmedWindow=Trimmed Window
+VWindowEditor_AddWindow=Window
VWindowSharedElementsEditor_TreeLabel=Shared Elements
VWindowSharedElementsEditor_TreeLabelDescription=Shared Elements Bla Bla Bla Bla
VWindowSharedElementsEditor_Controls=Controls
-VWindowSharedElementsEditor_AddPartSashContainer=Add Part Sash Container
-VWindowSharedElementsEditor_AddPart=Add Part
-VWindowSharedElementsEditor_AddInputPart=Add Input Part
+VWindowSharedElementsEditor_AddPartSashContainer=Part Sash Container
+VWindowSharedElementsEditor_AddPart=Part
+VWindowSharedElementsEditor_AddInputPart=Input Part
VWindowTrimEditor_TreeLabel=Window Trims
VWindowTrimEditor_TreeLabelDescription=Window Trims Bla Bla Bla Bla Bla
VWindowTrimEditor_Controls=Controls
-VWindowTrimEditor_AddWindowTrim=Add Window Trim
+VWindowTrimEditor_AddWindowTrim=Window Trim
AbstractIconDialog_IconName=IconName
@@ -545,7 +548,7 @@ ImageTooltip_FileSize=File-Size
VItemParametersEditor_TreeLabel=Parameters
VItemParametersEditor_TreeLabelDescription=Parameters Bla Bla Bla
VItemParametersEditor_Parameters=Parameters
-VItemParametersEditor_AddParameter=Add Parameter
+VItemParametersEditor_AddParameter=Parameter
CoreExpressionEditor_TreeLabel=Core Expression
CoreExpressionEditor_TreeLabelDescription=Core Expression Bla Bla Bla
@@ -557,7 +560,7 @@ ExpressionIdDialog_DialogMessage=Find the expression id defined through the 'org
ExpressionIdDialog_Id=Id
CommandToStringConverter_None=<None>
-VRootBindingContexts_AddContext=Add Binding Context
+VRootBindingContexts_AddContext=Binding Context
VRootBindingContexts_TreeLabel=Binding Context
VRootBindingContexts_TreeLabelDescription=Binding Context Bla Bla Bla
VRootBindingContexts_Contexts=Binding Contexts
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 1a689960..ee0d897a 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
@@ -159,6 +159,7 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider;
import org.eclipse.jface.databinding.viewers.TreeStructureAdvisor;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -498,10 +499,20 @@ public class ModelEditor {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
+ boolean addSeparator = false;
if (!s.isEmpty()) {
List<Action> actions;
if (s.getFirstElement() instanceof VirtualEntry<?>) {
actions = virtualEditors.get(((VirtualEntry<?>) s.getFirstElement()).getId()).getActions(s.getFirstElement());
+
+ if (actions.size() > 0) {
+ MenuManager addMenu = new MenuManager(messages.ModelEditor_AddChild);
+ for (Action a : actions) {
+ addSeparator = true;
+ addMenu.add(a);
+ }
+ manager.add(addMenu);
+ }
} else {
final EObject o = (EObject) s.getFirstElement();
AbstractComponentEditor editor = getEditor(o.eClass());
@@ -511,8 +522,18 @@ public class ModelEditor {
actions = new ArrayList<Action>();
}
+ if (actions.size() > 0) {
+ MenuManager addMenu = new MenuManager(messages.ModelEditor_AddChild);
+ for (Action a : actions) {
+ addSeparator = true;
+ addMenu.add(a);
+ }
+ manager.add(addMenu);
+ }
+
if (o.eContainer() != null) {
- actions.add(new Action(messages.ModelEditor_Delete, ImageDescriptor.createFromImage(resourcePool.getImageUnchecked(ResourceProvider.IMG_Obj16_cross))) {
+ addSeparator = true;
+ manager.add(new Action(messages.ModelEditor_Delete, ImageDescriptor.createFromImage(resourcePool.getImageUnchecked(ResourceProvider.IMG_Obj16_cross))) {
public void run() {
if (o.eContainingFeature().isMany()) {
Command cmd = RemoveCommand.create(ModelEditor.this.modelProvider.getEditingDomain(), o.eContainer(), o.eContainingFeature(), o);
@@ -528,15 +549,15 @@ public class ModelEditor {
}
});
}
-
- }
-
- for (Action a : actions) {
- manager.add(a);
}
}
if (project != null) {
+
+ if (addSeparator) {
+ manager.add(new Separator());
+ }
+
Action nlsAction = new Action(messages.ModelEditor_ExternalizeStrings) {
public void run() {
ExternalizeStringHandler h = ContextInjectionFactory.make(ExternalizeStringHandler.class, context);
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 9ac70683..3e30b5b6 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
@@ -41,6 +41,7 @@ import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MExpression;
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.MUiFactory;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
@@ -59,6 +60,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
@@ -99,6 +101,8 @@ public class MenuEditor extends AbstractComponentEditor {
@Optional
private IProject project;
+ private Action addExpression;
+
private static class Struct {
private final String label;
private final EClass eClass;
@@ -142,6 +146,16 @@ public class MenuEditor extends AbstractComponentEditor {
handleAdd(MenuPackageImpl.Literals.MENU_SEPARATOR, true);
}
});
+ addExpression = new Action(Messages.MenuEditor_AddCoreExpression, createImageDescriptor(ResourceProvider.IMG_CoreExpression)) {
+ @Override
+ public void run() {
+ MUIElement e = (MUIElement) getMaster().getValue();
+ Command cmd = SetCommand.create(getEditingDomain(), e, UiPackageImpl.Literals.UI_ELEMENT__VISIBLE_WHEN, MUiFactory.INSTANCE.createCoreExpression());
+ if (cmd.canExecute()) {
+ getEditingDomain().getCommandStack().execute(cmd);
+ }
+ }
+ };
}
@Override
@@ -523,6 +537,9 @@ public class MenuEditor extends AbstractComponentEditor {
public List<Action> getActions(Object element) {
ArrayList<Action> l = new ArrayList<Action>(super.getActions(element));
l.addAll(actions);
+ if (((MUIElement) getMaster().getValue()).getVisibleWhen() == null) {
+ l.add(addExpression);
+ }
return l;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuItemEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuItemEditor.java
index b6b9d8fd..4a476842 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
@@ -12,6 +12,7 @@ package org.eclipse.e4.tools.emf.ui.internal.common.component;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.Converter;
@@ -31,10 +32,12 @@ import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.MenuItemIco
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
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.MUiFactory;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
import org.eclipse.e4.ui.model.application.ui.menu.ItemType;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
+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.FeaturePath;
@@ -42,6 +45,8 @@ import org.eclipse.emf.databinding.edit.EMFEditProperties;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.viewers.ViewerProperties;
@@ -73,10 +78,26 @@ public abstract class MenuItemEditor extends AbstractComponentEditor {
@Optional
protected IProject project;
+ private Action addExpression;
+
public MenuItemEditor() {
super();
}
+ @PostConstruct
+ void init() {
+ addExpression = new Action(Messages.MenuItemEditor_AddCoreExpression, createImageDescriptor(ResourceProvider.IMG_CoreExpression)) {
+ @Override
+ public void run() {
+ MUIElement e = (MUIElement) getMaster().getValue();
+ Command cmd = SetCommand.create(getEditingDomain(), e, UiPackageImpl.Literals.UI_ELEMENT__VISIBLE_WHEN, MUiFactory.INSTANCE.createCoreExpression());
+ if (cmd.canExecute()) {
+ getEditingDomain().getCommandStack().execute(cmd);
+ }
+ }
+ };
+ }
+
@Override
public Image getImage(Object element, Display display) {
if (element instanceof MUIElement) {
@@ -308,6 +329,15 @@ public abstract class MenuItemEditor extends AbstractComponentEditor {
return new FeaturePath[] { FeaturePath.fromList(UiPackageImpl.Literals.UI_LABEL__LABEL), FeaturePath.fromList(UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED) };
}
+ @Override
+ public List<Action> getActions(Object element) {
+ ArrayList<Action> l = new ArrayList<Action>(super.getActions(element));
+ if (((MUIElement) getMaster().getValue()).getVisibleWhen() == null) {
+ l.add(addExpression);
+ }
+ return l;
+ }
+
static class EObject2EClass extends Converter {
Messages Messages;

Back to the top