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

The following examples show how to use org.eclipse.jface.preference.IPreferenceStore#setValue() . 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: ToggleMarkOccurrences.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ITextEditor activeEditor = EditorUtils.getActiveEditor();
    if (!(activeEditor instanceof PyEdit)) {
        return null;
    }
    PyEdit editor = (PyEdit) activeEditor;

    try {
        IPreferenceStore store = RefactoringPlugin.getDefault().getPreferenceStore();
        boolean prev = store.getBoolean(MarkOccurrencesPreferencesPage.USE_MARK_OCCURRENCES);
        store.setValue(MarkOccurrencesPreferencesPage.USE_MARK_OCCURRENCES, !prev);

        editor.getStatusLineManager().setMessage(
                "Toggled mark occurrences. Currently: " + (prev ? "Off" : "On"));

        MarkOccurrencesJob.scheduleRequest(new WeakReference<BaseEditor>(editor),
                editor.createTextSelectionUtils(), 0); //On the action, ask it to happen now.
    } catch (Exception e) {
        Log.log(e);
    }

    return null;
}
 
Example 2
Source File: SWTGefBotRule.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void initPreferences() {
    BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore()
            .setValue(BonitaAdvancedPreferencePage.HIDE_CONNECTOR_DEFINITION_CHANGE_WARNING, true);
    IPreferenceStore preferenceStore = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore();
    preferenceStore.setValue(BonitaCoolBarPreferenceConstant.COOLBAR_DEFAULT_SIZE,
            BonitaCoolBarPreferenceConstant.NORMAL);
    Display.getDefault().asyncExec(() -> {
        try {
            new NormalCoolBarHandler().execute(null);
        } catch (ExecutionException e) {
            BonitaStudioLog.error(e);
        }
    });

    preferenceStore
            .setValue(BonitaPreferenceConstants.ASK_RENAME_ON_FIRST_SAVE, false);
    preferenceStore
            .setValue(BonitaPreferenceConstants.CONSOLE_BROWSER_CHOICE, BonitaPreferenceConstants.INTERNAL_BROWSER);
    WebBrowserUIPlugin.getInstance().getPreferenceStore()
            .setValue(BonitaPreferenceConstants.CONSOLE_BROWSER_CHOICE, BonitaPreferenceConstants.INTERNAL_BROWSER);
    EnginePlugin.getDefault().getPreferenceStore().setValue(EnginePreferenceConstants.LAZYLOAD_ENGINE, true);
    FileActionDialog.setDisablePopup(true);
}
 
Example 3
Source File: ResourceFileFolderSelectionAction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void run( )
{
	ResourceFilterDialog dialog = new ResourceFilterDialog( );
	ArrayList filters = new ArrayList( );
	filters.addAll( ReportPlugin.getFilterMap( this.dialog.isShowEmptyFolderFilter( ) )
			.values( ) );
	dialog.setInput( filters );
	if ( dialog.open( ) == Window.OK )
	{
		IPreferenceStore store = ReportPlugin.getDefault( )
				.getPreferenceStore( );
		for ( int i = 0; i < filters.size( ); i++ )
		{
			ResourceFilter filter = (ResourceFilter) filters.get( i );
			store.setValue( filter.getType( ), filter.isEnabled( ) );
		}
		this.dialog.refreshRoot( );
	}
}
 
Example 4
Source File: OptionsConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public boolean hasProjectSpecificOptions(IProject project) {
	IPreferenceStore ps = preferenceStore;
	if (project != getProject()) {
		ps = preferenceStoreAccessImpl.getWritablePreferenceStore(project);
	}
	// backward compatibility
	boolean oldSettingsUsed = ps.getBoolean(IS_PROJECT_SPECIFIC);
	boolean newSettingsValue = ps.getBoolean(getIsProjectSpecificPropertyKey(getPropertyPrefix()));
	if (oldSettingsUsed) {
		if (!newSettingsValue) {
			ps.setValue(getIsProjectSpecificPropertyKey(getPropertyPrefix()), true);
			return true;
		}
	}
	return newSettingsValue;
}
 
