Fumbled around trying to solve problem of red squigglies only showing up on first...
authorp.ciardelli <p.ciardelli@localhost>
Tue, 18 Nov 2008 10:03:09 +0000 (10:03 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Tue, 18 Nov 2008 10:03:09 +0000 (10:03 +0000)
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/ErrorAnnotation.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameViewer.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/ReferenceSearchDialog.java

index 4280ead943628193344e19d7c0f79bd72b034542..a8d3ba780fe89f13252901411f2041a5eefed6f2 100644 (file)
@@ -22,7 +22,8 @@ public class ErrorAnnotation extends Annotation {
     }\r
 \r
     public ErrorAnnotation(int line, String text) {\r
-        super(ERROR_TYPE, true, null);\r
+//        super(ERROR_TYPE, true, text);\r
+       super(ERROR_TYPE, false, text);\r
         this.marker = null;\r
         this.line = line;\r
         this.text = text;\r
index 7ac28eaf32ae2ade22affb752c5a6df01206fefd..dab5edd36c6a922fbd80ea2d6f9e02d52a437311 100644 (file)
@@ -61,7 +61,10 @@ public class NameViewer extends SourceViewer {
                super(parent, null, SWT.WRAP | SWT.MULTI | SWT.RESIZE);\r
                                                        \r
                // Set name viewer's text to name cache\r
-               this.setDocument(new NameViewerDocument(""), new AnnotationModel());\r
+               AnnotationModel model = new AnnotationModel();\r
+               NameViewerDocument document = new NameViewerDocument("");\r
+               this.setDocument(document, model);\r
+//             model.connect(document);\r
 \r
                // Lay out StyledText\r
                StyledText textWidget = this.getTextWidget();\r
@@ -85,8 +88,6 @@ public class NameViewer extends SourceViewer {
                \r
                this.addPainter(annotationPainter);\r
                \r
-               this.getTextWidget().getLineCount();\r
-               \r
 //             DocumentUndoManagerRegistry.connect(this.getDocument());\r
 //             IDocumentUndoManager docUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(this.getDocument());\r
                \r
@@ -98,25 +99,46 @@ public class NameViewer extends SourceViewer {
 \r
        }\r
        \r
+       /**\r
+        * NOTE: possible solution to problem of one-lined red squigglies:\r
+        * AnnotationPainter uses an internal SquigglesStrategy which draws a \r
+        * polyline consisting of diagonal lines; this assumes one line;\r
+        * re-program to catch more than one lines, using \r
+        * this.getTextWidget().getLocationAtOffset to find linecount.\r
+        * \r
+        * @param hasProblem\r
+        */\r
        public void setShowError(boolean hasProblem) {\r
-                               \r
+               \r
                String text = this.getTextWidget().getText();\r
                \r
+               logger.warn(this.getTextWidget().getBaseline(0));\r
+               logger.warn(this.getTextWidget().getLocationAtOffset(60));\r
+               \r
+               if (text.length() > 0) {\r
+                       logger.warn(this.getTextWidget().getTextBounds(0, text.length()));\r
+               }\r
+               \r
                Iterator<Annotation> annotations = this.getAnnotationModel().getAnnotationIterator();\r
                while (annotations.hasNext()) {\r
                        Annotation annotation = annotations.next(); \r
                        if (annotation.getType().equals(ErrorAnnotation.ERROR_TYPE))\r
+                               annotation.markDeleted(true);\r
                                this.getAnnotationModel().removeAnnotation(annotation);\r
                }\r
                \r
                if (hasProblem && text.length() > 0) {\r
+//                     this.getAnnotationModel().addAnnotation(\r
+//                                     new ErrorAnnotation(0, text), \r
+//                                     new Position(0, text.length()));\r
+//                     this.getAnnotationModel().addAnnotation(\r
+//                                     new ErrorAnnotation(0, text), \r
+//                                     new Position(0, 40));\r
                        this.getAnnotationModel().addAnnotation(\r
-                                       new ErrorAnnotation(0, "Could not parse."), \r
-                                       new Position(0, text.length()));\r
+                                       new ErrorAnnotation(0, text), \r
+                                       new Position(39, text.length()));                               \r
+                       \r
                }\r
-               \r
-//             ILineTracker tracker = ((NameViewerDocument) this.getDocument()).getTracker();\r
-//             tracker.\r
        }\r
        \r
        public void setLineBreakListener(LineBreakListener lineBreakListener) {\r
@@ -217,4 +239,8 @@ public class NameViewer extends SourceViewer {
                        }\r
                }\r
        }\r
+       \r
+//     public boolean isMultiLine(Annotation annotation) {\r
+//         return true;\r
+//     }\r
 }\r
index 3cec70f5c186045a939c8ddc0b7eb497ea9be6f5..b28818a9d27fabf85ddc3d64991044f324997b53 100644 (file)
@@ -19,12 +19,10 @@ import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.events.KeyAdapter;\r
 import org.eclipse.swt.events.KeyEvent;\r
-import org.eclipse.swt.events.KeyListener;\r
 import org.eclipse.swt.events.MouseAdapter;\r
 import org.eclipse.swt.events.MouseEvent;\r
 import org.eclipse.swt.events.SelectionAdapter;\r
 import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.VerifyEvent;\r
 import org.eclipse.swt.layout.GridData;\r
 import org.eclipse.swt.layout.GridLayout;\r
 import org.eclipse.swt.widgets.Button;\r