Author: matt
Date: 2010-03-01 12:53:21 -0800 (Mon, 01 Mar 2010)
New Revision: 7187
Log:
Additions to the Database Editor.

Modified:
   branches/branch-1.3/fltk.db
   branches/branch-1.3/fluid/ide_support.cxx
   branches/branch-1.3/fluid/ide_support_ui.cxx
   branches/branch-1.3/fluid/ide_support_ui.fl
   branches/branch-1.3/fluid/ide_support_ui.h

Modified: branches/branch-1.3/fltk.db
===================================================================
--- branches/branch-1.3/fltk.db 2010-03-01 18:39:03 UTC (rev 7186)
+++ branches/branch-1.3/fltk.db 2010-03-01 20:53:21 UTC (rev 7187)
@@ -5,6 +5,9 @@
 [.]
 
 projectName:fltk
+databaseFormat:FLUID_IDE_DB
+databaseVersion:1.0
+projectVersion:1.3.0
 
 [./targets]
 
@@ -2199,6 +2202,9 @@
 
 refUUID:982AD0F7-700A-4C40-846E-A23239AB0E2D
 
+[./targets/tests/29FBDC99-F1CD-410A-BB9F-79B6853CF41F/sources]
+
+
 [./targets/tests/A80C35E8-4173-446F-9FE6-EED946E21370]
 
 name:file_chooser
@@ -2695,6 +2701,9 @@
 
 refUUID:982AD0F7-700A-4C40-846E-A23239AB0E2D
 
+[./targets/tests/29D8C656-F8D8-42A4-8D85-B5A3921E5E0A/sources]
+
+
 [./targets/tests/7B7BA865-F483-41BF-A34E-BF3C1DEC5AD0]
 
 name:input
@@ -3211,6 +3220,9 @@
 
 refUUID:982AD0F7-700A-4C40-846E-A23239AB0E2D
 
+[./targets/tests/20E51515-F82E-4C0D-8D21-84F90CCEB1EB/sources]
+
+
 [./targets/tests/8BA2602D-F8DD-4F78-8AB6-76DF41D29099]
 
 name:radio
@@ -3240,6 +3252,9 @@
 
 refUUID:982AD0F7-700A-4C40-846E-A23239AB0E2D
 
+[./targets/tests/8BA2602D-F8DD-4F78-8AB6-76DF41D29099/sources]
+
+
 [./targets/tests/DDD31943-5ED5-4CCF-A4D6-6494416A4A23]
 
 name:resizebox
@@ -3294,6 +3309,9 @@
 
 refUUID:982AD0F7-700A-4C40-846E-A23239AB0E2D
 
+[./targets/tests/BF668CC8-BD77-4440-8A9C-504BBE5C555F/sources]
+
+
 [./targets/tests/169ADBF8-D7E5-4CDC-92EC-D0660F23AFBB]
 
 name:scroll
@@ -3541,6 +3559,9 @@
 
 refUUID:982AD0F7-700A-4C40-846E-A23239AB0E2D
 
+[./targets/tests/C8EBC9CF-2CA1-46D3-ADEF-F0B768294B7F/sources]
+
+
 [./targets/tests/C512D026-C885-46F5-A955-0EC64BD96CF7]
 
 name:threads
@@ -3719,6 +3740,9 @@
 
 refUUID:982AD0F7-700A-4C40-846E-A23239AB0E2D
 
+[./targets/tests/84764B86-38CA-48AC-B49D-0101411A3C5D/sources]
+
+
 [./files]
 
 

Modified: branches/branch-1.3/fluid/ide_support.cxx
===================================================================
--- branches/branch-1.3/fluid/ide_support.cxx   2010-03-01 18:39:03 UTC (rev 
7186)
+++ branches/branch-1.3/fluid/ide_support.cxx   2010-03-01 20:53:21 UTC (rev 
7187)
@@ -331,7 +331,10 @@
   // the db, we have to do that manually!
   //db->clear();
   
+  db->set("databaseFormat", "FLUID_IDE_DB");
+  db->set("databaseVersion", "1.0");
   db->set("projectName", "fltk");
+  db->set("projectVersion", "1.3.0");
   
   Fl_Preferences targets_db(db, "targets");
   Fl_IDE_Prefs files_db(*db, "files");
