Java Code Examples for org.eclipse.jface.preference.IPreferenceStore#putValue()

The following examples show how to use org.eclipse.jface.preference.IPreferenceStore#putValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GamaActionBarAdvisor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the feature-dependent actions for the menu bar.
 */
private void makeFeatureDependentActions(final IWorkbenchWindow aWindow) {
	// final AboutInfo[] infos = null;

	final IPreferenceStore prefs = IDEWorkbenchPlugin.getDefault().getPreferenceStore();

	// Optimization: avoid obtaining the about infos if the platform state is
	// unchanged from last time. See bug 75130 for details.
	final String stateKey = "platformState"; //$NON-NLS-1$
	final String prevState = prefs.getString(stateKey);
	final String currentState = String.valueOf(Platform.getStateStamp());
	final boolean sameState = currentState.equals(prevState);
	if ( !sameState ) {
		prefs.putValue(stateKey, currentState);
	}
}
 
Example 2
Source File: DialogUtils.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * openIgnoreMessageDialogConfirm
 * 
 * @param shell
 * @param title
 * @param message
 * @param store
 * @param key
 *            Key to store the show/hide this message. Message will be hidden if true
 * @return int
 */
public static int openIgnoreMessageDialogConfirm(Shell shell, String title, String message, IPreferenceStore store,
		String key)
{
	String value = store.getString(key);
	if (!shouldShowDialog(key))
	{
		return value == MessageDialogWithToggle.ALWAYS ? IDialogConstants.YES_ID : IDialogConstants.NO_ID;
	}
	MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, title, message,
			Messages.DialogUtils_doNotShowMessageAgain, false, store, key);
	if (dialog.getToggleState())
	{
		setShouldShowDialog(key, false);
		store.putValue(key, dialog.getReturnCode() == IDialogConstants.YES_ID ? MessageDialogWithToggle.ALWAYS
				: MessageDialogWithToggle.NEVER);
	}
	return dialog.getReturnCode();
}
 
Example 3
Source File: XdsConsoleSettings.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean getKey(String name, boolean defVal) {
    String key = KEYPREFIX + name;
    IPreferenceStore store = XdsCorePlugin.getDefault().getPreferenceStore();
    boolean res;
    if (!store.contains(key)) {
        store.putValue(key, defVal ? STR_TRUE : STR_FALSE);
        res = defVal;
    } else {
        res = STR_TRUE.equals(store.getString(key));
    }
    return res;
}
 
Example 4
Source File: CompletionProposalComputerRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updateUninstalledComputerCount() {
	IPreferenceStore preferenceStore= PreferenceConstants.getPreferenceStore();
	fIsFirstTimeCheckForUninstalledComputers= !preferenceStore.contains(NUM_COMPUTERS_PREF_KEY);
	int lastNumberOfComputers= preferenceStore.getInt(NUM_COMPUTERS_PREF_KEY);
	int currNumber= fDescriptors.size();
	fHasUninstalledComputers= lastNumberOfComputers > currNumber;
	preferenceStore.putValue(NUM_COMPUTERS_PREF_KEY, Integer.toString(currNumber));
	JavaPlugin.flushInstanceScope();
}
 
Example 5
Source File: CompletionProposalComputerRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void preventDuplicateCategories(IPreferenceStore store, Set<String> disabled, CompletionProposalCategory allProposals, CompletionProposalCategory typeProposals,
		CompletionProposalCategory allButTypeProposals) {
	boolean adjusted= false;
	if (allProposals == null || !allProposals.isIncluded())
		return;

	if (allButTypeProposals != null && allButTypeProposals.isIncluded()) {
		allButTypeProposals.setIncluded(false);
		disabled.add(allButTypeProposals.getId());
		adjusted= true;
	}
	if (typeProposals != null && typeProposals.isIncluded()) {
		typeProposals.setIncluded(false);
		disabled.add(typeProposals.getId());
		adjusted= true;
	}

	if (adjusted) {
		StringBuffer buf= new StringBuffer(50 * disabled.size());
		Iterator<String> iter= disabled.iterator();
		while (iter.hasNext()) {
			buf.append(iter.next());
			buf.append('\0');
		}
		store.putValue(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, buf.toString());
	}
}
 
Example 6
Source File: DesignerActionBarAdvisor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the feature-dependent actions for the menu bar.
 */
private void makeFeatureDependentActions( IWorkbenchWindow window )
{
	IPreferenceStore prefs = ReportPlugin.getDefault( )
			.getPreferenceStore( );

	String stateKey = "platformState"; //$NON-NLS-1$
	String prevState = prefs.getString( stateKey );
	String currentState = String.valueOf( Platform.getStateStamp( ) );
	boolean sameState = currentState.equals( prevState );
	if ( !sameState )
	{
		prefs.putValue( stateKey, currentState );
	}
}
 
Example 7
Source File: PySourceLocatorPrefs.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a path to the translation table.
 * 
 * @param translation the translation path to be added. 
 * E.g.: 
 * path asked, new path -- means that a request for the "path asked" should return the "new path"
 * path asked, DONTASK -- means that if some request for that file was asked it should silently ignore it
 * 
 * E.g.: 
 * c:\foo\c.py,c:\temp\c.py
 * c:\foo\c.py,DONTASK
 */
private static void addPathTranslation(String[] translation) {
    String valid = isValid(translation);
    if (valid != null) {
        throw new RuntimeException(valid);
    }
    IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore();
    String available = store.getString(PyDevEditorPreferences.SOURCE_LOCATION_PATHS);

    if (available == null || available.trim().length() == 0) {
        available = StringUtils.join(",", translation);
    } else {
        String pathAsked = translation[0].trim();

        String existent = getPathTranslation(pathAsked);
        if (existent != null) {
            List<String> splitted = StringUtils.splitAndRemoveEmptyTrimmed(available, '\n');
            final int size = splitted.size();
            for (int i = 0; i < size; i++) {
                String s = splitted.get(i);
                String initialPart = StringUtils.splitAndRemoveEmptyTrimmed(s, ',').get(0).trim();
                if (initialPart.equals(pathAsked)) {
                    splitted.set(i, StringUtils.join(",", translation));
                    break;
                }
            }
            available = StringUtils.join("\n", splitted);
        } else {
            available += "\n";
            available += StringUtils.join(",", translation);
        }
    }
    store.putValue(PyDevEditorPreferences.SOURCE_LOCATION_PATHS, available);
}
 
Example 8
Source File: XdsConsoleSettings.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
private static void setKey(String name, boolean defVal, boolean val) {
    String key = KEYPREFIX + name;
    IPreferenceStore store = XdsCorePlugin.getDefault().getPreferenceStore();
    store.putValue(key, val ? STR_TRUE : STR_FALSE);
}
 
Example 9
Source File: PreferenceConstants.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * This stores the given RGB value without firing
 * a property changed event.
 *
 * @param store the preference store
 * @param key the key
 * @param rgb the RGB value
 * @since 3.4
 */
private static void setRGBValue(IPreferenceStore store, String key, RGB rgb) {
	PreferenceConverter.setDefault(store, key, rgb);
	String value= store.getString(key);
	store.putValue(key, value);
}