org.eclipse.core.runtime.Preferences Java Examples

The following examples show how to use org.eclipse.core.runtime.Preferences. 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 setToDefault( String name )
{
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		preference.setToDefault( name );
		firePreferenceChangeEvent( PreferenceChangeEvent.SPECIALTODEFAULT,
				null,
				null );
	}
	else
	{
		String oldValue = prefsStore.getString( name );
		prefsStore.setToDefault( name );
		firePreferenceChangeEvent( name,
				oldValue,
				prefsStore.getDefaultString( name ) );
	}
}
 
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, 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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public String getString( String name )
{
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null && preference.contains( name ) )
			return preference.getString( name );
	}
	return prefsStore.getString( name );
}
 
Example #10
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public float getFloat( String name )
{
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null && preference.contains( name ) )
			return preference.getFloat( name );
	}
	return prefsStore.getFloat( name );
}
 
Example #11
Source File: IDEReportPreferenceFactory.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public boolean hasSpecialSettings( Object adaptable, String name )
{
	IProject project = getProject( adaptable );
	if ( project == null )
		return false;
	else
	{
		Preferences preference = getReportPreference( adaptable );
		if ( preference != null )
			return !preference.isDefault( name );
		else
			return false;
	}
}
 
Example #12
Source File: MultiPageEditorContributor.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the uima pref int.
 *
 * @param key the key
 * @param defaultValue the default value
 * @return the uima pref int
 */
private static int getUimaPrefInt(String key, int defaultValue) {
  TAEConfiguratorPlugin plugin = TAEConfiguratorPlugin.getDefault();
  Preferences prefs = plugin.getPluginPreferences();
  boolean isDefault = prefs.isDefault(key);
  if (isDefault)
    prefs.setDefault(key, defaultValue);
  return prefs.getInt(key);
}
 
Example #13
Source File: MultiPageEditorContributor.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the uima pref boolean.
 *
 * @param key the key
 * @param defaultValue the default value
 * @return the uima pref boolean
 */
private static boolean getUimaPrefBoolean(String key, boolean defaultValue) {
  TAEConfiguratorPlugin plugin = TAEConfiguratorPlugin.getDefault();
  Preferences prefs = plugin.getPluginPreferences();
  boolean isDefault = prefs.isDefault(key);
  if (isDefault)
    prefs.setDefault(key, defaultValue);
  return prefs.getBoolean(key);
}
 
Example #14
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 #15
Source File: MultiPageEditorContributor.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the uima pref string.
 *
 * @param key the key
 * @param defaultValue the default value
 * @return the uima pref string
 */
private static String getUimaPrefString(String key, String defaultValue) {
  TAEConfiguratorPlugin plugin = TAEConfiguratorPlugin.getDefault();
  Preferences prefs = plugin.getPluginPreferences();
  boolean isDefault = prefs.isDefault(key);
  if (isDefault)
    prefs.setDefault(key, defaultValue);
  return prefs.getString(key);
}
 
Example #16
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 #17
Source File: IDEReportPreferenceFactory.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Preferences getReportPreference( Object adaptable )
{
	IProject project = getProject( adaptable );
	if ( project == null )
		return null;
	else if ( !containsReportPreference( adaptable ) )
	{
		ReportProjectPreference prefs = new ReportProjectPreference( pluginId,
				project );
		prefsMap.put( project.getFullPath( ).toOSString( ), prefs );
	}
	return (ReportProjectPreference) prefsMap.get( project.getFullPath( )
			.toOSString( ) );
}
 
Example #18
Source File: BaseUtils.java    From http4e with Apache License 2.0 5 votes vote down vote up
public static byte[] readFromPrefs( String prefName){
   try {
      Plugin pl = (Plugin) CoreContext.getContext().getObject("p");
      Preferences prefs = pl.getPluginPreferences();
      String str64 = prefs.getString(prefName);
      byte[] data = Base64.decodeBase64(str64.getBytes("UTF8"));
      return data;

   } catch (UnsupportedEncodingException e) {
      ExceptionHandler.handle(e);
   } catch (Exception ignore) {
      ExceptionHandler.handle(ignore);
   }
   return null;
}
 
Example #19
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Defaults was clicked. Restore the SVN preferences to
 * their default values
 */
