List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean
boolean getBoolean(String name);
From source file:com.google.dart.tools.ui.internal.text.dart.hover.SourceViewerInformationControl.java
License:Open Source License
private RGB getHoverBackgroundColorRGB() { IPreferenceStore store = DartToolsPlugin.getDefault().getPreferenceStore(); return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT) ? null : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); }
From source file:com.google.dart.tools.ui.internal.text.dart.SmartSemicolonAutoEditStrategy.java
License:Open Source License
@Override public void customizeDocumentCommand(IDocument document, DocumentCommand command) { // 0: early pruning // also customize if <code>doit</code> is false (so it works in code // completion situations) // if (!command.doit) // return;/*from ww w.ja va2 s .c o m*/ if (command.text == null) { return; } if (command.text.equals(SEMICOLON)) { fCharacter = SEMICHAR; } else if (command.text.equals(BRACE)) { fCharacter = BRACECHAR; } else { return; } IPreferenceStore store = DartToolsPlugin.getDefault().getPreferenceStore(); if (fCharacter == SEMICHAR && !store.getBoolean(PreferenceConstants.EDITOR_SMART_SEMICOLON)) { return; } if (fCharacter == BRACECHAR && !store.getBoolean(PreferenceConstants.EDITOR_SMART_OPENING_BRACE)) { return; } IWorkbenchPage page = DartToolsPlugin.getActivePage(); if (page == null) { return; } IEditorPart part = page.getActiveEditor(); if (!(part instanceof CompilationUnitEditor)) { return; } CompilationUnitEditor editor = (CompilationUnitEditor) part; if (editor.getInsertMode() != ITextEditorExtension3.SMART_INSERT || !editor.isEditable()) { return; } ITextEditorExtension2 extension = (ITextEditorExtension2) editor.getAdapter(ITextEditorExtension2.class); if (extension != null && !extension.validateEditorInputState()) { return; } if (isMultilineSelection(document, command)) { return; } // 1: find concerned line / position in java code, location in statement int pos = command.offset; ITextSelection line; try { IRegion l = document.getLineInformationOfOffset(pos); line = new TextSelection(document, l.getOffset(), l.getLength()); } catch (BadLocationException e) { return; } // 2: choose action based on findings (is for-Statement?) // for now: compute the best position to insert the new character int positionInLine = computeCharacterPosition(document, line, pos - line.getOffset(), fCharacter, fPartitioning); int position = positionInLine + line.getOffset(); // never position before the current position! if (position < pos) { return; } // never double already existing content if (alreadyPresent(document, fCharacter, position)) { return; } // don't do special processing if what we do is actually the normal // behaviour String insertion = adjustSpacing(document, position, fCharacter); if (command.offset == position && insertion.equals(command.text)) { return; } try { final SmartBackspaceManager manager = (SmartBackspaceManager) editor .getAdapter(SmartBackspaceManager.class); if (manager != null && DartToolsPlugin.getDefault().getPreferenceStore() .getBoolean(PreferenceConstants.EDITOR_SMART_BACKSPACE)) { TextEdit e1 = new ReplaceEdit(command.offset, command.text.length(), document.get(command.offset, command.length)); UndoSpec s1 = new UndoSpec(command.offset + command.text.length(), new Region(command.offset, 0), new TextEdit[] { e1 }, 0, null); DeleteEdit smart = new DeleteEdit(position, insertion.length()); ReplaceEdit raw = new ReplaceEdit(command.offset, command.length, command.text); UndoSpec s2 = new UndoSpec(position + insertion.length(), new Region(command.offset + command.text.length(), 0), new TextEdit[] { smart, raw }, 2, s1); manager.register(s2); } // 3: modify command command.offset = position; command.length = 0; command.caretOffset = position; command.text = insertion; command.doit = true; command.owner = null; } catch (MalformedTreeException e) { DartToolsPlugin.log(e); } catch (BadLocationException e) { DartToolsPlugin.log(e); } }
From source file:com.google.dart.tools.ui.internal.text.editor.CompilationUnitDocumentProvider.java
License:Open Source License
/** * Returns the preference whether handling temporary problems is enabled. * /*from w w w . jav a2 s.co m*/ * @return <code>true</code> if temporary problems are handled */ protected boolean isHandlingTemporaryProblems() { IPreferenceStore store = DartToolsPlugin.getDefault().getPreferenceStore(); return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS); }
From source file:com.google.dart.tools.ui.internal.text.editor.CompilationUnitEditor.java
License:Open Source License
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); IPreferenceStore preferenceStore = getPreferenceStore(); boolean closeBrackets = preferenceStore.getBoolean(CLOSE_BRACKETS); boolean closeStrings = preferenceStore.getBoolean(CLOSE_STRINGS); boolean closeAngularBrackets = closeBrackets; fBracketInserter.setCloseBracketsEnabled(closeBrackets); fBracketInserter.setCloseStringsEnabled(closeStrings); fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets); ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension) { ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter); }//from w ww .j a v a2 s. c o m if (isMarkingOccurrences()) { installOccurrencesFinder(false); } }
From source file:com.google.dart.tools.ui.internal.text.editor.DartEditor.java
License:Open Source License
@Override protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) { IPreferenceStore store = getPreferenceStore(); ISourceViewer viewer = createDartSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, store); DartUIHelp.setHelp(this, viewer.getTextWidget(), DartHelpContextIds.JAVA_EDITOR); DartSourceViewer dartSourceViewer = null; if (viewer instanceof DartSourceViewer) { dartSourceViewer = (DartSourceViewer) viewer; }//from w ww .j a va 2 s . c om /* * This is a performance optimization to reduce the computation of the text presentation * triggered by {@link #setVisibleDocument(IDocument)} */ if (dartSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS))) { dartSourceViewer.prepareDelayedProjection(); } ProjectionViewer projectionViewer = (ProjectionViewer) viewer; fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors()); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$ fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$ DartX.todo("hover"); fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() { @Override public IInformationControl createInformationControl(Shell shell) { return new SourceViewerInformationControl(shell, SWT.TOOL | SWT.NO_TRIM | getOrientation(), SWT.NONE, EditorsUI.getTooltipAffordanceString()); } }); fProjectionSupport.setInformationPresenterControlCreator(new IInformationControlCreator() { @Override public IInformationControl createInformationControl(Shell shell) { int shellStyle = SWT.RESIZE | SWT.TOOL | getOrientation(); int style = SWT.V_SCROLL | SWT.H_SCROLL; return new SourceViewerInformationControl(shell, shellStyle, style); } }); fProjectionSupport.install(); fProjectionModelUpdater = DartToolsPlugin.getDefault().getFoldingStructureProviderRegistry() .getCurrentFoldingProvider(); if (fProjectionModelUpdater != null) { fProjectionModelUpdater.install(this, projectionViewer); } // ensure source viewer decoration support has been created and configured getSourceViewerDecorationSupport(viewer); // // Add the required listeners so that changes to the document will cause the AST structure to be // flushed. // viewer.addTextInputListener(new ITextInputListener() { @Override public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { } @Override public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (newInput != null) { newInput.addDocumentListener(astCacheClearer); } astCache.clear(); } }); IDocument document = getDocumentProvider().getDocument(null); if (document != null) { document.addDocumentListener(astCacheClearer); } return viewer; }
From source file:com.google.dart.tools.ui.internal.text.editor.DartEditor.java
License:Open Source License
@Override protected void initializeEditor() { IPreferenceStore store = createCombinedPreferenceStore(null); setPreferenceStore(store);/*from w w w . jav a 2 s . c o m*/ setSourceViewerConfiguration(createDartSourceViewerConfiguration()); fMarkOccurrenceAnnotations = store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES); fStickyOccurrenceAnnotations = store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES); fMarkTypeOccurrences = store.getBoolean(PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES); fMarkMethodOccurrences = store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES); fMarkConstantOccurrences = store.getBoolean(PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES); fMarkFieldOccurrences = store.getBoolean(PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES); fMarkLocalVariableypeOccurrences = store .getBoolean(PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES); fMarkExceptions = store.getBoolean(PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES); fMarkImplementors = store.getBoolean(PreferenceConstants.EDITOR_MARK_IMPLEMENTORS); fMarkMethodExitPoints = store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS); fMarkBreakContinueTargets = store.getBoolean(PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS); }
From source file:com.google.dart.tools.ui.internal.text.editor.DartEditor.java
License:Open Source License
protected boolean isMarkingOccurrences() { IPreferenceStore store = getPreferenceStore(); return store != null && store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES); }
From source file:com.google.dart.tools.ui.internal.text.editor.DartEditor.java
License:Open Source License
/** * Returns the boolean preference for the given key. * /* w w w . j av a2 s .c om*/ * @param store the preference store * @param key the preference key * @return <code>true</code> if the key exists in the store and its value is <code>true</code> */ private boolean getBoolean(IPreferenceStore store, String key) { return key != null && store.getBoolean(key); }
From source file:com.google.dart.tools.ui.internal.text.editor.DartEditor.java
License:Open Source License
private void internalDoSetInput(IEditorInput input) throws CoreException { ISourceViewer sourceViewer = getSourceViewer(); DartSourceViewer dartSourceViewer = null; if (sourceViewer instanceof DartSourceViewer) { dartSourceViewer = (DartSourceViewer) sourceViewer; }/*from w w w . j ava 2 s . co m*/ IPreferenceStore store = getPreferenceStore(); if (dartSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS))) { dartSourceViewer.prepareDelayedProjection(); } super.doSetInput(input); if (dartSourceViewer != null && dartSourceViewer.getReconciler() == null) { IReconciler reconciler = getSourceViewerConfiguration().getReconciler(dartSourceViewer); if (reconciler != null) { reconciler.install(dartSourceViewer); dartSourceViewer.setReconciler(reconciler); } } if (fEncodingSupport != null) { fEncodingSupport.reset(); } setOutlinePageInput(fOutlinePage, input); if (isShowingOverrideIndicators()) { installOverrideIndicator(false); } }
From source file:com.google.dart.tools.ui.internal.text.editor.SemanticHighlightingManager_NEW.java
License:Open Source License
@Override public void applyTextPresentation(TextPresentation textPresentation) { synchronized (positionsLock) { if (positions == null) { return; }//from w w w .j a v a2 s .com // prepare damaged region IRegion damagedRegion = textPresentation.getExtent(); int daOffset = damagedRegion.getOffset(); int daEnd = daOffset + damagedRegion.getLength(); // prepare theme access IPreferenceStore store = DartToolsPlugin.getDefault().getPreferenceStore(); IColorManager colorManager = DartUI.getColorManager(); // add style ranges for (HighlightPosition position : positions) { // skip if outside of the damaged region int hiOffset = position.getOffset(); int hiLength = position.getLength(); int hiEnd = hiOffset + hiLength; if (hiEnd < daOffset || hiOffset >= daEnd) { continue; } if (hiEnd > daEnd) { continue; } // prepare highlight key String highlightType = position.highlight.getType(); String themeKey = getThemeKey(highlightType); if (themeKey == null) { continue; } themeKey = "semanticHighlighting." + themeKey; // prepare color RGB foregroundRGB = PreferenceConverter.getColor(store, themeKey + ".color"); if (foregroundRGB == PreferenceConverter.COLOR_DEFAULT_DEFAULT) { continue; } Color foregroundColor = colorManager.getColor(foregroundRGB); // prepare font style boolean fontBold = store.getBoolean(themeKey + ".bold"); boolean fontItalic = store.getBoolean(themeKey + ".italic"); int fontStyle = 0; if (fontBold) { fontStyle |= SWT.BOLD; } if (fontItalic) { fontStyle |= SWT.ITALIC; } // merge style range textPresentation .replaceStyleRange(new StyleRange(hiOffset, hiLength, foregroundColor, null, fontStyle)); } } }