Java 类org.eclipse.jface.text.source.ISourceViewer 实例源码

项目:eclipse-jenkins-editor    文件:JenkinsSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();

    addDefaultPresentation(reconciler);

    addPresentation(reconciler, JAVA_KEYWORD.getId(), getPreferences().getColor(COLOR_JAVA_KEYWORD), SWT.BOLD);
    addPresentation(reconciler, GROOVY_KEYWORD.getId(), getPreferences().getColor(COLOR_GROOVY_KEYWORD), SWT.BOLD);
    // Groovy provides different strings: simple and GStrings, so we use
    // separate colors:
    addPresentation(reconciler, STRING.getId(), getPreferences().getColor(COLOR_NORMAL_STRING), SWT.NONE);
    addPresentation(reconciler, GSTRING.getId(), getPreferences().getColor(COLOR_GSTRING), SWT.NONE);

    addPresentation(reconciler, COMMENT.getId(), getPreferences().getColor(COLOR_COMMENT), SWT.NONE);
    addPresentation(reconciler, ANNOTATION.getId(), getPreferences().getColor(COLOR_ANNOTATION), SWT.NONE);
    addPresentation(reconciler, GROOVY_DOC.getId(), getPreferences().getColor(COLOR_GROOVY_DOC), SWT.NONE);
    addPresentation(reconciler, JENKINS_KEYWORD.getId(), getPreferences().getColor(COLOR_JENKINS_KEYWORDS),
            SWT.BOLD);

    addPresentation(reconciler, JENKINS_VARIABLE.getId(), getPreferences().getColor(COLOR_JENKINS_VARIABLES),
            SWT.ITALIC);
    addPresentation(reconciler, JAVA_LITERAL.getId(), getPreferences().getColor(COLOR_JAVA_LITERAL), SWT.BOLD);
    return reconciler;
}
项目:vertigo-chroma-kspplugin    文件:KspSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {

    /* Créé un Reconsilier chargé de gérer les changements du document. */
    PresentationReconciler reconciler = new PresentationReconciler();

    /* Définition du nom du partitionnement effectué par KspDocumentSetupParticipant. */
    reconciler.setDocumentPartitioning(KspRegionType.PARTITIONING);

    /* Définition des scanners pour chacune des trois partitions. */
    setRepairer(reconciler, commentScanner, KspRegionType.COMMENT.getContentType());
    setRepairer(reconciler, stringScanner, KspRegionType.STRING.getContentType());
    setRepairer(reconciler, defaultScanner, KspRegionType.DEFAULT.getContentType());

    return reconciler;
}
项目:ec4e    文件:EditorConfigTextHover.java   
/***
 * Returns true if it exists a marker annotation in the given offset and false
 * otherwise.
 *
 * @param textViewer
 * @param offset
 * @return true if it exists a marker annotation in the given offset and false
 *         otherwise.
 */
private static boolean hasProblem(ITextViewer textViewer, int offset) {
    if (!(textViewer instanceof ISourceViewer)) {
        return false;
    }

    IAnnotationModel annotationModel = ((ISourceViewer) textViewer).getAnnotationModel();
    Iterator<Annotation> iter = (annotationModel instanceof IAnnotationModelExtension2)
            ? ((IAnnotationModelExtension2) annotationModel).getAnnotationIterator(offset, 1, true, true)
            : annotationModel.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation ann = iter.next();
        if (ann instanceof MarkerAnnotation) {
            return true;
        }
    }
    return false;
}
项目:ncl30-eclipse    文件:NCLEditor.java   
/**
 * @param nclElement
 */
