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

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

Introduction

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

Prototype

void putValue(String name, String value);

Source Link

Document

Sets the current value of the preference with the given name to the given string value without sending a property change.

Usage

From source file:org.eclipse.papyrus.diagram.activity.edit.dialogs.ConfirmActivityParameterNodeAndParameterSyncDialog.java

License:Open Source License

/**
 * Create a checkbox for not displaying the popup again
 * //from   w w  w. ja v  a2  s .c o m
 * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
 * 
 * @param parent
 *        parent composite
 * @return checkbox
 */
@Override
protected Control createCustomArea(Composite parent) {
    Button checkBox = new Button(parent, SWT.CHECK | SWT.LEFT);
    checkBox.setText(Messages.DiagramsPreferencePage_disableNotification);
    checkBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (e.getSource() instanceof Button) {
                boolean doNotShow = ((Button) e.getSource()).getSelection();
                final IPreferenceStore prefStore = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
                prefStore.putValue(
                        IActivityPreferenceConstants.PREF_CONFIRM_ACTIVITY_PARAMETER_SYNC_FROM_PARAMETER,
                        Boolean.toString(!doNotShow));
            }
        }
    });
    return checkBox;
}

From source file:org.eclipse.papyrus.diagram.activity.edit.dialogs.ConfirmPinAndParameterSyncDialog.java

License:Open Source License

/**
 * Create a checkbox for not displaying the popup again
 * // w  ww .j  av a  2s.co m
 * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
 * 
 * @param parent
 *        parent composite
 * @return checkbox
 */
@Override
protected Control createCustomArea(Composite parent) {
    Button checkBox = new Button(parent, SWT.CHECK | SWT.LEFT);
    checkBox.setText(Messages.DiagramsPreferencePage_disableNotification);
    checkBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (e.getSource() instanceof Button) {
                boolean doNotShow = ((Button) e.getSource()).getSelection();
                final IPreferenceStore prefStore = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
                prefStore.putValue(IActivityPreferenceConstants.PREF_CONFIRM_PIN_SYNC_FROM_PARAMETER,
                        Boolean.toString(!doNotShow));
            }
        }
    });
    return checkBox;
}

From source file:org.eclipse.php.internal.ui.compare.TextMergeViewer.java

License:Open Source License

private void handleEndOfDocumentReached(Shell shell, boolean next) {
    boolean hasNextElement = hasNextElement(next);
    IPreferenceStore store = CompareUIPlugin.getDefault().getPreferenceStore();
    String value = store.getString(ICompareUIConstants.PREF_NAVIGATION_END_ACTION);
    if (!value.equals(ICompareUIConstants.PREF_VALUE_PROMPT)) {
        // We only want to do the automatic thing if there is something to
        // do// www.  j a  v  a2  s . com
        if (hasNextElement || store.getString(ICompareUIConstants.PREF_NAVIGATION_END_ACTION)
                .equals(ICompareUIConstants.PREF_VALUE_LOOP)) {
            performEndOfDocumentAction(shell, store, ICompareUIConstants.PREF_NAVIGATION_END_ACTION, next);
            return;
        }
    }
    shell.getDisplay().beep();
    if (hasNextElement) {
        String loopMessage;
        String nextMessage;
        String message;
        String title;
        if (next) {
            title = CompareMessages.TextMergeViewer_0;
            message = CompareMessages.TextMergeViewer_1;
            loopMessage = CompareMessages.TextMergeViewer_2;
            nextMessage = CompareMessages.TextMergeViewer_3;
        } else {
            title = CompareMessages.TextMergeViewer_4;
            message = CompareMessages.TextMergeViewer_5;
            loopMessage = CompareMessages.TextMergeViewer_6;
            nextMessage = CompareMessages.TextMergeViewer_7;
        }
        String[] localLoopOption = new String[] { loopMessage, ICompareUIConstants.PREF_VALUE_LOOP };
        String[] nextElementOption = new String[] { nextMessage, ICompareUIConstants.PREF_VALUE_NEXT };
        NavigationEndDialog dialog = new NavigationEndDialog(shell, title, null, message,
                new String[][] { localLoopOption, nextElementOption, });
        int result = dialog.open();
        if (result == Window.OK) {
            performEndOfDocumentAction(shell, store, ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL,
                    next);
            if (dialog.getToggleState()) {
                store.putValue(ICompareUIConstants.PREF_NAVIGATION_END_ACTION,
                        store.getString(ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL));
            }
        }
    } else {
        String message;
        String title;
        if (next) {
            title = CompareMessages.TextMergeViewer_8;
            message = CompareMessages.TextMergeViewer_9;
        } else {
            title = CompareMessages.TextMergeViewer_10;
            message = CompareMessages.TextMergeViewer_11;
        }
        if (MessageDialog.openQuestion(shell, title, message)) {
            selectFirstDiff(next);
        }
    }
}

