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

The following examples show how to use org.eclipse.jface.preference.IPreferenceStore#contains() . 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: ViewerColorUpdater.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected Color createColor(IPreferenceStore store, String key, Display display) {
	
	RGB rgb = null;
	
	if(store.contains(key)) {
		
		if(store.isDefault(key)) {
			rgb = PreferenceConverter.getDefaultColor(store, key);
		} else {
			rgb = PreferenceConverter.getColor(store, key);
		}
		
		if(rgb != null)
			return new Color(display, rgb);
	}
	
	return null;
}
 
Example 2
Source File: UIUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static Color createColor( IPreferenceStore store, String key,
		Display display )
{
	RGB rgb = null;
	if ( store.contains( key ) )
	{
		if ( store.isDefault( key ) )
		{
			rgb = PreferenceConverter.getDefaultColor( store, key );
		}
		else
		{
			rgb = PreferenceConverter.getColor( store, key );
		}
		if ( rgb != null )
		{
			return new Color( display, rgb );
		}
	}
	return null;
}
 
Example 3
Source File: JavaSourceViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference store.
 * Returns <code>null</code> if there is no such information available.
 *
 * @param store the store to read from
 * @param key the key used for the lookup in the preference store
 * @param display the display used create the color
 * @return the created color according to the specification in the preference store
 * @since 3.0
 */
private Color createColor(IPreferenceStore store, String key, Display display) {

    RGB rgb= null;

    if (store.contains(key)) {

        if (store.isDefault(key))
            rgb= PreferenceConverter.getDefaultColor(store, key);
        else
            rgb= PreferenceConverter.getColor(store, key);

        if (rgb != null)
            return new Color(display, rgb);
    }

    return null;
}
 
Example 4
Source File: PythonSourceViewer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates the viewer's font to match the preferences.
 */
private void updateViewerFont() {
    IPreferenceStore store = getPreferenceStore();
    if (store != null) {
        FontData data = null;
        if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
            data = PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
        } else {
            data = PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
        }
        if (data != null) {
            Font font = new Font(getTextWidget().getDisplay(), data);
            applyFont(font);
            if (getFont() != null) {
                getFont().dispose();
            }
            setFont(font);
            return;
        }
    }
    // if all the preferences failed
    applyFont(JFaceResources.getTextFont());
}
 
Example 5
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference
 * store. Returns <code>null</code> if there is no such information
 * available.
 */
private Color createColor( IPreferenceStore store, String key,
		Display display )
{
	RGB rgb = null;
	if ( store.contains( key ) )
	{
		if ( store.isDefault( key ) )
		{
			rgb = PreferenceConverter.getDefaultColor( store, key );
		}
		else
		{
			rgb = PreferenceConverter.getColor( store, key );
		}
		if ( rgb != null )
		{
			return new Color( display, rgb );
		}
	}
	return null;
}
 
Example 6
Source File: Preferences.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static boolean is(String key) {
	if (key == null)
		return false;
	IPreferenceStore store = getStore();
	if (store == null)
		return false;
	if (!store.contains(key))
		return false;
	return store.getBoolean(key);
}
 
Example 7
Source File: PyPreferenceAccess.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Load the generator configuration from the preferences.
 *
 * @param generatorConfig the configuration to set up.
 * @param store the preference store access.
 */
public static void loadPreferences(PyGeneratorConfiguration generatorConfig, IPreferenceStore store) {
	final String key = ExtraLanguagePreferenceAccess.getPrefixedKey(PyGeneratorPlugin.PREFERENCE_ID,
			PyPreferenceAccess.JYTHON_COMPLIANCE_PROPERTY);
	if (store.contains(key)) {
		generatorConfig.setImplicitJvmTypes(store.getBoolean(key));
	}
}
 
Example 8
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 9
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create the Content Assist group and options if there are any for this language/editor.
 * 
 * @param parent
 */
protected Composite createContentAssistOptions(Composite parent)
{
	IPreferenceStore s = getChainedEditorPreferenceStore();

	Label label = new Label(parent, SWT.NONE);
	label.setText(Messages.CommonEditorPreferencePage_OnTypingCharacters);
	label.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create());

	if (s.contains(com.aptana.editor.common.contentassist.IPreferenceConstants.COMPLETION_PROPOSAL_ACTIVATION_CHARACTERS))
	{
		addField(new StringFieldEditor(
				com.aptana.editor.common.contentassist.IPreferenceConstants.COMPLETION_PROPOSAL_ACTIVATION_CHARACTERS,
				Messages.CommonEditorPreferencePage_DisplayProposals, parent));
	}

	if (s.contains(com.aptana.editor.common.contentassist.IPreferenceConstants.CONTEXT_INFORMATION_ACTIVATION_CHARACTERS))
	{
		addField(new StringFieldEditor(
				com.aptana.editor.common.contentassist.IPreferenceConstants.CONTEXT_INFORMATION_ACTIVATION_CHARACTERS,
				Messages.CommonEditorPreferencePage_DisplayContextualInfo, parent));
	}

	if (s.contains(com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS))
	{
		addField(new StringFieldEditor(
				com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS,
				Messages.CommonEditorPreferencePage_InsertProposal, parent));
	}

	return parent;
}
 
