类org.eclipse.ui.actions.ContributionItemFactory源码实例Demo

下面列出了怎么用org.eclipse.ui.actions.ContributionItemFactory的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: neoscada   文件: ApplicationActionBarAdvisor.java
@Override
protected void makeActions ( final IWorkbenchWindow window )
{
    this.exitAction = ActionFactory.QUIT.create ( window );
    register ( this.exitAction );

    this.aboutAction = ActionFactory.ABOUT.create ( window );
    register ( this.aboutAction );

    this.newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create ( window );
    register ( this.newWindowAction );

    register ( ActionFactory.NEW_WIZARD_DROP_DOWN.create ( window ) );
    register ( ActionFactory.NEW.create ( window ) );
    register ( ActionFactory.INTRO.create ( window ) );
    register ( ActionFactory.SAVE.create ( window ) );

    this.showViews = ContributionItemFactory.VIEWS_SHORTLIST.create ( window );
    this.newWizards = ContributionItemFactory.NEW_WIZARD_SHORTLIST.create ( window );

    register ( ActionFactory.NEW_EDITOR.create ( window ) );
    register ( ActionFactory.PREFERENCES.create ( window ) );
}
 
@Override
public void fillContextMenu(IMenuManager menu) {
	super.fillContextMenu(menu);
	if (!fIsTypeHiararchyViewerOwner)
		appendToGroup(menu, fOpenTypeHierarchy);
       if (!fIsCallHiararchyViewerOwner)
           appendToGroup(menu, fOpenCallHierarchy);

       if (fShowShowInMenu) {
		MenuManager showInSubMenu= new MenuManager(getShowInMenuLabel());
		IWorkbenchWindow workbenchWindow= fOpenSuperImplementation.getSite().getWorkbenchWindow();
		showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(workbenchWindow));
		menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, showInSubMenu);
       }

	IStructuredSelection selection= getStructuredSelection();
	if (fShowOpenPropertiesAction && selection != null && fOpenPropertiesDialog.isApplicableForSelection())
		menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
}
 
源代码3 项目: jbt   文件: ApplicationActionBarAdvisor.java
protected void makeActions(IWorkbenchWindow window) {
	this.window = window;

	this.saveBTAction = ActionFactory.SAVE.create(this.window);
	this.saveBTAsAction = ActionFactory.SAVE_AS.create(this.window);
	this.exportAsCppAction = new DialogExportAsCppAction(this.window);
	this.openBTAction = new DialogOpenBTAction(this.window);
	this.newBTAction = new NewBTAction();
	this.loadMMPMDomainAction = new DialogLoadMMPMDomainAction(this.window);
	this.viewsList = ContributionItemFactory.VIEWS_SHORTLIST.create(this.window);
	this.aboutAction = ActionFactory.ABOUT.create(this.window);

	/* For key bindings and for copy and paste actions... */
	this.register(this.saveBTAction);
	this.register(ActionFactory.COPY.create(this.window));
	this.register(ActionFactory.PASTE.create(this.window));
}
 
源代码4 项目: n4js   文件: N4JSEditor.java
@Override
protected void editorContextMenuAboutToShow(final IMenuManager menu) {
	super.editorContextMenuAboutToShow(menu);

	final IContributionItem[] items = menu.getItems();
	for (int i = 0; i < items.length; i++) {
		if (items[i] instanceof IMenuManager) {
			final IMenuManager subMenu = (IMenuManager) items[i];
			final IContributionItem testShowIn = subMenu.find(ContributionItemFactory.VIEWS_SHOW_IN.getId());
			if (null != testShowIn) {
				menu.remove(subMenu);
			}
		}
	}
}
 