Example 5
Source File: ExportHTTP4eAction.java    From http4e with Apache License 2.0 5 votes vote down vote up
private void updateUserHomeDir( String userDir){

      if (!BaseUtils.isEmpty(userDir)) {
         // Updating using Plugin directly persist the entry on each invokation
         // Plugin pl = (Plugin) CoreContext.getContext().getObject("p");
         // Preferences prefs = pl.getPluginPreferences();
         // prefs.setValue(PreferenceConstants.P_USER_HOME_DIR, userDir);
         // pl.savePluginPreferences();

         // Updating the preference "in memory" and persists "on Eclipse exit"
         IPreferenceStore store = HdPlugin.getDefault().getPreferenceStore();
         store.setValue(PreferenceConstants.P_USER_HOME_DIR, userDir);
      }
   }
 
Example 6
Source File: PyVariablesPreferences.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private static void setHelper(String key, boolean value) {
    if (SharedCorePlugin.inTestMode()) {
        // ignore set
    } else {
        PydevDebugPlugin plugin = PydevDebugPlugin.getDefault();
        IPreferenceStore preferenceStore = plugin.getPreferenceStore();
        preferenceStore.setValue(key, value);
    }
}
 
Example 7
Source File: ExtLibPreferencesPage.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void performDefaults() {
    super.performDefaults();
    IPreferenceStore prefs = ExtLibToolingPlugin.getDefault().getPreferenceStore();
    if (prefs != null) {
        prefs.setValue(ExtLibToolingPlugin.PREFKEY_HIDE_XPAGE_WARNING, false);
        if (showXPageWarnings != null)
            showXPageWarnings.setSelection(true);
    }
    
}
 
Example 8
Source File: PreferenceInitializer.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public static void addDBSetting(final DBSetting dbSetting) {
    final IPreferenceStore store = ERDiagramActivator.getDefault().getPreferenceStore();

    int num = store.getInt(PreferenceInitializer.DB_SETTING_LIST_NUM);
    num++;
    store.setValue(PreferenceInitializer.DB_SETTING_LIST_NUM, num);

    saveSetting(num, dbSetting);
}
 
Example 9
Source File: PackagesView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void switchViewer(int state) {
	//Indicate which viewer is to be used
	if (fCurrViewState == state)
		return;
	else {
		fCurrViewState= state;
		IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
		store.setValue(getViewSite().getId() + TAG_VIEW_STATE, state);
	}

	//get the information from the existing viewer
	StructuredViewer viewer= fWrappedViewer.getViewer();
	Object object= viewer.getInput();
	ISelection selection= viewer.getSelection();

	// create and set up the new viewer
	Control control= createViewer(fWrappedViewer.getControl().getParent()).getControl();

	setUpViewer(fWrappedViewer);

	createSelectAllAction();

	// add the selection information from old viewer
	fWrappedViewer.setViewerInput(object);
	fWrappedViewer.getControl().setFocus();
	fWrappedViewer.setSelection(selection, true);

	// dispose old viewer
	viewer.getContentProvider().dispose();
	viewer.getControl().dispose();

	// layout the new viewer
	if (control != null && !control.isDisposed()) {
		control.setVisible(true);
		control.getParent().layout(true);
	}
}
 
Example 10
Source File: PreferenceInitializer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences() {
    initializeWorkbenchPreferences();
    final IPreferenceStore store = getBonitaPreferenceStore();
    final IPreferenceStore webStore = getWebBrowserPreferenceStore();
    setUTF8DefaultEncoding();
    initDefaultWebPreferences(store, webStore);

    store.setDefault(SHOW_CONDITION_ON_TRANSITION, "false");
    store.setDefault(DELETE_TENANT_ON_EXIT, false);
    store.setDefault(LOAD_ORGANIZATION, false);
    store.setDefault(AUTOMATIC_ID, "true");

    initDefaultLocalesPreference(store);

    store.setDefault(BonitaCoolBarPreferenceConstant.COOLBAR_DEFAULT_SIZE, BonitaCoolBarPreferenceConstant.SMALL);
    store.setDefault(APLLICATION_DEPLOYMENT_MODE, ALL_IN_BAR);
    store.setDefault(DEFAULT_USERXP_THEME, "default");
    store.setDefault(DEFAULT_APPLICATION_THEME, "Default Application");
    store.setDefault(ASK_RENAME_ON_FIRST_SAVE, true);
    store.setDefault(ALWAYS_USE_SCRIPTING_MODE, false);
    store.setDefault(SHOW_LEGACY_6X_MODE, false);
    store.setDefault(UID_JVM_OPTS, "-Xmx256m");
    store.setDefault(BonitaPreferenceConstants.CUSTOM_PAGE_DEBUG, false);
    getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.DISABLE_OPEN_EDITOR_IN_PLACE, true);

    initDefaultDebugPreferences();

    final IPreferenceStore jdtUIStore = getJDTPreferenceStore();
    jdtUIStore.setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, Boolean.FALSE);
}
 
