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

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

Introduction

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

Prototype

void setValue(String name, boolean value);

Source Link

Document

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

Usage

From source file:com.aptana.ide.logging.LoggingPreferences.java

License:Open Source License

/**
 * Saves autobolding./*ww w.  j a  v  a  2 s  .co  m*/
 */
private void saveAutoBolding() {
    if (autoBolding != null) {
        IPreferenceStore store = getPreferenceStore();
        store.setValue(AUTOBOLDING_KEY, autoBolding);
    }
}

From source file:com.aptana.ide.logging.LoggingPreferences.java

License:Open Source License

/**
 * Saves read timeout.//ww  w.  j  av  a 2 s  . c o m
 */
private void saveReadTimeout() {
    if (readTimeout != null) {
        IPreferenceStore store = getPreferenceStore();
        store.setValue(READ_TIMEOUT_KEY, readTimeout);
    }
}

From source file:com.aptana.ide.logging.LoggingPreferences.java

License:Open Source License

/**
 * Saves read buffer./*from  ww w.  j  ava  2  s  .  co m*/
 */
private void saveReadBuffer() {
    if (readBuffer != null) {
        IPreferenceStore store = getPreferenceStore();
        store.setValue(READ_BUFFER_KEY, readBuffer);
    }
}

From source file:com.aptana.ide.logging.LoggingPreferences.java

License:Open Source License

/**
 * Saves wrapping.//from   w  w  w  .j a va  2  s .  com
 */
private void saveWrapping() {
    if (wrapping != null) {
        IPreferenceStore store = getPreferenceStore();
        store.setValue(WRAPPING_KEY, wrapping);
    }
}

From source file:com.aptana.ide.logging.LoggingPreferences.java

License:Open Source License

/**
 * Saves default encoding.//www. ja  va 2s  .  co m
 */
private void saveDefaultEncoding() {
    IPreferenceStore store = getPreferenceStore();
    store.setValue(DEFAULT_ENCODING_KEY, defaultEncoding);
}

From source file:com.aptana.ide.logging.LoggingPreferences.java

License:Open Source License

/**
 * Saves backlog lines./*  w  ww  .j  a v  a 2 s .c  o m*/
 */
private void saveBacklogLines() {
    IPreferenceStore store = getPreferenceStore();
    store.setValue(BACKLOG_LINES_KEY, backLogLines);
}

From source file:com.aptana.ide.rcp.dialogs.IDEStartupPreferencePage.java

License:Open Source License

/**
 * The user has pressed Ok. Store/apply this page's values appropriately.
 *//*  www .  j a va 2  s. co m*/
public boolean performOk() {
    IPreferenceStore store = getIDEPreferenceStore();

    // store the refresh workspace on startup setting
    store.setValue(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP, refreshButton.getSelection());

    // TODO: This should get the value from the configuration preference
    //       area, but dj said we shouldn't use it yet; some final details are
    //       being worked out. Hopefully it will be available soon, at which time
    //       the entire recentWorkspaces.xml file can be removed. But until then,
    //       this preference reads/writes the file each time.
    ChooseWorkspaceData.setShowDialogValue(launchPromptButton.getSelection());

    // store the exit prompt on last window close setting
    store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, exitPromptButton.getSelection());

    IDEWorkbenchPlugin.getDefault().savePluginPreferences();

    return super.performOk();
}

From source file:com.aptana.ide.rcp.IDEApplication.java

License:Open Source License

/**
 * Return true if a valid workspace path has been set and false otherwise.
 * Prompt for and set the path if possible and required.
 * /*  ww w. j a  v a  2 s .  co  m*/
 * @return true if a valid instance location has been set and false
 *         otherwise
 */