public void setFocusToElement(NCLElement nclElement) {
    int line = nclElement.getLineNumber();
    int lineOffset, lineLength;
    ISourceViewer viewer = getSourceViewer();
    try {
        lineOffset = viewer.getDocument().getLineOffset(line);
        lineLength = viewer.getDocument().getLineLength(line);

        // Move cursor to new position
        resetHighlightRange();
        setHighlightRange(lineOffset, lineLength, true);
        setFocus();
    } catch (BadLocationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelSourceViewerConfiguration.java   
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant assistant = new ContentAssistant();
    IContentAssistProcessor processor = new EiffelContentAssistantProcessor();
    assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    assistant.setContentAssistProcessor(new EiffelContentAssistantProcessor(),
            IDocument.DEFAULT_CONTENT_TYPE);

    assistant.setAutoActivationDelay(100);
    assistant.enableAutoActivation(true);
    assistant.enableAutoInsert(true);

    assistant.setProposalSelectorBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    return assistant;
}
项目:fluentmark    文件:FluentMkEditor.java   
/**
 * Computes and returns the source reference that includes the caret and serves as provider for the
 * outline pageModel selection and the editor range indication.
 *
 * @return the computed source reference
 */
public ISourceReference computeHighlightRange() {
    ISourceViewer sourceViewer = getSourceViewer();
    if (sourceViewer == null) return null;

    StyledText styledText = sourceViewer.getTextWidget();
    if (styledText == null) return null;

    int caret = 0;
    if (sourceViewer instanceof ITextViewerExtension5) {
        ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
        caret = extension.widgetOffset2ModelOffset(styledText.getSelection().x);
    } else {
        int offset = sourceViewer.getVisibleRegion().getOffset();
        caret = offset + styledText.getSelection().x;
    }

    PagePart part = getPagePartAt(caret, false);
    return (ISourceReference) part;
}
项目:texlipse    文件:TexWordWrapAction.java   
/**
 * Checks the type of the word wrap and activates the correct type.
 */
private void setType() {
    String wrapStyle = TexlipsePlugin.getPreference(TexlipseProperties.WORDWRAP_TYPE);
    ISourceViewer viewer = getTextEditor() != null ? getTextEditor().getViewer() : null;
    if (wrapStyle.equals(TexlipseProperties.WORDWRAP_TYPE_SOFT)) {
        TexAutoIndentStrategy.setHardWrap(false);
        if (viewer != null) {
            viewer.getTextWidget().setWordWrap(true);
        }
    } else if (wrapStyle.equals(TexlipseProperties.WORDWRAP_TYPE_HARD)) {
        TexAutoIndentStrategy.setHardWrap(true);
        if (viewer != null) {
            viewer.getTextWidget().setWordWrap(false);
        }
    }
}
项目:http4e    文件:XMLConfiguration.java   
public IContentFormatter getContentFormatter( ISourceViewer sourceViewer){
    ContentFormatter formatter = new ContentFormatter();
    XMLFormattingStrategy formattingStrategy = new XMLFormattingStrategy();
    DefaultFormattingStrategy defaultStrategy = new DefaultFormattingStrategy();
    TextFormattingStrategy textStrategy = new TextFormattingStrategy();
    DocTypeFormattingStrategy doctypeStrategy = new DocTypeFormattingStrategy();
    PIFormattingStrategy piStrategy = new PIFormattingStrategy();
    formatter.setFormattingStrategy(defaultStrategy,
            IDocument.DEFAULT_CONTENT_TYPE);
    formatter.setFormattingStrategy(textStrategy,
            XMLPartitionScanner.XML_TEXT);
    formatter.setFormattingStrategy(doctypeStrategy,
            XMLPartitionScanner.XML_DOCTYPE);
    formatter.setFormattingStrategy(piStrategy, XMLPartitionScanner.XML_PI);
    formatter.setFormattingStrategy(textStrategy,
            XMLPartitionScanner.XML_CDATA);
    formatter.setFormattingStrategy(formattingStrategy,
            XMLPartitionScanner.XML_START_TAG);
    formatter.setFormattingStrategy(formattingStrategy,
            XMLPartitionScanner.XML_END_TAG);

    return formatter;
}
项目:DarwinSPL    文件:DwprofileQuickAssistProcessor.java   
private List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> foundFixes = new ArrayList<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:fluentmark    文件:MkReconcilingStrategy.java   
/**
 * Creates a new Dsl reconciling strategy.
 * 
 * @param viewer the source viewer
 * @param editor the editor of the strategy's reconciler
 * @param documentPartitioning the document partitioning this strategy uses for configuration
 */
public MkReconcilingStrategy(ISourceViewer viewer, ITextEditor editor, String documentPartitioning) {
    this.viewer = viewer;
    this.editor = editor;
    this.store = FluentMkUI.getDefault().getPreferenceStore();
    setReconcilingStrategies(getReconcilingStrategies());

    // TODO: figure out how to dispose
    this.store.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(Prefs.SPELLING_ENABLED)) {
                setReconcilingStrategies(getReconcilingStrategies());
            }
        }
    });
}
项目:DarwinSPL    文件:HyexpressionQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:DarwinSPL    文件:HymappingQuickAssistProcessor.java   
private List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:mesfavoris    文件:SpellcheckableMessageArea.java   
private ActionHandler createContentAssistActionHandler(
        final ITextOperationTarget textOperationTarget) {
    Action proposalAction = new Action() {
        @Override
        public void run() {
            if (textOperationTarget
                    .canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)
                    && getTextWidget().isFocusControl())
                textOperationTarget
                        .doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
        }
    };
    proposalAction
            .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    return new ActionHandler(proposalAction);
}
项目:DarwinSPL    文件:HyvalidityformulaQuickAssistProcessor.java   
private List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> foundFixes = new ArrayList<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:DarwinSPL    文件:HydatavalueQuickAssistProcessor.java   
private List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> foundFixes = new ArrayList<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:n4js    文件:ContentAssistantFactory.java   
@Override
protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration,
        ISourceViewer sourceViewer) {
    super.setContentAssistProcessor(assistant, configuration, sourceViewer);
    assistant.setContentAssistProcessor(jsDocContentAssistProcessor, TokenTypeToPartitionMapper.JS_DOC_PARTITION);
    assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.REG_EX_PARTITION);
    assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.TEMPLATE_LITERAL_PARTITION);
    assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION);
    assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION);
}
项目:n4js    文件:N4JSHyperlinkDetector.java   
/**
 * Method copied from super class with only a minor change: call to "readOnly" changed to "tryReadOnly".
 */