From source file:org.eclipse.ptp.pldt.common.analysis.PldtAstVisitor.java

License:Open Source License

/**
 * Add an include path to the prefs - probably found dynamically during analysis
 * and requested to be added by the user <br>
 * Note that the path will be to the actual file in which the name was found;
 * the path that will be added to the prefs is the parent directory of that file.
 * /*w w w . j  a va2  s . c o  m*/
 * @param path
 * @param name
 *            the name (function etc) that was found in the path
 * @param dontAskAgain
 *            initial value of toggle "don't ask again"
 * 
 * @returns whether the user chose to add the path or not
 */
public boolean addIncludePath(IPath path, String name/* , IPreferenceStore store, String id */,
        boolean dontAskAgain) {

    IPreferenceStore store = getPreferenceStore();
    String id = getIncludesPrefID();
    String type = getTypeName();
    boolean doitThisTime = false;

    if (store == null || id == null) {
        CommonPlugin.log(IStatus.ERROR, "PLDT: Visitor subclass does not implement getPreferenceStore() or " + //$NON-NLS-1$
                "getIncludesPrefID() to return non-null values."); //$NON-NLS-1$
        return false;
    }

    try {
        String value = store.getString(id);
        if (traceOn)
            System.out.println("value: " + value); //$NON-NLS-1$

        if (!dontAskAgain) {
            // probably inefficient string construction, but rarely called.
            String msg = Messages.PldtAstVisitor_20 + name + Messages.PldtAstVisitor_21 + path.toString()
                    + Messages.PldtAstVisitor_22 + type + Messages.PldtAstVisitor_23 + value
                    + Messages.PldtAstVisitor_24;
            String title = Messages.PldtAstVisitor_25 + type + Messages.PldtAstVisitor_26;
            boolean[] twoAnswers = askUI(title, msg, dontAskToModifyIncludePathAgain);
            doitThisTime = twoAnswers[0];
            dontAskAgain = twoAnswers[1];
            dontAskToModifyIncludePathAgain = dontAskAgain;
        }

        if (doitThisTime) {
            String s = java.io.File.pathSeparator;
            String parent = path.toFile().getParent();
            // add path separator (: or ; ?) if necessary
            if (!value.endsWith(s)) {
                value += s;
            }
            // add this new include path location to the value stored in
            // preferences, and add it to the value within this class as well.
            value += parent + s;
            store.putValue(id, value);
            replaceIncludes(value);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return doitThisTime;
}

From source file:org.eclipse.rap.ui.interactiondesign.layout.LayoutRegistry.java

License:Open Source License

/**
 * Saves the new <code>Layout</code> id in a 
 * <code>ScopedPreferenceStore</code>.
 * //w  w w .  j ava 2 s. co  m
 * @param id the new <code>Layout</code> id to save.
 */
public void saveLayoutId(final String id) {
    IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
    preferenceStore.putValue(SAVED_LAYOUT_KEY, id);
    preferenceStore.firePropertyChangeEvent(SAVED_LAYOUT_KEY, "", id);
}

From source file:org.eclipse.rcptt.internal.launching.ext.ui.CleanBundlePoolStartup.java

License:Open Source License

public void earlyStartup() {
    Job job = new Job("Check RCPTT Runtime") {
        @Override// w w w  .  j a v a 2  s  .com
        public boolean belongsTo(Object family) {
            if (IBundlePoolConstansts.CLEAN_BUNDLE_POOL_JOB.equals(family)) {
                return true;
            }
            return false;
        }

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            String version = RcpttCore.getRuntimeVersion();

            IPreferenceStore store = Activator.getDefault().getPreferenceStore();
            String lastRuntimeVersion = store.getString(LAST_RUNTIME_VERSION);
            if (version == null || !version.equals(lastRuntimeVersion)) {
                if (version != null) {
                    store.putValue(LAST_RUNTIME_VERSION, version);
                }
                try {
                    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {

                        public void run(IProgressMonitor monitor) throws CoreException {

                            ILaunchConfiguration[] configurations = DebugPlugin.getDefault().getLaunchManager()
                                    .getLaunchConfigurations();
                            for (ILaunchConfiguration cfg : configurations) {
                                String platform = Q7TargetPlatformManager.getTargetPlatformName(cfg);
                                LaunchInfoCache.remove(cfg);
                                if (platform.length() > 0) {
                                    TargetPlatformManager.deleteTargetPlatform(platform);
                                    Q7LaunchUtils.deleteConfigFiles(cfg);
                                    Q7TargetPlatformManager.clear();
                                }
                            }

                            Q7LaunchingUtil.cleanBundlePool(monitor);
                        }
                    }, monitor);
                } catch (CoreException e) {
                    Activator.getDefault().log("Failed to update RCPTT runtime.", e);
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setSystem(true);
    job.schedule();
}

From source file:org.eclipse.recommenders.rcp.utils.UUIDs.java

License:Open Source License

private static void storeUUID(final String uuid) {
    final RcpPlugin plugin = RcpPlugin.getDefault();
    final IPreferenceStore prefStore = plugin.getPreferenceStore();
    prefStore.putValue(PREF_UUID, uuid);
}

From source file:org.eclipse.recommenders.utils.rcp.UUIDHelper.java

License:Open Source License

private static void storeUUID(final String uuid) {
    final RecommendersUtilsPlugin plugin = RecommendersUtilsPlugin.getDefault();
    final IPreferenceStore prefStore = plugin.getPreferenceStore();
    prefStore.putValue(PreferencesInitalizer.PROP_UUID, uuid);
}

From source file:org.eclipse.team.internal.ui.preferences.SyncViewerPreferencePage.java

License:Open Source License

private static void handleDeletedPerspectives() {
    IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
    String id = store.getString(SYNCVIEW_DEFAULT_PERSPECTIVE);
    if (PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id) == null) {
        store.putValue(SYNCVIEW_DEFAULT_PERSPECTIVE, SYNCVIEW_DEFAULT_PERSPECTIVE_NONE);
    }//from ww  w. jav a  2s.c o  m
}

From source file:org.eclipse.test.internal.performance.results.ui.PerformanceResultsPreferencePage.java

License:Open Source License

/**
 * Stores the values of the controls back to the preference store.
 *///from  w  ww  .  j  a  va2 s . co  m
private void storeValues() {
    IPreferenceStore store = getPreferenceStore();

    // Set version
    int version;
    if (this.mVersionRadioButton.getSelection()) {
        version = ECLIPSE_MAINTENANCE_VERSION;
    } else {
        version = ECLIPSE_DEVELOPMENT_VERSION;
    }
    store.setValue(PRE_ECLIPSE_VERSION, version);

    // Set database values
    store.setValue(PRE_DATABASE_CONNECTION, this.dbConnectionCheckBox.getSelection());
    final boolean dbLocal = this.dbLocalRadioButton.getSelection();
    store.setValue(PRE_DATABASE_LOCAL, dbLocal);
    String location = this.databaseLocationCombo.getText();
    if (dbLocal) {
        store.setValue(PRE_DATABASE_LOCATION, location);
    } else {
        store.setValue(PRE_DATABASE_LOCATION, NETWORK_DATABASE_LOCATION);
    }
    int count = this.databaseLocationCombo.getItemCount();
    for (int i = 0; i < count; i++) {
        String item = this.databaseLocationCombo.getItem(i);
        if (item.equals(location)) {
            this.databaseLocationCombo.remove(i);
            break;
        }
    }
    if (dbLocal) {
        this.databaseLocationCombo.add(location, 0);
    }
    int i = 0;
    for (; i < count; i++) {
        String item = this.databaseLocationCombo.getItem(i);
        if (item.length() == 0)
            break;
        store.setValue(PRE_DATABASE_LOCATION + "." + i, item);
    }
    while (store.getString(PRE_DATABASE_LOCATION + "." + i).length() > 0) {
        store.setToDefault(PRE_DATABASE_LOCATION + "." + i);
        i++;
    }

    // Set milestones
    count = this.milestonesCombo.getItemCount();
    for (i = 0; i < count; i++) {
        store.putValue(PRE_MILESTONE_BUILDS + version + i, this.milestonesCombo.getItem(i));
    }
    Util.setMilestones(this.milestonesCombo.getItems());

    // Set default dimension
    String defaultDimension = this.defaultDimensionCombo.getText();
    store.putValue(PRE_DEFAULT_DIMENSION, defaultDimension);
    DB_Results.setDefaultDimension(defaultDimension);

    // Set generated dimensions
    int[] indices = this.resultsDimensionsList.getSelectionIndices();
    int length = indices.length;
    String[] dimensions = new String[length];
    if (length > 0) {
        for (i = 0; i < indices.length; i++) {
            dimensions[i] = this.resultsDimensionsList.getItem(indices[i]);
            store.putValue(PRE_RESULTS_DIMENSION + "." + i, dimensions[i]);
        }
    }
    int currentLength = DB_Results.getResultsDimensions().length;
    if (currentLength > length) {
        for (i = currentLength - 1; i >= length; i--) {
            store.putValue(PRE_RESULTS_DIMENSION + "." + i, ""); // reset extra dimensions
        }
    }
    DB_Results.setResultsDimensions(dimensions);

    // Set config descriptors
    /* TODO See whether config descriptors need to be set as preferences or not...
    TableItem[] items = this.configDescriptorsTable.getItems();
    length = items.length;
    for (int i = 0; i < length; i++) {
       TableItem item = items[i];
       store.putValue(PRE_CONFIG_DESCRIPTOR_NAME + "." + i, item.getText(0));
       store.putValue(PRE_CONFIG_DESCRIPTOR_DESCRIPTION + "." + i, item.getText(1));
    }
    */
}