private boolean checkInstanceLocation(Shell shell) {
    // -data @none was specified but an ide requires workspace
    Location instanceLoc = Platform.getInstanceLocation();
    if (instanceLoc == null) {
        MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceMandatoryTitle,
                IDEWorkbenchMessages.IDEApplication_workspaceMandatoryMessage);
        return false;
    }

    // -data "/valid/path", workspace already set
    if (instanceLoc.isSet()) {
        // make sure the meta data version is compatible (or the user has
        // chosen to overwrite it).
        if (!checkValidWorkspace(shell, instanceLoc.getURL())) {
            return false;
        }

        // at this point its valid, so try to lock it and update the
        // metadata version information if successful
        try {
            if (instanceLoc.lock()) {
                writeWorkspaceVersion();
                return true;
            }

            // we failed to create the directory.  
            // Two possibilities:
            // 1. directory is already in use
            // 2. directory could not be created
            File workspaceDirectory = new File(instanceLoc.getURL().getFile());
            if (workspaceDirectory.exists()) {
                MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotLockTitle,
                        IDEWorkbenchMessages.IDEApplication_workspaceCannotLockMessage);
            } else {
                MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle,
                        IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage);
            }
        } catch (IOException e) {
            IDEWorkbenchPlugin.log("Could not obtain lock for workspace location", //$NON-NLS-1$
                    e);
            MessageDialog.openError(shell, IDEWorkbenchMessages.InternalError, e.getMessage());
        }
        return false;
    }

    IPreferenceStore store = new ScopedPreferenceStore(new ConfigurationScope(),
            IDEWorkbenchPlugin.IDE_WORKBENCH);

    boolean handledSHOW_WORKSPACE_SELECTION_DIALOG = store
            .getBoolean(OVERRIDE_SHOW_WORKSPACE_SELECTION_DIALOG_DEFAULT);
    if (!handledSHOW_WORKSPACE_SELECTION_DIALOG) {
        // We start with not asking the user for the workspace
        store.setValue(IDE.Preferences.SHOW_WORKSPACE_SELECTION_DIALOG, false);
        store.setValue(OVERRIDE_SHOW_WORKSPACE_SELECTION_DIALOG_DEFAULT, true);
    }

    // -data @noDefault or -data not specified, prompt and set
    ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc.getDefault());

    boolean force = false;
    while (true) {

        URL workspaceUrl = promptForWorkspace(shell, launchData, force);
        if (workspaceUrl == null) {
            return false;
        }

        // if there is an error with the first selection, then force the
        // dialog to open to give the user a chance to correct
        force = true;

        try {
            // the operation will fail if the url is not a valid
            // instance data area, so other checking is unneeded
            if (instanceLoc.set(workspaceUrl, true)) {
                launchData.writePersistedData();
                writeWorkspaceVersion();
                return true;
            }
        } catch (IOException e) {
            MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle,
                    IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage);
            return false;
        }

        // by this point it has been determined that the workspace is
        // already in use -- force the user to choose again
        MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceInUseTitle,
                IDEWorkbenchMessages.IDEApplication_workspaceInUseMessage);
    }
}

From source file:com.aptana.ide.rcp.IDEWorkbenchWindowAdvisor.java

License:Open Source License

public boolean preWindowShellClose() {
    if (getWorkbench().getWorkbenchWindowCount() > 1) {
        return true;
    }/*from w w w  .  j  a v a 2 s . c  o m*/
    // the user has asked to close the last window, while will cause the
    // workbench to close in due course - prompt the user for confirmation
    IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
    boolean promptOnExit = store.getBoolean(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW);

    if (promptOnExit) {
        String message;

        String productName = null;
        IProduct product = Platform.getProduct();
        if (product != null) {
            productName = product.getName();
        }
        if (productName == null) {
            message = IDEWorkbenchMessages.PromptOnExitDialog_message0;
        } else {
            message = NLS.bind(IDEWorkbenchMessages.PromptOnExitDialog_message1, productName);
        }

        MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm(
                getWindowConfigurer().getWindow().getShell(),
                IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, message,
                IDEWorkbenchMessages.PromptOnExitDialog_choice, false, null, null);
        if (dlg.getReturnCode() != IDialogConstants.OK_ID) {
            return false;
        }
        if (dlg.getToggleState()) {
            store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false);
            IDEWorkbenchPlugin.getDefault().savePluginPreferences();
        }
    }

    return true;
}

From source file:com.aptana.ide.scripting.Global.java

License:Open Source License

/**
     * Set a preference//w w  w .j a  v  a 2 s  .  c om
     * 
     * @param name
     *            The name of the preference to set
     * @param value
     *            The new value for the specified preference
     */
    public void setPreference(String name, String value) {
        if (name != null && name.length() > 0 && value != null && value.length() > 0) {
            IPreferenceStore prefStore = UnifiedEditorsPlugin.getDefault().getPreferenceStore();

            prefStore.setValue(name, value);

            UnifiedEditorsPlugin.getDefault().savePluginPreferences();
        }
    }