Example usage for org.eclipse.jface.util Util isCocoa

List of usage examples for org.eclipse.jface.util Util isCocoa

Introduction

In this page you can find the example usage for org.eclipse.jface.util Util isCocoa.

Prototype

public static boolean isCocoa() 

Source Link

Document

Common WS query helper method.

Usage

From source file:it.albertus.jface.cocoa.CocoaUIEnhancer.java

License:Open Source License

private void hookApplicationMenu(@Nullable final Listener quitListener, final CallbackObject callbackObject)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
        ClassNotFoundException {/* ww w  .  ja  v a2  s. c  o m*/
    // Check platform
    if (!Util.isCocoa()) {
        logger.log(Level.WARNING, JFaceMessages.get("err.cocoa.enhancer.platform"));
    }

    initialize(callbackObject);

    // Connect the quit/exit menu.
    if (!display.isDisposed() && quitListener != null) {
        display.addListener(SWT.Close, quitListener);
    }

    // Schedule disposal of callback object.
    display.disposeExec(new Runnable() {
        @Override
        public void run() {
            proc3Args.dispose();
        }
    });
}

From source file:org.eclipse.ui.internal.ide.WorkbenchActionBuilder.java

License:Open Source License

/**
 * Creates and returns the Window menu.//from w  ww .j av  a2s  . c  om
 */
private MenuManager createWindowMenu() {
    MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_window,
            IWorkbenchActionConstants.M_WINDOW);

    addMacWindowMenuItems(menu);

    menu.add(newWindowAction);
    menu.add(newEditorAction);

    menu.add(new Separator());
    addPerspectiveActions(menu);
    menu.add(new Separator());
    addKeyboardShortcuts(menu);
    Separator sep = new Separator(IWorkbenchActionConstants.MB_ADDITIONS);
    sep.setVisible(!Util.isMac());
    menu.add(sep);

    if (Util.isCocoa())
        menu.add(arrangeWindowsItem);

    // See the comment for quit in createFileMenu
    ActionContributionItem openPreferencesItem = new ActionContributionItem(openPreferencesAction);
    openPreferencesItem.setVisible(!Util.isMac());
    menu.add(openPreferencesItem);

    menu.add(ContributionItemFactory.OPEN_WINDOWS.create(getWindow()));
    return menu;
}

From source file:org.eclipse.ui.internal.ide.WorkbenchActionBuilder.java

License:Open Source License

private void addMacWindowMenuItems(MenuManager windowMenu) {

    if (!Util.isCocoa())
        return;//www  .jav  a  2s  .  c  o  m

    windowMenu.add(minimizeItem);
    windowMenu.add(zoomItem);
    windowMenu.add(fullscreenItem);
    windowMenu.add(new Separator());
}

From source file:org.eclipse.ui.internal.ide.WorkbenchActionBuilder.java

License:Open Source License

/**
 * Creates actions (and contribution items) for the menu bar, toolbar and status line.
 *///from w  w  w.  j ava  2 s  . co  m
