/*
* File : GOIMGlobalMenu.java
* Created : 25.12.2005
* By : kahless
*
* Gamer's Own Instant Messenger
* Copyright (C) 2005 Herbert Poul (kahless@sphene.net)
* http://goim.sphene.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package net.sphene.goim.rcp.ui.menu;
import net.sphene.goim.rcp.GOIMPlugin;
import net.sphene.goim.rcp.beans.GOIMGameList;
import net.sphene.goim.rcp.extensionpoints.menu.MenuExtensionPoint;
import net.sphene.goim.rcp.ui.actions.ExitAction;
import net.sphene.goim.rcp.ui.actions.LaunchGameContribution;
import net.sphene.goim.rcp.ui.actions.OpenPreferencesAction;
import net.sphene.goim.rcp.ui.actions.help.AboutGOIMAction;
import net.sphene.goim.rcp.ui.actions.help.FindInstallUpdates;
import net.sphene.goim.rcp.ui.actions.help.HelpContents;
import net.sphene.goim.rcp.ui.actions.help.ReportBug;
import net.sphene.goim.rcp.ui.actions.help.RequestFeature;
import net.sphene.goim.rcp.ui.actions.help.ShowCreditsAction;
import net.sphene.goim.rcp.ui.dialogs.GOIMErrorDialog;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ContributionItemFactory;
public class GOIMGlobalMenu {
MenuManager parentMenu;
public GOIMGlobalMenu(MenuManager parentMenu) {
this.parentMenu = parentMenu;
}
public void createDefaultMenuItems(final MenuManager menuManager) {
MenuManager helpMenuManager = new MenuManager("Help","goimhelpmenu");
menuManager.add(helpMenuManager);
helpMenuManager.add(new HelpContents());
helpMenuManager.add(new FindInstallUpdates());
helpMenuManager.add(new Separator());
helpMenuManager.add(new ReportBug());
helpMenuManager.add(new RequestFeature());
helpMenuManager.add(new Separator());
helpMenuManager.add(new ShowCreditsAction());
helpMenuManager.add(new AboutGOIMAction());
MenuManager toolsMenuManager = new MenuManager("Tools");
menuManager.add(toolsMenuManager);
MenuManager launchGameManager = new MenuManager("Launch Game");
toolsMenuManager.add(launchGameManager);
launchGameManager.add(new LaunchGameContribution(GOIMPlugin.getPreferenceObject(GOIMGameList.class)));
MenuManager showViewMenuManager = new MenuManager("Show View");
toolsMenuManager.add(showViewMenuManager);
IContributionItem viewsShortlist = ContributionItemFactory.VIEWS_SHORTLIST.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
showViewMenuManager.add(viewsShortlist);
menuManager.add(new Separator());
try {
if(MenuExtensionPoint.fillGlobalMenuManager(menuManager) > 0) {
menuManager.add(new Separator());
}
} catch (CoreException e) {
GOIMErrorDialog.openGOIMError(menuManager.getMenu().getShell(), "Error while creating Menu","An error occurred during creation of the global Menu",e);
e.printStackTrace();
}
menuManager.add(new OpenPreferencesAction());
menuManager.add(new Separator());
menuManager.add(new ExitAction());
}
}