Java Code Examples for org.eclipse.core.runtime.Preferences#setValue()

The following examples show how to use org.eclipse.core.runtime.Preferences#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: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setValue( String name, boolean value )
{
	boolean oldValue = getBoolean( name );
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null )
		{
			if ( preference.isDefault( name ) || oldValue != value )
			{
				preference.setValue( name, value );
				firePreferenceChangeEvent( name,
						Boolean.valueOf( oldValue ),
						Boolean.valueOf( value ) );
			}
			return;
		}
	}
	if ( oldValue != value )
	{
		prefsStore.setValue( name, value );
		firePreferenceChangeEvent( name,
				Boolean.valueOf( oldValue ),
				Boolean.valueOf( value ) );
	}
}
 
Example 2
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setValue( String name, String value )
{
	String oldValue = getString( name );
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null )
		{
			if ( preference.isDefault( name ) || !oldValue.equals( value ) )
			{
				preference.setValue( name, value );
				firePreferenceChangeEvent( name, oldValue, value );
			}
			return;
		}
	}
	if ( !oldValue.equals( value ) )
	{
		prefsStore.setValue( name, value );
		firePreferenceChangeEvent( name, oldValue, value );
	}
}
 
Example 3
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setValue( String name, long value )
{
	long oldValue = getLong( name );
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null )
		{
			if ( preference.isDefault( name ) || oldValue != value )
			{
				preference.setValue( name, value );
				firePreferenceChangeEvent( name,
						Long.valueOf( oldValue ),
						Long.valueOf( value ) );
			}
			return;
		}
	}
	if ( oldValue != value )
	{
		prefsStore.setValue( name, value );
		firePreferenceChangeEvent( name,
				Long.valueOf( oldValue ),
				Long.valueOf( value ) );
	}
}
 
Example 4
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setValue( String name, int value )
{
	int oldValue = getInt( name );
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null )
		{
			if ( preference.isDefault( name ) || oldValue != value )
			{
				preference.setValue( name, value );
				firePreferenceChangeEvent( name,
						Integer.valueOf( oldValue ),
						Integer.valueOf( value ) );
			}
			return;
		}
	}
	if ( oldValue != value )
	{
		prefsStore.setValue( name, value );
		firePreferenceChangeEvent( name,
				Integer.valueOf( oldValue ),
				Integer.valueOf( value ) );
	}
}
 
Example 5
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setValue( String name, float value )
{
	float oldValue = getFloat( name );
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null )
		{
			if ( preference.isDefault( name ) || oldValue != value )
			{
				preference.setValue( name, value );
				firePreferenceChangeEvent( name,
						new Float( oldValue ),
						new Float( value ) );
			}
			return;
		}
	}
	if ( oldValue != value )
	{
		prefsStore.setValue( name, value );
		firePreferenceChangeEvent( name,
				new Float( oldValue ),
				new Float( value ) );
	}
}
 
Example 6
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setValue( String name, double value )
{
	double oldValue = getDouble( name );
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null )
		{
			if ( preference.isDefault( name ) || oldValue != value )
			{
				preference.setValue( name, value );
				firePreferenceChangeEvent( name,
						new Double( oldValue ),
						new Double( value ) );
			}
			return;
		}
	}
	if ( oldValue != value )
	{
		prefsStore.setValue( name, value );
		firePreferenceChangeEvent( name,
				new Double( oldValue ),
				new Double( value ) );
	}
}
 
Example 7
Source File: ResultSetPreviewPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private int getMaxRowPreference( )
{
	int maxRow;
	Preferences preferences = ReportPlugin.getDefault( )
			.getPluginPreferences( );
	if ( preferences.contains( DateSetPreferencePage.USER_MAXROW ) )
	{
		maxRow = preferences.getInt( DateSetPreferencePage.USER_MAXROW );
	}
	else
	{
		maxRow = DateSetPreferencePage.DEFAULT_MAX_ROW;
		preferences.setValue( DateSetPreferencePage.USER_MAXROW, maxRow );
	}
	return maxRow;
}
 
Example 8
Source File: SQLDataSetEditorPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void setDefaultPereferencesIfNeed( )
{
	Preferences preferences = JdbcPlugin.getDefault( )
			.getPluginPreferences( );
	if ( !preferences.contains( DateSetPreferencePage.SCHEMAS_PREFETCH_CONFIG ) )
	{
		preferences.setValue( DateSetPreferencePage.SCHEMAS_PREFETCH_CONFIG,
				DateSetPreferencePage.ENABLED );
	}
	if ( !preferences.contains( DateSetPreferencePage.ENABLE_CODE_ASSIST ) )
	{
		preferences.setValue( DateSetPreferencePage.ENABLE_CODE_ASSIST,
				DateSetPreferencePage.ENABLED );
	}
	if ( !preferences.contains( DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA ) )
	{
		preferences.setValue( DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA,
				String.valueOf( DateSetPreferencePage.DEFAULT_MAX_NUM_OF_SCHEMA ) );
	}
	if ( !preferences.contains( DateSetPreferencePage.USER_MAX_NUM_OF_TABLE_EACH_SCHEMA ) )
	{
		preferences.setValue( DateSetPreferencePage.USER_MAX_NUM_OF_TABLE_EACH_SCHEMA,
				String.valueOf( DateSetPreferencePage.DEFAULT_MAX_NUM_OF_TABLE_EACH_SCHEMA ) );
	}
	if ( !preferences.contains( DateSetPreferencePage.USER_TIMEOUT_LIMIT ) )
	{
		preferences.setValue( DateSetPreferencePage.USER_TIMEOUT_LIMIT,
				String.valueOf( DateSetPreferencePage.DEFAULT_TIMEOUT_LIMIT ) );
	}
}
 
