List of usage examples for org.eclipse.jface.preference PreferenceStore getString
@Override
public String getString(String name)
From source file:com.android.ddms.PrefsDialog.java
License:Apache License
/** * Do some one-time prep./*from w w w. j a v a 2s . co m*/ * * The original plan was to let the individual classes define their * own defaults, which we would get and then override with the config * file. However, PreferencesStore.load() doesn't trigger the "changed" * events, which means we have to pull the loaded config values out by * hand. * * So, we set the defaults, load the values from the config file, and * then run through and manually export the values. Then we duplicate * the second part later on for the "changed" events. */ public static void init() { PreferenceStore prefStore = mStore.getPreferenceStore(); if (prefStore == null) { // we have a serious issue here... Log.e("ddms", "failed to access both the user HOME directory and the system wide temp folder. Quitting."); System.exit(1); } // configure default values setDefaults(System.getProperty("user.home")); //$NON-NLS-1$ // listen for changes prefStore.addPropertyChangeListener(new ChangeListener()); // Now we initialize the value of the preference, from the values in the store. // First the ddm lib. DdmPreferences.setDebugPortBase(prefStore.getInt(PREFS_DEBUG_PORT_BASE)); DdmPreferences.setSelectedDebugPort(prefStore.getInt(PREFS_SELECTED_DEBUG_PORT)); DdmPreferences.setLogLevel(prefStore.getString(PREFS_LOG_LEVEL)); DdmPreferences.setInitialThreadUpdate(prefStore.getBoolean(PREFS_DEFAULT_THREAD_UPDATE)); DdmPreferences.setInitialHeapUpdate(prefStore.getBoolean(PREFS_DEFAULT_HEAP_UPDATE)); DdmPreferences.setTimeOut(prefStore.getInt(PREFS_TIMEOUT)); DdmPreferences.setProfilerBufferSizeMb(prefStore.getInt(PREFS_PROFILER_BUFFER_SIZE_MB)); DdmPreferences.setUseAdbHost(prefStore.getBoolean(PREFS_USE_ADBHOST)); DdmPreferences.setAdbHostValue(prefStore.getString(PREFS_ADBHOST_VALUE)); // some static values String out = System.getenv("ANDROID_PRODUCT_OUT"); //$NON-NLS-1$ DdmUiPreferences.setSymbolsLocation(out + File.separator + "symbols"); //$NON-NLS-1$ DdmUiPreferences.setAddr2LineLocation("arm-linux-androideabi-addr2line"); //$NON-NLS-1$ DdmUiPreferences.setAddr2LineLocation64("aarch64-linux-android-addr2line"); String traceview = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$ if (traceview != null && traceview.length() != 0) { traceview += File.separator + DdmConstants.FN_TRACEVIEW; } else { traceview = DdmConstants.FN_TRACEVIEW; } DdmUiPreferences.setTraceviewLocation(traceview); // Now the ddmui lib DdmUiPreferences.setStore(prefStore); DdmUiPreferences.setThreadRefreshInterval(prefStore.getInt(PREFS_THREAD_REFRESH_INTERVAL)); }
From source file:com.android.ddms.UIThread.java
License:Apache License
private void createBottomPanel(final Composite comp) { final PreferenceStore prefs = PrefsDialog.getStore(); // create clipboard Display display = comp.getDisplay(); LogColors colors = new LogColors(); colors.infoColor = new Color(display, 0, 127, 0); colors.debugColor = new Color(display, 0, 0, 127); colors.errorColor = new Color(display, 255, 0, 0); colors.warningColor = new Color(display, 255, 127, 0); colors.verboseColor = new Color(display, 0, 0, 0); // set the preferences names LogPanel.PREFS_TIME = PREFS_COL_TIME; LogPanel.PREFS_LEVEL = PREFS_COL_LEVEL; LogPanel.PREFS_PID = PREFS_COL_PID;/* ww w. j a v a 2 s . com*/ LogPanel.PREFS_TAG = PREFS_COL_TAG; LogPanel.PREFS_MESSAGE = PREFS_COL_MESSAGE; comp.setLayout(new GridLayout(1, false)); ToolBar toolBar = new ToolBar(comp, SWT.HORIZONTAL); mCreateFilterAction = new ToolItemAction(toolBar, SWT.PUSH); mCreateFilterAction.item.setToolTipText("Create Filter"); mCreateFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay, "add.png", //$NON-NLS-1$ DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null)); mCreateFilterAction.item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mLogPanel.addFilter(); } }); mEditFilterAction = new ToolItemAction(toolBar, SWT.PUSH); mEditFilterAction.item.setToolTipText("Edit Filter"); mEditFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay, "edit.png", //$NON-NLS-1$ DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null)); mEditFilterAction.item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mLogPanel.editFilter(); } }); mDeleteFilterAction = new ToolItemAction(toolBar, SWT.PUSH); mDeleteFilterAction.item.setToolTipText("Delete Filter"); mDeleteFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay, "delete.png", //$NON-NLS-1$ DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null)); mDeleteFilterAction.item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mLogPanel.deleteFilter(); } }); new ToolItem(toolBar, SWT.SEPARATOR); LogLevel[] levels = LogLevel.values(); mLogLevelActions = new ToolItemAction[mLogLevelIcons.length]; for (int i = 0; i < mLogLevelActions.length; i++) { String name = levels[i].getStringValue(); final ToolItemAction newAction = new ToolItemAction(toolBar, SWT.CHECK); mLogLevelActions[i] = newAction; //newAction.item.setText(name); newAction.item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // disable the other actions and record current index for (int k = 0; k < mLogLevelActions.length; k++) { ToolItemAction a = mLogLevelActions[k]; if (a == newAction) { a.setChecked(true); // set the log level mLogPanel.setCurrentFilterLogLevel(k + 2); } else { a.setChecked(false); } } } }); newAction.item.setToolTipText(name); newAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay, mLogLevelIcons[i], DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null)); } new ToolItem(toolBar, SWT.SEPARATOR); mClearAction = new ToolItemAction(toolBar, SWT.PUSH); mClearAction.item.setToolTipText("Clear Log"); mClearAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay, "clear.png", //$NON-NLS-1$ DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null)); mClearAction.item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mLogPanel.clear(); } }); new ToolItem(toolBar, SWT.SEPARATOR); mExportAction = new ToolItemAction(toolBar, SWT.PUSH); mExportAction.item.setToolTipText("Export Selection As Text..."); mExportAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay, "save.png", //$NON-NLS-1$ DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null)); mExportAction.item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mLogPanel.save(); } }); toolBar.pack(); // now create the log view mLogPanel = new LogPanel(colors, new FilterStorage(), LogPanel.FILTER_MANUAL); mLogPanel.setActions(mDeleteFilterAction, mEditFilterAction, mLogLevelActions); String colMode = prefs.getString(PrefsDialog.LOGCAT_COLUMN_MODE); if (PrefsDialog.LOGCAT_COLUMN_MODE_AUTO.equals(colMode)) { mLogPanel.setColumnMode(LogPanel.COLUMN_MODE_AUTO); } String fontStr = PrefsDialog.getStore().getString(PrefsDialog.LOGCAT_FONT); if (fontStr != null) { try { FontData fdat = new FontData(fontStr); mLogPanel.setFont(new Font(display, fdat)); } catch (IllegalArgumentException e) { // Looks like fontStr isn't a valid font representation. // We do nothing in this case, the logcat view will use the default font. } catch (SWTError e2) { // Looks like the Font() constructor failed. // We do nothing in this case, the logcat view will use the default font. } } mLogPanel.createPanel(comp); // and start the logcat mLogPanel.startLogCat(mCurrentDevice); }
From source file:com.android.sdkstats.DdmsPreferenceStore.java
License:Apache License
/** * Retrieves the last SDK OS path.//from w w w . j av a 2 s . c o m * <p/> * This is just an information value, the path may not exist, may not * even be on an existing file system and/or may not point to an SDK * anymore. * * @return The last SDK OS path from the preference store, or null if * there is no store or an empty string if it is not defined. */ public String getLastSdkPath() { PreferenceStore prefs = getPreferenceStore(); synchronized (DdmsPreferenceStore.class) { return prefs == null ? null : prefs.getString(LAST_SDK_PATH); } }
From source file:com.archimatetool.editor.preferences.ColoursFontsPreferencePage.java
License:Open Source License
/** * @throws IOException//from w w w.j a va2 s . c o m * Import a User color scheme */ private void importUserColors() throws IOException { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); dialog.setText(Messages.ColoursFontsPreferencePage_4); if (!PlatformUtils.isMac()) { // Single file filtering in the Open dialog doesn't work on Mac dialog.setFilterExtensions(new String[] { "ArchiColours.prefs", "*.prefs", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ dialog.setFileName("ArchiColours.prefs"); //$NON-NLS-1$ } else { dialog.setFilterExtensions(new String[] { "*.prefs", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$ } String path = dialog.open(); if (path == null) { return; } PreferenceStore store = new PreferenceStore(path); store.load(); // Fill Colors for (Entry<Object, Color> entry : fColorsCache.entrySet()) { String key = DEFAULT_FILL_COLOR_PREFIX + getColorKey(entry.getKey()); String value = store.getString(key); if (StringUtils.isSet(value)) { setColor(entry.getKey(), ColorFactory.convertStringToRGB(value)); } } // Element Line Color String key = DEFAULT_ELEMENT_LINE_COLOR; String value = store.getString(key); if (StringUtils.isSet(value)) { setColor(key, ColorFactory.convertStringToRGB(value)); } // Connection Line Color key = DEFAULT_CONNECTION_LINE_COLOR; value = store.getString(key); if (StringUtils.isSet(value)) { setColor(key, ColorFactory.convertStringToRGB(value)); } }
From source file:com.mindquarry.desktop.preferences.pages.ProxySettingsPage.java
License:Open Source License
/** * Creates the controls for this page/* www . ja va 2 s . c om*/ */ @Override protected Control createContents(Composite parent) { PreferenceStore store = (PreferenceStore) getPreferenceStore(); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, true)); enableProxy = new Button(composite, SWT.CHECK); enableProxy.setText(I18N.get("Enable proxy support")); enableProxy.setSelection(store.getBoolean(PREF_PROXY_ENABLED)); enableProxy.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { enableProxyFields(enableProxy.getSelection()); performValidation(); } }); Group proxyGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); proxyGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); //settingsGroup.setText(Messages.get("Profile Settings")); //$NON-NLS-1$ proxyGroup.setLayout(new GridLayout(1, true)); CLabel label = new CLabel(proxyGroup, SWT.LEFT); label.setText(I18N.get("Proxy URL:")); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite errorComp = createErrorBorderComposite(proxyGroup); url = new Text(errorComp, SWT.SINGLE | SWT.BORDER); url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); registerErrorBorderComposite(errorComp, url); url.setText(store.getString(PREF_PROXY_URL)); url.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { performValidation(); } }); url.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { url.selectAll(); } }); label = new CLabel(proxyGroup, SWT.LEFT); label.setText(I18N.get("Proxy Login:")); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); login = new Text(proxyGroup, SWT.SINGLE | SWT.BORDER); login.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); login.setText(store.getString(PREF_PROXY_LOGIN)); login.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { performValidation(); } }); login.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { login.selectAll(); } }); label = new CLabel(proxyGroup, SWT.LEFT); label.setText(I18N.get("Proxy Password:")); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); pwd = new Text(proxyGroup, SWT.PASSWORD | SWT.BORDER); pwd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); pwd.setText(store.getString(PREF_PROXY_PASSWORD)); pwd.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { performValidation(); } }); pwd.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { pwd.selectAll(); } }); enableProxyFields(enableProxy.getSelection()); performValidation(); return composite; }
From source file:com.mindquarry.desktop.preferences.pages.ShortcutsPage.java
License:Open Source License
private void loadStoredShortcuts() { PreferenceStore store = (PreferenceStore) getPreferenceStore(); HashMap<Integer, Shortcut> storedProfiles = new HashMap<Integer, Shortcut>(); // load stored profiles String[] prefs = store.preferenceNames(); for (String pref : prefs) { if (pref.startsWith(SHORTCUT_KEY_BASE)) { // analyze preference int nbr = Integer .valueOf(pref.substring(SHORTCUT_KEY_BASE.length(), SHORTCUT_KEY_BASE.length() + 1)); String prefName = pref.substring(SHORTCUT_KEY_BASE.length() + 2, pref.length()); // init profile Shortcut shortcut;/*ww w .j av a 2s .co m*/ if (storedProfiles.containsKey(nbr)) { shortcut = storedProfiles.get(nbr); } else { shortcut = new Shortcut("", //$NON-NLS-1$ "", //$NON-NLS-1$ ""); //$NON-NLS-1$ storedProfiles.put(nbr, shortcut); } // set shortcut values if (prefName.equals("category")) { //$NON-NLS-1$ shortcut.setCategory(store.getString(pref)); } else if (prefName.equals("action")) { //$NON-NLS-1$ shortcut.setAction(store.getString(pref)); } else if (prefName.equals("shortcut")) { //$NON-NLS-1$ shortcut.setShortcutIdentifier(store.getString(pref)); } } } // set profile list Iterator<Integer> keyIter = storedProfiles.keySet().iterator(); while (keyIter.hasNext()) { Shortcut shortcut = storedProfiles.get(keyIter.next()); shortcuts.add(shortcut); } }
From source file:com.mindquarry.desktop.preferences.profile.Profile.java
License:Open Source License
public static List<Profile> loadProfiles(PreferenceStore store) { HashMap<Integer, Profile> storedProfiles = new HashMap<Integer, Profile>(); // load stored profiles String[] prefs = store.preferenceNames(); for (String pref : prefs) { if (pref.startsWith(PROFILE_KEY_BASE)) { String val = store.getString(pref); if (val.trim().equals(EMPTY)) { // ignore empty values as PreferenceStore cannot properly // delete entries, so we just set deleted entries to the // empty string continue; }/* w ww . ja v a 2s. com*/ // analyze preference int number = Integer .valueOf(pref.substring(PROFILE_KEY_BASE.length(), PROFILE_KEY_BASE.length() + 1)); String prefName = pref.substring(PROFILE_KEY_BASE.length() + 2, pref.length()); // initialize profile Profile profile; if (storedProfiles.containsKey(number)) { profile = storedProfiles.get(number); } else { // TODO: maybe set type here to a non-value? profile = new Profile(EMPTY, EMPTY, EMPTY, EMPTY, EMPTY); storedProfiles.put(number, profile); } setProfileAttribute(store, profile, pref, prefName); } } // set profile list List<Profile> profiles = new ArrayList<Profile>(); Iterator<Integer> keyIter = storedProfiles.keySet().iterator(); while (keyIter.hasNext()) { Profile profile = storedProfiles.get(keyIter.next()); profiles.add(profile); } return profiles; }
From source file:com.mindquarry.desktop.preferences.profile.Profile.java
License:Open Source License
public static Profile getSelectedProfile(PreferenceStore store) { Profile selected = getSelectedProfile(store, store.getString(PROFILE_SELECTED)); if (selected == null) { log.debug("No profile selected."); //$NON-NLS-1$ return null; }//from ww w.ja v a2 s .c o m return selected; }
From source file:com.mindquarry.desktop.preferences.profile.Profile.java
License:Open Source License
private static Profile getSelectedProfile(PreferenceStore store, String namePrefId) { Profile profile = null;/*w w w. j a v a2 s.c o m*/ int profileID = -1; String[] prefs = store.preferenceNames(); // try to find ID of the given for (String pref : prefs) { if (pref.startsWith(PROFILE_KEY_BASE)) { // analyze preference int id = Integer.valueOf(pref.substring(PROFILE_KEY_BASE.length(), PROFILE_KEY_BASE.length() + 1)); String prefName = pref.substring(PROFILE_KEY_BASE.length() + 2, pref.length()); if ((prefName.equals(PREF_NAME)) && (store.getString(pref).equals(namePrefId))) { profileID = id; } } } if (profileID == -1) { return profile; } for (String pref : prefs) { if (pref.startsWith(PROFILE_KEY_BASE)) { // analyze preference int id = Integer.valueOf(pref.substring(PROFILE_KEY_BASE.length(), PROFILE_KEY_BASE.length() + 1)); String prefName = pref.substring(PROFILE_KEY_BASE.length() + 2, pref.length()); // initialize profile if not done already if (profile == null) { profile = new Profile(EMPTY, EMPTY, EMPTY, EMPTY, EMPTY); } // set profile values if (id == profileID) { setProfileAttribute(store, profile, pref, prefName); } } } return profile; }
From source file:com.mindquarry.desktop.preferences.profile.Profile.java
License:Open Source License
private static void setProfileAttribute(PreferenceStore store, Profile profile, String pref, String prefName) { if (prefName.equals(PREF_NAME)) { profile.setName(store.getString(pref)); } else if (prefName.equals(PREF_TYPE)) { profile.setType(Type.valueOf(store.getString(pref))); } else if (prefName.equals(PREF_SVN_REPOS)) { profile.setSvnRepos(SVNRepoData.parseStrings(store.getString(pref).split(","))); } else if (prefName.equals(PREF_LOGIN)) { profile.setLogin(store.getString(pref)); } else if (prefName.equals(PREF_PASSWORD)) { profile.setPassword(decodeBase64(store.getString(pref))); } else if (prefName.equals(PREF_SERVER_URL)) { profile.setServerURL(store.getString(pref)); } else if (prefName.equals(PREF_WORKSPACES)) { profile.setWorkspaceFolder(store.getString(pref)); } else if (prefName.equals(PREF_SELECTED_TEAMS)) { profile.setSelectedTeams(new ArrayList<String>(Arrays.asList(store.getString(pref).split(",")))); }/* ww w. j a v a 2s . com*/ }