protected void makeActions(final IWorkbenchWindow window) {
    // @issue should obtain from ConfigurationItemFactory
    statusLineItem = new StatusLineContributionItem("ModeContributionItem"); //$NON-NLS-1$

    newWizardAction = ActionFactory.NEW.create(window);
    register(newWizardAction);

    newWizardDropDownAction = IDEActionFactory.NEW_WIZARD_DROP_DOWN.create(window);
    register(newWizardDropDownAction);

    importResourcesAction = ActionFactory.IMPORT.create(window);
    register(importResourcesAction);

    exportResourcesAction = ActionFactory.EXPORT.create(window);
    register(exportResourcesAction);

    buildAllAction = IDEActionFactory.BUILD.create(window);
    register(buildAllAction);

    cleanAction = IDEActionFactory.BUILD_CLEAN.create(window);
    register(cleanAction);

    toggleAutoBuildAction = IDEActionFactory.BUILD_AUTOMATICALLY.create(window);
    register(toggleAutoBuildAction);

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

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

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

    newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(getWindow());
    newWindowAction.setText(IDEWorkbenchMessages.Workbench_openNewWindow);
    register(newWindowAction);

    newEditorAction = ActionFactory.NEW_EDITOR.create(window);
    register(newEditorAction);

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

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

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

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

    closeOthersAction = ActionFactory.CLOSE_OTHERS.create(window);
    register(closeOthersAction);

    closeAllSavedAction = ActionFactory.CLOSE_ALL_SAVED.create(window);
    register(closeAllSavedAction);

    helpContentsAction = ActionFactory.HELP_CONTENTS.create(window);
    register(helpContentsAction);

    helpSearchAction = ActionFactory.HELP_SEARCH.create(window);
    register(helpSearchAction);

    dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create(window);
    register(dynamicHelpAction);

    aboutAction = ActionFactory.ABOUT.create(window);
    aboutAction.setImageDescriptor(
            IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_OBJS_DEFAULT_PROD));
    register(aboutAction);

    openPreferencesAction = ActionFactory.PREFERENCES.create(window);
    register(openPreferencesAction);

    makeFeatureDependentActions(window);

    // Actions for invisible accelerators
    showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window);
    register(showViewMenuAction);

    showPartPaneMenuAction = ActionFactory.SHOW_PART_PANE_MENU.create(window);
    register(showPartPaneMenuAction);

    nextEditorAction = ActionFactory.NEXT_EDITOR.create(window);
    register(nextEditorAction);
    prevEditorAction = ActionFactory.PREVIOUS_EDITOR.create(window);
    register(prevEditorAction);
    ActionFactory.linkCycleActionPair(nextEditorAction, prevEditorAction);

    nextPartAction = ActionFactory.NEXT_PART.create(window);
    register(nextPartAction);
    prevPartAction = ActionFactory.PREVIOUS_PART.create(window);
    register(prevPartAction);
    ActionFactory.linkCycleActionPair(nextPartAction, prevPartAction);

    nextPerspectiveAction = ActionFactory.NEXT_PERSPECTIVE.create(window);
    register(nextPerspectiveAction);
    prevPerspectiveAction = ActionFactory.PREVIOUS_PERSPECTIVE.create(window);
    register(prevPerspectiveAction);
    ActionFactory.linkCycleActionPair(nextPerspectiveAction, prevPerspectiveAction);

    activateEditorAction = ActionFactory.ACTIVATE_EDITOR.create(window);
    register(activateEditorAction);

    maximizePartAction = ActionFactory.MAXIMIZE.create(window);
    register(maximizePartAction);

    minimizePartAction = ActionFactory.MINIMIZE.create(window);
    register(minimizePartAction);

    switchToEditorAction = ActionFactory.SHOW_OPEN_EDITORS.create(window);
    register(switchToEditorAction);

    workbookEditorsAction = ActionFactory.SHOW_WORKBOOK_EDITORS.create(window);
    register(workbookEditorsAction);

    quickAccessAction = ActionFactory.SHOW_QUICK_ACCESS.create(window);

    hideShowEditorAction = ActionFactory.SHOW_EDITOR.create(window);
    register(hideShowEditorAction);
    editActionSetAction = ActionFactory.EDIT_ACTION_SETS.create(window);
    register(editActionSetAction);
    lockToolBarAction = ActionFactory.LOCK_TOOL_BAR.create(window);
    register(lockToolBarAction);
    closePerspAction = ActionFactory.CLOSE_PERSPECTIVE.create(window);
    register(closePerspAction);
    closeAllPerspsAction = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window);
    register(closeAllPerspsAction);

    forwardHistoryAction = ActionFactory.FORWARD_HISTORY.create(window);
    register(forwardHistoryAction);

    backwardHistoryAction = ActionFactory.BACKWARD_HISTORY.create(window);
    register(backwardHistoryAction);

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

    goIntoAction = ActionFactory.GO_INTO.create(window);
    register(goIntoAction);

    backAction = ActionFactory.BACK.create(window);
    register(backAction);

    forwardAction = ActionFactory.FORWARD.create(window);
    register(forwardAction);

    upAction = ActionFactory.UP.create(window);
    register(upAction);

    nextAction = ActionFactory.NEXT.create(window);
    nextAction.setImageDescriptor(
            IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV));
    register(nextAction);

    previousAction = ActionFactory.PREVIOUS.create(window);
    previousAction.setImageDescriptor(
            IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV));
    register(previousAction);

    buildProjectAction = IDEActionFactory.BUILD_PROJECT.create(window);
    register(buildProjectAction);

    openWorkspaceAction = IDEActionFactory.OPEN_WORKSPACE.create(window);
    register(openWorkspaceAction);

    projectPropertyDialogAction = IDEActionFactory.OPEN_PROJECT_PROPERTIES.create(window);
    register(projectPropertyDialogAction);

    if (window.getWorkbench().getIntroManager().hasIntro()) {
        introAction = ActionFactory.INTRO.create(window);
        register(introAction);
    }

    String showInQuickMenuId = IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_QUICK_MENU;
    showInQuickMenu = new QuickMenuAction(showInQuickMenuId) {
        protected void fillMenu(IMenuManager menu) {
            menu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(window));
        }
    };
    register(showInQuickMenu);

    final String newQuickMenuId = "org.eclipse.ui.file.newQuickMenu"; //$NON-NLS-1$
    newQuickMenu = new QuickMenuAction(newQuickMenuId) {
        protected void fillMenu(IMenuManager menu) {
            menu.add(new NewWizardMenu(window));
        }
    };
    register(newQuickMenu);

    if (Util.isCocoa()) {

        CommandContributionItemParameter minimizeParam = new CommandContributionItemParameter(window, null,
                "org.eclipse.ui.cocoa.minimizeWindow", CommandContributionItem.STYLE_PUSH); //$NON-NLS-1$
        minimizeItem = new CommandContributionItem(minimizeParam);
        CommandContributionItemParameter zoomParam = new CommandContributionItemParameter(window, null,
                "org.eclipse.ui.cocoa.zoomWindow", CommandContributionItem.STYLE_PUSH); //$NON-NLS-1$
        zoomItem = new CommandContributionItem(zoomParam);
        CommandContributionItemParameter fullscreenParam = new CommandContributionItemParameter(window, null,
                "org.eclipse.ui.cocoa.fullscreenWindow", CommandContributionItem.STYLE_PUSH); //$NON-NLS-1$
        fullscreenItem = new CommandContributionItem(fullscreenParam);
        CommandContributionItemParameter arrangeWindowsParam = new CommandContributionItemParameter(window,
                null, "org.eclipse.ui.cocoa.arrangeWindowsInFront", CommandContributionItem.STYLE_PUSH); //$NON-NLS-1$
        arrangeWindowsItem = new CommandContributionItem(arrangeWindowsParam);
    }

}

