Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 65352 Details for
Bug 184639
[PATCH] specfile editor - annotation hover support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
specfile-annotation-hover
specfile-annotation-hover.patch (text/plain), 4.67 KB, created by
Alphonse Van Assche
on 2007-04-29 14:29:45 EDT
(
hide
)
Description:
specfile-annotation-hover
Filename:
MIME Type:
Creator:
Alphonse Van Assche
Created:
2007-04-29 14:29:45 EDT
Size:
4.67 KB
patch
obsolete
>Index: src/org/eclipse/linuxtools/rpm/ui/editor/AnnotationHover.java >=================================================================== >--- src/org/eclipse/linuxtools/rpm/ui/editor/AnnotationHover.java (révision 0) >+++ src/org/eclipse/linuxtools/rpm/ui/editor/AnnotationHover.java (révision 0) >@@ -0,0 +1,99 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ >+ >+*******************************************************************************/ >+package org.eclipse.linuxtools.rpm.ui.editor; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+ >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.Position; >+import org.eclipse.jface.text.source.IAnnotationHover; >+import org.eclipse.jface.text.source.IAnnotationModel; >+import org.eclipse.jface.text.source.ISourceViewer; >+import org.eclipse.ui.texteditor.MarkerAnnotation; >+ >+ >+/** >+ * Class derived from org.eclipse.pde.internal.ui.editor.text.AnnotationHover >+ * >+ */ >+public class AnnotationHover implements IAnnotationHover { >+ >+ >+ public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) { >+ String[] messages = getMessagesForLine(sourceViewer, lineNumber); >+ >+ >+ if (messages.length == 0) >+ return null; >+ >+ >+ StringBuffer buffer = new StringBuffer(); >+ for (int i = 0; i < messages.length; i++) { >+ buffer.append(messages[i]); >+ if (i < messages.length - 1) >+ buffer.append(System.getProperty("line.separator")); //$NON-NLS-1$ >+ } >+ return buffer.toString(); >+ } >+ >+ >+ private String[] getMessagesForLine(ISourceViewer viewer, int line) { >+ IDocument document = viewer.getDocument(); >+ IAnnotationModel model = viewer.getAnnotationModel(); >+ >+ >+ if (model == null) >+ return new String[0]; >+ >+ >+ ArrayList messages = new ArrayList(); >+ >+ >+ Iterator iter = model.getAnnotationIterator(); >+ while (iter.hasNext()) { >+ Object object = iter.next(); >+ if (object instanceof MarkerAnnotation) { >+ MarkerAnnotation annotation = (MarkerAnnotation) object; >+ if (compareRulerLine(model.getPosition(annotation), >+ document, >+ line)) { >+ IMarker marker = annotation.getMarker(); >+ String message = >+ marker.getAttribute(IMarker.MESSAGE, (String) null); >+ if (message != null && message.trim().length() > 0) >+ messages.add(message); >+ } >+ } >+ } >+ return (String[]) messages.toArray(new String[messages.size()]); >+ } >+ >+ >+ private boolean compareRulerLine( >+ Position position, >+ IDocument document, >+ int line) { >+ >+ >+ try { >+ if (position.getOffset() > -1 && position.getLength() > -1) { >+ return document.getLineOfOffset(position.getOffset()) == line; >+ } >+ } catch (BadLocationException e) { >+ } >+ return false; >+ } >+} >\ Pas de fin de ligne à la fin du fichier >Index: src/org/eclipse/linuxtools/rpm/ui/editor/SpecfileConfiguration.java >=================================================================== >--- src/org/eclipse/linuxtools/rpm/ui/editor/SpecfileConfiguration.java (révision 610) >+++ src/org/eclipse/linuxtools/rpm/ui/editor/SpecfileConfiguration.java (copie de travail) >@@ -19,6 +19,7 @@ > import org.eclipse.jface.text.reconciler.MonoReconciler; > import org.eclipse.jface.text.rules.DefaultDamagerRepairer; > import org.eclipse.jface.text.rules.Token; >+import org.eclipse.jface.text.source.IAnnotationHover; > import org.eclipse.jface.text.source.ISourceViewer; > import org.eclipse.jface.text.source.SourceViewerConfiguration; > import org.eclipse.swt.SWT; >@@ -32,6 +33,7 @@ > private ColorManager colorManager; > private SpecfileHover specfileHover; > private SpecfileEditor editor; >+ private AnnotationHover annotationHover; > > public SpecfileConfiguration(ColorManager colorManager, SpecfileEditor editor) { > this.colorManager = colorManager; >@@ -171,5 +173,14 @@ > return null; > return new IHyperlinkDetector[] { new URLHyperlinkWithMacroDetector(editor.getSpecfile())}; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer) >+ */ >+ public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { >+ if (annotationHover == null) >+ annotationHover = new AnnotationHover(); >+ return annotationHover; >+ } > > } >\ Pas de fin de ligne à la fin du fichier
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 184639
: 65352