源代码5 项目: neoscada   文件: ApplicationActionBarAdvisor.java
@Override
protected void makeActions ( final IWorkbenchWindow window )
{
    this.newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create ( window );
    this.exitAction = ActionFactory.QUIT.create ( window );
    this.aboutAction = ActionFactory.ABOUT.create ( window );

    this.showViews = ContributionItemFactory.VIEWS_SHORTLIST.create ( window );
    this.newWizards = ContributionItemFactory.NEW_WIZARD_SHORTLIST.create ( window );

    this.showHelpAction = ActionFactory.HELP_CONTENTS.create ( window );
    this.searchHelpAction = ActionFactory.HELP_SEARCH.create ( window );
    this.dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create ( window );

    register ( this.exitAction );
    register ( this.aboutAction );
    register ( this.newWindowAction );

    register ( this.showHelpAction );
    register ( this.searchHelpAction );
    register ( this.dynamicHelpAction );

    register ( ActionFactory.NEW_WIZARD_DROP_DOWN.create ( window ) );
    register ( ActionFactory.NEW.create ( window ) );
    register ( ActionFactory.INTRO.create ( window ) );
    register ( ActionFactory.SAVE.create ( window ) );

    register ( ActionFactory.NEW_EDITOR.create ( window ) );
    register ( ActionFactory.PREFERENCES.create ( window ) );
}
 
源代码6 项目: depan   文件: ApplicationActionBarAdvisor.java
@Override
protected void fillMenuBar(IMenuManager menuBar) {
  //DepAn menu actions
  MenuManager newMenu = new MenuManager("New...", "New...");
  IContributionItem newWizards = ContributionItemFactory.NEW_WIZARD_SHORTLIST
      .create(getActionBarConfigurer().getWindowConfigurer().getWindow());
  newMenu.add(newWizards);

  // window menu actions
  MenuManager viewsMenu = new MenuManager("Views", "Views");
  IContributionItem views = ContributionItemFactory.VIEWS_SHORTLIST
      .create(getActionBarConfigurer().getWindowConfigurer().getWindow());
  viewsMenu.add(views);

  // top level menu
  MenuManager depanMenu = new MenuManager("&DepAn", "DepAn");
  depanMenu.add(newMenu);
  depanMenu.add(new Separator());
  depanMenu.add(saveAction);
  depanMenu.add(saveAsAction);
  depanMenu.add(new Separator());
  depanMenu.add(exitAction);

  MenuManager windowMenu = new MenuManager("&Window", "Window");
  windowMenu.add(viewsMenu);
  windowMenu.add(preferencesAction);

  MenuManager helpMenu = new MenuManager("&Help", "Help");
  helpMenu.add(aboutAction);

  menuBar.add(depanMenu);
  // Room for Edit, View, etc.
  menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
  menuBar.add(windowMenu);
  menuBar.add(helpMenu);
}
 
源代码7 项目: depan   文件: ApplicationActionBarAdvisor.java
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
  IToolBarManager toolbar = new ToolBarManager(coolBar.getStyle());
  toolbar.add(saveAction);
  toolbar.add(ContributionItemFactory.NEW_WIZARD_SHORTLIST
      .create(getActionBarConfigurer().getWindowConfigurer().getWindow()));

  coolBar.add(toolbar);
  // allow contributions here with id "additions" (MB_ADDITIONS)
  coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
}
 
源代码8 项目: gama   文件: ShowViewContributionItem.java
@Override
protected IContributionItem[] getContributionItems() {
	final List<IContributionItem> menuContributionList = new ArrayList<>();
	final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	final IContributionItem item = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
	menuContributionList.add(item); // add the list of views in the menu
	return menuContributionList.toArray(new IContributionItem[menuContributionList.size()]);
}
 
/**
 * 创建文件菜单
 * @return 返回文件菜单的 menu manager;
 */
private MenuManager createFileMenu() {
	MenuManager menu = new MenuManager(Messages.getString("ts.ApplicationActionBarAdvisor.menu.file"),
			IWorkbenchActionConstants.M_FILE); // &File
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
	// 添加 new.ext group,这样 IDE 中定义的 Open File... 可以显示在最顶端
	// menu.add(newAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
	menu.add(new Separator());
	menu.add(closeAction);
	menu.add(closeAllAction);
	menu.add(refreshAction);
	// menu.add(new Separator("net.heartsome.cat.ts.ui.menu.file.separator"));
	menu.add(new GroupMarker("xliff.switch"));
	menu.add(new GroupMarker("rtf.switch"));
	menu.add(new GroupMarker("xliff.split"));
	menu.add(new Separator());
	// 设置保存文件记录条数为 5 条
	WorkbenchPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.RECENT_FILES, 5);
	// 添加文件访问列表
	ContributionItemFactory REOPEN_EDITORS = new ContributionItemFactory("reopenEditors") { //$NON-NLS-1$
		/* (non-javadoc) method declared on ContributionItemFactory */
		public IContributionItem create(IWorkbenchWindow window) {
			if (window == null) {
				throw new IllegalArgumentException();
			}
			return new ReopenEditorMenu(window, getId(), false);
		}
	};
	menu.add(REOPEN_EDITORS.create(window));

	menu.add(exitAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
	return menu;
}
 
