List of usage examples for org.eclipse.jface.preference IPreferenceStore contains
boolean contains(String name);
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.editor.ruler.CommentAnnotationRulerColumn.java
License:Open Source License
public static RGB getColorFromAnnotationPreference(IPreferenceStore store, AnnotationPreference pref) { String key = pref.getColorPreferenceKey(); RGB rgb = null;/*from w w w.j av a 2s . c om*/ if (store.contains(key)) { if (store.isDefault(key)) { rgb = pref.getColorPreferenceValue(); } else { rgb = PreferenceConverter.getColor(store, key); } } if (rgb == null) { rgb = pref.getColorPreferenceValue(); } return rgb; }
From source file:com.axmor.eclipse.typescript.core.TypeScriptEditorSettings.java
License:Open Source License
/** * Loads settings from preferences.// w w w . j av a 2s . c o m * * @return settings */ public static TypeScriptEditorSettings load() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); TypeScriptEditorSettings settings = new TypeScriptEditorSettings(); if (store.contains("indentSize")) { settings.setIndentSize(store.getInt("indentSize")); } if (store.contains("tabSize")) { settings.setTabSize(store.getInt("tabSize")); } if (store.contains("newLineChar")) { settings.setNewLineCharacter(store.getString("newLineChar")); } if (store.contains("convertTabs")) { settings.setConvertTabsToSpaces(store.getBoolean("convertTabs")); } if (store.contains("autoFormatOnSave")) { settings.setAutoFormatOnSave(store.getBoolean("autoFormatOnSave")); } if (store.contains("insertSpaceComma")) { settings.setInsertSpaceAfterCommaDelimiter(store.getBoolean("insertSpaceComma")); } if (store.contains("insertSpaceSemicolon")) { settings.setInsertSpaceAfterSemicolon(store.getBoolean("insertSpaceSemicolon")); } if (store.contains("insertSpaceBinary")) { settings.setInsertSpaceBinaryOperators(store.getBoolean("insertSpaceBinary")); } if (store.contains("insertSpaceKeywords")) { settings.setInsertSpaceAfterKeywords(store.getBoolean("insertSpaceKeywords")); } if (store.contains("insertSpaceFunction")) { settings.setInsertSpaceAfterFunction(store.getBoolean("insertSpaceFunction")); } if (store.contains("insertSpaceParenthesis")) { settings.setInsertSpaceAfterNonemptyParenthesis(store.getBoolean("insertSpaceParenthesis")); } if (store.contains("placeBraceFunctions")) { settings.setPlaceOpenBraceFunctions(store.getBoolean("placeBraceFunctions")); } if (store.contains("placeBraceBlocks")) { settings.setPlaceOpenBraceControlBlocks(store.getBoolean("placeBraceBlocks")); } if (store.contains("insertCloseBrackets")) { settings.setInsertCloseBrackets(store.getBoolean("insertCloseBrackets")); } if (store.contains("insertSemicolons")) { settings.setInsertSemicolons(store.getBoolean("insertSemicolons")); } return settings; }
From source file:com.ebmwebsourcing.petals.server.PetalsServerBehavior.java
License:Open Source License
/** * Adds the server libraries in the launch class path. * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate * #setupLaunchConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.core.runtime.IProgressMonitor) *///from w ww. j a va2 s .com @Override public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException { // Add the server libraries in the class path List<String> classpath = new ArrayList<String>(); for (Object o : workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, Collections.emptyList())) { if (o instanceof String) classpath.add((String) o); } List<File> serverLibs = getPetalsServer().getPetalsServerLibraries(); for (File serverLib : serverLibs) { Path path = new Path(serverLib.getAbsolutePath()); IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(path); entry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES); classpath.add(entry.getMemento()); } // Update and force the use of this class path in the launch configuration workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath); workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false); // Get the server arguments String args = null; final IPreferenceStore store = PetalsServerPlugin.getDefault().getPreferenceStore(); if (store.contains(PetalsServerPreferencePage.START_IN_CONSOLE_MODE)) { String startMode = store.getString(PetalsServerPreferencePage.START_IN_CONSOLE_MODE); if (MessageDialogWithToggle.ALWAYS.equals(startMode)) args = "start -console"; else if (MessageDialogWithToggle.NEVER.equals(startMode)) args = "start"; } if (args == null) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { MessageDialogWithToggle.openYesNoQuestion(new Shell(), "Start Mode", "Do you want to start in console mode?", "Do not ask again", false, store, PetalsServerPreferencePage.START_IN_CONSOLE_MODE); }; }); String startMode = store.getString(PetalsServerPreferencePage.START_IN_CONSOLE_MODE); if (MessageDialogWithToggle.ALWAYS.equals(startMode)) args = "start -console"; else args = "start"; } workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args); }
From source file:com.elphel.vdt.core.options.OptionsUtils.java
License:Open Source License
public static void removeOption(final String key, final String contextID, IPreferenceStore store) { final String contentKey = getContentKey(contextID); if (contentKey.equals(key) || !store.contains(contentKey)) { return;//w w w . j av a 2 s . c o m } List<String> context = getStoreContext(contextID, store); ValueBasedListOption option = new ValueBasedListOption(contentKey, contextID, context); option.setPreferenceStore(store); context = option.doLoadList(); if (hasKey(key, context)) { context.remove(key); if (context.isEmpty()) { option.doClear(); store.setToDefault(contentKey); } else { option.doStore(context); } } }
From source file:com.elphel.vdt.core.options.OptionsUtils.java
License:Open Source License
public static void setStoreVersion(final String version, final String contextID, IPreferenceStore store) { final String contentKey = getContentKey(contextID); final String versionKey = getVersionKey(contextID); if ((version != null) && store.contains(contentKey)) store.setValue(versionKey, version); else//from w w w . java 2 s. c o m store.setToDefault(versionKey); }
From source file:com.elphel.vdt.core.options.OptionsUtils.java
License:Open Source License
public static boolean isVersionCompatible(final String version, final String contextID, IPreferenceStore store) { boolean compatible; final String versionKey = getVersionKey(contextID); if (version == null) { compatible = !store.contains(versionKey); } else if (store.contains(versionKey)) { compatible = version.equals(store.getString(versionKey)); } else {//from w w w . j av a 2s. c o m compatible = !store.contains(versionKey); } return compatible; }
From source file:com.github.picologger.eclipse.syslogcat.views.TableHelper.java
License:Apache License
/** * Create a TableColumn 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/*w w w .ja v a2 s . com*/ * @param style The column style * @param sample_text A sample text to figure out column width if preference * value is missing * @param pref_name The preference entry name for column width * @param prefs The preference store * @return The TableColumn object that was created */ public static TableColumn createTableColumn(Table parent, String header, int style, String sample_text, final String pref_name, final IPreferenceStore prefs) { // create the column TableColumn col = new TableColumn(parent, style); // 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)); } // set the header col.setText(header); // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put store the new width value. 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 = ((TableColumn) e.widget).getWidth(); // store in pref store prefs.setValue(pref_name, w); } }); } return col; }
From source file:com.github.picologger.eclipse.syslogcat.views.TableHelper.java
License:Apache 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 ww w . ja v a2s. 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 pref_name The preference entry name for column width * @param prefs The preference store */ public static void createTreeColumn(Tree parent, String header, int style, String sample_text, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); // 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)); } // set the header col.setText(header); // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put store the new width value. 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); } }); } }
From source file:com.github.picologger.eclipse.syslogcat.views.TableHelper.java
License:Apache 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// w ww . j av a2 s. c o m * @param style The column style * @param width the width of the column if the preference value is missing * @param pref_name The preference entry name for column width * @param prefs The preference store */ public static void createTreeColumn(Tree parent, String header, int style, int width, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); // 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.setWidth(width); // init the prefs store with the current value if (prefs != null) { prefs.setValue(pref_name, width); } } else { col.setWidth(prefs.getInt(pref_name)); } // set the header col.setText(header); // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put store the new width value. 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); } }); } }
From source file:com.google.dart.tools.ui.internal.text.editor.DartSourceViewer.java
License:Open Source License
/** * Creates a color from the information stored in the given preference store. Returns * <code>null</code> if there is no such information available. * /* w ww. ja va 2 s. c o m*/ * @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 */ 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; }