List of usage examples for org.eclipse.jface.preference IPreferenceStore setValue
void setValue(String name, boolean value);
From source file:com.android.ide.eclipse.adt.internal.sdk.Sdk.java
License:Open Source License
/** * Tries to fix all currently open Android legacy editors. * <p/>// w w w . ja v a 2s .co m * If an editor is found to match one of the legacy ids, we'll try to close it. * If that succeeds, we try to reopen it using the new common editor ID. * <p/> * This method must be run from the UI thread. */ private void fixOpenLegacyEditors() { AdtPlugin adt = AdtPlugin.getDefault(); if (adt == null) { return; } final IPreferenceStore store = adt.getPreferenceStore(); int currentValue = store.getInt(AdtPrefs.PREFS_FIX_LEGACY_EDITORS); // The target version we're comparing to. This must be incremented each time // we change the processing here so that a new version of the plugin would // try to fix existing editors. final int targetValue = 1; if (currentValue >= targetValue) { return; } // To be able to close and open editors we need to make sure this is done // in the UI thread, which this isn't invoked from. PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { HashSet<String> legacyIds = new HashSet<String>(Arrays.asList(CommonXmlEditor.LEGACY_EDITOR_IDS)); for (IWorkbenchWindow win : PlatformUI.getWorkbench().getWorkbenchWindows()) { for (IWorkbenchPage page : win.getPages()) { for (IEditorReference ref : page.getEditorReferences()) { try { IEditorInput input = ref.getEditorInput(); if (input instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) input).getFile(); IEditorPart part = ref.getEditor(true /*restore*/); if (part != null) { IWorkbenchPartSite site = part.getSite(); if (site != null) { String id = site.getId(); if (legacyIds.contains(id)) { // This editor matches one of legacy editor IDs. fixEditor(page, part, input, file, id); } } } } } catch (Exception e) { // ignore } } } } // Remember that we managed to do fix all editors store.setValue(AdtPrefs.PREFS_FIX_LEGACY_EDITORS, targetValue); } private void fixEditor(IWorkbenchPage page, IEditorPart part, IEditorInput input, IFile file, String id) { IDE.setDefaultEditor(file, CommonXmlEditor.ID); boolean ok = page.closeEditor(part, true /*save*/); AdtPlugin.log(IStatus.INFO, "Closed legacy editor ID %s for %s: %s", //$NON-NLS-1$ id, file.getFullPath(), ok ? "Success" : "Failed");//$NON-NLS-1$ //$NON-NLS-2$ if (ok) { // Try to reopen it with the new ID try { page.openEditor(input, CommonXmlEditor.ID); } catch (PartInitException e) { AdtPlugin.log(e, "Failed to reopen %s", //$NON-NLS-1$ file.getFullPath()); } } } }); }
From source file:com.android.ide.eclipse.adt.internal.ui.ResourceExplorerView.java
License:Open Source License
/** * Create a TreeColumn with the specified parameters. If a * <code>PreferenceStore</code> object and a preference entry name String * object are provided then the column will listen to change in its width * and update the preference store accordingly. * * @param parent The Table parent object * @param header The header string//from w w w . j a v a 2 s. co m * @param style The column style * @param sample_text A sample text to figure out column width if preference * value is missing * @param fixedSize a fixed size. If != -1 the column is non resizable * @param pref_name The preference entry name for column width * @param prefs The preference store */ public void createTreeColumn(Tree parent, String header, int style, String sample_text, int fixedSize, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); if (fixedSize != -1) { col.setWidth(fixedSize); col.setResizable(false); } else { // if there is no pref store or the entry is missing, we use the sample // text and pack the column. // Otherwise we just read the width from the prefs and apply it. if (prefs == null || prefs.contains(pref_name) == false) { col.setText(sample_text); col.pack(); // init the prefs store with the current value if (prefs != null) { prefs.setValue(pref_name, col.getWidth()); } } else { col.setWidth(prefs.getInt(pref_name)); } // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put the new width value into the store. if (prefs != null && pref_name != null) { col.addControlListener(new ControlListener() { @Override public void controlMoved(ControlEvent e) { } @Override public void controlResized(ControlEvent e) { // get the new width int w = ((TreeColumn) e.widget).getWidth(); // store in pref store prefs.setValue(pref_name, w); } }); } } // set the header col.setText(header); }
From source file:com.android.ide.eclipse.editors.resources.explorer.ResourceExplorerView.java
License:Open Source License
/** * Create a TreeColumn with the specified parameters. If a * <code>PreferenceStore</code> object and a preference entry name String * object are provided then the column will listen to change in its width * and update the preference store accordingly. * * @param parent The Table parent object * @param header The header string/* ww w . j av a 2 s . c o m*/ * @param style The column style * @param sample_text A sample text to figure out column width if preference * value is missing * @param fixedSize a fixed size. If != -1 the column is non resizable * @param pref_name The preference entry name for column width * @param prefs The preference store */ public void createTreeColumn(Tree parent, String header, int style, String sample_text, int fixedSize, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); if (fixedSize != -1) { col.setWidth(fixedSize); col.setResizable(false); } else { // if there is no pref store or the entry is missing, we use the sample // text and pack the column. // Otherwise we just read the width from the prefs and apply it. if (prefs == null || prefs.contains(pref_name) == false) { col.setText(sample_text); col.pack(); // init the prefs store with the current value if (prefs != null) { prefs.setValue(pref_name, col.getWidth()); } } else { col.setWidth(prefs.getInt(pref_name)); } // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put the new width value into the store. if (prefs != null && pref_name != null) { col.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { } public void controlResized(ControlEvent e) { // get the new width int w = ((TreeColumn) e.widget).getWidth(); // store in pref store prefs.setValue(pref_name, w); } }); } } // set the header col.setText(header); }
From source file:com.android.ide.eclipse.monitor.ddms.DebugPortProvider.java
License:Apache License
/** * Sets new [device, app, port] values./*w w w . ja va 2 s .co m*/ * The values are also sync'ed in the preference store. * @param map The map containing the new values. */ public void setPortList(Map<String, Map<String, Integer>> map) { // update the member map. mMap.clear(); mMap.putAll(map); // create the value to store in the preference store. // see format definition in getPortList StringBuilder sb = new StringBuilder(); Set<String> deviceKeys = map.keySet(); for (String deviceKey : deviceKeys) { Map<String, Integer> deviceMap = map.get(deviceKey); if (deviceMap != null) { Set<String> appKeys = deviceMap.keySet(); for (String appKey : appKeys) { Integer port = deviceMap.get(appKey); if (port != null) { sb.append(appKey).append(':').append(port.intValue()).append(':').append(deviceKey) .append('|'); } } } } String value = sb.toString(); // get the prefs store. IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore(); // and give it the new value. store.setValue(PREFS_STATIC_PORT_LIST, value); }
From source file:com.anirudh.emacseclipse.GnuClientPreferencePage.java
License:Open Source License
/** * Method declared on IPreferencePage. Save the * author name to the preference store./* w ww .j a va 2s. c o m*/ */ public boolean performOk() { IPreferenceStore store = getPreferenceStore(); store.setValue(Activator.GNUCLIENT_PREFERENCE, gnuClientText.getText()); store.setValue(Activator.SEXPR_PREFERENCE, clientArgsText.getText()); store.setValue(Activator.POSTLISP_PREFERENCE, elispText.getText()); return super.performOk(); }
From source file:com.apicloud.navigator.composite.ThemeUIComposite.java
License:Open Source License
private void setFont(String fontId, FontData[] data) { String fdString = PreferenceConverter.getStoredRepresentation(data); Font existing = JFaceResources.getFont(fontId); String existingString = ""; if (!(existing.isDisposed())) { existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData()); }//from ww w . j a v a 2s .co m if (existingString.equals(fdString)) { return; } JFaceResources.getFontRegistry().put(fontId, data); ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId); IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); store.setValue(key, fdString); }
From source file:com.appnativa.studio.preferences.MainPreferencePage.java
License:Open Source License
public static void savePreferences(String appNativa, String android) { IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); ps.setValue(PreferenceConstants.ANDROID_PATH, android); ps.setValue(PreferenceConstants.APPNATIVA_PATH, appNativa); updateSDKPathVariable();/*w w w . jav a2 s .c o m*/ }
From source file:com.aptana.editor.common.contentassist.UserAgentManagerTests.java
License:Open Source License
@Test public void testPreferenceMigration() { // set preference to older format IPreferenceStore prefs = UIEplPlugin.getDefault().getPreferenceStore(); prefs.setValue(IPreferenceConstants.USER_AGENT_PREFERENCE, "IE,Safari"); // force reload of preference key manager.loadPreference();//from ww w . j a v a 2 s . c om // now check that all natures are set to the list we specified above for (String natureID : ResourceUtil.getAptanaNaturesMap().values()) { // @formatter:off assertIDs(natureID, "IE", "Safari"); // @formatter:on } }
From source file:com.aptana.editor.findbar.impl.FindBarConfiguration.java
License:Open Source License
/** * Updates the settings in the preference store used by the find bar with the settings in the Eclipse find actions. *//*from w w w. j a va 2 s . c o m*/ public void updateFromEclipseFindSettings() { IPreferenceStore preferenceStore = getPreferenceStore(); preferenceStore.setValue(IPreferencesConstants.CASE_SENSITIVE_IN_FIND_BAR, eclipseFindSettings.fCase); preferenceStore.setValue(IPreferencesConstants.REGULAR_EXPRESSION_IN_FIND_BAR, eclipseFindSettings.fRegExSearch); preferenceStore.setValue(IPreferencesConstants.WHOLE_WORD_IN_FIND_BAR, eclipseFindSettings.fWholeWord); }
From source file:com.aptana.editor.findbar.impl.FindBarConfiguration.java
License:Open Source License
/** * Toggles the setting for the given preferences key. *//*from ww w . j a va 2 s .com*/ public void toggle(String preferencesKey) { IPreferenceStore preferenceStore = getPreferenceStore(); boolean b = !preferenceStore.getBoolean(preferencesKey); if (preferencesKey.equals(IPreferencesConstants.REGULAR_EXPRESSION_IN_FIND_BAR)) { setRegularExpression(b); } else if (preferencesKey.equals(IPreferencesConstants.WHOLE_WORD_IN_FIND_BAR)) { setWholeWord(b); } else if (preferencesKey.equals(IPreferencesConstants.CASE_SENSITIVE_IN_FIND_BAR)) { setCaseSensitive(b); } else { preferenceStore.setValue(preferencesKey, b); } }