Example 10
Source File: TLCPreferenceInitializer.java    From tlaplus with MIT License 5 votes vote down vote up
/**
   * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
   */
  public void initializeDefaultPreferences()
  {
      final IPreferenceStore uiPreferencesStore = TLCUIActivator.getDefault().getPreferenceStore();
      final IPreferenceStore tlcPreferencesStore = TLCActivator.getDefault().getPreferenceStore();

      tlcPreferencesStore.setDefault(TLCActivator.I_TLC_SNAPSHOT_KEEP_COUNT, 10);

      // This is so bad.. we store them in parallel because one is needed by plugin relied upon the PreferencePage
      //      and the other by a plugin which is on the opposite side of the dependency. (TLCModelLaunchDelegate)
      uiPreferencesStore.setDefault(TLCActivator.I_TLC_SNAPSHOT_KEEP_COUNT, 10);

      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_TRACE_MAX_SHOW_ERRORS, 10000);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_POPUP_ERRORS, true);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_REVALIDATE_ON_MODIFY, true);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_DEFAULT_WORKERS_COUNT,
      							  TLCConsumptionProfile.LOCAL_NORMAL.getWorkerThreads());
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_MAXIMUM_HEAP_SIZE_DEFAULT, MAX_HEAP_SIZE_DEFAULT);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_MAXSETSIZE_DEFAULT, TLCGlobals.setBound);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_FPBITS_DEFAULT, 1);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_FPSETIMPL_DEFAULT, FPSetFactory.getImplementationDefault());
      // store.setDefault(ITLCPreferenceConstants.I_TLC_DELETE_PREVIOUS_FILES, true);

// By default we want the Toolbox to show a modal progress dialog upon TLC
// startup. A user can opt to subsequently suppress the dialog.
// This restores the behavior prior to https://bugs.eclipse.org/146205#c10.
      if (!uiPreferencesStore.contains(ITLCPreferenceConstants.I_TLC_SHOW_MODAL_PROGRESS)) {
	final IEclipsePreferences node = InstanceScope.INSTANCE
			.getNode(WorkbenchPlugin.getDefault().getBundle().getSymbolicName());
	node.putBoolean(IPreferenceConstants.RUN_IN_BACKGROUND, false);
	try {
		node.flush();
	} catch (final BackingStoreException e) {
		TLCUIActivator.getDefault().logError("Error trying to flush the workbench plugin preferences store.",
				e);
	}
	uiPreferencesStore.setValue(ITLCPreferenceConstants.I_TLC_SHOW_MODAL_PROGRESS, true);
}
  }
 
Example 11
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Removes all consequent enumerated keys from given store staring with given prefix
 */
private static void resetStore(IPreferenceStore store, String prefix) {
    int start = 0;
    // 99 is paranoia.
    while (start < 99) {
        String name = prefix + start;
        if (store.contains(name)) {
            store.setToDefault(name);
        } else {
            break;
        }
        start++;
    }
}
 
Example 12
Source File: AbstractN4JSPreferencePage.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void setDescriptorValuesFromPreferences(IPreferenceStore preferenceStore, String outputName,
		DESCR_TYPE newCompilerDescriptor) {
	for (IComponentProperties<DESCR_TYPE> prop : getComponentPropertiesValues()) {
		if (preferenceStore.contains(prop.getKey(outputName))) {
			if (prop.getType() == Boolean.class) {
				prop.setValueInCompilerDescriptor(newCompilerDescriptor, outputName,
						preferenceStore.getBoolean(prop.getKey(outputName)));
			} else { // String
				prop.setValueInCompilerDescriptor(newCompilerDescriptor, outputName,
						preferenceStore.getString(prop.getKey(outputName)));
			}
		}
	}
}
 
Example 13
Source File: EditorPreferencePage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static void initEditorPrefsInStoreIfNeed(IPreferenceStore store) {
    if (store != null) {
        if (!store.contains(PREF_UNMATCHED_BRACKETS_COLOR)) {
            // NOTE: store.contains(ModulaEditor.EDITOR_MATCHING_BRACKETS) does not works - for boolean with FALSE value it returns TRUE averytime
            store.setValue(PREF_HIGHLIGHT_MATCHING_BRACKETS, true);
            PreferenceConverter.setValue(store, PREF_MATCHED_BRACKETS_COLOR, PairedBracketsPainter.DEF_RGB_MATCHED);
            PreferenceConverter.setValue(store, PREF_UNMATCHED_BRACKETS_COLOR, PairedBracketsPainter.DEF_RGB_UNMATCHED);
        }
    }
}
 
Example 14
Source File: PythonSourceViewer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference store. Returns <code>null</code> if there is no such information available.
 */
private Color createColor(IPreferenceStore store, String key, Display display) {
    RGB rgb = null;
    if (store.contains(key)) {
        if (store.isDefault(key)) {
            rgb = PreferenceConverter.getDefaultColor(store, key);
        } else {
            rgb = PreferenceConverter.getColor(store, key);
        }
        if (rgb != null) {
            return new Color(display, rgb);
        }
    }
    return null;
}
 