Example 11
Source File: N4JSBuilderPreferenceAccess.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setAutoBuildEnabled(Object context, boolean enabled) {
	IPreferenceStore preferenceStore = preferenceStoreAccess.getWritablePreferenceStore(context);
	String key = null;
	for (CompilerDescriptor compilerDescriptor : compositeGenerator.getCompilerDescriptors()) {
		key = CompilerProperties.IS_ACTIVE.getKey(compilerDescriptor.getIdentifier());
		preferenceStore.setValue(key, enabled);
	}
}
 
Example 12
Source File: Preferences.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static void set(String key, String value) {
	if (key == null)
		return;
	IPreferenceStore store = getStore();
	if (store == null)
		return;
	String val = value == null ? "" : value;
	store.setValue(key, val);
}
 
Example 13
Source File: FindBarEntriesHelper.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * When a search is entered, this method should be called to add the searched text to the list of available searches
 * (and it'll be replicated for all the combos controlled).
 */
public void addEntry(String entry, String preferenceName)
{
	if (entry.length() == 0)
	{
		return; // nothing to do in this case
	}

	synchronized (lock)
	{
		IPreferenceStore preferenceStore = FindBarPlugin.getDefault().getPreferenceStore();

		List<String> items = loadEntries(preferenceName);
		items.remove(entry); // Remove it if it already existed
		items.add(0, entry); // And always add it as the first
		while (items.size() > 20)
		{ // Hold at most 20 entries in the cache
			items.remove(items.size() - 1); // remove the last
		}
		Properties props = createPropertiesFromList(items);
		preferenceStore.setValue(preferenceName, createStringFromProperties(props));
		if (preferenceName.equals(PREFERENCE_NAME_FIND))
		{
			eclipseFindSettings.addEntry(entry);
		}
	}
}
 
Example 14
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void setTopLevelTypeOnly(boolean show) {
	fTopLevelTypeOnly= show;
	setChecked(show);
	fOutlineViewer.refresh(false);

	IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
	preferenceStore.setValue("GoIntoTopLevelTypeAction.isChecked", show); //$NON-NLS-1$
}
 
Example 15
Source File: XbaseBuilderPreferenceAccess.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void setJavaVersion(Object context, JavaVersion version) {
	IPreferenceStore preferenceStore = preferenceStoreAccess.getWritablePreferenceStore(context);
	preferenceStore.setValue(PREF_USE_COMPILER_SOURCE, false);
	preferenceStore.setValue(PREF_JAVA_VERSION, version.toString());
}
 
Example 16
Source File: TimeGraphStyleUtil.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Load default values into the state item from a preference store
 *
 * @param presentationProvider
 *            the presentation provider
 * @param stateItem
 *            the state item
 */
public static void loadValue(ITimeGraphPresentationProvider presentationProvider, StateItem stateItem) {
    IPreferenceStore store = getStore();
    String oldFillColorKey = getPreferenceName(presentationProvider, stateItem, ITimeEventStyleStrings.fillColor());
    String oldHeightFactorKey = getPreferenceName(presentationProvider, stateItem, ITimeEventStyleStrings.heightFactor());
    String fillColorKey = getPreferenceName(presentationProvider, stateItem, StyleProperties.BACKGROUND_COLOR);
    String heightFactorKey = getPreferenceName(presentationProvider, stateItem, StyleProperties.HEIGHT);
    String widthKey = getPreferenceName(presentationProvider, stateItem, StyleProperties.WIDTH);
    Map<String, Object> styleMap = stateItem.getStyleMap();

    String prefRgbColor = store.getString(fillColorKey);
    if (!prefRgbColor.isEmpty()) {
        styleMap.put(StyleProperties.BACKGROUND_COLOR, prefRgbColor);
        styleMap.put(StyleProperties.COLOR, prefRgbColor);
    } else {
        // Update the new value with the old
        String oldPrefRgbColor = store.getString(oldFillColorKey);
        if (!oldPrefRgbColor.isEmpty()) {
            RGBAColor prefRgba = RGBAColor.fromString(oldPrefRgbColor);
            if (prefRgba != null) {
                String hexColor = ColorUtils.toHexColor(prefRgba.getRed(), prefRgba.getGreen(), prefRgba.getBlue());
                styleMap.put(StyleProperties.BACKGROUND_COLOR, hexColor);
                styleMap.put(StyleProperties.COLOR, hexColor);
                store.setValue(fillColorKey, hexColor);
            }
        }
    }

    store.setDefault(heightFactorKey, -1.0f);
    store.setDefault(oldHeightFactorKey, -1.0f);
    float prefHeightFactor = store.getFloat(heightFactorKey);
    if (prefHeightFactor != -1.0f) {
        styleMap.put(StyleProperties.HEIGHT, prefHeightFactor);
    } else {
        // Update the new value with the old
        prefHeightFactor = store.getFloat(oldHeightFactorKey);
        if (prefHeightFactor != -1.0f) {
            styleMap.put(StyleProperties.HEIGHT, prefHeightFactor);
            store.setValue(heightFactorKey, prefHeightFactor);
        }
    }

    store.setDefault(widthKey, -1);
    int prefWidth = store.getInt(widthKey);
    if (prefWidth != -1) {
        styleMap.put(StyleProperties.WIDTH, prefWidth);
    }
}
 
Example 17
Source File: JavadocView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void internalCreatePartControl(Composite parent) {
	try {
		fBrowser= new Browser(parent, SWT.NONE);
		fBrowser.setJavascriptEnabled(false);
		fIsUsingBrowserWidget= true;
		addLinkListener(fBrowser);
		fBrowser.addOpenWindowListener(new OpenWindowListener() {
			public void open(WindowEvent event) {
				event.required= true; // Cancel opening of new windows
			}
		});

	} catch (SWTError er) {

		/* The Browser widget throws an SWTError if it fails to
		 * instantiate properly. Application code should catch
		 * this SWTError and disable any feature requiring the
		 * Browser widget.
		 * Platform requirements for the SWT Browser widget are available
		 * from the SWT FAQ web site.
		 */

		IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
		boolean doNotWarn= store.getBoolean(DO_NOT_WARN_PREFERENCE_KEY);
		if (WARNING_DIALOG_ENABLED) {
			if (!doNotWarn) {
				String title= InfoViewMessages.JavadocView_error_noBrowser_title;
				String message= InfoViewMessages.JavadocView_error_noBrowser_message;
				String toggleMessage= InfoViewMessages.JavadocView_error_noBrowser_doNotWarn;
				MessageDialogWithToggle dialog= MessageDialogWithToggle.openError(parent.getShell(), title, message, toggleMessage, false, null, null);
				if (dialog.getReturnCode() == Window.OK)
					store.setValue(DO_NOT_WARN_PREFERENCE_KEY, dialog.getToggleState());
			}
		}

		fIsUsingBrowserWidget= false;
	}

	if (!fIsUsingBrowserWidget) {
		fText= new StyledText(parent, SWT.V_SCROLL | SWT.H_SCROLL);
		fText.setEditable(false);
		fPresenter= new HTMLTextPresenter(false);

		fText.addControlListener(new ControlAdapter() {
			/*
			 * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
			 */
			@Override
			public void controlResized(ControlEvent e) {
				doSetInput(fOriginalInput);
			}
		});
	}

	initStyleSheet();
	listenForFontChanges();
	getViewSite().setSelectionProvider(new SelectionProvider(getControl()));
}
 
Example 18
Source File: PreferenceInitializer.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public void initializeDefaultPreferences() {
	System.out.println("init preferences");
	IPreferenceStore store = new ScopedPreferenceStore( InstanceScope.INSTANCE, "de.tudresden.slr.googlescholar");
	store.setValue(PreferenceConstants.P_MAX_WAIT, 30000);
	store.setValue(PreferenceConstants.P_MIN_WAIT, 5000);
}
 
Example 19
Source File: LoadersManager.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Saves the last loader in order to reload it on next session.
 *
 * @param id
 *            Standalone ID of the loader
 * @param id2
 *            Suffix ID of the loader
 */
public void saveLastLoader(String id, String id2) {
    IPreferenceStore p = Activator.getDefault().getPreferenceStore();
    p.setValue(LOADER_PREFIX + id2, id);
}
 
Example 20
Source File: GhidraScriptEditorPreferences.java    From ghidra with Apache License 2.0 2 votes vote down vote up
/**
 * Sets whether or not the script editor feature is enabled.
 * 
 * @param enabled True to enable the script editor feature; false to disable it.
 */
public static void setScriptEditorEnabled(boolean enabled) {
	IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
	prefs.setValue(GHIDRA_SCRIPT_EDITOR_ENABLED, enabled);
}