类org.eclipse.jface.text.IPainter源码实例Demo

下面列出了怎么用org.eclipse.jface.text.IPainter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: uima-uimaj   文件: AnnotationEditor.java
/**
 * Synchronizes all annotations with the eclipse annotation painter.
 */
public void syncAnnotationTypes() {

  mPainter.removeAllAnnotationTypes();
  getSourceViewer().getTextWidget().setLineSpacing(0);
  
  for (Type displayType : mShowAnnotationsMenu.getSelectedTypes()) {
    showAnnotationType(displayType, true);
  }

  if (!mShowAnnotationsMenu.getSelectedTypes().contains(getAnnotationMode())) {
    showAnnotationType(getAnnotationMode(), true);
  }

  mPainter.paint(IPainter.CONFIGURATION);
}
 
源代码2 项目: tm4e   文件: TMPresentationReconciler.java
/**
 * Initialize foreground, background color, current line highlight from the
 * current theme if needed.
 *
 */
private void applyThemeEditorIfNeeded() {
	if (!initializeViewerColors) {
		StyledText styledText = viewer.getTextWidget();
		((ITheme) tokenProvider).initializeViewerColors(styledText);
		initializeViewerColors = true;
	}
	if (updateTextDecorations) {
		return;
	}
	try {
		// Ugly code to update "current line highlight" :
		// - get the PaintManager from the ITextViewer with reflection.
		// - get the list of IPainter of PaintManager with reflection
		// - loop for IPainter to retrieve CursorLinePainter which manages "current line
		// highlight".
		PaintManager paintManager = ClassHelper.getFieldValue(viewer, "fPaintManager", TextViewer.class);
		if (paintManager == null) {
			return;
		}
		List<IPainter> painters = ClassHelper.getFieldValue(paintManager, "fPainters", PaintManager.class);
		if (painters == null) {
			return;
		}
		for (IPainter painter : painters) {
			if (painter instanceof CursorLinePainter) {
				// Update current line highlight
				Color background = tokenProvider.getEditorCurrentLineHighlight();
				if (background != null) {
					((CursorLinePainter) painter).setHighlightColor(background);
				}
				updateTextDecorations = true;
			}
		}
	} catch (Exception e) {
		TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
	}
}
 
源代码3 项目: xds-ide   文件: IndentGuidesModel.java
/**
 * Sets the given document as the indents' model input and updates
 * the model accordingly.
 * 
 * @param document the models's new input document, <code>null</code> if none
 * @param painter the painter to be notified about model changes, <code>null</code> if none
 */
public void applyToDocument(IDocument document, IPainter painter, StyledText widget) {
    deactivate();
    textWidget       = widget;
    documentPainter  = painter;
    listenedDocument = document;
    listenedDocument.addDocumentListener(documentListener);
    requestUpdate();
}
 
源代码4 项目: xds-ide   文件: PairedBracketsPainter.java
@Override
public void paint(int reason) {

    IDocument document= fSourceViewer.getDocument();
    if (document == null) {
        deactivate(false);
        return;
    }

    Point selection= fSourceViewer.getSelectedRange();
    if (selection.y > 0) {
        deactivate(true);
        return;
    }

    IRegion pair= fMatcher.match(document, selection.x);
    if (pair == null) {
        deactivate(true);
        return;
    }

    if (fIsActive) {

        if (IPainter.CONFIGURATION == reason) {

            // redraw current highlighting
            handleDrawRequest(null);

        } else if (pair.getOffset() != fPairPosition.getOffset() ||
                pair.getLength() != fPairPosition.getLength() ||
                fMatcher.getAnchor() != fAnchor || fMatcher.getMatchFlags() != fMatchFlags) 
        {

            // otherwise only do something if position is different

            // remove old highlighting
            handleDrawRequest(null);
            // update position
            updatePos(pair);
            // apply new highlighting
            handleDrawRequest(null);

        }
    } else {
        fIsActive = true;
        updatePos(pair);
        fTextWidget.addPaintListener(this);
        fPaintPositionManager.managePosition(fPairPosition);
        handleDrawRequest(null);
    }
}
 
源代码5 项目: xds-ide   文件: IndentGuidesModel.java
/**
 * Schedules the update of indent guides model to be run. The job is added to a 
 * queue of waiting jobs, and will be run when it arrives at the beginning 
 * of the queue.
 */    
protected void requestUpdate() {
    Job job = new Job(Messages.UpdateIndentGuides) {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            IDocument document = listenedDocument;
            if (document != null) {
                try {
                    final int[] tabSizeNah = new int[1];
                    tabSizeNah[0] = -1;
                    Display.getDefault().syncExec(new Runnable() {
                        @Override
                        public void run() {
                        	if (!textWidget.isDisposed()){
                        		tabSizeNah[0] = textWidget.getTabs(); //#^(@!! gui thread expected
                        	}
                        }
                    });
                    if (tabSizeNah[0] == -1) { // Widget is disposed
                    	return Status.OK_STATUS;
                    }
                    CharSequence chars = document.get();
                    assumeIndents(IndentsParser.buildDescriptors(chars, tabSizeNah[0], eolPrefix));
                } catch (Exception e) {
                    LogHelper.logError(e);
                }
                
                if (documentPainter != null) {
                    Display.getDefault().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            IPainter painter = documentPainter; 
                            if (painter != null) 
                                painter.paint(IPainter.CONFIGURATION);
                        }
                    });
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
 
源代码6 项目: Pydev   文件: ScriptConsoleViewerWrapper.java
public void addPainter(IPainter painter) {
    viewer.addPainter(painter);
}
 
源代码7 项目: Pydev   文件: ScriptConsoleViewerWrapper.java
public void removePainter(IPainter painter) {
    viewer.removePainter(painter);
}
 
 类所在包
 同包方法