Example 15
Source File: CloudSdkPreferences.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static void initializeDefaultPreferences(IPreferenceStore preferences) {
  if (!preferences.contains(CLOUD_SDK_MANAGEMENT)) {
    // If the CLOUD_SDK_MANAGEMENT preference has not been set, then determine the
    // appropriate setting. Note that CloudSdkPreferenceResolver only checks for
    // the Managed Cloud SDK when CLOUD_SDK_MANAGEMENT has been explicitly set
    // (i.e., this code has been run).
    configureManagementPreferences(preferences, isCloudSdkAvailable());
  }
  preferences.setDefault(CLOUD_SDK_MANAGEMENT, CloudSdkManagementOption.AUTOMATIC.name());
}
 
Example 16
Source File: XFindPanel.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public XFindPanel(final Composite parent, IEditorPart editorPart) {
      super(parent, SWT.NONE);
      statusLine = new StatusLine(editorPart.getEditorSite());
      setVisible(false);

      if (editorPart != null) {
          target = (IFindReplaceTarget) editorPart.getAdapter(IFindReplaceTarget.class);
          isRegExSupported = (target instanceof IFindReplaceTargetExtension3);
      }

      final IPreferenceStore store = XFindPlugin.getDefault().getPreferenceStore(); 
      if (!store.contains(XFIND_PANEL_PLACEMENT)) {
          store.setDefault(XFIND_PANEL_PLACEMENT, XFIND_PANEL_PLACEMENT_TOP);
      }

      if (store.getInt(XFIND_PANEL_PLACEMENT) == XFIND_PANEL_PLACEMENT_BOTTOM) {
          moveBelow(null);
      } else {
          moveAbove(null);
      }
      
      createContents();
      loadHistory(store);

      store.addPropertyChangeListener(new IPropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent event) {
              Display.getDefault().syncExec(new Runnable() {
                  @Override
                  public void run() {
                      if (XFIND_PANEL_PLACEMENT.equals(event.getProperty())) {
                          if (store.getInt(XFIND_PANEL_PLACEMENT) == XFIND_PANEL_PLACEMENT_BOTTOM) {
                              moveBelow(null);
                          } else {
                              moveAbove(null);
                          }
                          parent.layout();
                      }
                  }
              });
          }
      });
      
      parent.addDisposeListener(new DisposeListener() {
	@Override
	public void widgetDisposed(DisposeEvent e) {
		saveHistory(store);
	}
});
  }
 
Example 17
Source File: SaveUtils.java    From txtUML with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean saveAutomatically() {
	IPreferenceStore s = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.ide");
	return s.contains("SAVE_ALL_BEFORE_BUILD") && s.getBoolean("SAVE_ALL_BEFORE_BUILD");
}
 
Example 18
Source File: EclipseOutputConfigurationProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private String getString(OutputConfiguration outputConfiguration, String name, IPreferenceStore preferenceStore,
		String defaultValue) {
	String preferenceKey = getKey(outputConfiguration, name);
	return preferenceStore.contains(preferenceKey) ? preferenceStore.getString(preferenceKey) : defaultValue;
}
 
Example 19
Source File: CloudSdkPreferences.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
static boolean isAutoManaging(IPreferenceStore preferences) {
  return preferences.contains(CloudSdkPreferences.CLOUD_SDK_MANAGEMENT)
      && preferences.getString(CLOUD_SDK_MANAGEMENT).equals(
          CloudSdkManagementOption.AUTOMATIC.name());
}
 
Example 20
Source File: UnOpenAgainEditorPresentationFactory.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public StackPresentation createEditorPresentation(Composite parent,
		IStackPresentationSite site) {
	DefaultTabFolder folder = new DefaultTabFolder(parent,
			editorTabPosition | SWT.BORDER, site
					.supportsState(IStackPresentationSite.STATE_MINIMIZED),
			site.supportsState(IStackPresentationSite.STATE_MAXIMIZED));

	/*
	 * Set the minimum characters to display, if the preference is something
	 * other than the default. This is mainly intended for RCP applications
	 * or for expert users (i.e., via the plug-in customization file).
	 * 
	 * Bug 32789.
	 */
	final IPreferenceStore store = PlatformUI.getPreferenceStore();
	if (store
			.contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) {
		final int minimumCharacters = store
				.getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS);
		if (minimumCharacters >= 0) {
			folder.setMinimumCharacters(minimumCharacters);
		}
	}

	PresentablePartFolder partFolder = new PresentablePartFolder(folder);

	TabbedStackPresentation result = new TabbedStackPresentation(site,
			partFolder, new StandardEditorSystemMenu(site));

	DefaultThemeListener themeListener = new DefaultThemeListener(folder,
			result.getTheme());
	result.getTheme().addListener(themeListener);

	new DefaultMultiTabListener(result.getApiPreferences(),
			IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder);

	new DefaultSimpleTabListener(result.getApiPreferences(),
			IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
			folder);

	return result;
}