@Override
public IHyperlink[] detectHyperlinks(final ITextViewer textViewer, final IRegion region,
        final boolean canShowMultipleHyperlinks) {
    final IDocument xtextDocument = textViewer.getDocument();
    if (!(xtextDocument instanceof N4JSDocument)) {
        return super.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
    }
    final IHyperlinkHelper helper = getHelper();
    return ((N4JSDocument) xtextDocument).tryReadOnly(new IUnitOfWork<IHyperlink[], XtextResource>() {
        @Override
        public IHyperlink[] exec(XtextResource resource) throws Exception {
            if (resource == null) {
                return null;
            }
            if (helper instanceof ISourceViewerAware && textViewer instanceof ISourceViewer) {
                ((ISourceViewerAware) helper).setSourceViewer((ISourceViewer) textViewer);
            }
            return helper.createHyperlinksByOffset(resource, region.getOffset(), canShowMultipleHyperlinks);
        }
    }, null);
}
项目:n4js    文件:EditorOverlay.java   
private void draw() {
    XtextEditor editor = EditorUtils.getActiveXtextEditor();
    if (editor != null && (hoveredElement != null || !selectedElements.isEmpty())) {
        ISourceViewer isv = editor.getInternalSourceViewer();
        styledText = isv.getTextWidget();
        drawSelection();
    } else {
        clear();
    }
}
项目:ContentAssist    文件:EditorUtilities.java   
/**
 * Obtains the source viewer of an editor.
 * @param editor the editor
 * @return the source viewer of the editor
 */
public static ISourceViewer getSourceViewer(IEditorPart editor) {
    if (editor == null) {
        return null;
    }

    ISourceViewer viewer = (ISourceViewer)editor.getAdapter(ITextOperationTarget.class);
    return viewer;
}
项目:ContentAssist    文件:EditorUtilities.java   
/**
 * Obtains the styled text of an editor.
 * @param editor the editor
 * @return the styled text of the editor
 */
public static StyledText getStyledText(IEditorPart editor) {
    ISourceViewer viewer = getSourceViewer(editor);
    if (viewer != null) {
        return viewer.getTextWidget();
    }
    return null;
}
项目:ContentAssist    文件:EditorUtilities.java   
/**
 * Obtains the content assistant facade of an editor.
 * @param editor the editor
 * @return the content assistant facade of the editor
 */
