Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2012-05-11 07:00:15 -0400
committerTom Schindl2012-05-11 07:00:15 -0400
commite3004c14b952898f778d3856b180862f09547ecc (patch)
treeb959ae0c18bf7d0ca8f40640803934fe770cc006
parent8de946e407a2062e3aa539e97239e557aa0b6aab (diff)
downloadorg.eclipse.e4.tools-e3004c14b952898f778d3856b180862f09547ecc.tar.gz
org.eclipse.e4.tools-e3004c14b952898f778d3856b180862f09547ecc.tar.xz
org.eclipse.e4.tools-e3004c14b952898f778d3856b180862f09547ecc.zip
Bug 378606 - [Tooling] Adding a Part menu does not add the required tag
<tags>ViewMenu</tags>
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/MenuEditor.java5
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VMenuEditor.java49
4 files changed, 50 insertions, 6 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 d8e672f6..72f5591c 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
@@ -121,6 +121,7 @@ public class Messages {
public String KeyBindingEditor_AddParameter;
public String MenuEditor_Label;
+ public String MenuEditor_Label_ViewMenu;
public String MenuEditor_Description;
public String MenuEditor_MenuItems;
public String MenuEditor_MenuItemType;
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 ee118fb2..203dd427 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
@@ -118,6 +118,7 @@ KeyBindingEditor_SequenceEmpty=Keysequence must not be empty!
KeyBindingEditor_AddParameter=Parameter
MenuEditor_Label=Menu
+MenuEditor_Label_ViewMenu=View Menu
MenuEditor_Description=Menu bla bla bla
MenuEditor_MenuItems=MenuItems
MenuEditor_MenuItemType=Type
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 8aadbcad..4dde73d6 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
@@ -36,6 +36,7 @@ import org.eclipse.e4.tools.emf.ui.internal.common.component.ControlFactory.Text
import org.eclipse.e4.tools.emf.ui.internal.common.component.MenuItemEditor.EClass2EObject;
import org.eclipse.e4.tools.emf.ui.internal.common.component.MenuItemEditor.EObject2EClass;
import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.MenuIconDialogEditor;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.virtual.VMenuEditor;
import org.eclipse.e4.tools.emf.ui.internal.common.uistructure.UIViewer;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
@@ -523,7 +524,11 @@ public class MenuEditor extends AbstractComponentEditor {
EObject o = (EObject) element;
if (o.eContainer() instanceof MWindow) {
return Messages.MenuEditor_MainMenu;
+ } else if (menu.getTags().contains(VMenuEditor.VIEW_MENU_TAG)) {
+ return Messages.MenuEditor_Label_ViewMenu;
}
+ } else if (menu.getTags().contains(VMenuEditor.VIEW_MENU_TAG)) {
+ return Messages.MenuEditor_Label_ViewMenu;
}
return Messages.MenuEditor_Label;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VMenuEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VMenuEditor.java
index 7fc2f058..0dcfffff 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VMenuEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VMenuEditor.java
@@ -21,6 +21,8 @@ import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.VirtualEntry;
import org.eclipse.e4.ui.model.application.commands.impl.CommandsPackageImpl;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuFactoryImpl;
import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.databinding.EMFDataBindingContext;
@@ -59,6 +61,12 @@ public class VMenuEditor extends AbstractComponentEditor {
private List<Action> actions = new ArrayList<Action>();
private EStructuralFeature feature;
+ public static final String VIEW_MENU_TAG = "ViewMenu"; //$NON-NLS-1$
+
+ enum Types {
+ MENU, POPUP_MENU, VIEW_MENU
+ }
+
protected VMenuEditor(EStructuralFeature feature) {
super();
this.feature = feature;
@@ -78,6 +86,12 @@ public class VMenuEditor extends AbstractComponentEditor {
handleAdd(MenuPackageImpl.Literals.POPUP_MENU);
}
});
+ actions.add(new Action(Messages.MenuEditor_Label_ViewMenu, createImageDescriptor(ResourceProvider.IMG_Menu)) {
+ @Override
+ public void run() {
+ handleAddViewMenu();
+ }
+ });
}
@Override
@@ -202,12 +216,16 @@ public class VMenuEditor extends AbstractComponentEditor {
childrenDropDown.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
- EClass eclass = (EClass) element;
- return eclass.getName();
+ if (element == Types.MENU) {
+ return Messages.MenuEditor_Label;
+ } else if (element == Types.POPUP_MENU) {
+ return Messages.PopupMenuEditor_TreeLabel;
+ }
+ return Messages.MenuEditor_Label_ViewMenu;
}
});
- childrenDropDown.setInput(new EClass[] { MenuPackageImpl.Literals.MENU, MenuPackageImpl.Literals.POPUP_MENU });
- childrenDropDown.setSelection(new StructuredSelection(MenuPackageImpl.Literals.MENU));
+ childrenDropDown.setInput(Types.values());
+ childrenDropDown.setSelection(new StructuredSelection(Types.MENU));
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
b.setImage(createImage(ResourceProvider.IMG_Obj16_table_add));
@@ -215,8 +233,14 @@ public class VMenuEditor extends AbstractComponentEditor {
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- EClass eClass = (EClass) ((IStructuredSelection) childrenDropDown.getSelection()).getFirstElement();
- handleAdd(eClass);
+ Types t = (Types) ((IStructuredSelection) childrenDropDown.getSelection()).getFirstElement();
+ if (t == Types.MENU) {
+ handleAdd(MenuPackageImpl.Literals.MENU);
+ } else if (t == Types.POPUP_MENU) {
+ handleAdd(MenuPackageImpl.Literals.POPUP_MENU);
+ } else {
+ handleAddViewMenu();
+ }
}
});
@@ -259,6 +283,19 @@ public class VMenuEditor extends AbstractComponentEditor {
}
}
+ protected void handleAddViewMenu() {
+ MMenu menu = MenuFactoryImpl.eINSTANCE.createMenu();
+ menu.getTags().add(VIEW_MENU_TAG);
+ setElementId(menu);
+
+ Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), feature, menu);
+
+ if (cmd.canExecute()) {
+ getEditingDomain().getCommandStack().execute(cmd);
+ getEditor().setSelection(menu);
+ }
+ }
+
@Override
public List<Action> getActions(Object element) {
ArrayList<Action> l = new ArrayList<Action>(super.getActions(element));

Back to the top