Java 类org.eclipse.ui.internal.WorkbenchWindow 实例源码

项目:eclipse-plugin-commander    文件:EclipseCommandProvider.java   
public EclipseCommandProvider initializeWithCurrentContext() {
    commandsAvailableWithCurrentContext.clear();

    WorkbenchWindow workbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    final org.eclipse.e4.ui.model.application.ui.basic.MWindow model = workbenchWindow.getModel();

    providers = new ArrayList<>();
    //providers.add(new EditorProvider());
    providers.add(new ViewProvider(model.getContext().get(MApplication.class), model));
    providers.add(new PerspectiveProvider());
    providers.add(new CommandProvider(new ExpressionContext(model.getContext().getActiveLeaf())));
    providers.add(new ActionProvider());
    providers.add(new PreferenceProvider());
    providers.add(new PropertiesProvider());
    providers.add(new WizardProvider());
    providers.add(new LaunchProvider());

    getAllCommands();

    return this;
}
项目:gama    文件:CleanupHelper.java   
public static void run() {
    WorkbenchHelper.run(() -> {
        final IWorkbenchWindow window = Workbench.getInstance().getActiveWorkbenchWindow();
        if (window instanceof WorkbenchWindow) {
            final IMenuManager menuManager = ((WorkbenchWindow) window).getMenuManager();
            for (final IContributionItem item : menuManager.getItems()) {
                IMenuManager menu = null;
                if (item instanceof MenuManager) {
                    menu = (MenuManager) item;
                } else if (item instanceof ActionSetContributionItem) {
                    if (((ActionSetContributionItem) item).getInnerItem() instanceof MenuManager) {
                        menu = (MenuManager) ((ActionSetContributionItem) item).getInnerItem();
                    }
                }
                if (menu != null) {
                    processItems(menu);
                }
            }
            menuManager.updateAll(true);
        }

    });

}
项目:APICloud-Studio    文件:UIUtils.java   
public static void setCoolBarVisibility(boolean visible)
{
    IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
    if (activeWorkbenchWindow instanceof WorkbenchWindow)
    {
        WorkbenchWindow workbenchWindow = (WorkbenchWindow) activeWorkbenchWindow;
        workbenchWindow.setCoolBarVisible(visible);
        workbenchWindow.setPerspectiveBarVisible(visible);

        // Try to force a refresh of the text on the action
        IWorkbenchPart activePart = getActivePart();
        if (activePart != null)
        {
            ICommandService cmdService = (ICommandService) activePart.getSite().getService(ICommandService.class);
            cmdService.refreshElements("org.eclipse.ui.ToggleCoolbarAction", null); //$NON-NLS-1$
        }
    }
}
项目:Hydrograph    文件:WorkbenchWidgetsUtils.java   
/**
 * Returns tool-bar instance of given id
 * @param toolBarId
 *      toolBar -  Id
 * @return
 *      toolBar with given toolBar-id 
 */ 
public ToolBarContributionItem getToolBarMangerOrMenuManagerFromCoolBar(String toolBarId) {
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IContributionItem[] contributionItems = ((WorkbenchWindow) workbenchWindow).getActionBars().getCoolBarManager()
            .getItems();
    for (IContributionItem contributionItem : contributionItems) {
        if (contributionItem instanceof ToolBarContributionItem
                && StringUtils.equals(contributionItem.getId(), toolBarId)) {
            return (ToolBarContributionItem) contributionItem;
        }
    }
    return null;
}
项目:org.csstudio.display.builder    文件:RCPHacks.java   
/** Remove toolbar and menu entries unrelated to the display builder
 *  @param page {@link IWorkbenchPage}
 */
