Mercurial > projects > dwt-addons
diff dwtx/jface/internal/text/revisions/RevisionPainter.d @ 150:5cf141e43417
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 23:05:26 +0200 |
parents | 000f9136b8f7 |
children | f70d9508c95c |
line wrap: on
line diff
--- a/dwtx/jface/internal/text/revisions/RevisionPainter.d Sun Aug 24 22:41:48 2008 +0200 +++ b/dwtx/jface/internal/text/revisions/RevisionPainter.d Sun Aug 24 23:05:26 2008 +0200 @@ -98,7 +98,7 @@ /** * A strategy for painting the live annotate colors onto the vertical ruler column. It also manages * the revision hover. - * + * * @since 3.2 */ public final class RevisionPainter { @@ -109,7 +109,7 @@ private static const RGB BY_DATE_START_COLOR= new RGB(199, 134, 57); private static const RGB BY_DATE_END_COLOR= new RGB(241, 225, 206); - + /** * The annotations created to show a revision in the overview ruler. */ @@ -160,14 +160,14 @@ /** * Sets the revision information, which is needed to compute the relative age of a revision. - * + * * @param info the new revision info, <code>null</code> for none. */ public void setInfo(RevisionInformation info) { fRevisions= null; fColors.clear(); fFocusColors.clear(); - + if (info is null) return; List revisions= new ArrayList(); @@ -220,7 +220,7 @@ int index= fRevisions.indexOf(new Long(age)); return index; } - + private RGB getShadedColor(RGB color, float scale, bool focus) { Assert.isLegal(scale >= 0.0); Assert.isLegal(scale <= 1.0); @@ -252,7 +252,7 @@ /** * Returns the color for a revision based on relative age and author. - * + * * @param revision the revision * @param focus <code>true</code> to return the focus color * @return the color for a revision @@ -262,7 +262,7 @@ RGB color= cast(RGB) map.get(revision); if (color !is null) return color; - + color= adaptColor(revision, focus); map.put(revision, color); return color; @@ -275,7 +275,7 @@ private class MouseHandler : MouseMoveListener, MouseTrackListener, Listener { private RevisionRange fMouseDownRegion; - + private void handleMouseUp(Event e) { if (e.button is 1) { RevisionRange upRegion= fFocusRange; @@ -366,7 +366,7 @@ */ private static final class HoverInformationControlCreator : AbstractReusableInformationControlCreator { private bool fIsFocusable; - + public this(bool isFocusable) { fIsFocusable= isFocusable; } @@ -385,11 +385,11 @@ content= addCSSToHTMLFragment(content); super.setInformation(content); } - + /** * Adds a HTML header and CSS info if <code>html</code> is only an HTML fragment (has no * <html> section). - * + * * @param html the html / text produced by a revision * @return modified html */ @@ -398,14 +398,14 @@ if (html.substring(0, max).indexOf("<html>") !is -1) //$NON-NLS-1$ // there is already a header return html; - + StringBuffer info= new StringBuffer(512 + html.length()); HTMLPrinter.insertPageProlog(info, 0, fgStyleSheet); info.append(html); HTMLPrinter.addPageEpilog(info); return info.toString(); } - + }; } return new DefaultInformationControl(parent, fIsFocusable); @@ -451,12 +451,12 @@ "var { font-style: italic }\n" + //$NON-NLS-1$ "th { font-weight: bold }\n" + //$NON-NLS-1$ ""; //$NON-NLS-1$ - + /** * The revision hover displays information about the currently selected revision. */ private final class RevisionHover : IAnnotationHover, IAnnotationHoverExtension, IAnnotationHoverExtension2, IInformationProviderExtension2 { - + /* * @see dwtx.jface.text.source.IAnnotationHover#getHoverInfo(dwtx.jface.text.source.ISourceViewer, * int) @@ -633,7 +633,7 @@ /** * Creates a new revision painter for a vertical ruler column. - * + * * @param column the column that will delegate{@link #paint(GC, ILineRange) painting} to the * newly created painter. * @param sharedColors a shared colors object to store shaded colors in @@ -647,7 +647,7 @@ /** * Sets the revision information to be drawn and triggers a redraw. - * + * * @param info the revision information to show, <code>null</code> to draw none */ public void setRevisionInformation(RevisionInformation info) { @@ -666,7 +666,7 @@ /** * Changes the rendering mode and triggers redrawing if needed. - * + * * @param renderingMode the rendering mode * @since 3.3 */ @@ -681,7 +681,7 @@ /** * Sets the background color. - * + * * @param background the background color, <code>null</code> for the platform's list * background */ @@ -692,7 +692,7 @@ /** * Sets the parent ruler - the delegating column must call this method as soon as it creates its * control. - * + * * @param parentRuler the parent ruler */ public void setParentRuler(CompositeRuler parentRuler) { @@ -703,7 +703,7 @@ * Delegates the painting of the quick diff colors to this painter. The painter will draw the * color boxes onto the passed {@link GC} for all model (document) lines in * <code>visibleModelLines</code>. - * + * * @param gc the {@link GC} to draw onto * @param visibleLines the lines (in document offsets) that are currently (perhaps only * partially) visible @@ -724,14 +724,14 @@ } fAuthorInset= gc.stringExtent(new String(string)).x; } - + // recompute colors (show intense colors if ruler is narrow) int width= getWidth(); if (width !is fLastWidth) { fColorTool.setInfo(fRevisionInfo); fLastWidth= width; } - + // draw change regions List/* <RevisionRange> */ranges= getRanges(visibleLines); for (Iterator it= ranges.iterator(); it.hasNext();) { @@ -772,13 +772,13 @@ handleDispose(); } }); - + fRevisionSelectionProvider.install(fViewer); } /** * Returns <code>true</code> if the column is fully connected. - * + * * @return <code>true</code> if the column is fully connected, false otherwise */ private bool isConnected() { @@ -787,7 +787,7 @@ /** * Sets the annotation model. - * + * * @param model the annotation model, possibly <code>null</code> * @see IVerticalRulerColumn#setModel(IAnnotationModel) */ @@ -804,7 +804,7 @@ /** * Sets the annotation model. - * + * * @param model the annotation model. */ private void setAnnotationModel(IAnnotationModel model) { @@ -814,7 +814,7 @@ /** * Sets the line differ. - * + * * @param differ the line differ or <code>null</code> if none */ private void setDiffer(IAnnotationModel differ) { @@ -839,13 +839,13 @@ (cast(IAnnotationModel) fLineDiffer).removeAnnotationModelListener(fAnnotationListener); fLineDiffer= null; } - + fRevisionSelectionProvider.uninstall(); } /** * Paints a single change region onto <code>gc</code>. - * + * * @param range the range to paint * @param gc the {@link GC} to paint on */ @@ -915,16 +915,16 @@ */ int offset= fWidget.getOffsetAtLine(widgetLine); int widgetBaseline= fWidget.getBaseline(offset); - + FontMetrics fm = gc.getFontMetrics(); int fontBaseline = fm.getAscent() + fm.getLeading(); int baselineBias= widgetBaseline - fontBaseline; return Math.max(0, baselineBias); } - + /** * Looks up the color for a certain revision. - * + * * @param revision the revision to get the color for * @param focus <code>true</code> if it is the focus revision * @return the color for the revision @@ -936,7 +936,7 @@ /** * Returns the revision range that contains the given line, or * <code>null</code> if there is none. - * + * * @param line the line of interest * @return the corresponding <code>RevisionRange</code> or <code>null</code> */ @@ -961,7 +961,7 @@ /** * Returns the sublist of all <code>RevisionRange</code>s that intersect with the given lines. - * + * * @param lines the model based lines of interest * @return elementType: RevisionRange */ @@ -992,7 +992,7 @@ /** * Gets all change ranges of the revisions in the revision model and adapts them to the current * quick diff information. The list is cached. - * + * * @return the list of all change regions, with diff information applied */ private List getRangeCache() { @@ -1019,11 +1019,11 @@ private void clearRangeCache() { fRevisionRanges= null; } - + /** * Returns <code>true</code> if <code>range</code> contains <code>line</code>. A line is * not contained in a range if it is the range's exclusive end line. - * + * * @param range the range to check whether it contains <code>line</code> * @param line the line the line * @return <code>true</code> if <code>range</code> contains <code>line</code>, @@ -1035,7 +1035,7 @@ /** * Computes the end index of a line range. - * + * * @param range a line range * @return the last line (exclusive) of <code>range</code> */ @@ -1045,7 +1045,7 @@ /** * Returns the visible extent of a document line range in widget lines. - * + * * @param range the document line range * @return the visible extent of <code>range</code> in widget lines */ @@ -1083,7 +1083,7 @@ /** * Returns the revision hover. - * + * * @return the revision hover */ public IAnnotationHover getHover() { @@ -1094,7 +1094,7 @@ * Computes and returns the bounds of the rectangle corresponding to a widget line range. The * rectangle is in pixel coordinates relative to the text widget's * {@link StyledText#getClientArea() client area} and has the width of the ruler. - * + * * @param range the widget line range * @return the box bounds corresponding to <code>range</code> */ @@ -1111,7 +1111,7 @@ private void updateOverviewAnnotations() { if (fAnnotationModel is null) return; - + Revision revision= fFocusRevision !is null ? fFocusRevision : fSelectedRevision; Map added= null; @@ -1153,7 +1153,7 @@ /** * Returns the character offset based region of a line range. - * + * * @param lines the line range to convert * @return the character offset range corresponding to <code>range</code> * @throws BadLocationException if the line range is not within the document bounds @@ -1172,7 +1172,7 @@ /** * Handles the selection of a revision and informs listeners. - * + * * @param revision the selected revision, <code>null</code> for none */ void handleRevisionSelected(Revision revision) { @@ -1184,7 +1184,7 @@ /** * Handles the selection of a revision id and informs listeners - * + * * @param id the selected revision id */ void handleRevisionSelected(String id) { @@ -1206,7 +1206,7 @@ /** * Returns the selection provider. - * + * * @return the selection provider */ public RevisionSelectionProvider getRevisionSelectionProvider() { @@ -1215,7 +1215,7 @@ /** * Updates the focus line with a new line. - * + * * @param line the new focus line, -1 for no focus */ private void updateFocusLine(int line) { @@ -1225,13 +1225,13 @@ /** * Handles a changing focus line. - * + * * @param previousLine the old focus line (-1 for no focus) * @param nextLine the new focus line (-1 for no focus) */ private void onFocusLineChanged(int previousLine, int nextLine) { - if cast(DEBUG) - System.out_.println("line: " + previousLine + " > " + nextLine); //$NON-NLS-1$ //$NON-NLS-2$ + if (DEBUG) + System.out_.println("line: " ~ previousLine ~ " > " ~ nextLine); //$NON-NLS-1$ //$NON-NLS-2$ fFocusLine= nextLine; RevisionRange region= getRange(nextLine); updateFocusRange(region); @@ -1239,7 +1239,7 @@ /** * Updates the focus range. - * + * * @param range the new focus range, <code>null</code> for no focus */ private void updateFocusRange(RevisionRange range) { @@ -1249,12 +1249,12 @@ /** * Handles a changing focus range. - * + * * @param previousRange the old focus range (<code>null</code> for no focus) * @param nextRange the new focus range (<code>null</code> for no focus) */ private void onFocusRangeChanged(RevisionRange previousRange, RevisionRange nextRange) { - if cast(DEBUG) + if (DEBUG) System.out_.println("range: " + previousRange + " > " + nextRange); //$NON-NLS-1$ //$NON-NLS-2$ fFocusRange= nextRange; Revision revision= nextRange is null ? null : nextRange.getRevision(); @@ -1268,12 +1268,12 @@ /** * Handles a changing focus revision. - * + * * @param previousRevision the old focus revision (<code>null</code> for no focus) * @param nextRevision the new focus revision (<code>null</code> for no focus) */ private void onFocusRevisionChanged(Revision previousRevision, Revision nextRevision) { - if cast(DEBUG) + if (DEBUG) System.out_.println("revision: " + previousRevision + " > " + nextRevision); //$NON-NLS-1$ //$NON-NLS-2$ fFocusRevision= nextRevision; uninstallWheelHandler(); @@ -1305,7 +1305,7 @@ /** * Handles a mouse wheel event. - * + * * @param event the mouse wheel event */ private void handleMouseWheel(Event event) { @@ -1381,7 +1381,7 @@ /** * Translates a y coordinate in the pixel coordinates of the column's control to a document line * number. - * + * * @param y the y coordinate * @return the corresponding document line, -1 for no line * @see CompositeRuler#toDocumentLineNumber(int) @@ -1406,7 +1406,7 @@ /** * Returns the width of the column. - * + * * @return the width of the column */ private int getWidth() { @@ -1415,7 +1415,7 @@ /** * Returns the System background color for list widgets. - * + * * @return the System background color for list widgets */ private Color getBackground() { @@ -1426,7 +1426,7 @@ /** * Sets the hover later returned by {@link #getHover()}. - * + * * @param hover the hover */ public void setHover(IAnnotationHover hover) { @@ -1435,7 +1435,7 @@ /** * Returns <code>true</code> if the receiver can provide a hover for a certain document line. - * + * * @param activeLine the document line of interest * @return <code>true</code> if the receiver can provide a hover */ @@ -1445,7 +1445,7 @@ /** * Returns the revision at a certain document offset, or <code>null</code> for none. - * + * * @param offset the document offset * @return the revision at offset, or <code>null</code> for none */ @@ -1467,7 +1467,7 @@ /** * Returns <code>true</code> if a revision model has been set, <code>false</code> otherwise. - * + * * @return <code>true</code> if a revision model has been set, <code>false</code> otherwise */ public bool hasInformation() { @@ -1476,7 +1476,7 @@ /** * Returns the width in chars required to display information. - * + * * @return the width in chars required to display information * @since 3.3 */ @@ -1506,7 +1506,7 @@ /** * Enables showing the revision id. - * + * * @param show <code>true</code> to show the revision, <code>false</code> to hide it */ public void showRevisionId(bool show) { @@ -1517,10 +1517,10 @@ postRedraw(); } } - + /** * Enables showing the revision author. - * + * * @param show <code>true</code> to show the author, <code>false</code> to hide it */ public void showRevisionAuthor(bool show) { @@ -1534,7 +1534,7 @@ /** * Adds a revision listener. - * + * * @param listener the listener * @since 3.3 */ @@ -1544,7 +1544,7 @@ /** * Removes a revision listener. - * + * * @param listener the listener * @since 3.3 */ @@ -1554,7 +1554,7 @@ /** * Informs the revision listeners about a change. - * + * * @since 3.3 */ private void informListeners() {