org.eclipse.jface.text.IInformationControlExtension2 Java Examples

The following examples show how to use org.eclipse.jface.text.IInformationControlExtension2. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaExpandHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Object getHoverInfoForLine(final ISourceViewer viewer, final int line) {
	final boolean showTemporaryProblems= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
	IAnnotationModel model= viewer.getAnnotationModel();
	IDocument document= viewer.getDocument();

	if (model == null)
		return null;

	List<Annotation> exact= new ArrayList<Annotation>();
	HashMap<Position, Object> messagesAtPosition= new HashMap<Position, Object>();

	Iterator<Annotation> e= model.getAnnotationIterator();
	while (e.hasNext()) {
		Annotation annotation= e.next();

		if (fAnnotationAccess instanceof IAnnotationAccessExtension)
			if (!((IAnnotationAccessExtension)fAnnotationAccess).isPaintable(annotation))
				continue;

		if (annotation instanceof IJavaAnnotation && !isIncluded((IJavaAnnotation)annotation, showTemporaryProblems))
			continue;

		AnnotationPreference pref= fLookup.getAnnotationPreference(annotation);
		if (pref != null) {
			String key= pref.getVerticalRulerPreferenceKey();
			if (key != null && !fStore.getBoolean(key))
				continue;
		}

		Position position= model.getPosition(annotation);
		if (position == null)
			continue;

		if (compareRulerLine(position, document, line) == 1) {

			if (isDuplicateMessage(messagesAtPosition, position, annotation.getText()))
				continue;

			exact.add(annotation);
		}
	}

	sort(exact, model);

	if (exact.size() > 0)
		setLastRulerMouseLocation(viewer, line);

	if (exact.size() > 0) {
		Annotation first= exact.get(0);
		if (!isBreakpointAnnotation(first))
			exact.add(0, new NoBreakpointAnnotation());
	}

	if (exact.size() <= 1)
		return null;

	AnnotationHoverInput input= new AnnotationHoverInput();
	input.fAnnotations= exact.toArray(new Annotation[0]);
	input.fViewer= viewer;
	input.fRulerInfo= fCompositeRuler;
	input.fAnnotationListener= fgListener;
	input.fDoubleClickListener= fDblClickListener;
	input.redoAction= new AnnotationExpansionControl.ICallback() {

		public void run(IInformationControlExtension2 control) {
			control.setInput(getHoverInfoForLine(viewer, line));
		}

	};
	input.model= model;

	return input;
}
 
Example #2
Source File: AnnotationExpansionControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 votes vote down vote up
void run(IInformationControlExtension2 control);