Eclipse RCP 菜单 子菜单

1 GMF muicm.diagram.application包中DiagramEditorActionBarAdvisor.java

package muicm.diagram.application;


import java.io.File;
import java.util.Iterator;


import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.edit.ui.action.LoadResourceAction;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.GroupMarker;
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.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;


import muicm.diagram.part.Messages;
import muicm.diagram.part.MuicmCreationWizard;


import muicm.diagram.actions.*;


/**
 * @generated
 */
public class DiagramEditorActionBarAdvisor extends ActionBarAdvisor {


/**
* @generated
*/
private ActionFactory.IWorkbenchAction lockToolBarAction;


/**
* @generated
*/
private ActionFactory.IWorkbenchAction toggleCoolbarAction;

private ActionFactory.IWorkbenchAction exitAction;


private ActionFactory.IWorkbenchAction aboutAction;

private ActionFactory.IWorkbenchAction A;

private ActionFactory.IWorkbenchAction B;






/**
* @generated
*/
public DiagramEditorActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}


/**
* @generated
*/
private IWorkbenchWindow getWindow() {
return getActionBarConfigurer().getWindowConfigurer().getWindow();
}


/**
* @generated
*/
protected void makeActions(IWorkbenchWindow window) {
toggleCoolbarAction = ActionFactory.TOGGLE_COOLBAR.create(window);
register(toggleCoolbarAction);
lockToolBarAction = ActionFactory.LOCK_TOOL_BAR.create(window);
register(lockToolBarAction);


register(ActionFactory.CLOSE.create(window));


register(ActionFactory.CLOSE_ALL.create(window));


register(ActionFactory.SAVE.create(window));


register(ActionFactory.SAVE_AS.create(window));


register(ActionFactory.SAVE_ALL.create(window));


register(ActionFactory.QUIT.create(window));


register(ActionFactory.UNDO.create(window));


register(ActionFactory.REDO.create(window));


register(ActionFactory.CUT.create(window));


register(ActionFactory.COPY.create(window));


register(ActionFactory.PASTE.create(window));


register(ActionFactory.DELETE.create(window));


register(ActionFactory.SELECT_ALL.create(window));


register(ActionFactory.OPEN_NEW_WINDOW.create(window));


register(ActionFactory.PRINT.create(window));

exitAction = ActionFactory.QUIT.create(window);

register(exitAction);

aboutAction =  ActionFactory.ABOUT.create(window);


register( aboutAction);

A = new A(window);  
A.setId("Trans2Android");  
A.setText("转换到Android");  
        register(A);
        
B = new A(window);  
B.setId("Trans2iOS");  
B.setText("转换到iOS");  
        register(B);

       
}



/**
* @generated
*/
protected void fillMenuBar(IMenuManager menu) {


{
IMenuManager menuX = new MenuManager(Messages.ApplicationMenuName_File, IWorkbenchActionConstants.M_FILE);


menuX.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));


{
IMenuManager menuXX = new MenuManager(Messages.ApplicationMenuName_New, "new");


menuXX.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menuX.add(menuXX);
}


menuX.add(new Separator());


menuX.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));


menuX.add(new Separator());


menuX.add(getAction(ActionFactory.CLOSE.getId()));


menuX.add(getAction(ActionFactory.CLOSE_ALL.getId()));


menuX.add(new Separator());


menuX.add(getAction(ActionFactory.SAVE.getId()));


menuX.add(getAction(ActionFactory.SAVE_AS.getId()));


menuX.add(getAction(ActionFactory.SAVE_ALL.getId()));


menuX.add(new Separator());


menuX.add(getAction(ActionFactory.QUIT.getId()));


menuX.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
menu.add(menuX);
}


{
IMenuManager menuX = new MenuManager(Messages.ApplicationMenuName_Edit, IWorkbenchActionConstants.M_EDIT);


menuX.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));


menuX.add(getAction(ActionFactory.UNDO.getId()));


menuX.add(getAction(ActionFactory.REDO.getId()));


menuX.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));


menuX.add(new Separator());


menuX.add(getAction(ActionFactory.CUT.getId()));


menuX.add(getAction(ActionFactory.COPY.getId()));