源代码10 项目: tmxeditor8   文件: ApplicationActionBarAdvisor.java
/**
 * 创建文件菜单
 * @return 返回文件菜单的 menu manager;
 */
private MenuManager createFileMenu() {
	MenuManager menu = new MenuManager(Messages.getString("ts.ApplicationActionBarAdvisor.menu.file"),
			IWorkbenchActionConstants.M_FILE); // &File
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
	// 添加 new.ext group,这样 IDE 中定义的 Open File... 可以显示在最顶端
	menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
	menu.add(new Separator());
	menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));
	menu.add(new GroupMarker("xliff.switch"));
	menu.add(new GroupMarker("rtf.switch"));
	menu.add(new GroupMarker("xliff.split"));
	menu.add(new Separator());
	// 设置保存文件记录条数为 5 条
	WorkbenchPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.RECENT_FILES, 5);
	// 添加文件访问列表
	ContributionItemFactory REOPEN_EDITORS = new ContributionItemFactory("reopenEditors") { //$NON-NLS-1$
		/* (non-javadoc) method declared on ContributionItemFactory */
		public IContributionItem create(IWorkbenchWindow window) {
			if (window == null) {
				throw new IllegalArgumentException();
			}
			return new ReopenEditorMenu(window, getId(), false);
		}
	};
	menu.add(REOPEN_EDITORS.create(window));

	menu.add(exitAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
	return menu;
}
 
源代码11 项目: birt   文件: DesignerActionBarAdvisor.java
/**
 * Creates and returns the File menu.
 */
private MenuManager createFileMenu( )
{
	MenuManager menu = new MenuManager( DesignerWorkbenchMessages.Workbench_file,
			IWorkbenchActionConstants.M_FILE );
	
	MenuManager newMenu = new MenuManager(DesignerWorkbenchMessages.Workbench_new, ActionFactory.NEW.getId());
	newMenu.add(newReportAction);
	newMenu.add(newLibraryAction);
	newMenu.add(newReportTemplateAction);
	for (int i=0; i<newActions.length; i++)
	{
		newMenu.add(newActions[i]);
	}
	menu.add(newMenu);
	
	menu.add(openFileAction);
	menu.add( new Separator( ) );

	menu.add( closeAction );
	menu.add( closeAllAction );
	menu.add( new GroupMarker( IWorkbenchActionConstants.CLOSE_EXT ) );
	menu.add( new Separator( ) );
	menu.add( saveAction );
	menu.add( saveAsAction );
	menu.add( saveAllAction );
	menu.add( new GroupMarker( IWorkbenchActionConstants.SAVE_EXT ) );

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

	menu.add( ContributionItemFactory.REOPEN_EDITORS.create( getWindow( ) ) );
	menu.add( new GroupMarker( IWorkbenchActionConstants.MRU ) );
	menu.add( new Separator( ) );
	menu.add( quitAction );
	menu.add( new GroupMarker( IWorkbenchActionConstants.FILE_END ) );
	return menu;
}
 
源代码12 项目: birt   文件: DesignerActionBarAdvisor.java
/**
 * Adds the perspective actions to the specified menu.
 */
private void addPerspectiveActions( MenuManager menu )
{
	{
		MenuManager showViewMenuMgr = new MenuManager( DesignerWorkbenchMessages.Workbench_showView,
				"showView" ); //$NON-NLS-1$
		IContributionItem showViewMenu = ContributionItemFactory.VIEWS_SHORTLIST.create( getWindow( ) );
		showViewMenuMgr.add( showViewMenu );
		menu.add( showViewMenuMgr );
	}
}
 
源代码13 项目: ice   文件: ClientActionBarAdvisor.java
/**
 * This operation overrides makeActions to setup actions for ICE.
 */
