fix remove css for error tree
[roobuilder] / src / Builder4 / WindowLeftProps.bjs
index 369cd6a..90cd323 100644 (file)
@@ -18,6 +18,7 @@
    "bool loading" : false,
    "bool vexpand" : true,
    "id" : "LeftProps",
+   "int last_error_counter" : "-1",
    "items" : [
     {
      "$ xns" : "Gtk",
           "\t ",
           "}"
          ],
+         "| int propToRow" : [
+          "(JsRender.NodeProp prop) {",
+          "\tfor (var i = 0 ; i < this.el.n_items; i++) {",
+          "\t\tvar r = (JsRender.NodeProp)this.el.get_item(i);",
+          "\t\tif (r.equals(prop)) {",
+          "\t\t\treturn i;",
+          "\t\t\t",
+          "\t\t}",
+          "\t}",
+          "\treturn -1;",
+          "\t ",
+          "}"
+         ],
          "| void selectProp" : [
           "(JsRender.NodeProp prop) {",
           "\tfor (var i = 0 ; i < this.el.n_items; i++) {",
         "\t\t\t\t}",
         "\t\t\t\tchild = child.get_first_child(); ",
         "\t\t\t\treading_header = false;",
+        "\t\t\t\tcontinue;",
         "\t        }",
         "\t\t    if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
         "    \t\t    child = child.get_next_sibling();",
     "   ",
     "   \tthis.loading = false;",
     "    this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
+    "    this.updateErrors();",
     "   // clear selection?",
     "  //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..",
     "   ",
     "   ",
     "}",
     ""
+   ],
+   "| void removeErrors" : [
+    "() {",
+    "\tvar  child = this.view.el.get_first_child(); ",
+    " ",
+    "\tvar reading_header = true;",
+    " ",
+    "\twhile (child != null) {",
+    "\t\tGLib.debug(\"Got %s\", child.get_type().name());",
+    "\t   ",
+    "\t   if (reading_header) {",
+    "\t\t\t",
+    "",
+    "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
+    "\t\t\t   ",
+    "\t\t\t\tchild = child.get_next_sibling();",
+    "\t\t\t\tcontinue;",
+    "\t\t\t}",
+    "\t\t\t// should be columnlistview",
+    "\t\t\tchild = child.get_first_child(); ",
+    "\t\t ",
+    "\t\t ",
+    "\t\t\t",
+    "\t\t\treading_header = false;",
+    "\t\t\t ",
+    "\t    }",
+    "\t    ",
+    "\t  \tif (child.has_css_class(\"node-err\")) {",
+    "\t\t\tchild.remove_css_class(\"node-err\");",
+    "\t\t}",
+    "\t\tif (child.has_css_class(\"node-warn\")) {",
+    "\t\t\tchild.remove_css_class(\"node-warn\");",
+    "\t\t}",
+    "\t\t",
+    "\t\tif (child.has_css_class(\"node-depr\")) {",
+    "\t\t\tchild.remove_css_class(\"node-depr\");",
+    "\t\t}",
+    "\t\t",
+    "        child = child.get_next_sibling(); ",
+    "\t}",
+    "\t//GLib.debug(\"Rturning null\");",
+    "     ",
+    "}"
+   ],
+   "| void updateErrors" : [
+    "() {",
+    "\tvar file = this.file;",
+    "\tvar ar = file.getErrors();",
+    "\tif (ar.size < 1) {",
+    "\t\tthis.removeErrors();",
+    "\t\tthis.last_error_counter = file.error_counter ;",
+    "",
+    "\t\treturn;",
+    "\t}",
+    " \tif (this.last_error_counter == file.error_counter) {",
+    "\t\treturn;",
+    "\t}",
+    "\tthis.removeErrors();",
+    "\t",
+    "\tforeach(var diag in ar) { ",
+    "\t",
+    "\t\t ",
+    "//        print(\"get inter\\n\");",
+    "\t    var node= file.lineToNode( (int)diag.range.start.line) ;",
+    "\t    if (node == null || node.oid != this.node.oid) {",
+    "\t    \tcontinue;",
+    "    \t}",
+    "    \tvar prop = node.lineToProp( (int)diag.range.start.line) ;",
+    "    \t",
+    "    \tvar row = _this.selmodel.propToRow(prop);",
+    "    \tif (row < 0) {",
+    "    \t\tcontinue;",
+    "\t\t}",
+    "    \tvar w = this.view.getWidgetAtRow(row);",
+    "    \tif (w == null) {",
+    "    \t\treturn;",
+    "\t\t}",
+    "\t  \t\tvar ed = diag.category.down();",
+    "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
+    "\t\t\tcontinue;",
+    "\t\t}",
+    "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
+    "\t\t\tw.remove_css_class(\"node-warn\");",
+    "\t\t}",
+    "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
+    "\t\t\tw.remove_css_class(\"node-depr\");",
+    "\t\t}",
+    "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
+    "\t\t\tw.add_css_class(\"node-\" + ed);",
+    "\t\t}",
+    "\t\t",
+    "\t}",
+    "\t",
+    "}"
    ]
   }
  ],