分类: Java
2012-05-01 20:04:19
RCP基本启动顺序:
Application->ApplicationWorkbenchAdvisor->ApplicationWorkbenchWindowAdvisor->ApplicationActionBarAdvisor
另外管理窗口layout的Perspective, 是在plugin.xml中定义的, 同样Application也是在plugin.xml中定义的。
Menu:
有两种方法,一个是用代码来声明。
关联两个类。
一个是ApplicationWorkbenchWindowAdvisor
要在其
public void preWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setInitialSize(new Point(400, 300));
configurer.setShowCoolBar(true);
configurer.setShowStatusLine(true);
configurer.setShowMenuBar(true);
configurer.setTitle("Hello RCP"); //$NON-NLS-1$
}
另外一个是在。
ApplicationActionBarAdvisor
private IWorkbenchAction exitAction;
private IWorkbenchAction aboutAction;
protected void makeActions(IWorkbenchWindow window) {
exitAction = ActionFactory.QUIT.create(window);
register(exitAction);
aboutAction = ActionFactory.ABOUT.create(window);
register(aboutAction);
}
protected void fillMenuBar(IMenuManager menuBar) {
MenuManager hyperbolaMenu = new MenuManager(
"&Hyperbola", "hyperbola");
hyperbolaMenu.add(exitAction);
MenuManager helpMenu = new MenuManager("&Help", "help");
helpMenu.add(aboutAction);
menuBar.add(hyperbolaMenu);
menuBar.add(helpMenu);
}
另一种是在配置文件中声明, 下面分别说明了如何用配置文件定义一个菜单与一个toolbar的按钮。
point="org.eclipse.ui.menus">
locationURI="menu:org.eclipse.ui.main.menu">
label="File">
commandId="org.eclipse.ui.file.exit"
icon="icons/exit.png"
label="Exit"
tooltip="edit">
allPopups="false"
locationURI="toolbar:org.eclipse.ui.main.toolbar">
id="RCPEyes.exitgrp"
label="editGrp">
commandId="org.eclipse.ui.file.exit"
icon="icons/exit.png"
label="Exit"
tooltip="edit">
最后一种是声明在actionset里。
point="org.eclipse.ui.actionSets">
id="org.rcpeyes.explorer.actionSet"
label="Edit Action Set"
visible="true">
id="editMenu"
label="Edit &Menu">
name="editGroup">
class="org.rcpeyes.explorer.actions.DeleteAction"
icon="icons/delete.png"
id="org.rcpeyes.explorer.actions.DeleteAction"
label="&DeleteAction"
menubarPath="editMenu/editGroup"
toolbarPath="editGroup"
tooltip="delete">
class="org.rcpeyes.explorer.actions.MoveAction"
icon="icons/move.png"
id="org.rcpeyes.explorer.actions.MoveAction"
label="&MoveAction"
menubarPath="editMenu/editGroup"
toolbarPath="editGroup"
tooltip="move">
class="org.rcpeyes.explorer.actions.CopyAction"
icon="icons/Copy.png"
id="org.rcpeyes.explorer.actions.CopyAction"
label="&CopyAction"
menubarPath="editMenu/editGroup"
toolbarPath="editGroup"
tooltip="copy">