Mercurial > hg > ltpda
diff m-toolbox/classes/@workspaceBrowser/cb_query.m @ 30:317b5f447f3e database-connection-manager
Update workspaceBrowser
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line diff
--- a/m-toolbox/classes/@workspaceBrowser/cb_query.m Mon Dec 05 16:20:06 2011 +0100 +++ b/m-toolbox/classes/@workspaceBrowser/cb_query.m Mon Dec 05 16:20:06 2011 +0100 @@ -9,27 +9,19 @@ function cb_query(varargin) wb = getappdata(0, 'WorkspaceBrowser'); - - % Get a connection from the repository manager - rm = LTPDARepositoryManager; - conn = rm.manager.selectConnection([]); + + % Get a connection from the database connection manager + conn = LTPDADatabaseConnectionManager().connect(); + + % Get submission info from the user + rqd = awtcreate('mpipeline.repository.RepositoryQueryDialog', 'Lmpipeline.main.MainWindow;ZLjava.sql.Connection;Z', [], false, conn, false); + awtinvoke(rqd, 'setVisible', 'true'); + + hExec = handle(rqd.getExecuteBtn(),'callbackproperties'); + hExec.ActionPerformedCallback = @cb_executeQuery; - if ~isempty(conn) - % Update - if ~isempty(rm.gui) - awtinvoke(rm.gui, 'reloadConnectionTable()'); - end - % Get submission info from the user - rqd = awtcreate('mpipeline.repository.RepositoryQueryDialog', 'Lmpipeline.main.MainWindow;ZLmpipeline.repository.RepositoryConnection;Z', [], false, conn, false); - awtinvoke(rqd, 'setVisible', 'true'); - - hExec = handle(rqd.getExecuteBtn(),'callbackproperties'); - hExec.ActionPerformedCallback = @cb_executeQuery; - - hGuiCloses1 = handle(rqd, 'callbackproperties'); - hGuiCloses1.WindowClosedCallback = @cb_guiClosed1; - - end + hGuiCloses1 = handle(rqd, 'callbackproperties'); + hGuiCloses1.WindowClosedCallback = @cb_guiClosed1; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function cb_guiClosed1(varargin) @@ -53,37 +45,27 @@ jQueryTextField = awtinvoke(rqd, 'getQueryTxtField()'); jQuery = awtinvoke(jQueryTextField, 'getText()'); - if ~(awtinvoke(conn, 'isConnected()')) - awtinvoke(conn, 'openConnection()'); - end - - if (awtinvoke(conn, 'isConnected()')) + jStmt = awtinvoke(conn, 'createStatement()'); - % lock connection - awtinvoke(conn, 'setLocked(Z)', true); - jStmt = awtinvoke(conn, 'createStatement()'); - - try - - jResult = awtinvoke(jStmt, 'executeQuery(Ljava.lang.String;)', jQuery); + try - % pass to query results table - qrt = awtcreate('mpipeline.repository.QueryResultsTableDialog', 'Lmpipeline.main.MainWindow;ZLjava.sql.ResultSet;Ljava.lang.String;Z', [], false, jResult, jQuery, false); - awtinvoke(qrt, 'setUsedConn(Lmpipeline.repository.RepositoryConnection;)', conn); - awtinvoke(qrt, 'setVisible(Z)', 'true'); - - hRetrieve = handle(qrt.getCreateConstructors,'callbackproperties'); - hRetrieve.ActionPerformedCallback = @cb_retrieveObjectsFromTable; - - hGuiCloses2 = handle(qrt, 'callbackproperties'); - hGuiCloses2.WindowClosedCallback = @cb_guiClosed2; - - catch err - fprintf(2, [err.message, '\n']); - end - awtinvoke(conn, 'setLocked(Z)', false); + jResult = awtinvoke(jStmt, 'executeQuery(Ljava.lang.String;)', jQuery); + + % pass to query results table + qrt = awtcreate('mpipeline.repository.QueryResultsTableDialog', 'Lmpipeline.main.MainWindow;ZLjava.sql.ResultSet;Ljava.lang.String;Z', [], false, jResult, jQuery, false); + awtinvoke(qrt, 'setUsedConn(Ljava.sql.Connection;)', conn); + awtinvoke(qrt, 'setVisible(Z)', 'true'); + hRetrieve = handle(qrt.getCreateConstructors,'callbackproperties'); + hRetrieve.ActionPerformedCallback = @cb_retrieveObjectsFromTable; + + hGuiCloses2 = handle(qrt, 'callbackproperties'); + hGuiCloses2.WindowClosedCallback = @cb_guiClosed2; + + catch err + fprintf(2, [err.message, '\n']); end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function cb_guiClosed2(varargin)