@Override
protected void makeActions(IWorkbenchWindow window) {

	// Create an Exit application action
	exitAction = ActionFactory.QUIT.create(window);
	// Create an about application action
	// Create a connect to Core action
	// Create an action to create Items
	createItemAction = new CreateItemAction(window);
	// Create an action for saving something and an action for saving
	// everything
	saveAction = ActionFactory.SAVE.create(window);
	saveAllAction = ActionFactory.SAVE_ALL.create(window);
	// Create an action for importing files
	importFileAction = new ImportFileAction(window);
	// Create an action for launching a Mesh Editor.
	launchMeshEditorAction = new LaunchMeshEditorAction();
	// Create an action for importing input files as Items
	openImportWizardAction = new ImportItemWizardAction(window);

	// Register these actions with the ActionBarAdvisor
	register(exitAction);
	register(createItemAction);
	register(saveAction);
	register(saveAllAction);
	register(importFileAction);
	register(openImportWizardAction);

	// Create a Perspectives menu item
	perspectivesMenu = ContributionItemFactory.PERSPECTIVES_SHORTLIST
			.create(window);

	// Add the "Show View" menu
	showViewMenu = ContributionItemFactory.VIEWS_SHORTLIST.create(window);

	return;
}
 
源代码14 项目: olca-app   文件: RcpActionBarAdvisor.java
@Override
protected void makeActions(IWorkbenchWindow window) {
	// save
	saveAction = ActionFactory.SAVE.create(window);
	saveAction.setText(M.Save);
	saveAction.setImageDescriptor(Icon.SAVE.descriptor());
	saveAction.setDisabledImageDescriptor(Icon.SAVE_DISABLED.descriptor());

	// save as
	saveAsAction = ActionFactory.SAVE_AS.create(window);
	saveAsAction.setText(M.SaveAs);
	saveAsAction.setImageDescriptor(Icon.SAVE_AS.descriptor());
	saveAsAction.setDisabledImageDescriptor(Icon.SAVE_AS_DISABLED.descriptor());

	// save all
	saveAllAction = ActionFactory.SAVE_ALL.create(window);
	saveAllAction.setText(M.SaveAll);
	saveAllAction.setImageDescriptor(Icon.SAVE_ALL.descriptor());
	saveAllAction.setDisabledImageDescriptor(Icon.SAVE_ALL_DISABLED.descriptor());

	// close & close all
	closeAction = ActionFactory.CLOSE.create(window);
	closeAction.setText(M.Close);
	closeAllAction = ActionFactory.CLOSE_ALL.create(window);
	closeAllAction.setText(M.CloseAll);

	// preferences
	preferencesAction = ActionFactory.PREFERENCES.create(window);
	preferencesAction.setImageDescriptor(Icon.PREFERENCES.descriptor());
	preferencesAction.setText(M.Settings);

	// other
	exitAction = ActionFactory.QUIT.create(window);
	exitAction.setText(M.Exit);
	showViews = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
	aboutAction = ActionFactory.ABOUT.create(window);
	aboutAction.setText(M.AboutOpenLCA);
}
 
源代码15 项目: gama   文件: GamaActionBarAdvisor.java
/**
 * Creates and returns the File menu.
 */