menuX.add(getAction(ActionFactory.PASTE.getId()));


menuX.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));


menuX.add(new Separator());


menuX.add(getAction(ActionFactory.DELETE.getId()));


menuX.add(getAction(ActionFactory.SELECT_ALL.getId()));


menuX.add(new Separator());


menuX.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));


menuX.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));


menuX.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(menuX);
}


menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));


{
IMenuManager menuX = new MenuManager(Messages.ApplicationMenuName_Window,
IWorkbenchActionConstants.M_WINDOW);


menuX.add(getAction(ActionFactory.OPEN_NEW_WINDOW.getId()));


menuX.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(menuX);
}


{
IMenuManager menuX = new MenuManager(Messages.ApplicationMenuName_Help, IWorkbenchActionConstants.M_HELP);


menuX.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));


menuX.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));


menuX.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(menuX);
}

{
IMenuManager menuX = new MenuManager("转换"); 

{
IMenuManager menuXX = new MenuManager("&转换到原生", "转换到原生");


menuXX.add(A);

menuX.add(menuXX);


menuXX.add(B);

menuX.add(menuXX);

}

       menu.add(menuX);  
}



}


/**
* @generated
*/
protected void fillCoolBar(ICoolBarManager toolBar) {
IMenuManager popUpMenu = new MenuManager();
popUpMenu.add(new ActionContributionItem(lockToolBarAction));
popUpMenu.add(new ActionContributionItem(toggleCoolbarAction));
toolBar.setContextMenuManager(popUpMenu);


toolBar.add(new GroupMarker("group.file"));


{
IToolBarManager toolBarX = new ToolBarManager();


toolBarX.add(new Separator(IWorkbenchActionConstants.NEW_GROUP));


toolBarX.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));


toolBarX.add(new GroupMarker(IWorkbenchActionConstants.SAVE_GROUP));


toolBarX.add(getAction(ActionFactory.SAVE.getId()));


toolBarX.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT));


toolBarX.add(getAction(ActionFactory.PRINT.getId()));


toolBarX.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT));


toolBarX.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
toolBar.add(new ToolBarContributionItem(toolBarX, IWorkbenchActionConstants.TOOLBAR_FILE));
}


toolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));


toolBar.add(new GroupMarker("group.nav"));


toolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));


toolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP));


{
IToolBarManager toolBarX = new ToolBarManager();


toolBarX.add(new Separator(IWorkbenchActionConstants.GROUP_HELP));


toolBarX.add(new GroupMarker(IWorkbenchActionConstants.GROUP_APP));
toolBar.add(new ToolBarContributionItem(toolBarX, IWorkbenchActionConstants.TOOLBAR_HELP));
}
}


/**
* @generated
*/
private static boolean openEditor(IWorkbench workbench, URI fileURI) {
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());
if (editorDescriptor == null) {
MessageDialog.openError(workbenchWindow.getShell(),
Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorTitle,
NLS.bind(Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorMessage, fileURI.toFileString()));
return false;
} else {
try {
page.openEditor(new URIEditorInput(fileURI), editorDescriptor.getId());
} catch (PartInitException exception) {
MessageDialog.openError(workbenchWindow.getShell(),
Messages.DiagramEditorActionBarAdvisor_DefaultEditorOpenErrorTitle, exception.getMessage());
return false;
}
}
return true;
}


/**
* @generated
*/
public static class NewDiagramAction extends WorkbenchWindowActionDelegate {


/**
* @generated
*/
public void run(IAction action) {
MuicmCreationWizard wizard = new MuicmCreationWizard();
wizard.init(getWindow().getWorkbench(), StructuredSelection.EMPTY);
WizardDialog wizardDialog = new WizardDialog(getWindow().getShell(), wizard);
wizardDialog.open();
}
}


/**
* @generated
*/
public static class OpenURIAction extends WorkbenchWindowActionDelegate {


/**
* @generated
*/
public void run(IAction action) {
LoadResourceAction.LoadResourceDialog loadResourceDialog = new LoadResourceAction.LoadResourceDialog(
getWindow().getShell());
if (Dialog.OK == loadResourceDialog.open()) {
for (Iterator i = loadResourceDialog.getURIs().iterator(); i.hasNext();) {
openEditor(getWindow().getWorkbench(), (URI) i.next());
}
}
}
}


