Author: fmancinelli Date: 2007-11-05 12:26:40 +0100 (Mon, 05 Nov 2007) New Revision: 5642
Modified: xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/plugin.xml xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/src/main/java/org/xwiki/xeclipse/rcp/ApplicationActionBarAdvisor.java Log: * Added a "show view" menu Modified: xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/plugin.xml =================================================================== --- xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/plugin.xml 2007-11-05 10:49:43 UTC (rev 5641) +++ xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/plugin.xml 2007-11-05 11:26:40 UTC (rev 5642) @@ -46,9 +46,7 @@ <extension point="org.eclipse.ui.menus"> <menuContribution - locationURI="menu:org.eclipse.ui.main.menu"> - <menu - label="File"> + locationURI="menu:org.xwiki.xeclipse.menu.File"> <command commandId="org.xwiki.xeclipse.command.NewConnection" id="New connection..."> @@ -76,13 +74,10 @@ <command commandId="org.eclipse.ui.file.exit" id="Exit"> - </command> - </menu> + </command> </menuContribution> <menuContribution - locationURI="menu:org.eclipse.ui.main.menu"> - <menu - label="Edit"> + locationURI="menu:org.xwiki.xeclipse.menu.Edit"> <command commandId="org.eclipse.ui.edit.cut" id="Cut"> @@ -106,29 +101,18 @@ <command commandId="org.xwiki.xeclipse.command.RemovePage" id="Remove page"> - </command> - </menu> + </command> </menuContribution> <menuContribution - locationURI="menu:org.eclipse.ui.main.menu"> - <menu - label="Window"> - <menu - id="org.eclipse.ui.window.showViewMenu" - label="Show view"> - </menu> - </menu> - </menuContribution> - <menuContribution - locationURI="menu:org.eclipse.ui.main.menu"> - <menu - label="Help"> + locationURI="menu:org.xwiki.xeclipse.menu.Help"> <command commandId="org.eclipse.ui.help.aboutAction" id="About"> - </command> - </menu> + </command> </menuContribution> + <group + id="CONTRIBUTION"> + </group> </extension> </plugin> Modified: xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/src/main/java/org/xwiki/xeclipse/rcp/ApplicationActionBarAdvisor.java =================================================================== --- xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/src/main/java/org/xwiki/xeclipse/rcp/ApplicationActionBarAdvisor.java 2007-11-05 10:49:43 UTC (rev 5641) +++ xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.xeclipse.rcp/src/main/java/org/xwiki/xeclipse/rcp/ApplicationActionBarAdvisor.java 2007-11-05 11:26:40 UTC (rev 5642) @@ -1,44 +1,128 @@ package org.xwiki.xeclipse.rcp; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.ContributionItemFactory; import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.views.IViewDescriptor; -public class ApplicationActionBarAdvisor extends ActionBarAdvisor { - - public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { +public class ApplicationActionBarAdvisor extends ActionBarAdvisor +{ + + private IContributionItem views; + + private List<Action> showViewActions; + + class ShowViewAction extends Action + { + public final String ID = "org.xwiki.xeclipse.actions.ShowView"; + + private IWorkbenchWindow window; + + private IViewDescriptor viewDescriptor; + + public ShowViewAction(IWorkbenchWindow window, IViewDescriptor viewDescriptor) + { + this.window = window; + this.viewDescriptor = viewDescriptor; + + setId(ID); + setText(viewDescriptor.getLabel()); + setImageDescriptor(viewDescriptor.getImageDescriptor()); + } + + @Override + public void run() + { + try { + window.getActivePage().showView(viewDescriptor.getId()); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + + } + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) + { super(configurer); } - protected void makeActions(IWorkbenchWindow window) { + protected void makeActions(IWorkbenchWindow window) + { IWorkbenchAction saveAction = ActionFactory.SAVE.create(window); - register(saveAction); - + register(saveAction); + IWorkbenchAction cutAction = ActionFactory.CUT.create(window); - register(cutAction); - + register(cutAction); + IWorkbenchAction copyAction = ActionFactory.COPY.create(window); - register(copyAction); - + register(copyAction); + IWorkbenchAction pasteAction = ActionFactory.PASTE.create(window); - register(pasteAction); - + register(pasteAction); + IWorkbenchAction exitAction = ActionFactory.QUIT.create(window); register(exitAction); - + IWorkbenchAction showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window); - register(showViewMenuAction); - - IContributionItem item = ContributionItemFactory.VIEWS_SHORTLIST.create(window); - + register(showViewMenuAction); + + showViewActions = new ArrayList<Action>(); + + for (IViewDescriptor v : window.getWorkbench().getViewRegistry().getViews()) { + String[] categoryPath = v.getCategoryPath(); + + boolean addView = false; + if (categoryPath != null) { + for (String category : categoryPath) { + if (category.equalsIgnoreCase("XWIKI")) { + addView = true; + break; + } + } + } + + if (addView) { + ShowViewAction action = new ShowViewAction(window, v); + showViewActions.add(action); + register(action); + } + } + } - protected void fillMenuBar(IMenuManager menuBar) { + protected void fillMenuBar(IMenuManager menuBar) + { + MenuManager fileMenu = new MenuManager("File", "org.xwiki.xeclipse.menu.File"); + menuBar.add(fileMenu); + + MenuManager editMenu = new MenuManager("Edit", "org.xwiki.xeclipse.menu.Edit"); + menuBar.add(editMenu); + + MenuManager windowMenu = new MenuManager("Window", "org.xwiki.xeclipse.menu.Window"); + MenuManager showViewMenu = + new MenuManager("Show view", "org.xwiki.xeclipse.menu.ShowView"); + for (Action action : showViewActions) { + showViewMenu.add(action); + } + windowMenu.add(showViewMenu); + menuBar.add(windowMenu); + + MenuManager helpMenu = new MenuManager("Help", "org.xwiki.xeclipse.menu.Help"); + menuBar.add(helpMenu); + } - + } _______________________________________________ notifications mailing list notifications@xwiki.org http://lists.xwiki.org/mailman/listinfo/notifications