List of usage examples for org.eclipse.jface.preference IPreferenceStore setToDefault
void setToDefault(String name);
From source file:ccw.preferences.OverlayPreferenceStore.java
License:Open Source License
private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { if (orgin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) target.setToDefault(key.fKey); return;/*from w ww .j a va 2s .c o m*/ } TypeDescriptor d = key.fDescriptor; if (BOOLEAN == d) { boolean originValue = orgin.getBoolean(key.fKey); boolean targetValue = target.getBoolean(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (DOUBLE == d) { double originValue = orgin.getDouble(key.fKey); double targetValue = target.getDouble(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (FLOAT == d) { float originValue = orgin.getFloat(key.fKey); float targetValue = target.getFloat(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (INT == d) { int originValue = orgin.getInt(key.fKey); int targetValue = target.getInt(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (LONG == d) { long originValue = orgin.getLong(key.fKey); long targetValue = target.getLong(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (STRING == d) { String originValue = orgin.getString(key.fKey); String targetValue = target.getString(key.fKey); if (targetValue != null && originValue != null && !targetValue.equals(originValue)) target.setValue(key.fKey, originValue); } }
From source file:com.android.ide.eclipse.adt.internal.lint.GlobalLintConfiguration.java
License:Open Source License
/** * Sets the custom severities for the given issues, in bulk. * * @param severities a map from detector to severity to use from now on * @return true if something changed from the current settings *///from ww w . j a v a2 s . c o m private boolean setSeverities(Map<Issue, Severity> severities) { mSeverities = severities; String value = ""; if (severities.size() > 0) { List<Issue> sortedKeys = new ArrayList<Issue>(severities.keySet()); Collections.sort(sortedKeys); StringBuilder sb = new StringBuilder(severities.size() * 20); for (Issue issue : sortedKeys) { Severity severity = severities.get(issue); if (severity != issue.getDefaultSeverity()) { if (sb.length() > 0) { sb.append(','); } sb.append(issue.getId()); sb.append('='); sb.append(severity.name()); } } value = sb.toString(); } IPreferenceStore store = getStore(); String previous = store.getString(AdtPrefs.PREFS_LINT_SEVERITIES); boolean changed = !value.equals(previous); if (changed) { if (value.length() == 0) { store.setToDefault(AdtPrefs.PREFS_LINT_SEVERITIES); } else { store.setValue(AdtPrefs.PREFS_LINT_SEVERITIES, value); } } return changed; }
From source file:com.android.ide.eclipse.adt.internal.lint.LintEclipseContext.java
License:Open Source License
/** * Sets the custom severity for the given detector to the given new severity * * @param severities a map from detector to severity to use from now on *//* w w w.j a va 2 s .co m*/ public void setSeverities(Map<Issue, Severity> severities) { mSeverities = null; IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); if (severities.size() == 0) { store.setToDefault(AdtPrefs.PREFS_LINT_SEVERITIES); return; } List<Issue> sortedKeys = new ArrayList<Issue>(severities.keySet()); Collections.sort(sortedKeys); StringBuilder sb = new StringBuilder(severities.size() * 20); for (Issue issue : sortedKeys) { Severity severity = severities.get(issue); if (severity != issue.getDefaultSeverity()) { if (sb.length() > 0) { sb.append(','); } sb.append(issue.getId()); sb.append('='); sb.append(severity.name()); } } if (sb.length() > 0) { store.setValue(AdtPrefs.PREFS_LINT_SEVERITIES, sb.toString()); } else { store.setToDefault(AdtPrefs.PREFS_LINT_SEVERITIES); } }
From source file:com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.java
License:Open Source License
/** * Sets the {@link RenderPreviewMode}//from w w w.j a v a2s . com * * @param previewMode the preview mode */ public void setPreviewMode(@NonNull RenderPreviewMode previewMode) { mPreviewMode = previewMode; IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); if (previewMode != RenderPreviewMode.NONE) { store.setValue(PREFS_PREVIEWS, previewMode.name().toLowerCase(Locale.US)); } else { store.setToDefault(PREFS_PREVIEWS); } }
From source file:com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.java
License:Open Source License
/** * Sets whether auto-pick render target mode is enabled. * * @param autoPick if true, auto pick the best render target in the layout editor *///from w w w . j av a 2s . c o m public void setAutoPickRenderTarget(boolean autoPick) { mAutoPickTarget = autoPick; IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); if (autoPick) { store.setToDefault(PREFS_AUTO_PICK_TARGET); } else { store.setValue(PREFS_AUTO_PICK_TARGET, autoPick); } }
From source file:com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.java
License:Open Source License
/** * Sets whether libraries should be excluded when running lint on a project * * @param exclude if true, exclude library projects *//*from w w w . ja v a 2 s. co m*/ public void setSkipLibrariesFromLint(boolean exclude) { if (exclude != mSkipLibrariesFromLint) { mSkipLibrariesFromLint = exclude; IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); if (exclude) { store.setValue(PREFS_SKIP_LINT_LIBS, true); } else { store.setToDefault(PREFS_SKIP_LINT_LIBS); } } }
From source file:com.aptana.editor.js.folding.JSEditorFoldingTest.java
License:Open Source License
@Test public void testExecute() throws Exception { IWorkbenchPage page = UIUtils.getActivePage(); String contents = "/*comment\ncomment*/\nfunction myfunc(){\nvar a = 10\n};"; editor = (JSSourceEditor) page.openEditor(new FileStoreEditorInput(getFileStore(contents)), "com.aptana.editor.js"); JSSourceViewerConfiguration jsSourceViewerConfiguration = editor.getJSSourceViewerConfiguration(); CommonReconciler reconciler = (CommonReconciler) jsSourceViewerConfiguration .getReconciler(editor.getISourceViewer()); // Get the default strategy (i.e.: no match means default will be returned). CompositeReconcilingStrategy strategy = (CompositeReconcilingStrategy) reconciler .getReconcilingStrategy("default_strategy"); // Accessing private field with the strategies in unit-test. Field field = CompositeReconcilingStrategy.class.getDeclaredField("fStrategies"); field.setAccessible(true);/* w w w. ja va 2 s. com*/ IReconcilingStrategy[] fStrategies = (IReconcilingStrategy[]) field.get(strategy); CommonReconcilingStrategy commonStrategy = null; for (IReconcilingStrategy iReconcilingStrategy : fStrategies) { if (iReconcilingStrategy instanceof CommonReconcilingStrategy) { commonStrategy = (CommonReconcilingStrategy) iReconcilingStrategy; break; } } try { // Reconcile and check if we have 2 entries (for comments and for the function). commonStrategy.setDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput())); commonStrategy.fullReconcile(); Map<ProjectionAnnotation, Position> positions = commonStrategy.getPositions(); setFoldingEnabled(true); assertTrue(editor.isFoldingEnabled()); assertEquals(2, positions.size()); Collection<Position> values = positions.values(); checkFound(values, 0, 20); checkFound(values, 20, 32); assertComments(editor.getAST(), true); setFoldingEnabled(false); // Clear the ast cache (as we may match a version with comments when asking for a version // without comments). ParserPoolFactory instance = ParserPoolFactory.getInstance(); field = instance.getClass().getDeclaredField("fParsingEngine"); field.setAccessible(true); ParsingEngine engine = (ParsingEngine) field.get(instance); engine.clearCache(); commonStrategy.setDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput())); commonStrategy.fullReconcile(); positions = commonStrategy.getPositions(); assertEquals(0, positions.size()); assertComments(editor.getAST(), true); } finally { // Set default value again. IPreferenceStore preferenceStore = JSPlugin.getDefault().getPreferenceStore(); preferenceStore.setToDefault(IPreferenceConstants.EDITOR_ENABLE_FOLDING); } }
From source file:com.aptana.ide.editors.preferences.PreferenceInitializer.java
License:Open Source License
/** * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() *///from w w w . jav a 2s .co m public void initializeDefaultPreferences() { IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); store.setDefault(com.aptana.ide.core.preferences.IPreferenceConstants.SHOW_LIVE_HELP, true); store.setDefault(IPreferenceConstants.CACHE_BUST_BROWSERS, true); store.setDefault(IPreferenceConstants.PIANO_KEY_DIFFERENCE, 7); store.setDefault(IPreferenceConstants.MATCH_BRACKETS, "true"); //$NON-NLS-1$ store.setDefault(IPreferenceConstants.MATCH_BRACKETS_COLOR, StringConverter.asString(new RGB(150, 150, 150))); store.setDefault(IPreferenceConstants.SHOW_WHITESPACE, false); store.setDefault(IPreferenceConstants.ENABLE_WORD_WRAP, false); store.setDefault(IPreferenceConstants.USER_AGENT_PREFERENCE, "IE,Mozilla"); //$NON-NLS-1$ store.setDefault(IPreferenceConstants.INSERT_ON_TAB, false); store.setDefault(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END, false); store.setDefault(IPreferenceConstants.CONTENT_ASSIST_DELAY, 200); store.setDefault(IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_ENABLED, false); store.setDefault(IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_BACKGROUND_COLOR, StringConverter.asString(new RGB(212, 212, 212))); store.setDefault(IPreferenceConstants.COLORIZER_MAXCOLUMNS, 500); store.setDefault(IPreferenceConstants.EXPAND_EDITOR_OPTIONS, true); store.setDefault(IPreferenceConstants.EXPAND_TOKENS, true); store.setDefault(IPreferenceConstants.EXPAND_REGIONS, false); store.setDefault(IPreferenceConstants.SHOW_ERRORS, true); store.setDefault(IPreferenceConstants.SHOW_WARNINGS, false); store.setDefault(IPreferenceConstants.SHOW_INFOS, false); store.setDefault(IPreferenceConstants.DRAG_AND_DROP_ENABLED, true); store.setDefault(IPreferenceConstants.SORT_OUTLINE_ALPHABETICALLY, false); store.setDefault(IPreferenceConstants.PARSER_OFF_UI, true); // Tasks store.setDefault(IPreferenceConstants.COMPILER_TASK_CASE_SENSITIVE, true); store.setDefault(IPreferenceConstants.COMPILER_TASK_TAGS, "TODO,FIXME,XXX,OPTIMIZE"); store.setDefault(IPreferenceConstants.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,NORMAL,LOW"); // These two _must_ be set as a preference, or UnifiedEditor will crash // hard without // warning on initialization. // store.setDefault(ColorizerPreferencePage.HRD_SET, "default"); // store.setDefault(ColorizerPreferencePage.USE_BACK, true); // // store.setDefault(ColorizerPreferencePage.FULL_BACK, true); // store.setDefault(ColorizerPreferencePage.PAIRS_MATCH, // "PAIRS_OUTLINE"); // // store.setDefault(ColorizerPreferencePage.HORZ_CROSS, true); // store.setDefault(ColorizerPreferencePage.VERT_CROSS, true); // To set preferences for AbstractTextEditor CoreUIUtils.getDisplay().asyncExec(new Runnable() { public void run() { IPreferenceStore store = org.eclipse.ui.internal.editors.text.EditorsPlugin.getDefault() .getPreferenceStore(); store.setToDefault(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END); store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE, 500); } }); }
From source file:com.archimatetool.editor.preferences.ColoursFontsPreferencePage.java
License:Open Source License
/** * @param store//from www . ja v a2 s .c o m * Save colors to preference store */ private void saveColors(IPreferenceStore store) { for (Entry<Object, Color> entry : fColorsCache.entrySet()) { Color colorNew = entry.getValue(); Color colorDefault; String key; // Element line color default if (entry.getKey().equals(DEFAULT_ELEMENT_LINE_COLOR)) { // Outline color - use any object eClass as there is only one colorDefault = ColorFactory .getInbuiltDefaultLineColor(IArchimatePackage.eINSTANCE.getBusinessActor()); key = DEFAULT_ELEMENT_LINE_COLOR; } // Connection line color default else if (entry.getKey().equals(DEFAULT_CONNECTION_LINE_COLOR)) { // Outline color - use any object eClass as there is only one colorDefault = ColorFactory .getInbuiltDefaultLineColor(IArchimatePackage.eINSTANCE.getAssociationRelationship()); key = DEFAULT_CONNECTION_LINE_COLOR; } // Fill color default else { colorDefault = ColorFactory.getInbuiltDefaultFillColor(entry.getKey()); key = DEFAULT_FILL_COLOR_PREFIX + getColorKey(entry.getKey()); } // If default color if (colorNew.equals(colorDefault)) { store.setToDefault(key); } // Else user color else { store.setValue(key, ColorFactory.convertColorToString(colorNew)); } } }
From source file:com.archimatetool.export.svg.SVGExportProviderTests.java
License:Open Source License
@Before public void runOnceBeforeEachTest() { provider = new SVGExportProvider(); shell = new Shell(); // Set prefs to defaults IPreferenceStore store = ExportSVGPlugin.getDefault().getPreferenceStore(); store.setToDefault(IPreferenceConstants.SVG_EXPORT_PREFS_EMBED_FONTS); store.setToDefault(IPreferenceConstants.SVG_EXPORT_PREFS_VIEWBOX_ENABLED); store.setToDefault(IPreferenceConstants.SVG_EXPORT_PREFS_VIEWBOX); rootFigure = new FreeformLayer(); rootFigure.setBounds(new Rectangle(0, 0, 500, 500)); }