/**
* This file is part of HIDB2.
*
* HIDB2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HIDB2 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 Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser Public License
* along with HIDB2. If not, see <http://www.gnu.org/licenses/>.
*/
package hidb2.gui;
import hidb2.gui.action.SearchAction;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
public class ApplicationActionBarAdvisor extends ActionBarAdvisor
{
// Actions - important to allocate these only in makeActions, and then use them
// in the fill methods. This ensures that the actions aren't recreated
// when fillActionBars is called with FILL_PROXY.
private IWorkbenchAction exitAction;
private IWorkbenchAction aboutAction;
private IWorkbenchAction openPerspectiveAction;
private IWorkbenchAction closePerspectiveAction;
private IWorkbenchAction showViewMenuAction;
private IWorkbenchAction saveAction;
private IWorkbenchAction closeAction;
private IWorkbenchAction prefAction;
private IWorkbenchAction newWindowAction;
private IWorkbenchAction copyAction;
private IWorkbenchAction pasteAction;
private SearchAction searchAction;
public ApplicationActionBarAdvisor(IActionBarConfigurer configurer)
{
super(configurer);
}
protected void fillMenuBar(IMenuManager menuBar)
{
MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
MenuManager windMenu = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW);
MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
menuBar.add(fileMenu);
// Add a group marker indicating where action set menus will appear.
menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menuBar.add(windMenu);
menuBar.add(helpMenu);
// File
fileMenu.add(newWindowAction);
fileMenu.add(saveAction);
fileMenu.add(closeAction);
fileMenu.add(new Separator());
fileMenu.add(exitAction);
// Window menu
windMenu.add(openPerspectiveAction);
windMenu.add(closePerspectiveAction);
windMenu.add(showViewMenuAction);
// Help
helpMenu.add(aboutAction);
helpMenu.add(prefAction);
}
protected void fillCoolBar(ICoolBarManager coolBar)
{
IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
coolBar.add(new ToolBarContributionItem(toolbar, "main"));
toolbar.add(saveAction);
toolbar.add(copyAction);
toolbar.add(pasteAction);
toolbar.add(searchAction);
}
protected void makeActions(final IWorkbenchWindow window)
{
// Creates the actions and registers them.
// Registering is needed to ensure that key bindings work.
// The corresponding commands keybindings are defined in the plugin.xml file.
// Registering also provides automatic disposal of the actions when
// the window is closed.
closePerspectiveAction = ActionFactory.CLOSE_PERSPECTIVE.create(window);
register(closePerspectiveAction);
openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window);
register(openPerspectiveAction);
showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window);
register(showViewMenuAction);
exitAction = ActionFactory.QUIT.create(window);
register(exitAction);
aboutAction = ActionFactory.ABOUT.create(window);
register(aboutAction);
prefAction = ActionFactory.PREFERENCES.create(window);
register(prefAction);
newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);
register(newWindowAction);
closeAction = ActionFactory.CLOSE.create(window);
register(closeAction);
saveAction = ActionFactory.SAVE.create(window);
register(saveAction);
copyAction = ActionFactory.COPY.create(window);
register(copyAction);
pasteAction = ActionFactory.PASTE.create(window);
register(pasteAction);
// openFileCheckerAction = new OpenFileChecker("Open File Checker", window);
// register(openFileCheckerAction);
//
// refreshFileListAction = new RefreshFileList("Refresh File List",window);
// register(refreshFileListAction);
searchAction = new SearchAction("Search", window);
register(searchAction);
}
}