public static void hideUnrelatedUI(final IWorkbenchPage page)
{
    // Hide BOY "Top Files" tool bar drop-down
    page.hideActionSet("org.csstudio.opibuilder.actionSet");
    // Hide "Search" (git, file) from tool bar
    page.hideActionSet("org.eclipse.search.searchActionSet");

    if (! (page.getWorkbenchWindow() instanceof WorkbenchWindow))
        return;
    final WorkbenchWindow window = (WorkbenchWindow)page.getWorkbenchWindow();

    final ICoolBarManager toolbar = window.getCoolBarManager2();
    for (IContributionItem item : toolbar.getItems())
    {
        // System.out.println(item.getId());
        if (remove_from_toolbar.contains(item.getId()))
        {   // Result of trial-and-error:
            // * item.setVisible(false) has no effect
            // * toolbar.remove(item) results in
            //   Error disposing widget for : org.eclipse.e4.ui.model.application.ui.menu.impl.ToolBarImpl
            //     java.lang.NullPointerException
            //     at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.cleanUpCopy(ToolBarManagerRenderer.java:554)
            //     at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.cleanUp(ToolBarManagerRenderer.java:534)
            //     at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer$4.widgetDisposed(ToolBarManagerRenderer.java:423
            // * disposing the item without removing it from the toolbar "works" ?!
            item.dispose();
        }
    }
    toolbar.update(true);

    patchMenu(window);
}
项目:org.csstudio.display.builder    文件:FullScreenAction.java   
@Override
public void run()
{
    final Shell shell = page.getWorkbenchWindow().getShell();
    final boolean fullscreen = ! shell.getFullScreen();

    final WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow();
    shell.setFullScreen(fullscreen);
    window.setCoolBarVisible(! fullscreen);
    window.setPerspectiveBarVisible(! fullscreen);
    setStatusBarVisibile(shell, ! fullscreen);
    // For Mac OS X, menu bar is automatically hidden,
    // but still available when moving mouse up,
    // so keep it.
    if (! PlatformInfo.is_mac_os_x)
    {
        // For Linux and Windows, show/hide
        // to maximize screen space
        if (fullscreen)
        {
            // menubar.setVisible(false) has no effect.
            // Need to remember current menu bar, then remove
            menubar = shell.getMenuBar();
            //
            shell.setMenuBar(null);
        }
        else if (menubar != null)
            // Restore saved menu bar
            shell.setMenuBar(menubar);
    }
}
项目:gama    文件:CleanupHelper.java   
@Override
public void perspectiveActivated(final IWorkbenchPage page, final IPerspectiveDescriptor perspective) {
    final WorkbenchWindow w = (WorkbenchWindow) page.getWorkbenchWindow();
    WorkbenchHelper.asyncRun(() -> {
        // RearrangeMenus.run();
        final IContributionItem[] items = w.getCoolBarManager2().getItems();
        // System.out.println(Arrays.toString(items));
        // We remove all contributions to the toolbar that do not
        // relate
        // to gama
        for (final IContributionItem item : items) {

            for (final String s1 : TOOLBAR_ACTION_SETS_TO_REMOVE) {
                if (item.getId().contains(s1)) {
                    try {
                        if (w.getCoolBarManager2().find(item.getId()) != null)
                            w.getCoolBarManager2().remove(item);
                    } catch (final Exception e) {}
                }
            }
        }

        // exploreMenus(w.getMenuBarManager(), "");
        for (final String s2 : MENUS_TO_REMOVE) {
            w.getMenuBarManager().remove(s2);
            w.getMenuManager().remove(s2);
        }
        // Update the tool and menu bars
        w.getCoolBarManager2().update(true);
        w.getMenuManager().update(true);
        w.getMenuBarManager().update(true);
    });
}
项目:APICloud-Studio    文件:UIUtils.java   
public static boolean getCoolBarVisibility()
{
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench != null)
    {
        IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
        if (activeWorkbenchWindow instanceof WorkbenchWindow)
        {
            return ((WorkbenchWindow) activeWorkbenchWindow).getCoolBarVisible();
        }
    }
    return true;
}
项目:translationstudio8    文件:OpenToolBarHandler.java   
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    if (activeWorkbenchWindow instanceof WorkbenchWindow) {
        WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow;
        window.toggleToolbarVisibility();
    }

    ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    commandService.refreshElements(event.getCommand().getId(), null);

    return null;
}
项目:translationstudio8    文件:OpenToolBarHandler.java   
@SuppressWarnings("rawtypes")
public void updateElement(final UIElement element, Map parameters) {
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (activeWorkbenchWindow instanceof WorkbenchWindow) {
                WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow;
                boolean coolbarVisible = window.getCoolBarVisible();
                element.setIcon(coolbarVisible ? Activator.getImageDescriptor("icons/enabled_co.png") : Activator
                        .getImageDescriptor("icons/disabled_co.png"));
            }
        }
    });

}
项目:translationstudio8    文件:PluginConfigManage.java   
@SuppressWarnings("restriction")
public PluginConfigManage() {
    pluginXmlLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation()
            .append(PluginConstants.PC_pluginConfigLocation).toOSString();
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    parentManager = window.getMenuBarManager();
    shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
}
项目:sadlos2    文件:SADL.java   
@Override
public void createInitialLayout(IPageLayout factory) {
    this.factory = factory;

    IWorkbenchWindow window = Workbench.getInstance()
            .getActiveWorkbenchWindow();

    if (window instanceof WorkbenchWindow) {
        window = Workbench.getInstance().getActiveWorkbenchWindow();
        MenuManager menuManager = ((WorkbenchWindow) window)
                .getMenuManager();

        String[] itemIds = { "Navigate", "Help" };
        for (String itemId : itemIds) {
            // represents a contribution to a shared UI resource
            IContributionItem item = menuManager.find(itemId);
            // if the item is not null then set it to not visible?
            if (item != null) {
                item.setVisible(false);
                menuManager.update();

            }

        }
    }
    addViews();
    addActionSets();
    addNewWizardShortcuts();
    addPerspectiveShortcuts();
    addViewShortcuts();
}
项目:tmxeditor8    文件:OpenToolBarHandler.java   
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    if (activeWorkbenchWindow instanceof WorkbenchWindow) {
        WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow;
        window.toggleToolbarVisibility();
    }

    ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    commandService.refreshElements(event.getCommand().getId(), null);

    return null;
}
项目:tmxeditor8    文件:OpenToolBarHandler.java   
@SuppressWarnings("rawtypes")
public void updateElement(final UIElement element, Map parameters) {
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (activeWorkbenchWindow instanceof WorkbenchWindow) {
                WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow;
                boolean coolbarVisible = window.getCoolBarVisible();
                element.setIcon(coolbarVisible ? Activator.getImageDescriptor("icons/enabled_co.png") : Activator
                        .getImageDescriptor("icons/disabled_co.png"));
            }
        }
    });

}
项目:tmxeditor8    文件:PluginConfigManage.java   
@SuppressWarnings("restriction")
public PluginConfigManage() {
    pluginXmlLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation()
            .append(PluginConstants.PC_pluginConfigLocation).toOSString();
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    parentManager = window.getMenuBarManager();
    shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
}
项目:e4macs    文件:BrowseKillRingHandler.java   
/**
 * Insert text from kill ring entry into the most recently activated text editor
 * 
 * @param text - the text from the kill ring entry
 */
//  @SuppressWarnings("restriction")    // for cast to internal org.eclipse.ui.internal.WorkbenchWindow
private void insertFromBrowseRing(String text) {
    // insert into most recently active editor
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    RecentEditor recent = getRecentEditor();
    // use widget to avoid unpleasant scrolling side effects of IRewriteTarget      
    Control widget = MarkUtils.getTextWidget(recent.editor);
    if (recent.editor != null) {
        try {
            // cache for ancillary computations
            setThisEditor(recent.editor);
            // reduce the amount of unnecessary work
            if (window instanceof WorkbenchWindow) {
                ((WorkbenchWindow) window).largeUpdateStart();
            }
            widget.setRedraw(false);
            recent.page.activate(recent.epart);
            insertText(recent.editor.getDocumentProvider().getDocument(recent.editor.getEditorInput()),
                    (ITextSelection)recent.editor.getSelectionProvider().getSelection(), text);
        } catch (Exception e) {
        } finally {
            widget.setRedraw(true);
            setThisEditor(null);
            if (window instanceof WorkbenchWindow) {
                ((WorkbenchWindow) window).largeUpdateEnd();
            }
        }
    } else {
        beep();
    }
}
项目:eclipseRecorder    文件:LogoManager.java   
private synchronized IStatusLineManager getStatusLineManager() {
    if (statusLineManager != null)
        return statusLineManager;
    IWorkbenchWindow activeWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWindow == null)
        return null;

    statusLineManager = ((WorkbenchWindow)activeWindow).getStatusLineManager();

    return statusLineManager;
}
项目:Hydrograph    文件:CoolBarHelperUtility.java   
/**
 * @param enable Edit option for tracking sub job is removed.
 */
@SuppressWarnings("restriction")
public void enableSaveAs(boolean enable) {
     IContributionItem contributionItem  = (IContributionItem) ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getMenuBarManager().getItems()[2];
     contributionItem.setVisible(enable);
}
项目:pandionj    文件:PandionJPerspective.java   
private void setupPrefs() {
        IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode("org.eclipse.debug.ui");
        prefs.put("org.eclipse.debug.ui.activate_debug_view", "false");
        prefs.put("org.eclipse.debug.ui.switch_perspective_on_suspend", "never");
        IEclipsePreferences prefsUi = InstanceScope.INSTANCE.getNode("org.eclipse.ui.ide");
        prefsUi.put("SWITCH_PERSPECTIVE_ON_PROJECT_CREATION", "never");

        IEclipsePreferences prefsJdt = InstanceScope.INSTANCE.getNode("org.eclipse.jdt.ui");
        prefsJdt.put("hoverModifiers", " org.eclipse.jdt.ui.BestMatchHover;!0;org.eclipse.jdt.internal.debug.ui.JavaDebugHover;!0;org.eclipse.jdt.ui.ProblemHover;!0;org.eclipse.jdt.ui.NLSStringHover;Command+Alt;org.eclipse.jdt.ui.JavadocHover;Command+Shift;org.eclipse.jdt.ui.AnnotationHover;!0;org.eclipse.jdt.ui.JavaSourceHover;Shift;");

        char c = '\u0000';
        prefsJdt.put("content_assist_disabled_computers", 
                "org.eclipse.jdt.ui.swtProposalCategory" + c + 
                "org.eclipse.jdt.ui.javaNoTypeProposalCategory" + c + 
                "org.eclipse.jdt.ui.javaTypeProposalCategory" + c + 
                "org.eclipse.jdt.ui.textProposalCategory" + c +  
                "org.eclipse.jdt.ui.javaAllProposalCategory" + c + 
                "org.eclipse.mylyn.java.ui.javaAllProposalCategory" + c +
                "org.eclipse.e4.tools.jdt.templates.e4ProposalCategory" + c + 
                "org.eclipse.pde.api.tools.ui.apitools_proposal_category" + c + 
                "org.eclipse.recommenders.calls.rcp.proposalCategory.templates" + c + 
                "org.eclipse.recommenders.chain.rcp.proposalCategory.chain" + c + 
                "org.eclipse.recommenders.completion.rcp.proposalCategory.intelligent" + c + 
                "org.eclipse.jdt.ui.templateProposalCategory" + c);

        prefsJdt.put("closeBraces", "false");
        prefsJdt.put("closeBrackets", "false");
        prefsJdt.put("closeJavaDocs", "false");
        prefsJdt.put("closeStrings", "false");
        prefsJdt.put("smart_opening_brace", "false");
        prefsJdt.put("content_assist_fill_method_arguments", "false");
        prefsJdt.put("editor_folding_enabled", "false");

        IEclipsePreferences prefsWb = InstanceScope.INSTANCE.getNode("org.eclipse.ui.workbench");
        prefsWb.put("org.eclipse.debug.ui.consoleFont","1|Monaco|14.0|0|COCOA|1|Monaco");

//      IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
//      try {
//          Object executeCommand = handlerService.executeCommand("org.eclipse.ui.ToggleCoolbarAction", null);
//          System.out.println(executeCommand);
//      } catch (Exception e) {
//          e.printStackTrace();
//      } 
        WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        boolean coolBarVisible = window.getCoolBarVisible();
        if(coolBarVisible)
            window.toggleToolbarVisibility();
    }
项目:translationstudio8    文件:PluginConfigManage.java   
@SuppressWarnings("restriction")
public PluginConfigManage(String pluginXmlLocation) {
    this.pluginXmlLocation = pluginXmlLocation;
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    parentManager = window.getMenuBarManager();
}
项目:tmxeditor8    文件:PluginConfigManage.java   
@SuppressWarnings("restriction")
public PluginConfigManage(String pluginXmlLocation) {
    this.pluginXmlLocation = pluginXmlLocation;
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    parentManager = window.getMenuBarManager();
}
项目:mytourbook    文件:MenuAnalyzer.java   
public TranslatableMenuItem createTranslatableMenu() {
    WorkbenchWindow window = (WorkbenchWindow)PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    MenuManager menuManager = window.getMenuBarManager();


    return createTranslatableMenu(menuManager, null);
}