From source file:org.eclipse.ui.tests.session.SessionTests.java

License:Open Source License

/**
 * /*from  w ww  .j  av  a2 s  .co m*/
 */
private void addWindowlessSessionTest() {
    // Windowless apps are available only on Cocoa
    if (Util.isCocoa()) {
        Map arguments = new HashMap(2);
        arguments.put("product", null);
        arguments.put("testApplication", "org.eclipse.ui.tests.windowLessRcpApplication");
        WorkbenchSessionTest test = new WorkbenchSessionTest("windowlessSessionTests", arguments);
        test.addTest(WindowlessSessionTest.suite());
        addTest(test);
    }
}

From source file:org.eclipse.ui.tests.session.WorkbenchSessionTest.java

License:Open Source License

/**
 * Ensures setup uses this suite's instance location.
 * //from ww  w .  j a  v  a2 s .c o  m
 * @throws SetupException
 */
protected Setup newSetup() throws SetupException {
    Setup base = super.newSetup();
    try {
        base.setEclipseArgument(Setup.DATA, copyDataLocation());
        if (arguments != null) {
            for (Iterator i = arguments.entrySet().iterator(); i.hasNext();) {
                Map.Entry entry = (Map.Entry) i.next();
                String key = (String) entry.getKey();
                String value = (String) entry.getValue();
                base.setEclipseArgument(key, value);
            }
        }

        // <== Kludge for the bug 345127. Force spawned VM to be 32 bit
        // if we are in a 32bit Eclipse
        if (Util.isCocoa()) {
            String arch = System.getProperty("osgi.arch");
            if (Constants.ARCH_X86.equals(arch)) {
                Map vmArguments = new HashMap(1);
                vmArguments.put("d32", null);
                base.setVMArguments(vmArguments);
            }
        }
        // ==> End of kludge for the bug 345127.
    } catch (Exception e) {
        throw SetupManager.getInstance().new SetupException(e.getMessage(), e);
    }
    return base;
}

