Mercurial > hg > ltpda
comparison m-toolbox/classes/@LTPDARepositoryManager/basic_newConnection.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % basic_newConnection basic method which creates a new connection. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % description: basic_newConnection basic method which creates a new | |
5 % connection. | |
6 % | |
7 % version: $Id: basic_newConnection.m,v 1.6 2010/08/16 18:04:36 ingo Exp $ | |
8 % | |
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
10 | |
11 function varargout = basic_newConnection(rm, dbhost, dbname, dbuser, dbpass) | |
12 | |
13 % Build a new connection | |
14 conn = mpipeline.repository.RepositoryConnection([]); | |
15 conn.setUsername(dbuser); | |
16 conn.setPassword(dbpass); | |
17 conn.setDatabase(dbname); | |
18 conn.setHostname(dbhost); | |
19 | |
20 % Don't show the GUI if the connection have all information | |
21 if ~isempty(dbhost) && ... | |
22 ~isempty(dbname) && ... | |
23 ~isempty(dbuser) | |
24 if ~isempty(char(conn.getPassword)) | |
25 conn.openConnection(); | |
26 end | |
27 else | |
28 % Open connection GUI | |
29 prefs = getappdata(0, 'LTPDApreferences'); | |
30 hosts = prefs.getRepoPrefs.getHostnames; | |
31 | |
32 % Build connection dialog | |
33 warning('off', 'MATLAB:JavaEDTAutoDelegation'); | |
34 rcd = mpipeline.repository.RepositoryConnectionDialog([], true, hosts, conn); | |
35 rcd.setVisible(true); | |
36 warning('on', 'MATLAB:JavaEDTAutoDelegation'); | |
37 | |
38 conn = rcd.getRepositoryConnection; | |
39 | |
40 if rcd.isCancelled | |
41 disp('operation cancelled'); | |
42 conn = []; | |
43 else | |
44 if ~isempty(char(conn.getPassword)) | |
45 conn.openConnection(); | |
46 end | |
47 end | |
48 | |
49 end | |
50 | |
51 % Add valid connection to the Repository Manager | |
52 if isa(conn, 'mpipeline.repository.RepositoryConnection') | |
53 rm.manager.addConnection(conn); | |
54 if ~isempty(rm.gui) | |
55 rm.gui.reloadConnectionTable(); | |
56 end | |
57 else | |
58 conn = []; | |
59 end | |
60 | |
61 varargout{1} = conn; | |
62 | |
63 end | |
64 | |
65 |