⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 applicationactionbaradvisor.java

📁 eclise rcp 项目,是非常好的学习源码
💻 JAVA
字号:
/******************************************************************************* * Copyright (c) 2007 Siemens AG *  * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: *    Kai T鰀ter - initial API and implementation *******************************************************************************/package com.siemens.ct.mp3m;import org.eclipse.jface.action.GroupMarker;import org.eclipse.jface.action.IContributionItem;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.ContributionItemFactory;import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;import org.eclipse.ui.application.ActionBarAdvisor;import org.eclipse.ui.application.IActionBarConfigurer;public class ApplicationActionBarAdvisor extends ActionBarAdvisor {	private IWorkbenchAction exitAction;	private IWorkbenchAction aboutAction;	private IWorkbenchAction helpAction;	private IWorkbenchAction helpSearchAction;	private IWorkbenchAction closeAction;	private IWorkbenchAction closeAllAction;	private IWorkbenchAction saveAction;	private IWorkbenchAction saveAllAction;	private IWorkbenchAction saveAsAction;	private IWorkbenchAction newWindowAction;	private IWorkbenchAction newEditorAction;	private IWorkbenchAction preferencesAction;	private IContributionItem viewsAction;	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {		super(configurer);	}	@Override	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.		closeAction = ActionFactory.CLOSE.create(window);		register(closeAction);		closeAllAction = ActionFactory.CLOSE_ALL.create(window);		register(closeAllAction);		saveAction = ActionFactory.SAVE.create(window);		register(saveAction);		saveAsAction = ActionFactory.SAVE_AS.create(window);		register(saveAsAction);		saveAllAction = ActionFactory.SAVE_ALL.create(window);		register(saveAllAction);		exitAction = ActionFactory.QUIT.create(window);		register(exitAction);		helpAction = ActionFactory.HELP_CONTENTS.create(window);		register(helpAction);		helpSearchAction = ActionFactory.HELP_SEARCH.create(window);		register(helpSearchAction);		aboutAction = ActionFactory.ABOUT.create(window);		register(aboutAction);		newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);		register(newWindowAction);		newEditorAction = ActionFactory.NEW_EDITOR.create(window);		register(newEditorAction);		preferencesAction = ActionFactory.PREFERENCES.create(window);		register(preferencesAction);		viewsAction = ContributionItemFactory.VIEWS_SHORTLIST.create(window);	}	@Override	protected void fillMenuBar(IMenuManager menuBar) {		MenuManager fileMenu = new MenuManager(Messages				.getString("ApplicationActionBarAdvisor.file"), IWorkbenchActionConstants.M_FILE); //$NON-NLS-1$		MenuManager windowMenu = new MenuManager(				Messages.getString("ApplicationActionBarAdvisor.window"), IWorkbenchActionConstants.M_WINDOW); //$NON-NLS-1$		MenuManager helpMenu = new MenuManager(Messages				.getString("ApplicationActionBarAdvisor.help"), IWorkbenchActionConstants.M_HELP); //$NON-NLS-1$		menuBar.add(fileMenu);		// Add a group marker indicating where action set menus will appear.		menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));		menuBar.add(windowMenu);		menuBar.add(helpMenu);		// File		fileMenu.add(newWindowAction);		fileMenu.add(new Separator());		fileMenu.add(closeAction);		fileMenu.add(closeAllAction);		fileMenu.add(new Separator());		fileMenu.add(saveAction);		fileMenu.add(saveAsAction);		fileMenu.add(saveAllAction);		fileMenu.add(new Separator());		fileMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));		fileMenu.add(new Separator());		fileMenu.add(exitAction);		// Window		windowMenu.add(newWindowAction);		windowMenu.add(newEditorAction);		windowMenu.add(new Separator());		MenuManager viewsMenu = new MenuManager(Messages				.getString("ApplicationActionBarAdvisor.openViews"), "openViews");		viewsMenu.add(viewsAction);		windowMenu.add(viewsMenu);		windowMenu.add(new Separator());		windowMenu.add(preferencesAction);		// Help		helpMenu.add(helpAction);		helpMenu.add(helpSearchAction);		helpMenu.add(new Separator());		helpMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));		helpMenu.add(new Separator());		helpMenu.add(aboutAction);	}	@Override	protected void fillCoolBar(ICoolBarManager coolBar) {		IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);		coolBar.add(new ToolBarContributionItem(toolbar, "main")); //$NON-NLS-1$		toolbar.add(saveAction);		toolbar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));		toolbar.add(new GroupMarker("mp3m.test"));	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -