Example usage for org.eclipse.jface.preference IPreferenceStore getBoolean

List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore getBoolean.

Prototype

boolean getBoolean(String name);

Source Link

Document

Returns the current value of the boolean-valued preference with the given name.

Usage

From source file:com.aptana.editor.findbar.impl.FindBarOption.java

License:Open Source License

public ToolItem createToolItem(ToolBar optionsToolBar) {
    if (!canCreateItem()) {
        return null;
    }/*from www  .  ja  v  a 2s . c o m*/
    ToolItem item = isCheckable() ? new ToolItem(optionsToolBar, SWT.CHECK)
            : new ToolItem(optionsToolBar, SWT.PUSH);

    item.setImage(FindBarPlugin.getImage(this.image));
    if (imageDisabled != null) {
        item.setDisabledImage(FindBarPlugin.getImage(this.imageDisabled));
    }
    item.setToolTipText(this.initialText);
    if (preferencesKey != null) {
        IPreferenceStore preferenceStore = FindBarPlugin.getDefault().getPreferenceStore();
        item.setSelection(preferenceStore.getBoolean(preferencesKey));
    }
    item.addSelectionListener(this);
    if (!this.initiallyEnabled) {
        item.setEnabled(false);
    }
    setToolItemInDecorator(item);
    return item;
}

From source file:com.aptana.formatter.FormatterUtils.java

License:Open Source License

/**
 * Returns the editor's setting for 'Insert Spaces for Tabs'. This setting exists in the general 'Text Editors'
 * preference page./*from w w w  . ja  v  a 2  s .  c o m*/
 * 
 * @param preferenceStore
 *            The editor's preferences store; Null, in case a workspace setting is needed.
 * @return The value for the generic editor's 'Insert Spaces for Tabs'
 */
public static boolean isInsertSpacesForTabs(IPreferenceStore preferenceStore) {
    IPreferenceStore prefs = getChainedPreferences(preferenceStore,
            EditorsPlugin.getDefault().getPreferenceStore());
    return prefs.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
}

From source file:com.aptana.ide.core.ui.InitialRestartStartup.java

License:Open Source License

public static void start() {
    try {/*w  ww.  ja va2  s . co  m*/
        IPreferenceStore preferences = CoreUIPlugin.getDefault().getPreferenceStore();

        IdeLog.logInfo(CoreUIPlugin.getDefault(),
                StringUtils.format(Messages.InitialRestartStartup_INF_CleanPreference,
                        preferences.getBoolean(IPreferenceConstants.PREF_CLEAN_RESTART)));

        if (preferences.getBoolean(IPreferenceConstants.PREF_CLEAN_RESTART)) {
            preferences.setValue(IPreferenceConstants.PREF_CLEAN_RESTART, false);
            System.setProperty(PROP_EXIT_CODE, Integer.toString(24));

            String commandLine = buildCommandLine("-clean"); //$NON-NLS-1$
            if (commandLine != null) {
                IdeLog.logInfo(CoreUIPlugin.getDefault(),
                        Messages.InitialRestartStartup_INF_NewCommandLine + commandLine);
                System.setProperty(PROP_EXIT_DATA, commandLine);
                restartIDE();
            }
        }
    } catch (Exception e) {
        IdeLog.logError(CoreUIPlugin.getDefault(),
                Messages.InitialRestartStartup_ERR_UnableToCleanConfiguration, e);
    }

    IdeLog.flushCache();
}

From source file:com.aptana.ide.core.ui.InitialStartup.java

License:Open Source License

public static void start() {
    ImageDescriptor imageDescriptor = CoreUIPlugin.getImageDescriptor("icons/editorarea.gif"); //$NON-NLS-1$
    if (imageDescriptor != null) {
        editorAreaImage_studio = imageDescriptor.createImage();
        editorAreaImage = editorAreaImage_studio;
    }//www  . j a v a2  s.  c om

    ImageDescriptor imageDescriptor_radrails = CoreUIPlugin.getImageDescriptor("icons/editorarea_radrails.gif"); //$NON-NLS-1$
    if (imageDescriptor_radrails != null) {
        editorAreaImage_radrails = imageDescriptor_radrails.createImage();
    }

    IPreferenceStore prefs = CoreUIPlugin.getDefault().getPreferenceStore();
    boolean hasRunFirstStartup = prefs.getBoolean(IPreferenceConstants.PREF_KEY_FIRST_STARTUP);
    if (!hasRunFirstStartup) {
        initForFirstTimeStartup();
        prefs.setValue(IPreferenceConstants.PREF_KEY_FIRST_STARTUP, true);
    }

    final IWorkbench workbench = PlatformUI.getWorkbench();

    perpListener = new IPerspectiveListener() {
        public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
            recordPerspectiveActivation(perspective);
            checkPerspective(page, perspective);
            setEditorAreaPaintListener(page);
        }

        public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective,
                String changeId) {
        }
    };

    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow w = workbench.getActiveWorkbenchWindow();
            addListenerToWindow(w);
        }
    });

    addWindowListener(workbench);

    final IPartListener _partListener = createPartActivationListener();

    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

            if (window != null) {
                window.getPartService().addPartListener(_partListener);

            }
        }
    });
}

From source file:com.aptana.ide.core.ui.install.PlatformValidatorPatcher.java

License:Open Source License

/**
 * /*from   w w w.  ja  va2 s .  c o  m*/
 */
private static void exportPreferences() {
    IPreferenceStore preferenceStore = CoreUIPlugin.getDefault().getPreferenceStore();
    if (preferenceStore.getBoolean(IPreferenceConstants.PREF_AUTO_BACKUP_ENABLED)) {
        String string = preferenceStore.getString(IPreferenceConstants.PREF_AUTO_BACKUP_PATH);
        File folder = new File(string);
        folder.mkdirs();
        doExport(folder);
    }
}

From source file:com.aptana.ide.core.ui.RectangleAnimation.java

License:Open Source License

/**
  * Creates an animation that will morph the start rectangle to the end rectangle in the
  * given number of milliseconds. The animation will take the given number of milliseconds to
  * complete./*from w w w.jav a  2 s . c o  m*/
  * 
  * Note that this is a Job, so you must invoke schedule() before the animation will begin 
  * 
  * @param whereToDraw specifies the composite where the animation will be drawn. Note that
  * although the start and end rectangles can accept any value in display coordinates, the
  * actual animation will be clipped to the boundaries of this composite. For this reason,
  * it is good to select a composite that encloses both the start and end rectangles.
  * @param start initial rectangle (display coordinates)
  * @param end final rectangle (display coordinates)
  * @param duration number of milliseconds over which the animation will run 
  */
public RectangleAnimation(Shell parentShell, Rectangle start, Rectangle end, int duration) {
    super(WorkbenchMessages.RectangleAnimation_Animating_Rectangle);

    // if animations aren't on this is a NO-OP
    IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
    enableAnimations = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS);

    if (!enableAnimations) {
        return;
    }

    // Capture paraeters
    display = parentShell.getDisplay();
    this.duration = duration;

    // Don't show the job in monitors
    setSystem(true);

    // Pick the renderer (could be a preference...)
    feedbackRenderer = AnimationFeedbackFactory.createAnimationRenderer(parentShell);

    // Set it up
    feedbackRenderer.initialize(parentShell, start, end);

    // Set the animation's initial state
    stepCount = 0;
    //long totalFrames = (long) ((duration / 1000.0) * framesPerSec);       
    curTime = startTime = System.currentTimeMillis();
}

From source file:com.aptana.ide.core.ui.WebPerspectiveFactory.java

License:Open Source License

/**
 * Resets the current perspective.// www .j  a  va2  s  .c o m
 * 
 * @param page
 */