private MenuManager createFileMenu() {
	final MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_file, IWorkbenchActionConstants.M_FILE);
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
	{
		// create the New submenu, using the same id for it as the New action
		final String newText = IDEWorkbenchMessages.Workbench_new;
		final String newId = ActionFactory.NEW.getId();
		final MenuManager newMenu = new MenuManager(newText, newId);
		newMenu.setActionDefinitionId("org.eclipse.ui.file.newQuickMenu"); //$NON-NLS-1$
		newMenu.setImageDescriptor(icons.desc("navigator/navigator.new2"));
		newMenu.add(new Separator(newId));
		this.newWizardMenu = new BaseNewWizardMenu(getWindow(), null) {

			@Override
			protected void addItems(final List list) {
				addShortcuts(list);
			}
		};
		newMenu.add(this.newWizardMenu);
		newMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
		menu.add(newMenu);
	}

	menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
	menu.add(new Separator());

	menu.add(closeAction);
	menu.add(closeAllAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));
	menu.add(new Separator());
	menu.add(saveAction);
	menu.add(saveAsAction);
	menu.add(saveAllAction);
	// menu.add(getRevertItem());
	menu.add(new Separator());
	menu.add(getMoveItem());
	menu.add(getRenameItem());
	menu.add(getRefreshItem());

	menu.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT));
	menu.add(new Separator());
	menu.add(getPrintItem());
	menu.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT));
	menu.add(new Separator());
	menu.add(openWorkspaceAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT));
	menu.add(new GroupMarker(IWorkbenchActionConstants.IMPORT_EXT));
	menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

	menu.add(new Separator());
	menu.add(getPropertiesItem());

	menu.add(ContributionItemFactory.REOPEN_EDITORS.create(getWindow()));
	menu.add(new GroupMarker(IWorkbenchActionConstants.MRU));
	menu.add(new Separator());

	// If we're on OS X we shouldn't show this command in the File menu. It
	// should be invisible to the user. However, we should not remove it -
	// the carbon UI code will do a search through our menu structure
	// looking for it when Cmd-Q is invoked (or Quit is chosen from the
	// application menu.
	final ActionContributionItem quitItem = new ActionContributionItem(quitAction);
	quitItem.setVisible(!Util.isMac());
	menu.add(quitItem);
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
	return menu;
}
 
protected void fillMenuBar(IMenuManager menuBar){
	
	fileMenu =
		new MenuManager(Messages.ApplicationActionBarAdvisor_3,
			IWorkbenchActionConstants.M_FILE);
	fileMenu.addMenuListener(reflectRightsListener);
	editMenu =
		new MenuManager(Messages.ApplicationActionBarAdvisor_4,
			IWorkbenchActionConstants.M_EDIT);
	editMenu.addMenuListener(reflectRightsListener);
	windowMenu =
		new MenuManager(Messages.ApplicationActionBarAdvisor_5,
			IWorkbenchActionConstants.M_WINDOW);
	helpMenu =
		new MenuManager(Messages.ApplicationActionBarAdvisor_6,
			IWorkbenchActionConstants.M_HELP);
	helpMenu.addMenuListener(reflectRightsListener);
	menuBar.add(fileMenu);
	menuBar.add(editMenu);
	menuBar.add(windowMenu);
	menuBar.add(helpMenu);
	
	fileMenu.add(GlobalActions.loginAction);
	fileMenu.add(GlobalActions.changeMandantAction);
	fileMenu.add(GlobalActions.connectWizardAction);
	fileMenu.add(GlobalActions.prefsAction);
	fileMenu.add(new Separator());
	fileMenu.add(GlobalActions.importAction);
	fileMenu.add(new GroupMarker(IMPORTER_GROUP));
	fileMenu.add(new Separator());
	// fileMenu.add(GlobalActions.updateAction);
	fileMenu.add(new GroupMarker(ADDITIONS));
	fileMenu.add(new Separator());
	fileMenu.add(GlobalActions.exitAction);
	
	editMenu.add(GlobalActions.copyAction);
	editMenu.add(GlobalActions.cutAction);
	editMenu.add(GlobalActions.pasteAction);

	
	GlobalActions.perspectiveMenu =
		new MenuManager(Messages.ApplicationActionBarAdvisor_7, "openPerspective"); //$NON-NLS-1$
	perspectiveMenu.add(resetPerspectiveAction);
	windowMenu.add(perspectiveMenu);
	
	GlobalActions.viewMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_9);
	GlobalActions.viewList = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
	GlobalActions.viewMenu.add(GlobalActions.viewList);
	windowMenu.add(GlobalActions.viewMenu);
	windowMenu.addMenuListener(new IMenuListener() {
		
		@Override
		public void menuAboutToShow(IMenuManager manager){
			IContributionItem[] items = manager.getItems();
			for (IContributionItem iContributionItem : items) {
				if( "viewsShortlist".equals(iContributionItem.getId())) {
					iContributionItem.setVisible(CoreHub.acl.request(AC_SHOWVIEW));
				}
			}
		}
	});
	
	/* helpMenu.add(testAction); */
	helpMenu.add(GlobalActions.helpAction);
	helpMenu.add(new Separator("additions"));
	helpMenu.add(new Separator());
	helpMenu.add(GlobalActions.aboutAction);
}
 
 类所在包
 同包方法