Example 9
Source File: OldMechanicPreferences.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Saves the supplied Task id set in the preferences system.
 */
public static void setBlockedTaskIds(Set<String> ids) {
  BlockedTaskIdsParser parser = new BlockedTaskIdsParser();

  String unparse = parser.unparse(ids);

  Preferences prefs = getPreferences();
  prefs.setValue(IMechanicPreferences.BLOCKED_PREF, unparse);
}
 
Example 10
Source File: NewWizardHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional ISelection selection) {
    Preferences preferences = ResourcesPlugin.getPlugin()
            .getPluginPreferences();

    preferences.setValue(ResourcesPlugin.PREF_DISABLE_LINKING, true);
    new WizardDialog(Display.getDefault().getActiveShell(), createWizard((IStructuredSelection) selection)).open();
    preferences.setValue(ResourcesPlugin.PREF_DISABLE_LINKING, false);
}
 
Example 11
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * OK was clicked. Store the SVN preferences.
 *
 * @return whether it is okay to close the preference page
 */
public boolean performOk() {
	IPreferenceStore store = getPreferenceStore();
	Preferences corePreferences = SVNProviderPlugin.getPlugin().getPluginPreferences();
	store.setValue(ISVNUIConstants.PREF_FILETEXT_DECORATION, fileTextFormat.getText());
	store.setValue(ISVNUIConstants.PREF_FOLDERTEXT_DECORATION, folderTextFormat.getText());
	store.setValue(ISVNUIConstants.PREF_PROJECTTEXT_DECORATION, projectTextFormat.getText());
	
	store.setValue(ISVNUIConstants.PREF_DATEFORMAT_DECORATION, dateFormatText.getText());
	
	store.setValue(ISVNUIConstants.PREF_ADDED_FLAG, addedFlag.getText());
	store.setValue(ISVNUIConstants.PREF_DIRTY_FLAG, dirtyFlag.getText());
       store.setValue(ISVNUIConstants.PREF_EXTERNAL_FLAG, externalFlag.getText());
	
	store.setValue(ISVNUIConstants.PREF_SHOW_DIRTY_DECORATION, imageShowDirty.getSelection());
	store.setValue(ISVNUIConstants.PREF_SHOW_ADDED_DECORATION, imageShowAdded.getSelection());
	store.setValue(ISVNUIConstants.PREF_SHOW_HASREMOTE_DECORATION, imageShowHasRemote.getSelection());
	store.setValue(ISVNUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, imageShowNewResource.getSelection());
	store.setValue(ISVNUIConstants.PREF_SHOW_EXTERNAL_DECORATION, imageShowExternal.getSelection());
	corePreferences.setValue(ISVNCoreConstants.PREF_SHOW_READ_ONLY, imageShowReadOnly.getSelection());
	
	store.setValue(ISVNUIConstants.PREF_CALCULATE_DIRTY, showDirty.getSelection());
	store.setValue(ISVNUIConstants.PREF_USE_FONT_DECORATORS, enableFontDecorators.getSelection());
       
       // Update the strategy used to calculate the dirty state
	SVNProviderPlugin.getPlugin().getPluginPreferences().setValue(ISVNCoreConstants.PREF_RECURSIVE_STATUS_UPDATE, showDirty.getSelection());
       SVNProviderPlugin.getPlugin().savePluginPreferences();
       
	SVNLightweightDecorator.refresh();

	SVNUIPlugin.getPlugin().savePluginPreferences();
	return true;
}
 
Example 12
Source File: BaseUtils.java    From http4e with Apache License 2.0 5 votes vote down vote up
public static void writeToPrefs( String prefName, byte[] prefData){
   try {
      Plugin pl = (Plugin) CoreContext.getContext().getObject("p");
      Preferences prefs = pl.getPluginPreferences();

      String str64 = new String(Base64.encodeBase64(prefData), "UTF8");
      prefs.setValue(prefName, str64);
      pl.savePluginPreferences();

   } catch (UnsupportedEncodingException e) {
      ExceptionHandler.handle(e);
   } catch (Exception ignore) {
      ExceptionHandler.handle(ignore);
   }
}
 
Example 13
Source File: PreviewPreferencePage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see IPreferencePage
 */
