工具、菜单栏右对齐

方法一:指定menuContribution:

toolbar:org.eclipse.ui.main.toolbar-thetop-leveltoolbar

toolbar:org.eclipse.ui.trim.command1-thetoplefttrim

toolbar:org.eclipse.ui.trim.command2-thetoprighttrim

toolbar:org.eclipse.ui.trim.vertical1-theleftverticaltrim

toolbar:org.eclipse.ui.trim.vertical2-therightverticaltrim

toolbar:org.eclipse.ui.trim.status-thestatuslinetrim

配合http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fworkbench_cmd_menus.htm适用

方法二:

<?xmlversion="1.0"encoding="UTF-8"?>

<?eclipseversion="3.4"?>

<plugin>

<extension

id="application"

point="org.eclipse.core.runtime.applications">

<application>

<run

class="de.vogella.rcp.commands.runtimecommands.Application">

</run>

</application>

</extension>

<extension

point="org.eclipse.ui.perspectives">

<perspective

name="RCPPerspective"

class="de.vogella.rcp.commands.runtimecommands.Perspective"

id="de.vogella.rcp.commands.runtimecommands.perspective">

</perspective>

</extension>

<extension

point="org.eclipse.ui.menus">

<menuContribution

class="de.vogella.rcp.commands.runtimecommands.DefineCommands"

locationURI="menu:org.eclipse.ui.main.menu">

</menuContribution>

</extension>

</plugin>

packagede.vogella.rcp.commands.runtimecommands;

importorg.eclipse.swt.SWT;

importorg.eclipse.ui.menus.CommandContributionItem;

importorg.eclipse.ui.menus.CommandContributionItemParameter;

importorg.eclipse.ui.menus.ExtensionContributionFactory;

importorg.eclipse.ui.menus.IContributionRoot;

importorg.eclipse.ui.services.IServiceLocator;

publicclassDefineCommandsextendsExtensionContributionFactory{

@Override

publicvoidcreateContributionItems(IServiceLocatorserviceLocator,

IContributionRootadditions){

CommandContributionItemParameterp=newCommandContributionItemParameter(

serviceLocator,"",

"org.eclipse.ui.file.exit",

SWT.PUSH);

p.label="Exittheapplication";

p.icon=Activator.getImageDescriptor("icons/alt_window_16.gif");

CommandContributionItemitem=newCommandContributionItem(p);

item.setVisible(true);

additions.addContributionItem(item,null);

}

}

来自:http://www.vogella.com/blog/2009/12/03/commands-menu-runtime/

http://www.imilo.cn

相关推荐