public static void resetPerspective(final IWorkbenchPage page) {
    if (Display.getCurrent() == null) {
        return;
    }

    final Shell shell = Display.getCurrent().getActiveShell();
    final IPreferenceStore p = CoreUIPlugin.getDefault().getPreferenceStore();
    if (p.getBoolean(IPreferenceConstants.WEB_PERSPECTIVE_RESET_PERSPECTIVE)) {
        return;
    }

    UIJob job = new UIJob("Resetting Aptana perspective") { //$NON-NLS-1$

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            if (shell != null) {
                p.setValue(IPreferenceConstants.WEB_PERSPECTIVE_RESETTING_PERSPECTIVE, true);

                boolean ret = MessageDialog.openQuestion(CoreUIUtils.getActiveShell(),
                        Messages.WebPerspectiveFactory_UpdatePerspectiveTitle,
                        Messages.WebPerspectiveFactory_UpdatePerspectiveConfirmation);
                p.setValue(IPreferenceConstants.WEB_PERSPECTIVE_LAST_VERSION, WebPerspectiveFactory.VERSION);
                if (!ret) {
                    return Status.OK_STATUS;
                }

                p.setValue(IPreferenceConstants.WEB_PERSPECTIVE_RESET_PERSPECTIVE, true);

                // fire all resetting handlers
                if (resettingHandlers != null) {
                    for (int i = 0; i < resettingHandlers.size(); i++) {
                        resettingHandlers.get(i).run();
                    }
                }

                page.resetPerspective();
            }
            return Status.OK_STATUS;
        }

    };
    job.setRule(MutexJobRule.getInstance());
    job.setSystem(true);
    job.schedule();
}

From source file:com.aptana.ide.debug.internal.ui.actions.ShowConstantsActionDelegate.java

License:Open Source License

/**
 * getPreferenceValue/*from   www  .j av  a2 s .co m*/
 * 
 * @param part
 * @return boolean
 */
protected boolean getPreferenceValue(IViewPart part) {
    String baseKey = getPreferenceKey();
    String viewKey = part.getSite().getId();
    String compositeKey = viewKey + "." + baseKey; //$NON-NLS-1$
    IPreferenceStore store = getPreferenceStore();
    boolean value = false;
    if (store.contains(compositeKey)) {
        value = store.getBoolean(compositeKey);
    } else {
        value = store.getBoolean(baseKey);
    }
    return value;
}

From source file:com.aptana.ide.debug.internal.ui.preferences.JSDebugPreferencePage.java

License:Open Source License

private void setInitialValues() {
    suspendOnFirstLine.setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_FIRST_LINE));
    suspendOnExceptions.setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_EXCEPTIONS));
    suspendOnErrors.setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_ERRORS));
    suspendOnDebuggerKeyword/*w w  w . ja v a  2s.  co m*/
            .setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_DEBUGGER_KEYWORD));

    IPreferenceStore uiStore = DebugUiPlugin.getDefault().getPreferenceStore();
    if (!uiStore.contains(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) {
        confirmExitDebugger.setSelection(true); // for compatibility with existing workspace/preferences
    } else {
        confirmExitDebugger.setSelection(uiStore.getBoolean(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER));
    }
}

From source file:com.aptana.ide.debug.internal.ui.WorkbenchCloseListener.java

License:Open Source License

/**
 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
 *//*from   w w  w .j av  a 2s .  c  o m*/
public void handleEvent(Event event) {
    if (event.widget instanceof Shell && PlatformUI.getWorkbench().getWorkbenchWindowCount() == 1
            && PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell() == event.widget) {
        // last workbench window is about to close
        if ("true".equals(System.getProperty(JSDebugOptionsManager.DEBUGGER_ACTIVE))) { //$NON-NLS-1$
            IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore();
            if (store.contains(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) {
                if (store.getBoolean(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER) == false) {
                    return;
                }
            }
            event.doit = false;
            MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm((Shell) event.widget,
                    Messages.WorkbenchCloseListener_ConfirmDebuggerExit,
                    Messages.WorkbenchCloseListener_AptanaDebuggerIsActive_DoYouWantToExit,
                    Messages.WorkbenchCloseListener_AlwaysExitDebuggerWithoutPrompt, false, null, null);
            int returnValue = dlg.getReturnCode();
            if (returnValue != IDialogConstants.OK_ID) {
                // SWT hack - discard close event
                event.type = SWT.None;
                return;
            }
            if (dlg.getToggleState()) {
                store.setValue(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, false);
                DebugUiPlugin.getDefault().savePluginPreferences();
            }
        }
    }
}