public boolean performOk( )
{
	Preferences pref = ViewerPlugin.getDefault( ).getPluginPreferences( );

	// for ( int i = 0; i < externalBrowsers.length; i++ )
	// {
	// if ( externalBrowsers[i].getSelection( ) )
	// {
	// // set new current browser
	// String browserID = ( (BrowserDescriptor) externalBrowsers[i].getData(
	// ) ).getID( );
	// BrowserManager.getInstance( ).setCurrentBrowserID( browserID );
	// // save id in help preferences
	// pref.setValue( BrowserManager.DEFAULT_BROWSER_ID_KEY, browserID );
	// break;
	// }
	// }
	//
	// customBrowserPath.getText( );
	// pref.setValue( CustomBrowser.CUSTOM_BROWSER_PATH_KEY,
	// customBrowserPath.getText( ) );

	if ( svgFlag != null )
	{
		pref.setValue( WebViewer.SVG_FLAG, svgFlag.getSelection( ) );
	}

	if ( masterPageContent != null )
	{
		pref.setValue( WebViewer.MASTER_PAGE_CONTENT,
				masterPageContent.getSelection( ) );
	}

	if ( alwaysExternal != null )
	{
		pref.setValue( BrowserManager.ALWAYS_EXTERNAL_BROWSER_KEY,
				alwaysExternal.getSelection( ) );
		BrowserManager.getInstance( )
				.setAlwaysUseExternal( alwaysExternal.getSelection( ) );
	}

	if ( timeZoneCombo != null )
	{
		String timeZoneId = ViewerPlugin.getTimeZoneTable_disKey().get( timeZoneCombo.getText( ) );
		if ( timeZoneId == null || timeZoneId.trim( ).length( ) <= 0 )
		{
			timeZoneId = TimeZone.getDefault( ).getID( );
		}
		pref.setValue( WebViewer.USER_TIME_ZONE, timeZoneId );
	}

	if ( localeCombo != null )
	{
		if ( WebViewer.LOCALE_TABLE.containsKey( localeCombo.getText( ) ) )
		{
			pref.setValue( WebViewer.USER_LOCALE,
					WebViewer.LOCALE_TABLE.get( localeCombo.getText( ) ) );
		}
		else
			pref.setValue( WebViewer.USER_LOCALE, localeCombo.getText( ) );
	}

	if ( bidiCombo != null )
	{
		int selection = bidiCombo.getSelectionIndex( );
		selection = selection < 0 ? 0 : selection;
		pref.setValue( WebViewer.BIDI_ORIENTATION,
				BIDI_CHOICE_NAMES[selection] );
	}
	ViewerPlugin.getDefault( ).savePluginPreferences( );

	return true;
}
 
Example 14
Source File: OldMechanicPreferences.java    From workspacemechanic with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Disable the preference that shows the notification popup.
 */
public static void doNotShowPopup() {
  Preferences prefs = getPreferences();
  prefs.setValue(IMechanicPreferences.SHOW_POPUP_PREF, false);
}
 
Example 15
Source File: OldMechanicPreferences.java    From workspacemechanic with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Set the string value of a preference on the MechanicPreferences scope.
 */
public static void setString(String key, String value) {
  Preferences prefs = getPreferences();
  prefs.setValue(key, value);
}
 
Example 16
Source File: OldMechanicPreferences.java    From workspacemechanic with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Set the long value of a preference on the MechanicPreferences scope.
 */
public static void setLong(String key, long value) {
  Preferences prefs = getPreferences();
  prefs.setValue(key, value);
}
 
Example 17
Source File: JavaEditorColoringConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
private Preferences createTemporaryCorePreferenceStore() {
	Preferences result= new Preferences();

	result.setValue(COMPILER_TASK_TAGS, "TASK,TODO"); //$NON-NLS-1$

	return result;
}
 
Example 18
Source File: PreviewServerPreferencePage.java    From birt with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * @see IPreferencePage
 */
public boolean performOk( )
{
	Preferences pref = ViewerPlugin.getDefault( ).getPluginPreferences( );

	pref.setValue( AppServerWrapper.HOST_KEY, textServerAddr.getText( ) );

	pref.setValue( AppServerWrapper.PORT_KEY, textServerPort.getText( ) );

	ViewerPlugin.getDefault( ).savePluginPreferences( );

	return true;
}
 
Example 19
Source File: ContentAssistHistory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Stores the history as XML document into the given preferences.
 *
 * @param history the history to store
 * @param preferences the preferences to store the history into
 * @param key the key under which to store the history
 * @throws CoreException if serialization fails
 * @see #load(Preferences, String) on how to restore a history stored by this method
 */
public static void store(ContentAssistHistory history, Preferences preferences, String key) throws CoreException {
	StringWriter writer= new StringWriter();
	new ReaderWriter().store(history, new StreamResult(writer));
	preferences.setValue(key, writer.toString());
}
 
Example 20
Source File: OldMechanicPreferences.java    From workspacemechanic with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Enable preference that shows the notification popup.
 *
 * <p>For tests only.
 */
public static void showPopup() {
  Preferences prefs = getPreferences();
  prefs.setValue(IMechanicPreferences.SHOW_POPUP_PREF, true);
}