org.eclipse.ui.actions.ContributionItemFactory Java Examples

The following examples show how to use org.eclipse.ui.actions.ContributionItemFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationActionBarAdvisor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@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 ) );
}
 
Example #2
Source File: OpenViewActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: ApplicationActionBarAdvisor.java    From jbt with Apache License 2.0 6 votes vote down vote up
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));
}
 
Example #4
Source File: N4JSEditor.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@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);
			}
		}
	}
}
 
Example #5
Source File: ApplicationActionBarAdvisor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@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 ) );
}
 
Example #6
Source File: ApplicationActionBarAdvisor.java    From depan with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: ApplicationActionBarAdvisor.java    From depan with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example #8
Source File: ShowViewContributionItem.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@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()]);
}
 
Example #9
Source File: ApplicationActionBarAdvisor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件菜单
 * @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;
}
 
Example #10
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件菜单
 * @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;
}
 
Example #11
Source File: DesignerActionBarAdvisor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: DesignerActionBarAdvisor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 );
	}
}
 
Example #13
Source File: ClientActionBarAdvisor.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #14
Source File: RcpActionBarAdvisor.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: GamaActionBarAdvisor.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source File: ApplicationActionBarAdvisor.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
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);
}