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

📄 applicationactionbaradvisor.java

📁 学生成绩管理系统 eclipse rcp开发 swt技术
💻 JAVA
字号:
package com.zdh.sms;import org.eclipse.jface.action.Action;import org.eclipse.jface.action.IAction;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;import com.zdh.sms.db.Constants;public class ApplicationActionBarAdvisor extends ActionBarAdvisor {	private IWorkbenchAction preferencesAction;// 首选项	private IWorkbenchAction quitAction; // 退出	private IWorkbenchAction aboutAction;// 关于	private IWorkbenchAction newWindowAction;// 打开新窗口	private IAction scorePersAction;// 成绩管理透视图	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {		super(configurer);	}	@Override	protected void makeActions(IWorkbenchWindow window) {		preferencesAction = ActionFactory.PREFERENCES.create(window);		quitAction = ActionFactory.QUIT.create(window);		aboutAction = ActionFactory.ABOUT.create(window);		newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);		scorePersAction = new ScorePerspectiveAction();		register(preferencesAction);		register(quitAction);		register(aboutAction);		register(newWindowAction);		register(scorePersAction);	}	@Override	protected void fillMenuBar(IMenuManager menuBar) {		// 创建主菜单		IMenuManager fileMenu = new MenuManager("文件(&F)",				IWorkbenchActionConstants.M_FILE);		IMenuManager persMenu = new MenuManager("透视图(&P)");		IMenuManager helpMenu = new MenuManager("帮助(&H)",				IWorkbenchActionConstants.M_HELP);		menuBar.add(fileMenu);		menuBar.add(persMenu);		menuBar.add(helpMenu);		// 给各菜单加入菜单项		fileMenu.add(newWindowAction);		fileMenu.add(preferencesAction);		fileMenu.add(new Separator());// 分隔符		fileMenu.add(quitAction);		persMenu.add(scorePersAction);		helpMenu.add(aboutAction);	}	@Override	protected void fillCoolBar(ICoolBarManager coolBar) {		IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);		coolBar.add(new ToolBarContributionItem(toolbar, "main"));		toolbar.add(scorePersAction);		toolbar.add(quitAction);	}	// 打开"成绩管理"透视图的Action	private static class ScorePerspectiveAction extends Action {		public ScorePerspectiveAction() {			setId("ACTIONS_SCORE_PERSPECTIVE");// 必须设置一个ID标识			setText("成绩管理");			setImageDescriptor(Activator					.getImageDescriptor("icons/alt_window_16.gif"));			setActionDefinitionId(Constants.SCORE_PERSPECTIVE_ID);		}		public void run() {			Activator.showPerspective(Constants.SCORE_PERSPECTIVE_ID);		}	}}

⌨️ 快捷键说明

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