Search in sources :

Example 1 with ContributionItemFactory

use of org.eclipse.ui.actions.ContributionItemFactory in project translationstudio8 by heartsome.

the class ApplicationActionBarAdvisor method createFileMenu.

/**
	 * 创建文件菜单
	 * @return 返回文件菜单的 menu manager;
	 */
private MenuManager createFileMenu() {
    MenuManager menu = new MenuManager(Messages.getString("ts.ApplicationActionBarAdvisor.menu.file"), // &File
    IWorkbenchActionConstants.M_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 //$NON-NLS-1$
    ContributionItemFactory(//$NON-NLS-1$
    "reopenEditors") {

        /* (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;
}
Also used : ContributionItemFactory(org.eclipse.ui.actions.ContributionItemFactory) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ReopenEditorMenu(org.eclipse.ui.internal.ReopenEditorMenu) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) GroupMarker(org.eclipse.jface.action.GroupMarker) Separator(org.eclipse.jface.action.Separator)

Aggregations

GroupMarker (org.eclipse.jface.action.GroupMarker)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 ContributionItemFactory (org.eclipse.ui.actions.ContributionItemFactory)1 ReopenEditorMenu (org.eclipse.ui.internal.ReopenEditorMenu)1