From source file:org.eclipse.viatra.query.patternlanguage.emf.ui.labeling.HTMLPrinter.java

License:Open Source License

/** JFaceColors#getInformationViewerBackgroundColor was only introduced in Neon */
private static Color getInformationViewerBackgroundColor(Display display) {
    if (Util.isWin32() || Util.isCocoa()) {
        // Technically COLOR_INFO_* should only be used for tooltips. But on
        // Windows/Cocoa COLOR_INFO_* gives info viewers/hovers a
        // yellow background which is very suitable for information
        // presentation.
        return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    }//from w w  w .  ja  va 2  s. c  o m

    // Technically, COLOR_LIST_* is not the best system color for this
    // because it is only supposed to be used for Tree/List controls. But at
    // the moment COLOR_TEXT_* is not implemented, so this should work for
    // now. See Bug 508612.
    return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
}

From source file:org.eclipse.viatra.query.patternlanguage.emf.ui.labeling.HTMLPrinter.java

License:Open Source License

/** JFaceColors#getInformationViewerForegroundColor was only introduced in Neon */
private static Color getInformationViewerForegroundColor(Display display) {
    if (Util.isWin32() || Util.isCocoa()) {
        // Technically COLOR_INFO_* should only be used for tooltips. But on
        // Windows/Cocoa COLOR_INFO_* gives info viewers/hovers a
        // yellow background which is very suitable for information
        // presentation.
        return display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    }//w  w  w  .j av  a  2s  . c  om

    // Technically, COLOR_LIST_* is not the best system color for this
    // because it is only supposed to be used for Tree/List controls. But at
    // the moment COLOR_TEXT_* is not implemented, so this should work for
    // now. See Bug 508612.
    return display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
}

From source file:org.springsource.ide.eclipse.commons.ui.HtmlTooltip.java

License:Open Source License

public static Color getInformationViewerBackgroundColor(Display display) {
    if (Util.isWin32() || Util.isCocoa()) {
        // Technically COLOR_INFO_* should only be used for tooltips. But on
        // Windows/Cocoa COLOR_INFO_* gives info viewers/hovers a
        // yellow background which is very suitable for information
        // presentation.
        return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    }//from w ww.java2  s.co  m

    // Technically, COLOR_LIST_* is not the best system color for this
    // because it is only supposed to be used for Tree/List controls. But at
    // the moment COLOR_TEXT_* is not implemented, so this should work for
    // now. See Bug 508612.
    return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
}

From source file:org.springsource.ide.eclipse.commons.ui.HtmlTooltip.java

License:Open Source License

public static Color getInformationViewerForegroundColor(Display display) {
    if (Util.isWin32() || Util.isCocoa()) {
        // Technically COLOR_INFO_* should only be used for tooltips. But on
        // Windows/Cocoa COLOR_INFO_* gives info viewers/hovers a
        // yellow background which is very suitable for information
        // presentation.
        return display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    }/*from w  ww  .  j a  v a  2 s  .  c  om*/

    // Technically, COLOR_LIST_* is not the best system color for this
    // because it is only supposed to be used for Tree/List controls. But at
    // the moment COLOR_TEXT_* is not implemented, so this should work for
    // now. See Bug 508612.
    return display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
}