[libgda] GdaBrowser's Data manager perspective improvements



commit 8c32acf9db4853ee5a5773355b39953ca6f49b7d
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Apr 1 21:16:49 2010 +0200

    GdaBrowser's Data manager perspective improvements

 tools/browser/canvas/browser-canvas-db-relations.c |    8 ++++--
 tools/browser/data-manager/data-console.c          |    2 +-
 tools/browser/data-manager/data-source.c           |   22 ++++++++++----------
 tools/browser/data-manager/spec-editor.c           |    6 ++++-
 4 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/tools/browser/canvas/browser-canvas-db-relations.c b/tools/browser/canvas/browser-canvas-db-relations.c
index b9a6e44..ed9bc99 100644
--- a/tools/browser/canvas/browser-canvas-db-relations.c
+++ b/tools/browser/canvas/browser-canvas-db-relations.c
@@ -683,9 +683,11 @@ browser_canvas_db_relations_items_to_data_manager (BrowserCanvasDbRelations *can
 				GooCanvasItem *fk_item;
 				
 				fk_item = g_hash_table_lookup (canvas->priv->hash_fkeys, fk);
-				if (fk_item)
-					xmlNewChild (node, NULL, BAD_CAST "link_with",
-						     BAD_CAST fk->depend_on->obj_short_name);
+				if (fk_item) {
+					node = xmlNewChild (node, NULL, BAD_CAST "depend", NULL);
+					xmlSetProp (node, BAD_CAST "foreign_key_table",
+						    BAD_CAST fk->depend_on->obj_short_name);
+				}
 			}
 
 		}
diff --git a/tools/browser/data-manager/data-console.c b/tools/browser/data-manager/data-console.c
index 769198e..0f49e0d 100644
--- a/tools/browser/data-manager/data-console.c
+++ b/tools/browser/data-manager/data-console.c
@@ -266,7 +266,7 @@ data_console_new (BrowserConnection *bcnc)
 "\n    <!-- specifies that we want the contents of the 'orders' table, where the order ID \n" \
 "         depends on the selected customer's ID -->\n"						\
 "    <table name=\"orders\">\n" \
-"        <link_with>customers</link_with>\n" \
+"        <depend foreign_key_table=\"customers\"/>\n" \
 "    </table>\n" \
 "\n    <!-- specifies that we want the result of the execution of a SELECT query, notice the WHERE clause\n" \
 "          which enables to filter on the previously selected order ID-->\n" \
diff --git a/tools/browser/data-manager/data-source.c b/tools/browser/data-manager/data-source.c
index aae9c9c..af9205a 100644
--- a/tools/browser/data-manager/data-source.c
+++ b/tools/browser/data-manager/data-source.c
@@ -448,14 +448,14 @@ init_from_table_node (DataSource *source, xmlNodePtr node, GError **error)
 	/* linking */
 	xmlNodePtr subnode;
 	for (subnode = node->children; subnode; subnode = subnode->next) {
-		if (!strcmp ((gchar*)subnode->name, "link_with")) {
-			xmlChar *contents, *id;
+		if (!strcmp ((gchar*)subnode->name, "depend")) {
+			xmlChar *fk_table, *id;
 			GdaMetaTable *mlinked;
 			
-			contents = xmlNodeGetContent (subnode);
-			mlinked = get_meta_table (source, (gchar*) contents, error);
+			fk_table = xmlGetProp (subnode, BAD_CAST "foreign_key_table");
+			mlinked = get_meta_table (source, (gchar*) fk_table, error);
 			if (!mlinked) {
-				xmlFree (contents);
+				xmlFree (fk_table);
 				g_object_unref (b);	
 				return FALSE;
 			}
@@ -471,8 +471,8 @@ init_from_table_node (DataSource *source, xmlNodePtr node, GError **error)
 			}
 			if (!fk) {
 				g_set_error (error, 0, 0,
-					     _("Could not find any foreign key to \"%s\""), (gchar*) contents);
-				xmlFree (contents);
+					     _("Could not find any foreign key to \"%s\""), (gchar*) fk_table);
+				xmlFree (fk_table);
 				if (id) xmlFree (id);
 				g_object_unref (b);	
 				return FALSE;
@@ -480,8 +480,8 @@ init_from_table_node (DataSource *source, xmlNodePtr node, GError **error)
 			else if (fk->cols_nb <= 0) {
 				g_set_error (error, 0, 0,
 					     _("The fields involved in the foreign key to \"%s\" are not known"),
-					     (gchar*) contents);
-				xmlFree (contents);
+					     (gchar*) fk_table);
+				xmlFree (fk_table);
 				if (id) xmlFree (id);
 				g_object_unref (b);	
 				return FALSE;
@@ -492,7 +492,7 @@ init_from_table_node (DataSource *source, xmlNodePtr node, GError **error)
 				col = GDA_META_TABLE_COLUMN (g_slist_nth_data (mlinked->columns, fk->fk_cols_array [0]));
 				g_assert (col);
 				gda_sql_builder_add_id (b, 1, fk->fk_names_array [0]);
-				tmp = g_strdup_printf ("%s %s", id ? (gchar*) id : (gchar*) contents,
+				tmp = g_strdup_printf ("%s %s", id ? (gchar*) id : (gchar*) fk_table,
 						       fk->ref_pk_names_array [0]);
 				gda_sql_builder_add_param (b, 2, tmp, col->gtype, FALSE);
 				g_free (tmp);
@@ -503,7 +503,7 @@ init_from_table_node (DataSource *source, xmlNodePtr node, GError **error)
 				TO_IMPLEMENT;
 			}
 
-			xmlFree (contents);
+			xmlFree (fk_table);
 			if (id)
 				xmlFree (id);
 			break;
diff --git a/tools/browser/data-manager/spec-editor.c b/tools/browser/data-manager/spec-editor.c
index abf7964..cbfdbeb 100644
--- a/tools/browser/data-manager/spec-editor.c
+++ b/tools/browser/data-manager/spec-editor.c
@@ -178,8 +178,12 @@ static void help_expand_cb (GtkWidget *exp, SpecEditor *sped)
 			  " - <span foreground=\"#4e9a06\">\"title\"</span> to specify a title.\n\n" \
 			  "Use the <span foreground=\"#4e9a06\"><tt>&lt;query&gt;</tt></span> tag to specify an SQL SELECT statement, as the contents of the tag. Linkage to other\n" \
 			  "data sources can be achieved using variables in the SELECT's SQL.\n\n" \
-			  "Use the <span foreground=\"#4e9a06\"><tt>&lt;table&gt;</tt></span> tag to define a data source which will display the contents of a table. This tag:\n" \
+			  "Use the <span foreground=\"#4e9a06\"><tt>&lt;table&gt;</tt></span> node to define a data source which will display the contents of a table. This tag:\n" \
 			  " - requires the <span foreground=\"#4e9a06\">\"name\"</span> attribute which represents the table name.\n" \
+			  " - can contain a <span foreground=\"#4e9a06\"><tt>&lt;depend&gt;</tt></span> node which defines a dependency on another data source with the \n" \
+			  "   <span foreground=\"#4e9a06\">\"foreign_key_table\"</span> attribute defining the name of the table to which there are foreign keys\n" \
+			  "   used to determine the dependency, and the <span foreground=\"#4e9a06\">\"id\"</span> attribute can specify a data source ID if different than\n" \
+			  "   the aforementioned table.\n"			\
 			  "</small>")
 	if (! sped->priv->help) {
 		sped->priv->help = gtk_label_new ("");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]