Version for WGB.
authorp.ciardelli <p.ciardelli@localhost>
Wed, 9 Sep 2009 09:30:35 +0000 (09:30 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Wed, 9 Sep 2009 09:30:35 +0000 (09:30 +0000)
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/NameComposite.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/NameViewer.java

index f7311c76b787dd127f335505a3b0d6b240c4ed74..bada0fdfa531d486db9593252afb41c78c2986b5 100644 (file)
@@ -287,12 +287,13 @@ public abstract class NameComposite<T extends TaxonBase> extends GroupedComposit
        \r
        public abstract void setName(TaxonNameBase name);\r
        \r
-       protected void calculateErrors() {\r
+       synchronized protected void calculateErrors() {\r
                textViewer.clearErrors();\r
                \r
                TaxonNameBase name = getParsedName() != null ? getParsedName() : getName();\r
                \r
-               textViewer.setShowParsingErrors(name);\r
+//             textViewer.setShowParsingErrors(name);\r
+               textViewer.setShowParsingError(name);\r
        }\r
 \r
        protected void handleSplitText(String text) {\r
index 01bb241e1aea2f81862566feba634ac29fdd486c..a2856fbcf0f9bdbe45d1e6fb931f668160971053 100644 (file)
@@ -180,6 +180,10 @@ public class NameViewer extends SourceViewer {
                \r
 //             testMarkers();\r
                \r
+               if (0 == 0) {\r
+                       return;\r
+               }\r
+               \r
                for (ParserProblem problem : name.getParsingProblems()) {\r
                        \r
 //                     boolean hasProblem = name.getHasProblem();\r
@@ -209,12 +213,12 @@ public class NameViewer extends SourceViewer {
                        }\r
 \r
                        Annotation annotation = null;\r
-                       if (problem.isWarning()) {\r
-                               annotation = new WarningAnnotation(0, problem.toString());\r
-                       }\r
-//                     if (problem.isError()) {\r
-//                             annotation = new ErrorAnnotation(0, problem.toString());\r
+//                     if (problem.isWarning()) {\r
+//                             annotation = new WarningAnnotation(0, problem.toString());\r
 //                     }\r
+                       if (problem.isError()) {\r
+                               annotation = new ErrorAnnotation(0, problem.toString());\r
+                       }\r
                        \r
                        this.getAnnotationModel().addAnnotation(\r
                                        annotation, \r
@@ -223,6 +227,37 @@ public class NameViewer extends SourceViewer {
                }\r
        }\r
 \r
+       public void setShowParsingError(TaxonNameBase<?, ?> name) {\r
+               \r
+//             testMarkers();\r
+               \r
+               if (!name.hasProblem()) {\r
+                       logger.debug(name.getProblemStarts());\r
+               }\r
+               \r
+               String text = this.getTextWidget().getText();\r
+                                               \r
+               if (name.hasProblem() && text.length() > 0) {\r
+//                     logger.warn("Name: " + name.getTitleCache() + ", start: " + name.getProblemStarts()+ ", end: " + name.getProblemEnds());\r
+                       int start = name.getProblemStarts();\r
+                       int length = name.getProblemEnds() - start;\r
+                       \r
+                       if (start == -1 || name.getProblemEnds() == -1) {\r
+//                             logger.warn("Start: " + start + ", End " + name.getProblemEnds());\r
+                               return;\r
+                       }\r
+                       \r
+                       // Don't let squigglies try to draw beyond the end of the text\r
+                       if (text.length() < start + length) {\r
+                               length = text.length() - start;\r
+                       }\r
+                       \r
+                       this.getAnnotationModel().addAnnotation(\r
+                                       new ErrorAnnotation(0, "Error parsing string '" + text + "'"), \r
+                                       new Position(start, length));\r
+               }\r
+       }\r
+       \r
        public void setShowSecError(Taxon taxon) {\r
                \r
                // If taxon has no sec, show an annotation\r