List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt
int getInt(String name);
From source file:com.aptana.ide.editor.js.formatting.HTMLCodeFormatterOptions.java
License:Open Source License
private void initFromPreferences() { AbstractUIPlugin abstractUIPlugin = ((AbstractUIPlugin) Platform.getPlugin("com.aptana.ide.editor.html")); //$NON-NLS-1$ if ((abstractUIPlugin != null)) { IPreferenceStore preferenceStore = abstractUIPlugin.getPreferenceStore(); formatterTabChar = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR); tabSize = preferenceStore.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE); } else {//from ww w.ja v a2 s. c om initDefaults(); } }
From source file:com.aptana.ide.editor.js.formatting.JSCodeFormatterOptions.java
License:Open Source License
private void initFromPreferences() { IPreferenceStore preferenceStore = JSPlugin.getDefault().getPreferenceStore(); insertNewLineBeforeReturn = parseInsert(preferenceStore .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_RETURN_STATEMENT)); insertNewLineBeforeIf = parseInsert(preferenceStore .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_IF_STATEMENT)); insertNewLineBeforeElse = parseInsert(preferenceStore .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT)); insertNewLineBeforeCatch = parseInsert(preferenceStore .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT)); insertNewLineBeforeFinally = parseInsert(preferenceStore.getString( DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT)); insertNewLineBeforeWhile = parseInsert(preferenceStore .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT)); keepThenSameLine = preferenceStore//from w w w . j a v a2 s. c o m .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE); keepSimpleIfOnOneLine = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE); keepElseStatementOnSameLine = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE); compactElseIf = preferenceStore.getBoolean(DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF); keepGuardianClauseOnOneLine = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE); formatterTabChar = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR); tabSize = preferenceStore.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE); indentStatementsCompareToBody = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY); indentStatementsCompareToBlock = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK); indentStatementsCompareToSwitch = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH); indentStatementsCompareToCases = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES); indentBreaksCompareToCases = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES); indentEmptyLines = preferenceStore.getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES); blankLinesBeforeMethod = preferenceStore .getInt(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD); blankLinesInStartOfMethodBody = preferenceStore .getInt(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY); preserveLineBreaks = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_EXTRA_CARRIAGE_RETURNS); formatterBracePositionForMethodDecl = parseOption(preferenceStore, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION); formatterBracePositionForBlock = parseOption(preferenceStore, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK); formatterBracePositionForBlockInCase = parseOption(preferenceStore, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE); formatterBracePositionForBlockInSwitch = parseOption(preferenceStore, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH); formatterBracePositionForArrayInitializer = parseOption(preferenceStore, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER); keepEmptyArrayInitializerOnOneLine = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE); addSpaceAfterFunctionDeclaration = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK); String string = preferenceStore.getString(DefaultCodeFormatterConstants.NO_FORMATTING); if (string.length() > 0) { doFormatting = false; } }
From source file:com.aptana.ide.editor.xml.formatting.XMLCodeFormatterOptions.java
License:Open Source License
/** * initializes options from preference store *//*from w ww .j av a 2s. co m*/ private void initFromPreferences() { IPreferenceStore preferenceStore = XMLPlugin.getDefault().getPreferenceStore(); formatterTabChar = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR); tabSize = preferenceStore.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE); spacesInMultiline = preferenceStore .getInt(DefaultCodeFormatterConstants.FORMATTER_SPACES_BEFORE_ATTRS_ON_MULTILINE); String sm = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_DO_NOT_WRAP_TAGS2); initTags(sm, notWrappingTags); sm = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_WRAP_TAGS2); initTags(sm, allwaysWrap); String string = preferenceStore.getString(DefaultCodeFormatterConstants.NO_FORMATTING); if (string.length() > 0) { doFormatting = false; } preserveReturns = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_EXTRA_CARRIAGE_RETURNS); preserveWhitespacesInCDATA = preferenceStore .getBoolean(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_WHITESPACE_IN_CDATA); doNotWrapSimple = preferenceStore.getBoolean(DefaultCodeFormatterConstants.DO_NOT_WRAP_SIMPLE_TAGS); }
From source file:com.aptana.ide.editor.yml.YMLEditor.java
License:Open Source License
/** * Force YML editor to always use spaces instead of tabs, regardless of what user preference is. * */// w w w. j a v a 2 s. co m private void setToUseSpaces() { ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer == null) { return; } IPreferenceStore store = getPreferenceStore(); if (store == null) { return; } SourceViewerConfiguration sv = getSourceViewerConfiguration(); int prefs = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); if (sv != null && sv instanceof UnifiedConfiguration) { UnifiedConfiguration uc = (UnifiedConfiguration) sv; uc.setTabWidth(prefs, true, sourceViewer); } }
From source file:com.aptana.ide.editors.preferences.GeneralPreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various * types of preferences. Each field editor knows how to save and restore itself. *///from w ww . j a va2 s . c o m public void createFieldEditors() { addTab(Messages.GeneralPreferencePage_General); Composite appearanceComposite = getFieldEditorParent(); Composite group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.GeneralPreferencePage_Formatting); Composite occurrenceComp = new Composite(group, SWT.NONE); GridLayout occLayout = new GridLayout(2, false); occLayout.marginWidth = 0; occLayout.marginHeight = 0; occurrenceComp.setLayout(occLayout); occurrenceComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); enableOccurrences = new Button(occurrenceComp, SWT.CHECK); enableOccurrences.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { occurrenceColor.setEnabled(enableOccurrences.getSelection()); } }); enableOccurrences.setSelection( getPreferenceStore().getBoolean(IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_ENABLED)); enableOccurrences.setText(Messages.GeneralPreferencePage_MarkOccurrences); occurrenceColor = new ColorSelector(occurrenceComp); occurrenceColor.setEnabled(enableOccurrences.getSelection()); occurrenceColor.setColorValue(PreferenceConverter.getColor(getPreferenceStore(), IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_BACKGROUND_COLOR)); // addField(new BooleanFieldEditor(IPreferenceConstants.ENABLE_WORD_WRAP, // Messages.GeneralPreferencePage_EnableWordWrap, group)); addField(new BooleanFieldEditor(IPreferenceConstants.INSERT_ON_TAB, Messages.GeneralPreferencePage_InsertSelectedProposal, group)); addField(new RadioGroupFieldEditor(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END, Messages.GeneralPreferencePage_HomeEndBehavior, 1, new String[][] { { Messages.GeneralPreferencePage_ToggleBetween, "true" }, //$NON-NLS-1$ { Messages.GeneralPreferencePage_JumpsStartEnd, "false" } }, //$NON-NLS-1$ appearanceComposite, true)); group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.GeneralPreferencePage_LBL_Colorization); Composite pianoKeyComp = new Composite(group, SWT.NONE); GridLayout pkcLayout = new GridLayout(3, false); pkcLayout.marginWidth = 0; pkcLayout.marginHeight = 0; pianoKeyComp.setLayout(pkcLayout); pianoKeyComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); Label pianoKeyLabel = new Label(pianoKeyComp, SWT.LEFT); pianoKeyLabel.setText(Messages.GeneralPreferencePage_LBL_PianoKeyColorDifference); GridData pklData = new GridData(SWT.FILL, SWT.FILL, true, false); pklData.horizontalSpan = 3; pianoKeyLabel.setLayoutData(pklData); Label less = new Label(pianoKeyComp, SWT.LEFT); less.setText(Messages.GeneralPreferencePage_LBL_Less); pianoKeySlider = new Scale(pianoKeyComp, SWT.HORIZONTAL); pianoKeySlider.setIncrement(5); pianoKeySlider.setMinimum(1); pianoKeySlider.setMaximum(50); pianoKeySlider.setSelection(getPreferenceStore().getInt(IPreferenceConstants.PIANO_KEY_DIFFERENCE)); Label more = new Label(pianoKeyComp, SWT.LEFT); more.setText(Messages.GeneralPreferencePage_LBL_More); Composite wsGroup = com.aptana.ide.core.ui.preferences.GeneralPreferencePage .createGroup(appearanceComposite, Messages.GeneralPreferencePage_TabInsertion); Composite wsComp = new Composite(wsGroup, SWT.NONE); GridLayout wsLayout = new GridLayout(3, false); wsLayout.marginWidth = 0; wsLayout.marginHeight = 0; wsComp.setLayout(wsLayout); wsComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); tabs = new Button(wsComp, SWT.RADIO); Composite spaceComp = new Composite(wsComp, SWT.NONE); wsLayout = new GridLayout(2, false); wsLayout.marginWidth = 0; wsLayout.marginHeight = 0; wsLayout.horizontalSpacing = 0; spaceComp.setLayout(wsLayout); spaceComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); spaces = new Button(spaceComp, SWT.RADIO); final Link currentTabSize = new Link(spaceComp, SWT.NONE); IPreferenceStore store = EditorsPlugin.getDefault().getPreferenceStore(); int size = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); spaces.setText(StringUtils.format(Messages.GeneralPreferencePage_UseSpaces, size)); tabs.setText(Messages.GeneralPreferencePage_UseTabs); store.addPropertyChangeListener(tabWidthListener); currentTabSize.setText(Messages.GeneralPreferencePage_EditLink); currentTabSize.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ((IWorkbenchPreferenceContainer) getContainer()) .openPage("org.eclipse.ui.preferencePages.GeneralTextEditor", null); //$NON-NLS-1$ } }); boolean useSpaces = getPreferenceStore().getBoolean(IPreferenceConstants.INSERT_SPACES_FOR_TABS); spaces.setSelection(useSpaces); tabs.setSelection(!useSpaces); tabs.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { spaces.setSelection(!tabs.getSelection()); } }); spaces.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { tabs.setSelection(!spaces.getSelection()); } }); // Link to general text editor prefs from Eclipse - they can set tabs/spaces/whitespace drawing, etc Link link = new Link(appearanceComposite, SWT.NONE); link.setText(Messages.GeneralPreferencePage_GeneralTextEditorPrefLink); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ((IWorkbenchPreferenceContainer) getContainer()) .openPage("org.eclipse.ui.preferencePages.GeneralTextEditor", null); //$NON-NLS-1$ } }); addTab(Messages.GeneralPreferencePage_Advanced); appearanceComposite = getFieldEditorParent(); addField(new BooleanFieldEditor(IPreferenceConstants.ENABLE_WORD_WRAP, Messages.GeneralPreferencePage_EnableWordWrap, appearanceComposite)); appearanceComposite = getFieldEditorParent(); addField(new IntegerFieldEditor(IPreferenceConstants.COLORIZER_MAXCOLUMNS, Messages.GeneralPreferencePage_MaxColorizeColumns, appearanceComposite, 4)); group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.GeneralPreferencePage_CodeAssist); addField(new IntegerFieldEditor(IPreferenceConstants.CONTENT_ASSIST_DELAY, Messages.GeneralPreferencePage_DelayBeforeShowing, group, 4)); }
From source file:com.aptana.ide.editors.unified.UnifiedConfiguration.java
License:Open Source License
/** * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getUndoManager(org.eclipse.jface.text.source.ISourceViewer) */// w w w. j a va2 s.co m public IUndoManager getUndoManager(ISourceViewer sourceViewer) { IPreferenceStore store = org.eclipse.ui.internal.editors.text.EditorsPlugin.getDefault() .getPreferenceStore(); int historySize = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE); if (historySize <= 0) { historySize = UnifiedConfiguration.HISTORY_BUFFER_SIZE; } return new DefaultUndoManager(historySize); }
From source file:com.aptana.ide.editors.unified.UnifiedEditor.java
License:Open Source License
/** * @see org.eclipse.ui.texteditor.AbstractTextEditor#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent) *///from www .j a va 2 s . co m protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { try { ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer == null) { return; } String property = event.getProperty(); if (IPreferenceConstants.COLORIZER_MAXCOLUMNS.equals(property)) { this._maxColorizingColumns = getPreferenceStore().getInt(IPreferenceConstants.COLORIZER_MAXCOLUMNS); } else if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property) || IPreferenceConstants.INSERT_SPACES_FOR_TABS.equals(property)) { IPreferenceStore store = getPreferenceStore(); if (store == null) { throw new Exception(Messages.UnifiedEditor_UnableToRetrievePreferenceStore); } int prefs = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); SourceViewerConfiguration sv = getSourceViewerConfiguration(); boolean tabsOrSpaces = store.getBoolean(IPreferenceConstants.INSERT_SPACES_FOR_TABS); if (sv != null && sv instanceof UnifiedConfiguration) { UnifiedConfiguration uc = (UnifiedConfiguration) sv; uc.setTabWidth(prefs, tabsOrSpaces, sourceViewer); } else { IdeLog.logInfo(UnifiedEditorsPlugin.getDefault(), Messages.UnifiedEditor_ErrorUpdateTabWidth); } } else if (IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_ENABLED.equals(property)) { boolean textHighlightEnabled = getPreferenceStore() .getBoolean(IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_ENABLED); if (textHighlightEnabled) { installTextOccurrenceHighlightSupport(); } else { uninstallTextOccurrenceHighlightSupport(); // remove highlights } } else if (property != null && property.startsWith(IPreferenceConstants.EDITOR_FOLDING_ENABLED)) { String language = property.substring(IPreferenceConstants.EDITOR_FOLDING_ENABLED.length() + 1, property.length()); if (this.getViewer() != null && this.getViewer() instanceof ProjectionViewer) { ProjectionViewer viewer = (ProjectionViewer) this.getViewer(); if (UnifiedEditorsPlugin.getDefault().getPreferenceStore().getBoolean(property)) { if (this.getConfiguration() instanceof UnifiedConfiguration) { UnifiedReconcilingStrategy reconciler = ((UnifiedConfiguration) this.getConfiguration()) .getStrategy(); if (reconciler != null) { reconciler.initialReconcile(); } } } else if (viewer.getProjectionAnnotationModel() != null) { List<Annotation> mods = new ArrayList<Annotation>(); Iterator annotationIterator = viewer.getProjectionAnnotationModel().getAnnotationIterator(); if (annotationIterator != null) { while (annotationIterator.hasNext()) { Annotation annotation = (Annotation) annotationIterator.next(); if (annotation instanceof LanguageProjectAnnotation) { LanguageProjectAnnotation lpa = (LanguageProjectAnnotation) annotation; if (language.equals(lpa.getLanguage())) { lpa.markDeleted(true); mods.add(lpa); } } } viewer.getProjectionAnnotationModel() .modifyAnnotations(mods.toArray(new Annotation[mods.size()]), null, null); } } } } // This updates the folding icons when the colorization changes else if (property != null && property.startsWith("Colorization")) //$NON-NLS-1$ { syncFoldingPreferenceStore(); if (this.getConfiguration() instanceof UnifiedConfiguration) { UnifiedReconcilingStrategy reconciler = ((UnifiedConfiguration) this.getConfiguration()) .getStrategy(); ProjectionAnnotationModel currentModel = getProjectionAnnotationModel(); if (reconciler != null && currentModel != null) { currentModel.removeAllAnnotations(); reconciler.initialReconcile(); } } } // boolean wordWrap = // getPreferenceStore().getBoolean(IPreferenceConstants.ENABLE_WORD_WRAP); // this.getViewer().getTextWidget().setWordWrap(wordWrap); // this can be null (? either when closing or when sourceViewer is // UndefinedViewer) StyledText viewer = sourceViewer.getTextWidget(); if (viewer != null) { sourceViewer.getTextWidget().redraw(); } } catch (Exception ex) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), Messages.UnifiedEditor_ErrorHandlingPreferenceChange, ex); } finally { super.handlePreferenceStoreChanged(event); // Editor options must be changed after super is called so that the // Eclipse editor prefs don't affect the // Aptana color prefs if the Eclipse prefs are overriden by the // language editor // Refresh editor options in case changed // Always run in UI thread! Display display = Display.getCurrent(); if (display == null) display = Display.getDefault(); display.asyncExec(new Runnable() { public void run() { setEditorOptions(); } }); } }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Reads rules from preferences./*from ww w. j a v a 2 s .com*/ * @return rules. */ private List<Rule> loadRules() { IPreferenceStore store = getPreferenceStore(); int length = store.getInt(LENGTH_KEY); List<Rule> result = new ArrayList<Rule>(); for (int i = 0; i < length; i++) { String ruleName = store.getString(NAME_KEY + i); String ruleContent = store.getString(CONTENT_KEY + i); Boolean ruleIsRegexp = store.getBoolean(REGEXP_KEY + i); Boolean isCaseInsensitive = store.getBoolean(CASEINSENSITIVE_KEY + i); Rule rule = new Rule(ruleName, ruleContent, ruleIsRegexp, isCaseInsensitive); result.add(rule); } return result; }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Loads read timeout./*from w ww .ja v a 2 s .com*/ */ private void loadReadTimeout() { IPreferenceStore store = getPreferenceStore(); readTimeout = store.getInt(READ_TIMEOUT_KEY); }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Loads read buffer./*w w w. ja va 2 s .c o m*/ */ private void loadReadBuffer() { IPreferenceStore store = getPreferenceStore(); readBuffer = store.getInt(READ_BUFFER_KEY); }