public static ContentAssistantFacade getContentAssistantFacade(IEditorPart editor) {
    ISourceViewer viewer = getSourceViewer(editor);
    if (viewer != null && viewer instanceof SourceViewer) {
        return ((SourceViewer)viewer).getContentAssistantFacade();
    }
    return null;
}
项目:eclipse-jenkins-editor    文件:JenkinsSourceViewerConfiguration.java   
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    if (sourceViewer == null){
        return null;
    }

    return new IHyperlinkDetector[] { new URLHyperlinkDetector() };
}
项目:eclipse-batch-editor    文件:BatchSourceViewerConfiguration.java   
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
    /* @formatter:off */
    return allIdsToStringArray( 
            IDocument.DEFAULT_CONTENT_TYPE);
    /* @formatter:on */
}
项目:eclipse-batch-editor    文件:BatchSourceViewerConfiguration.java   
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    if (sourceViewer == null)
        return null;

    return new IHyperlinkDetector[] { new URLHyperlinkDetector(), new BatchHyperlinkDetector(adaptable) };
}
项目:eclipse-batch-editor    文件:BatchEditor.java   
private void ensureColorsFetched() {
    if (bgColor == null || fgColor == null) {

        ISourceViewer sourceViewer = getSourceViewer();
        if (sourceViewer == null) {
            return;
        }
        StyledText textWidget = sourceViewer.getTextWidget();
        if (textWidget == null) {
            return;
        }

        /*
         * TODO ATR, 03.02.2017: there should be an easier approach to get
         * editors back and foreground, without syncexec
         */
        EclipseUtil.getSafeDisplay().syncExec(new Runnable() {

            @Override
            public void run() {
                bgColor = ColorUtil.convertToHexColor(textWidget.getBackground());
                fgColor = ColorUtil.convertToHexColor(textWidget.getForeground());
            }
        });
    }

}
项目:eclipse-batch-editor    文件:BatchEditor.java   
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (BatchEditor.class.equals(adapter)) {
        return (T) this;
    }
    if (IContentOutlinePage.class.equals(adapter)) {
        return (T) getOutlinePage();
    }
    if (ColorManager.class.equals(adapter)) {
        return (T) getColorManager();
    }
    if (IFile.class.equals(adapter)) {
        IEditorInput input = getEditorInput();
        if (input instanceof IFileEditorInput) {
            IFileEditorInput feditorInput = (IFileEditorInput) input;
            return (T) feditorInput.getFile();
        }
        return null;
    }
    if (ISourceViewer.class.equals(adapter)) {
        return (T) getSourceViewer();
    }
    if (StatusMessageSupport.class.equals(adapter)) {
        return (T) this;
    }
    if (ITreeContentProvider.class.equals(adapter) || BatchEditorTreeContentProvider.class.equals(adapter)) {
        if (outlinePage==null){
            return null;
        }
        return (T) outlinePage.getContentProvider();
    }
    return super.getAdapter(adapter);
}
项目:eclipse-batch-editor    文件:BatchEditor.java   
public void handleColorSettingsChanged() {
    // done like in TextEditor for spelling
    ISourceViewer viewer = getSourceViewer();
    SourceViewerConfiguration configuration = getSourceViewerConfiguration();
    if (viewer instanceof ISourceViewerExtension2) {
        ISourceViewerExtension2 viewerExtension2 = (ISourceViewerExtension2) viewer;
        viewerExtension2.unconfigure();
        if (configuration instanceof BatchSourceViewerConfiguration) {
            BatchSourceViewerConfiguration gconf = (BatchSourceViewerConfiguration) configuration;
            gconf.updateTextScannerDefaultColorToken();
        }
        viewer.configure(configuration);
    }
}
项目:eclipse-batch-editor    文件:BatchBracketsSupport.java   
protected final IRegion getSignedSelection(ISourceViewer sourceViewer) {
    Point viewerSelection = sourceViewer.getSelectedRange();

    StyledText text = sourceViewer.getTextWidget();
    Point selection = text.getSelectionRange();
    if (text.getCaretOffset() == selection.x) {
        viewerSelection.x = viewerSelection.x + viewerSelection.y;
        viewerSelection.y = -viewerSelection.y;
    }

    return new Region(viewerSelection.x, viewerSelection.y);
}
项目:eclipse-bash-editor    文件:BashSourceViewerConfiguration.java   
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
    /* @formatter:off */
    return allIdsToStringArray( 
            IDocument.DEFAULT_CONTENT_TYPE);
    /* @formatter:on */
}
项目:eclipse-bash-editor    文件:BashSourceViewerConfiguration.java   
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    if (sourceViewer == null)
        return null;

    return new IHyperlinkDetector[] { new URLHyperlinkDetector(), new BashHyperlinkDetector(adaptable) };
}
项目:eclipse-bash-editor    文件:BashSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();

    addDefaultPresentation(reconciler);

    addPresentation(reconciler, HERE_DOCUMENT.getId(), getPreferences().getColor(COLOR_HEREDOCS),SWT.ITALIC);
    addPresentation(reconciler, HERE_STRING.getId(), getPreferences().getColor(COLOR_HERESTRINGS),SWT.ITALIC);

    addPresentation(reconciler, BASH_KEYWORD.getId(), getPreferences().getColor(COLOR_BASH_KEYWORD),SWT.BOLD);
    addPresentation(reconciler, BASH_SYSTEM_KEYWORD.getId(), getPreferences().getColor(COLOR_BASH_KEYWORD),SWT.BOLD);

    // Groovy provides different strings: simple and GStrings, so we use separate colors:
    addPresentation(reconciler, SINGLE_STRING.getId(), getPreferences().getColor(COLOR_NORMAL_STRING),SWT.NONE);
    addPresentation(reconciler, DOUBLE_STRING.getId(), getPreferences().getColor(COLOR_GSTRING),SWT.NONE);
    addPresentation(reconciler, BACKTICK_STRING.getId(), getPreferences().getColor(COLOR_BSTRING),SWT.NONE);

    addPresentation(reconciler, COMMENT.getId(), getPreferences().getColor(COLOR_COMMENT),SWT.NONE);
    addPresentation(reconciler, PARAMETER.getId(), getPreferences().getColor(COLOR_PARAMETERS),SWT.NONE);
    addPresentation(reconciler, INCLUDE_KEYWORD.getId(), getPreferences().getColor(COLOR_INCLUDE_KEYWORD),SWT.BOLD);
    addPresentation(reconciler, BASH_COMMAND.getId(), getPreferences().getColor(COLOR_BASH_COMMAND),SWT.BOLD|SWT.NONE);


    addPresentation(reconciler, VARIABLES.getId(), getPreferences().getColor(COLOR_KNOWN_VARIABLES),SWT.NONE);
    addPresentation(reconciler, KNOWN_VARIABLES.getId(), getPreferences().getColor(COLOR_KNOWN_VARIABLES),SWT.NONE);

    return reconciler;
}
项目:eclipse-bash-editor    文件:BashBracketsSupport.java   
protected final IRegion getSignedSelection(ISourceViewer sourceViewer) {
    Point viewerSelection = sourceViewer.getSelectedRange();

    StyledText text = sourceViewer.getTextWidget();
    Point selection = text.getSelectionRange();
    if (text.getCaretOffset() == selection.x) {
        viewerSelection.x = viewerSelection.x + viewerSelection.y;
        viewerSelection.y = -viewerSelection.y;
    }

    return new Region(viewerSelection.x, viewerSelection.y);
}
项目:eclipse-bash-editor    文件:BashEditor.java   
private void ensureColorsFetched() {
    if (bgColor == null || fgColor == null) {

        ISourceViewer sourceViewer = getSourceViewer();
        if (sourceViewer == null) {
            return;
        }
        StyledText textWidget = sourceViewer.getTextWidget();
        if (textWidget == null) {
            return;
        }

        /*
         * TODO ATR, 03.02.2017: there should be an easier approach to get
         * editors back and foreground, without syncexec
         */
        EclipseUtil.getSafeDisplay().syncExec(new Runnable() {

            @Override
            public void run() {
                bgColor = ColorUtil.convertToHexColor(textWidget.getBackground());
                fgColor = ColorUtil.convertToHexColor(textWidget.getForeground());
            }
        });
    }

}
项目:eclipse-bash-editor    文件:BashEditor.java   
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
    if (BashEditor.class.equals(adapter)) {
        return (T) this;
    }
    if (IContentOutlinePage.class.equals(adapter)) {
        return (T) getOutlinePage();
    }
    if (ColorManager.class.equals(adapter)) {
        return (T) getColorManager();
    }
    if (IFile.class.equals(adapter)) {
        IEditorInput input = getEditorInput();
        if (input instanceof IFileEditorInput) {
            IFileEditorInput feditorInput = (IFileEditorInput) input;
            return (T) feditorInput.getFile();
        }
        return null;
    }
    if (ISourceViewer.class.equals(adapter)) {
        return (T) getSourceViewer();
    }
    if (StatusMessageSupport.class.equals(adapter)) {
        return (T) this;
    }
    if (ITreeContentProvider.class.equals(adapter) || BashEditorTreeContentProvider.class.equals(adapter)) {
        if (outlinePage == null) {
            return null;
        }
        return (T) outlinePage.getContentProvider();
    }
    return super.getAdapter(adapter);
}
项目:eclipse-bash-editor    文件:BashEditor.java   
public void handleColorSettingsChanged() {
    // done like in TextEditor for spelling
    ISourceViewer viewer = getSourceViewer();
    SourceViewerConfiguration configuration = getSourceViewerConfiguration();
    if (viewer instanceof ISourceViewerExtension2) {
        ISourceViewerExtension2 viewerExtension2 = (ISourceViewerExtension2) viewer;
        viewerExtension2.unconfigure();
        if (configuration instanceof BashSourceViewerConfiguration) {
            BashSourceViewerConfiguration gconf = (BashSourceViewerConfiguration) configuration;
            gconf.updateTextScannerDefaultColorToken();
        }
        viewer.configure(configuration);
    }
}
项目:pgcodekeeper    文件:SQLEditorSourceViewerConfiguration.java   
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    if (editor == null) {
        return null;
    }
    ContentAssistant assistant= new ContentAssistant();
    assistant.setContentAssistProcessor(new SQLEditorCompletionProcessor(editor), SQLEditorCommonDocumentProvider.SQL_CODE);
    assistant.enableAutoActivation(true);
    assistant.enableAutoInsert(true);
    assistant.setAutoActivationDelay(500);
    assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
    assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    return assistant;
}
项目:pgcodekeeper    文件:SQLEditorSourceViewerConfiguration.java   
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
    return new String[] {
            SQLEditorCommonDocumentProvider.SQL_CODE,
            SQLEditorCommonDocumentProvider.SQL_SINGLE_COMMENT
    };
}
项目:pgcodekeeper    文件:SQLEditorSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler= new PresentationReconciler();
    reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));

    addDamagerRepairer(reconciler, createCommentScanner(), SQLEditorCommonDocumentProvider.SQL_SINGLE_COMMENT);
    addDamagerRepairer(reconciler, createMultiCommentScanner(), SQLEditorCommonDocumentProvider.SQL_MULTI_COMMENT);
    addDamagerRepairer(reconciler, createCharacterStringLiteralCommentScanner(), SQLEditorCommonDocumentProvider.SQL_CHARACTER_STRING_LITERAL);
    addDamagerRepairer(reconciler, createRecipeScanner(), SQLEditorCommonDocumentProvider.SQL_CODE);

    return reconciler;
}
项目:pgcodekeeper    文件:SQLEditorSourceViewerConfiguration.java   
@Override
protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
    Map<String, IAdaptable> targets = super.getHyperlinkDetectorTargets(sourceViewer);
    if (editor != null) {
        targets.put("ru.taximaxim.codekeeper.ui.SQLEditorTarget", editor); //$NON-NLS-1$
    }
    return targets;
}
项目:vertigo-chroma-kspplugin    文件:KspSourceViewerConfiguration.java   
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
    IHyperlinkDetector[] hyperlinkDetectors = super.getHyperlinkDetectors(sourceViewer);
    List<IHyperlinkDetector> list = new ArrayList<>(Arrays.asList(hyperlinkDetectors));
    list.add(new KspNameHyperLinkDetector());
    list.add(new SqlTableHyperLinkDetector());
    list.add(new CanonicalJavaNameHyperLinkDetector());
    list.add(new DtoDefinitionPathHyperLinkDetector());
    return list.toArray(new IHyperlinkDetector[] {});
}