@@ -1135,8 +1138,83 @@
 
 void ui_load_database(const char *filename)
 {
+  char buf[1024];
+  float v = 0.0f;
+  int i, j;
+  
+  // FIXME: must be global, so we can close it
   Fl_Preferences *db = new Fl_Preferences(filename, "fltk.org", 0);
-  db->copyTo(dbmanager_tree);
+
+  // Check if this is a database
+  if (db->entries()==0) {
+    fl_alert("%s\nis not a database", filename);
+    delete db;
+    return;
+  }
+  
+  // Check if the database has the correct format
+  if (!db->entryExists("databaseFormat")) {
+    fl_alert("%s\nis not a Fluid database", filename);
+    delete db;
+    return;
+  }
+  db->get("databaseFormat", buf, "", 1024);
+  if (strcmp(buf, "FLUID_IDE_DB")!=0) {
+    fl_alert("%s\nis not a Fluid IDE database", filename);
+    delete db;
+    return;
+  }
+  db->get("databaseVersion", buf, "", 1024);
+  sscanf(buf, "%f", &v);
+  if (v>1.0f) {
+    fl_alert("The Fluid IDE database\n%s\nversion %f is not suported.", 
filename, v);
+    delete db;
+    return;
+  }
+  
+  // set the dialog label to the project name
+  char *name; db->get("projectName", name, "unnamed");
+  char *vers; db->get("projectVersion", vers, "0.1");
+  sprintf(buf, "%s V%s", name, vers);
+  dbmanager_window->label(buf);
+  free(vers); free(name);
+  
+  Fl_Preferences targetsDB(db, "targets");
+  Fl_Preferences filesDB(db, "files");
+  Fl_Tree_Item *ti;
+  
+  // load all tests
+  ti = dbmanager_tree->add("Applications");
+  
+  // load all tests
+  ti = dbmanager_tree->add("Libraries & Frameworks");
+  
+  // load all tests
+  ti = dbmanager_tree->add("Test Applications");
+  Fl_Preferences testsDB(targetsDB, "tests");
+  for (i=0; i<testsDB.groups(); i++) {
+    Fl_Preferences testDB(testsDB, i);
+    testDB.get("name", buf, "DB-Error", 1024);
+    Fl_Tree_Item *tt = dbmanager_tree->add(ti, buf); tt->close();
+    
+    if (testDB.groupExists("sources")) {
+      Fl_Tree_Item *ts = dbmanager_tree->add(tt, "Sources"); ts->close();
+      Fl_Preferences srcsDB(testDB, "sources");
+      for (j=0; j<srcsDB.groups(); j++) {
+        Fl_Preferences srcDB(srcsDB, j);
+        srcDB.get("refUUID", buf, "DBERROR", 1024);
+        Fl_File_Prefs fileDB(filesDB, buf);
+        Fl_Tree_Item *tb = dbmanager_tree->add(ts, fileDB.fullName());
+        tb->user_data(0L); // TODO: add the callback information here
+      }
+    }
+    
+    //ts = dbmanager_tree->add(tt, "Dependencies");
+    //ts = dbmanager_tree->add(tt, "Libraries");
+    //ts = dbmanager_tree->add(tt, "Externals");
+  }
+  
+
   dbmanager_tree->redraw();
   delete db;
 }
@@ -1175,6 +1253,7 @@
   void show_panel() {
     if (!dbmanager_window)
       make_dbmanager_window();
+    dbmanager_window->label("IDE Database Manager");
     dbmanager_window->show();
   }
 };

Modified: branches/branch-1.3/fluid/ide_support_ui.cxx
===================================================================
--- branches/branch-1.3/fluid/ide_support_ui.cxx        2010-03-01 18:39:03 UTC 
(rev 7186)
+++ branches/branch-1.3/fluid/ide_support_ui.cxx        2010-03-01 20:53:21 UTC 
(rev 7187)
@@ -33,24 +33,25 @@
 
 Fl_Double_Window *dbmanager_window=(Fl_Double_Window *)0;
 