/**
* @generated
*/
public static class OpenAction extends WorkbenchWindowActionDelegate {


/**
* @generated
*/
public void run(IAction action) {
FileDialog fileDialog = new FileDialog(getWindow().getShell(), SWT.OPEN);
fileDialog.open();
if (fileDialog.getFileName() != null && fileDialog.getFileName().length() > 0) {
openEditor(getWindow().getWorkbench(),
URI.createFileURI(fileDialog.getFilterPath() + File.separator + fileDialog.getFileName()));
}
}
}


/**
* @generated
*/
public static class AboutAction extends WorkbenchWindowActionDelegate {


/**
* @generated
*/
public void run(IAction action) {
MessageDialog.openInformation(getWindow().getShell(),
Messages.DiagramEditorActionBarAdvisor_AboutDialogTitle,
Messages.DiagramEditorActionBarAdvisor_AboutDialogMessage);
}
}


}

目 录 1.富客户端平台 1 1.1.概述 1 1.2.Eclipse RCP 建设风格——插件,扩展和扩展点 1 2.创建你的第一个RCP程序 1 2.1.创建一个RCP程序 2 2.2.启动你的RCP程序 5 2.3.应用程序VS 产品 6 3.应用程序里的插件ID 7 4.Actions的用法(菜单和工具栏) 7 4.1.概述 7 4.2.通过编码添加 8 4.3.由“扩展”方式向程序添加菜单和工具栏 11 5.添加组合键 19 5.1.概述 19 5.2.声明actions的组合键 19 6.系统托盘 24 7.外观 30 7.1.向程序中添加视图模板 31 7.2.向应用程序添加VIEW 36 7.3.向VIEW里添加action 40 8.和编辑器一起工作 51 8.1.概述 51 8.2.创建工程 51 8.3.创建并准备domain 模型 51 8.4.在视口中使用domain模型 57 8.5.加入编辑器 58 8.6.调用编辑器 66 8.7.向编辑器提供内容 70 9.对话框 71 9.1概述 71 9.2.预定义的对话框 71 9.2.1.概述 71 9.2.2.创建工程 71 9.2.3.声明action 71 9.2.4.调用对话框 71 9.3.用户自定义对话框 74 9.3.1.概述 74 9.3.2.创建工程 74 9.3.3.声明action 74 9.3.4.声明action 74 9.3.5.创建对话框 75 10.向导(wizard) 77 10.1.概述 77 10.2.例 77 11.首选项 85 11.1 首选项 85 11.2.使用首选项 85 11.3.首选项页 91 12.添加状态条 97 12.1.安装状态条 97 12.2.共享状态条 98 13.透视 103 13.1.向你的程序中添加透视图 103 13.2.使透视图可选。 107 13.2.1.使透视图可由一个coolbar可选 107 13.2.2.使透视图可通过菜单选择。 109 14.进度报告 112 15.将外部类包含进你的程序 118 15.1.概述 118 15.2.向构建路径中添加jar 118 15.3.使jar在你的运行路径里有效 119 16.提示和策略 120 16.1.控制台日志 120 16.2.保存用户的布局 121 16.3.获得display 122 16.4.使用eclipse的“保存”action 123 16.5.装载模型 127 16.6.向你的程序添加错误日志视口 127 17.制造一个产品 129 17.1.概述 129 17.2.创建一个工程 130 17.3.测试你的产品 134 18.商标 134 18.1.欢迎页面 134 18.2.商标 135 18.3.风格化launcher 136 19.发布你的产品 137 20.发布引入外部jar的产品 141 20.1.整合外部jar和第三方库 141 Tip 142 21.1.创建一个新工程 144 21.2.创建一个产品 144 21.3.添加依赖性 145 21.4.向程序中添加action 146 21.5.创建一个帮助插件工程////原著写的不好 149 22.附录:配置文件 152 22.1.概述 152 22.2..project 153 22.3.Manifest.MF 154 23.附录:使用接口技术 154 23.2.Jface 154
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值