diff --git a/org.fortiss.tooling.kernel/trunk/plugin.xml b/org.fortiss.tooling.kernel/trunk/plugin.xml index f5fb82f826d668819f071abb44ed9890521a3bfd..2b9379055b7b540a3a6764b4b5c9436895dad0fe 100644 --- a/org.fortiss.tooling.kernel/trunk/plugin.xml +++ b/org.fortiss.tooling.kernel/trunk/plugin.xml @@ -48,7 +48,7 @@ <menuContribution allPopups="false" - locationURI="popup:org.fortiss.tooling.kernel.model.navigator?before=custom"> + locationURI="popup:org.fortiss.tooling.kernel.model.navigator2?before=custom"> <menu icon="icons/add.png" id="org.fortiss.tooling.kernel.model.navigator.newmenu" diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICustomMenuContributor.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICustomMenuContributor.java index 9f9704e41cd0c7b290fefa06bfda91bc090a86af..f09a38b71e1859b38f8c8bd65d2127854c3c07df 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICustomMenuContributor.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICustomMenuContributor.java @@ -17,6 +17,9 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.interfaces; +import java.util.List; + +import org.eclipse.jface.action.IContributionItem; import org.fortiss.tooling.kernel.services.IContextMenuService; /** @@ -29,5 +32,7 @@ import org.fortiss.tooling.kernel.services.IContextMenuService; * @levd.rating RED Rev: */ public interface ICustomMenuContributor { - // TODO (FH): implement + + /** Returns the contributed items, i.e., actions or menus. */ + List<IContributionItem> getContributedItems(); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ContextMenuService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ContextMenuService.java index 5114c99b820d47bce9f4a6f3d429b16d7758e680..e3b5f5216178a30613878ba36feaad9b047af9fd 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ContextMenuService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ContextMenuService.java @@ -17,6 +17,7 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.internal; +import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; @@ -75,7 +76,11 @@ public class ContextMenuService implements IContextMenuService { addVisibleSectionSeparator(menu, IWorkbenchActionConstants.MB_ADDITIONS); - // TODO (FH): add custom menu to custom section + if (contributor != null) { + for (IContributionItem item : contributor.getContributedItems()) { + menu.appendToGroup(CUSTOM_MENU_SEPARATOR_ID, item); + } + } IActionService.INSTANCE.addGlobalDefaultActionSectionToMenu(menu); } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java index 568ca7101bd8617a519418f66ce93d1d16a2da2e..aee683c188866d4664bc579464e3fb12089acfb9 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java @@ -17,6 +17,9 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.internal.navigator; +import java.util.ArrayList; +import java.util.List; + import org.conqat.ide.commons.ui.logging.LoggingUtils; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -24,6 +27,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.impl.AdapterImpl; import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.DecoratingLabelProvider; import org.eclipse.jface.viewers.DoubleClickEvent; @@ -44,6 +48,7 @@ import org.eclipse.ui.views.properties.IPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.fortiss.tooling.kernel.ToolingKernelActivator; +import org.fortiss.tooling.kernel.interfaces.ICustomMenuContributor; import org.fortiss.tooling.kernel.internal.NavigatorService; import org.fortiss.tooling.kernel.services.IActionService; import org.fortiss.tooling.kernel.services.IContextMenuService; @@ -68,7 +73,7 @@ import org.unicase.ecp.model.workSpaceModel.WorkSpaceModelPackage; */ public final class NavigatorViewPart extends ViewPart implements ISelectionListener, IDoubleClickListener, - ITabbedPropertySheetPageContributor { + ITabbedPropertySheetPageContributor, ICustomMenuContributor { /** Stores the TreeViewer. */ private TreeViewer viewer; @@ -208,7 +213,7 @@ public final class NavigatorViewPart extends ViewPart implements /** Creates the context menu. */ private void createContextMenu() { menuManager = IContextMenuService.INSTANCE - .createDefaultContextMenu(null); + .createDefaultContextMenu(this); Menu contextMenu = menuManager.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(contextMenu); @@ -296,4 +301,15 @@ public final class NavigatorViewPart extends ViewPart implements } return super.getAdapter(adapter); } + + /** {@inheritDoc} */ + @Override + public List<IContributionItem> getContributedItems() { + List<IContributionItem> result = new ArrayList<IContributionItem>(); + // FIXME (FH): provide a wrapper menu with the new menu + // currently, only the entries are shown, but not a sub-menu + result.add(new NewMenu()); + return result; + } + }