protected void performDefaults() {
	super.performDefaults();
	IPreferenceStore store = getPreferenceStore();
	Preferences corePreferences = SVNProviderPlugin.getPlugin().getPluginPreferences();
	
	fileTextFormat.setText(store.getDefaultString(ISVNUIConstants.PREF_FILETEXT_DECORATION));
	folderTextFormat.setText(store.getDefaultString(ISVNUIConstants.PREF_FOLDERTEXT_DECORATION));
	projectTextFormat.setText(store.getDefaultString(ISVNUIConstants.PREF_PROJECTTEXT_DECORATION));
	
	dateFormatText.setText(""); //$NON-NLS-1$
	
	addedFlag.setText(store.getDefaultString(ISVNUIConstants.PREF_ADDED_FLAG));
	dirtyFlag.setText(store.getDefaultString(ISVNUIConstants.PREF_DIRTY_FLAG));
       externalFlag.setText(store.getDefaultString(ISVNUIConstants.PREF_EXTERNAL_FLAG));
	
	imageShowDirty.setSelection(store.getDefaultBoolean(ISVNUIConstants.PREF_SHOW_DIRTY_DECORATION));
	imageShowAdded.setSelection(store.getDefaultBoolean(ISVNUIConstants.PREF_SHOW_ADDED_DECORATION));
	imageShowHasRemote.setSelection(store.getDefaultBoolean(ISVNUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
	imageShowNewResource.setSelection(store.getDefaultBoolean(ISVNUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION));
	imageShowExternal.setSelection(store.getDefaultBoolean(ISVNUIConstants.PREF_SHOW_EXTERNAL_DECORATION));
	imageShowReadOnly.setSelection(false);
	
	showDirty.setSelection(store.getDefaultBoolean(ISVNUIConstants.PREF_CALCULATE_DIRTY));
	enableFontDecorators.setSelection(store.getDefaultBoolean(ISVNUIConstants.PREF_USE_FONT_DECORATORS));
	
	setValid(true);
   }
 
Example #20
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public long getLong( String name )
{
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null && preference.contains( name ) )
			return preference.getLong( name );
	}
	return prefsStore.getLong( name );
}
 
Example #21
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public int getInt( String name )
{
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null && preference.contains( name ) )
			return preference.getInt( name );
	}
	return prefsStore.getInt( name );
}
 
Example #22
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 #23
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public double getDouble( String name )
{
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null && preference.contains( name ) )
			return preference.getDouble( name );
	}
	return prefsStore.getDouble( name );
}
 
Example #24
Source File: PreferenceWrapper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public boolean getBoolean( String name )
{
	if ( this.preferenceType == SPECIAL_TYPE && project != null )
	{
		Preferences preference = prefs.getReportPreference( project );
		if ( preference != null && preference.contains( name ) )
			return preference.getBoolean( name );
	}
	return prefsStore.getBoolean( name );
}
 
Example #25
Source File: PreviewServerPreferencePage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Performs special processing when this page's Defaults button has been
 * pressed.
 * <p>
 * This is a framework hook method for sublcasses to do special things when
 * the Defaults button has been pressed. Subclasses may override, but should
 * call <code>super.performDefaults</code>.
 * </p>
 */
protected void performDefaults( )
{
	Preferences pref = ViewerPlugin.getDefault( ).getPluginPreferences( );

	textServerAddr.setText( pref.getDefaultString( AppServerWrapper.HOST_KEY ) );

	textServerPort.setText( pref.getDefaultString( AppServerWrapper.PORT_KEY ) );

	super.performDefaults( );
}
 
Example #26
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 #27
Source File: JavaCommentScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public JavaCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty, String[] tokenProperties) {
	super(manager, store);

	fCorePreferenceStore= coreStore;
	fDefaultTokenProperty= defaultTokenProperty;
	fTokenProperties= tokenProperties;

	initialize();
}
 
Example #28
Source File: SQLDataSetEditorPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void readPreferences( )
{
	setDefaultPereferencesIfNeed( );
	Preferences preferences = JdbcPlugin.getDefault( )
			.getPluginPreferences( );

	if ( DateSetPreferencePage.ENABLED.equals( preferences.getString( DateSetPreferencePage.SCHEMAS_PREFETCH_CONFIG ) ) )
	{
		prefetchSchema = true;
	}
	if ( DateSetPreferencePage.ENABLED.equals( preferences.getString( DateSetPreferencePage.ENABLE_CODE_ASSIST ) ) )
	{
		enableCodeAssist = true;
	}
	maxSchemaCount = preferences.getInt( DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA );
	maxTableCountPerSchema = preferences.getInt( DateSetPreferencePage.USER_MAX_NUM_OF_TABLE_EACH_SCHEMA );
	timeOutLimit = preferences.getInt( DateSetPreferencePage.USER_TIMEOUT_LIMIT );
	if ( maxSchemaCount <= 0 )
	{
		maxSchemaCount = Integer.MAX_VALUE;
	}
	if ( maxTableCountPerSchema <= 0 )
	{
		maxTableCountPerSchema = Integer.MAX_VALUE;
	}
	if ( timeOutLimit < 0 )
	{
		timeOutLimit = 0;
	}
}
 
Example #29
Source File: TextUMLPreferencePage.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean performOk() {
    Preferences preferences = TextUMLUIPlugin.getDefault().getPluginPreferences();
    boolean formatOnSaveSetting = formatOnSaveCheckBox.getSelection();
    preferences.setValue(TextUMLUIPlugin.FORMAT_ON_SAVE, formatOnSaveSetting);
    preferences.setValue(TextUMLUIPlugin.OPTIONS, createStoreString());
    TextUMLUIPlugin.getDefault().savePluginPreferences();
    return true;
}
 
Example #30
Source File: TextUMLPreferencePage.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
private Object[] findCheckedElements() {
    Preferences preferences = TextUMLUIPlugin.getDefault().getPluginPreferences();
    String rawString = preferences.getString(TextUMLUIPlugin.OPTIONS);
    List a = new ArrayList();
    if (isNotEmpty(rawString)) {
        String[] selected = rawString.split(",");
        for (String optId : selected) {
            a.add(options.get(optId));
        }
    }
    return a.toArray();
}