-static void cb_fileopen(Fl_Button*, void*) {
+Fl_Tree *dbmanager_tree=(Fl_Tree *)0;
+
+static void cb_Open(Fl_Button*, void*) {
   const char *filename = fl_file_chooser("Load Database", "*.db", 0, 0);
 if (filename) {
   ui_load_database(filename);
 };
 }
 
-Fl_Tree *dbmanager_tree=(Fl_Tree *)0;
+static void cb_New(Fl_Button*, void*) {
+  const char *filename = fl_file_chooser("Load Database", "*.db", 0, 0);
+if (filename) {
+  ui_load_database(filename);
+};
+}
 
 Fl_Double_Window* make_dbmanager_window() {
-  { dbmanager_window = new Fl_Double_Window(409, 510);
-    { new Fl_File_Input(80, 4, 280, 36, "Database:");
-    } // Fl_File_Input* o
-    { Fl_Button* o = new Fl_Button(360, 14, 36, 26, "@fileopen");
-      o->labelcolor((Fl_Color)94);
-      o->callback((Fl_Callback*)cb_fileopen);
-    } // Fl_Button* o
-    { dbmanager_tree = new Fl_Tree(12, 52, 208, 444);
+  { dbmanager_window = new Fl_Double_Window(427, 500);
+    { dbmanager_tree = new Fl_Tree(8, 8, 200, 480);
       dbmanager_tree->box(FL_DOWN_BOX);
       dbmanager_tree->color((Fl_Color)55);
       dbmanager_tree->selection_color(FL_BACKGROUND_COLOR);
@@ -64,18 +65,27 @@
       dbmanager_tree->showroot(0);
       dbmanager_tree->labelsize(12);
     } // Fl_Tree* dbmanager_tree
-    { Fl_Group* o = new Fl_Group(232, 52, 164, 444);
-      { new Fl_Button(304, 468, 92, 28, "Close");
-      } // Fl_Button* o
-      { Fl_Group* o = new Fl_Group(232, 128, 164, 340);
+    { Fl_Group* o = new Fl_Group(216, 8, 200, 444);
+      o->box(FL_ENGRAVED_BOX);
+      { Fl_Group* o = new Fl_Group(224, 271, 184, 172);
         o->end();
         Fl_Group::current()->resizable(o);
       } // Fl_Group* o
-      { Fl_Box* o = new Fl_Box(232, 52, 164, 76, "Show editor\nfor 
selected\nItem here");
+      { Fl_Box* o = new Fl_Box(224, 108, 184, 160, "Show editor\nfor 
selected\nItem here");
         o->box(FL_THIN_DOWN_BOX);
       } // Fl_Box* o
+      { Fl_Button* o = new Fl_Button(242, 60, 148, 28, "Open Database...");
+        o->callback((Fl_Callback*)cb_Open);
+      } // Fl_Button* o
+      { Fl_Button* o = new Fl_Button(242, 24, 148, 28, " (New Database... )");
+        o->callback((Fl_Callback*)cb_New);
+        o->deactivate();
+      } // Fl_Button* o
       o->end();
     } // Fl_Group* o
+    { Fl_Button* o = new Fl_Button(324, 460, 92, 28, "( Close )");
+      o->deactivate();
+    } // Fl_Button* o
     dbmanager_window->end();
   } // Fl_Double_Window* dbmanager_window
   return dbmanager_window;

Modified: branches/branch-1.3/fluid/ide_support_ui.fl
===================================================================
--- branches/branch-1.3/fluid/ide_support_ui.fl 2010-03-01 18:39:03 UTC (rev 
7186)
+++ branches/branch-1.3/fluid/ide_support_ui.fl 2010-03-01 20:53:21 UTC (rev 
7187)
@@ -37,49 +37,53 @@
 decl {\#include "ide_support.h"} {private global
 } 
 
-decl {\#include <FL/Fl_File_Chooser.H>} {selected private global
+decl {\#include <FL/Fl_File_Chooser.H>} {private global
 } 
 
 Function {make_dbmanager_window()} {open
 } {
   Fl_Window dbmanager_window {open
-    xywh {459 167 409 510} type Double resizable visible
+    xywh {459 167 427 500} type Double resizable visible
   } {
-    Fl_File_Input {} {
-      label {Database:}
-      xywh {80 4 280 36}
-    }
-    Fl_Button {} {
-      label {...@fileopen}
-      callback {const char *filename = fl_file_chooser("Load Database", 
"*.db", 0, 0);
-if (filename) {
-  ui_load_database(filename);
-}}
-      xywh {360 14 36 26} labelcolor 94
-    }
     Fl_Box dbmanager_tree {
-      xywh {12 52 208 444} box DOWN_BOX color 55 resizable
+      xywh {8 8 200 480} box DOWN_BOX color 55 resizable
       code0 {dbmanager_tree->showroot(0);}
       code1 {dbmanager_tree->labelsize(12);}
       class Fl_Tree
     }
     Fl_Group {} {open
-      xywh {232 52 164 444}
+      xywh {216 8 200 444} box ENGRAVED_BOX
     } {
-      Fl_Button {} {
-        label Close
-        xywh {304 468 92 28}
-      }
       Fl_Group {} {open
-        xywh {232 128 164 340} resizable
+        xywh {224 271 184 172} resizable
       } {}
       Fl_Box {} {
         label {Show editor
 for selected
 Item here}
-        xywh {232 52 164 76} box THIN_DOWN_BOX
+        xywh {224 108 184 160} box THIN_DOWN_BOX
       }
+      Fl_Button {} {
+        label {Open Database...}
+        callback {const char *filename = fl_file_chooser("Load Database", 
"*.db", 0, 0);
+if (filename) {
+  ui_load_database(filename);
+}}
+        xywh {242 60 148 28}
+      }
+      Fl_Button {} {
+        label { (New Database... )}
+        callback {const char *filename = fl_file_chooser("Load Database", 
"*.db", 0, 0);
+if (filename) {
+  ui_load_database(filename);
+}} selected
+        xywh {242 24 148 28} deactivate
+      }
     }
+    Fl_Button {} {
+      label {( Close )}
+      xywh {324 460 92 28} deactivate
+    }
   }
 } 
 

Modified: branches/branch-1.3/fluid/ide_support_ui.h
===================================================================
--- branches/branch-1.3/fluid/ide_support_ui.h  2010-03-01 18:39:03 UTC (rev 
7186)
+++ branches/branch-1.3/fluid/ide_support_ui.h  2010-03-01 20:53:21 UTC (rev 
7187)
@@ -33,11 +33,10 @@
 #include <FL/Fl_Tree.H>
 #include <FL/Fl_Double_Window.H>
 extern Fl_Double_Window *dbmanager_window;
-#include <FL/Fl_File_Input.H>
-#include <FL/Fl_Button.H>
 extern Fl_Tree *dbmanager_tree;
 #include <FL/Fl_Group.H>
 #include <FL/Fl_Box.H>
+#include <FL/Fl_Button.H>
 Fl_Double_Window* make_dbmanager_window();
 #endif
 

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to