List of usage examples for org.eclipse.jface.preference IPreferenceStore getDefaultString
String getDefaultString(String name);
From source file:org.eclipse.ui.ide.dialogs.AbstractEncodingFieldEditor.java
License:Open Source License
public void setPreferenceStore(IPreferenceStore store) { super.setPreferenceStore(store); defaultEnc = store.getDefaultString(getPreferenceName()); updateDefaultEncoding();//from w w w. ja v a 2 s .c om }
From source file:org.eclipse.ui.internal.activities.ExtensionActivityRegistry.java
License:Open Source License
private void load() throws IOException { if (activityRequirementBindingDefinitions == null) { activityRequirementBindingDefinitions = new ArrayList(); } else {/*from w w w.j av a2 s. c o m*/ activityRequirementBindingDefinitions.clear(); } if (activityDefinitions == null) { activityDefinitions = new ArrayList(); } else { activityDefinitions.clear(); } if (activityPatternBindingDefinitions == null) { activityPatternBindingDefinitions = new ArrayList(); } else { activityPatternBindingDefinitions.clear(); } if (categoryActivityBindingDefinitions == null) { categoryActivityBindingDefinitions = new ArrayList(); } else { categoryActivityBindingDefinitions.clear(); } if (categoryDefinitions == null) { categoryDefinitions = new ArrayList(); } else { categoryDefinitions.clear(); } if (defaultEnabledActivities == null) { defaultEnabledActivities = new ArrayList(); } else { defaultEnabledActivities.clear(); } IConfigurationElement[] configurationElements = extensionRegistry .getConfigurationElementsFor(Persistence.PACKAGE_FULL); for (int i = 0; i < configurationElements.length; i++) { IConfigurationElement configurationElement = configurationElements[i]; String name = configurationElement.getName(); if (Persistence.TAG_ACTIVITY_REQUIREMENT_BINDING.equals(name)) { readActivityRequirementBindingDefinition(configurationElement); } else if (Persistence.TAG_ACTIVITY.equals(name)) { readActivityDefinition(configurationElement); } else if (Persistence.TAG_ACTIVITY_PATTERN_BINDING.equals(name)) { readActivityPatternBindingDefinition(configurationElement); } else if (Persistence.TAG_CATEGORY_ACTIVITY_BINDING.equals(name)) { readCategoryActivityBindingDefinition(configurationElement); } else if (Persistence.TAG_CATEGORY.equals(name)) { readCategoryDefinition(configurationElement); } else if (Persistence.TAG_DEFAULT_ENABLEMENT.equals(name)) { readDefaultEnablement(configurationElement); } } // merge enablement overrides from plugin_customization.ini IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); for (Iterator i = activityDefinitions.iterator(); i.hasNext();) { ActivityDefinition activityDef = (ActivityDefinition) i.next(); String id = activityDef.getId(); String preferenceKey = createPreferenceKey(id); if ("".equals(store.getDefaultString(preferenceKey))) //$NON-NLS-1$ continue; if (store.getDefaultBoolean(preferenceKey)) { if (!defaultEnabledActivities.contains(id) && activityDef.getEnabledWhen() == null) defaultEnabledActivities.add(id); } else { defaultEnabledActivities.remove(id); } } // Removal of all defaultEnabledActivites which target to expression // controlled activities. for (int i = 0; i < defaultEnabledActivities.size();) { String id = (String) defaultEnabledActivities.get(i); ActivityDefinition activityDef = getActivityDefinitionById(id); if (activityDef != null && activityDef.getEnabledWhen() != null) { defaultEnabledActivities.remove(i); StatusManager.getManager().handle(new Status(IStatus.WARNING, PlatformUI.PLUGIN_ID, "Default enabled activity declarations will be ignored (id: " + id + ")")); //$NON-NLS-1$ //$NON-NLS-2$ } else { i++; } } // remove all requirement bindings that reference expression-bound activities for (Iterator i = activityRequirementBindingDefinitions.iterator(); i.hasNext();) { ActivityRequirementBindingDefinition bindingDef = (ActivityRequirementBindingDefinition) i.next(); ActivityDefinition activityDef = getActivityDefinitionById(bindingDef.getRequiredActivityId()); if (activityDef != null && activityDef.getEnabledWhen() != null) { i.remove(); StatusManager.getManager().handle(new Status(IStatus.WARNING, PlatformUI.PLUGIN_ID, "Expression activity cannot have requirements (id: " + activityDef.getId() + ")")); //$NON-NLS-1$ //$NON-NLS-2$ continue; } activityDef = getActivityDefinitionById(bindingDef.getActivityId()); if (activityDef != null && activityDef.getEnabledWhen() != null) { i.remove(); StatusManager.getManager().handle(new Status(IStatus.WARNING, PlatformUI.PLUGIN_ID, "Expression activity cannot be required (id: " + activityDef.getId() + ")")); //$NON-NLS-1$ //$NON-NLS-2$ } } boolean activityRegistryChanged = false; if (!activityRequirementBindingDefinitions.equals(super.activityRequirementBindingDefinitions)) { super.activityRequirementBindingDefinitions = Collections .unmodifiableList(new ArrayList(activityRequirementBindingDefinitions)); activityRegistryChanged = true; } if (!activityDefinitions.equals(super.activityDefinitions)) { super.activityDefinitions = Collections.unmodifiableList(new ArrayList(activityDefinitions)); activityRegistryChanged = true; } if (!activityPatternBindingDefinitions.equals(super.activityPatternBindingDefinitions)) { super.activityPatternBindingDefinitions = Collections .unmodifiableList(new ArrayList(activityPatternBindingDefinitions)); activityRegistryChanged = true; } if (!categoryActivityBindingDefinitions.equals(super.categoryActivityBindingDefinitions)) { super.categoryActivityBindingDefinitions = Collections .unmodifiableList(new ArrayList(categoryActivityBindingDefinitions)); activityRegistryChanged = true; } if (!categoryDefinitions.equals(super.categoryDefinitions)) { super.categoryDefinitions = Collections.unmodifiableList(new ArrayList(categoryDefinitions)); activityRegistryChanged = true; } if (!defaultEnabledActivities.equals(super.defaultEnabledActivities)) { super.defaultEnabledActivities = Collections.unmodifiableList(new ArrayList(defaultEnabledActivities)); activityRegistryChanged = true; } if (activityRegistryChanged) { fireActivityRegistryChanged(); } }
From source file:org.eclipse.ui.internal.ActivityPersistanceHelper.java
License:Open Source License
/** * Load the enabled states for the given activity IDs. * //from w w w. j a va 2s. co m * @param previouslyEnabledActivities the activity states to maintain. This set must be writabe. * @param activityIdsToProcess the activity ids to process */ protected void loadEnabledStates(Set previouslyEnabledActivities, Set activityIdsToProcess) { if (activityIdsToProcess.isEmpty()) { return; } Set enabledActivities = new HashSet(previouslyEnabledActivities); IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); IWorkbenchActivitySupport support = PlatformUI.getWorkbench().getActivitySupport(); IActivityManager activityManager = support.getActivityManager(); for (Iterator i = activityIdsToProcess.iterator(); i.hasNext();) { String activityId = (String) i.next(); String preferenceKey = createPreferenceKey(activityId); try { IActivity activity = activityManager.getActivity(activityId); if (activity.getExpression() != null) { continue; } if ("".equals(store.getDefaultString(preferenceKey))) { //$NON-NLS-1$ // no override has been provided in the customization file store // the default should be whatever the XML specifies .setDefault(preferenceKey, activity.isDefaultEnabled()); } } catch (NotDefinedException e) { // can't happen - we're iterating over defined activities } if (store.getBoolean(preferenceKey)) { enabledActivities.add(activityId); } else { enabledActivities.remove(activityId); } } support.setEnabledActivityIds(enabledActivities); }
From source file:org.eclipse.ui.internal.dialogs.GlobalizationPreferencePage.java
License:Open Source License
/** * The default button has been pressed./*from w w w.j a v a2 s . co m*/ */ @Override protected void performDefaults() { IPreferenceStore store = getPreferenceStore(); nlExtensionsField.setStringValue(store.getDefaultString(IPreferenceConstants.NL_EXTENSIONS)); layoutDirection = store.getDefaultInt(IPreferenceConstants.LAYOUT_DIRECTION); bidiSupport = store.getDefaultBoolean(IPreferenceConstants.BIDI_SUPPORT); textDirection = store.getDefaultString(IPreferenceConstants.TEXT_DIRECTION); layoutDirectionCombo.select(getLayoutDirectionIndex(layoutDirection)); bidiSupportClickButton.setSelection(bidiSupport); textDirectionCombo.select(getTextDirectionIndex(textDirection)); textDirectionCombo.setEnabled(bidiSupport); super.performDefaults(); }
From source file:org.eclipse.ui.internal.keys.BindingPersistence.java
License:Open Source License
/** * Returns the default scheme identifier for the currently running * application.//from www. ja v a 2s.c o m * * @return The default scheme identifier (<code>String</code>); never * <code>null</code>, but may be empty or point to an undefined * scheme. */ public static final String getDefaultSchemeId() { final IPreferenceStore store = PlatformUI.getPreferenceStore(); return store.getDefaultString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); }
From source file:org.eclipse.ui.internal.keys.BindingPersistence.java
License:Open Source License
/** * <p>/*www. j a va2s.co m*/ * Reads the registry and the preference store, and determines the * identifier for the scheme that should be active. There is a complicated * order of priorities for this. The registry will only be read if there is * no user preference, and the default active scheme id is different than * the default default active scheme id. * </p> * <ol> * <li>A non-default preference.</li> * <li>The legacy preference XML memento.</li> * <li>A default preference value that is different than the default * default active scheme id.</li> * <li>The registry.</li> * <li>The default default active scheme id.</li> * </ol> * * @param configurationElements * The configuration elements from the commands extension point; * must not be <code>null</code>. * @param configurationElementCount * The number of configuration elements that are really in the * array. * @param preferences * The memento wrapping the commands preference key; may be * <code>null</code>. * @param bindingManager * The binding manager that should be updated with the active * scheme. This binding manager must already have its schemes * defined. This value must not be <code>null</code>. */ private static final void readActiveScheme(final IConfigurationElement[] configurationElements, final int configurationElementCount, final IMemento preferences, final BindingManager bindingManager) { // A non-default preference. final IPreferenceStore store = PlatformUI.getPreferenceStore(); final String defaultActiveSchemeId = store .getDefaultString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); final String preferenceActiveSchemeId = store.getString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); if ((preferenceActiveSchemeId != null) && (!preferenceActiveSchemeId.equals(defaultActiveSchemeId))) { try { bindingManager.setActiveScheme(bindingManager.getScheme(preferenceActiveSchemeId)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } // A legacy preference XML memento. if (preferences != null) { final IMemento[] preferenceMementos = preferences.getChildren(TAG_ACTIVE_KEY_CONFIGURATION); int preferenceMementoCount = preferenceMementos.length; for (int i = preferenceMementoCount - 1; i >= 0; i--) { final IMemento memento = preferenceMementos[i]; String id = memento.getString(ATT_KEY_CONFIGURATION_ID); if (id != null) { try { bindingManager.setActiveScheme(bindingManager.getScheme(id)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } } } // A default preference value that is different than the default. if ((defaultActiveSchemeId != null && defaultActiveSchemeId.length() > 0) && (!defaultActiveSchemeId.equals(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID))) { try { bindingManager.setActiveScheme(bindingManager.getScheme(defaultActiveSchemeId)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } // The registry. for (int i = configurationElementCount - 1; i >= 0; i--) { final IConfigurationElement configurationElement = configurationElements[i]; String id = configurationElement.getAttribute(ATT_KEY_CONFIGURATION_ID); if (id != null) { try { bindingManager.setActiveScheme(bindingManager.getScheme(id)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } id = configurationElement.getAttribute(ATT_VALUE); if (id != null) { try { bindingManager.setActiveScheme(bindingManager.getScheme(id)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } } // The default default active scheme id. try { bindingManager .setActiveScheme(bindingManager.getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID)); } catch (final NotDefinedException e) { //this is bad - the default default scheme should always exist throw new Error("The default default active scheme id is not defined."); //$NON-NLS-1$ } }
From source file:org.eclipse.ui.internal.keys.BindingPersistence.java
License:Open Source License
/** * Writes the active scheme to its own preference key. This key is used by * RCP applications as part of their plug-in customization. * //from w w w. j a v a2s.c o m * @param scheme * The scheme to write to the preference store. If the scheme is * <code>null</code>, then it is removed. */ private static final void writeActiveScheme(final Scheme scheme) { final IPreferenceStore store = PlatformUI.getPreferenceStore(); final String schemeId = (scheme == null) ? null : scheme.getId(); final String defaultSchemeId = store.getDefaultString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); if ((defaultSchemeId == null) ? (scheme != null) : (!defaultSchemeId.equals(schemeId))) { store.setValue(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID, scheme.getId()); } else { store.setToDefault(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); } }
From source file:org.eclipse.ui.internal.keys.BindingPersistence.java
License:Open Source License
/** * Writes the active scheme to the memento. If the scheme is * <code>null</code>, then all schemes in the memento are removed. * //from w w w . ja va 2 s. co m * @param memento * The memento to which the scheme should be written; must not be * <code>null</code>. * @param scheme * The scheme that should be written; must not be * <code>null</code>. */ private static final void writeActiveSchemeToPreferences(final IMemento memento, final Scheme scheme) { // Add this active scheme, if it is not the default. final IPreferenceStore store = PlatformUI.getPreferenceStore(); final String schemeId = scheme.getId(); final String defaultSchemeId = store.getDefaultString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); if ((defaultSchemeId == null) ? (schemeId != null) : (!defaultSchemeId.equals(schemeId))) { final IMemento child = memento.createChild(TAG_ACTIVE_KEY_CONFIGURATION); child.putString(ATT_KEY_CONFIGURATION_ID, schemeId); } }
From source file:org.eclipse.ui.internal.PerspectiveSwitcher.java
License:Open Source License
private void addDockOnSubMenu(Menu menu) { MenuItem item = new MenuItem(menu, SWT.CASCADE); item.setText(WorkbenchMessages.PerspectiveSwitcher_dockOn); final Menu subMenu = new Menu(item); final MenuItem menuItemTopRight = new MenuItem(subMenu, SWT.RADIO); menuItemTopRight.setText(WorkbenchMessages.PerspectiveSwitcher_topRight); window.getWorkbench().getHelpSystem().setHelp(menuItemTopRight, IWorkbenchHelpContextIds.DOCK_ON_PERSPECTIVE_ACTION); final MenuItem menuItemTopLeft = new MenuItem(subMenu, SWT.RADIO); menuItemTopLeft.setText(WorkbenchMessages.PerspectiveSwitcher_topLeft); window.getWorkbench().getHelpSystem().setHelp(menuItemTopLeft, IWorkbenchHelpContextIds.DOCK_ON_PERSPECTIVE_ACTION); final MenuItem menuItemLeft = new MenuItem(subMenu, SWT.RADIO); menuItemLeft.setText(WorkbenchMessages.PerspectiveSwitcher_left); window.getWorkbench().getHelpSystem().setHelp(menuItemLeft, IWorkbenchHelpContextIds.DOCK_ON_PERSPECTIVE_ACTION); SelectionListener listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MenuItem item = (MenuItem) e.widget; String pref = null;/*from ww w .ja va 2s . co m*/ if (item.equals(menuItemLeft)) { updateLocationItems(subMenu, LEFT); pref = IWorkbenchPreferenceConstants.LEFT; } else if (item.equals(menuItemTopLeft)) { updateLocationItems(subMenu, TOP_LEFT); pref = IWorkbenchPreferenceConstants.TOP_LEFT; } else { updateLocationItems(subMenu, TOP_RIGHT); pref = IWorkbenchPreferenceConstants.TOP_RIGHT; } IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore(); if (!pref.equals(apiStore.getDefaultString(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR))) { PrefUtil.getInternalPreferenceStore().setValue(IPreferenceConstants.OVERRIDE_PRESENTATION, true); } apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, pref); } }; menuItemTopRight.addSelectionListener(listener); menuItemTopLeft.addSelectionListener(listener); menuItemLeft.addSelectionListener(listener); item.setMenu(subMenu); updateLocationItems(subMenu, currentLocation); }
From source file:org.eclipse.ui.texteditor.ChainedPreferenceStore.java
License:Open Source License
public String getDefaultString(String name) { IPreferenceStore visibleStore = getVisibleStore(name); if (visibleStore != null) return visibleStore.getDefaultString(name); return STRING_DEFAULT_DEFAULT; }