Revision 44419
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geodb.app/org.gvsig.geodb.app.mainplugin/src/main/java/org/gvsig/geodb/databaseworkspace/ConnectToDatabaseWorkspacePanel.java | ||
---|---|---|
9 | 9 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
10 | 10 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.CONFIG_NAME_STORESREPOSITORYID; |
11 | 11 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.CONFIG_NAME_STORESREPOSITORYLABEL; |
12 |
import org.gvsig.fmap.dal.StoresRepository; |
|
13 | 12 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
14 | 13 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
15 | 14 |
import org.gvsig.tools.swing.api.Component; |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/java/org/gvsig/export/swing/impl/panels/SelectAttributesPanel.java | ||
---|---|---|
11 | 11 |
import java.util.Comparator; |
12 | 12 |
import java.util.Iterator; |
13 | 13 |
import java.util.List; |
14 |
import java.util.Map; |
|
15 | 14 |
import java.util.Objects; |
16 | 15 |
import javax.swing.DefaultCellEditor; |
17 | 16 |
import javax.swing.DefaultComboBoxModel; |
... | ... | |
51 | 50 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
52 | 51 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
53 | 52 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
54 |
import org.gvsig.tools.util.LabeledValue; |
|
55 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
56 | 53 |
import org.slf4j.Logger; |
57 | 54 |
import org.slf4j.LoggerFactory; |
58 | 55 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataServerExplorerPool.java | ||
---|---|---|
8 | 8 |
|
9 | 9 |
public interface DataServerExplorerPool extends Persistent, Iterable<DataServerExplorerPoolEntry> { |
10 | 10 |
|
11 |
public DataServerExplorerPoolEntry createEntry(String name, String description, DataServerExplorerParameters explorer); |
|
11 | 12 |
|
12 | 13 |
public void add(String name, DataServerExplorerParameters explorer); |
13 | 14 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DatabaseWorkspaceManager.java | ||
---|---|---|
15 | 15 |
extends LabeledValue<DatabaseWorkspaceManager>, SymbolTable |
16 | 16 |
{ |
17 | 17 |
|
18 |
public interface AddDatabaseWorkspaceListener { |
|
19 |
|
|
20 |
public String getName(); |
|
21 |
|
|
22 |
public void onAddDatabaseWorkspace(DatabaseWorkspaceManager databaseWorkspace); |
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
|
|
18 | 27 |
public static final String CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES = "CanAnonymousUserWriteInTheTables"; |
19 | 28 |
|
20 | 29 |
public static final String TABLE_REPOSITORY_NAME = "gvsigd_repository"; |
... | ... | |
181 | 190 |
public File getBaseFolder(); |
182 | 191 |
|
183 | 192 |
public void setBaseFolder(File baseFolder); |
193 |
|
|
194 |
public ResourcesStorage getResourcesStorage(); |
|
184 | 195 |
|
185 | 196 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataServerExplorer.java | ||
---|---|---|
167 | 167 |
*/ |
168 | 168 |
public File getResourcePath(DataStore dataStore, String resourceName) throws DataException; |
169 | 169 |
|
170 |
public ResourcesStorage getResourcesStorage(); |
|
171 |
|
|
170 | 172 |
public ResourcesStorage getResourcesStorage(DataStore dataStore); |
171 | 173 |
|
172 | 174 |
public ResourcesStorage getResourcesStorage(DataStoreParameters parameters); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataManager.java | ||
---|---|---|
519 | 519 |
|
520 | 520 |
public void addDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace); |
521 | 521 |
|
522 |
public void addDatabaseWorkspaceListener(DatabaseWorkspaceManager.AddDatabaseWorkspaceListener listener); |
|
523 |
|
|
522 | 524 |
public DatabaseWorkspaceManager getDatabaseWorkspace(String name); |
523 | 525 |
|
524 | 526 |
public DatabaseWorkspaceManager getDatabaseWorkspace(DataStoreParameters params); |
... | ... | |
527 | 529 |
|
528 | 530 |
public void writeDALResource(ResourcesStorage resources, FeatureType featureType); |
529 | 531 |
|
532 |
/** |
|
533 |
* Return a 35-40 characters unique identifier. |
|
534 |
* |
|
535 |
* @return the unique identifier |
|
536 |
*/ |
|
537 |
public String createUniqueID(); |
|
538 |
|
|
530 | 539 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/DataManagerProviderServices.java | ||
---|---|---|
153 | 153 |
|
154 | 154 |
public DynObjectValueItem[] getAvailableValues(FeatureStore myStore, FeatureAttributeDescriptor descriptor); |
155 | 155 |
|
156 |
/** |
|
157 |
* Return a 35-40 characters unique identifier. |
|
158 |
* |
|
159 |
* @return the unique identifier |
|
160 |
*/ |
|
161 |
public String createUniqueID(); |
|
162 | 156 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/AbstractDataServerExplorer.java | ||
---|---|---|
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
@Override |
57 |
public ResourcesStorage getResourcesStorage() { |
|
58 |
EmptyResourcesStorage resourcesStorage = new EmptyResourcesStorage(); |
|
59 |
return resourcesStorage; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
57 | 63 |
public ResourcesStorage getResourcesStorage(DataStore dataStore) { |
58 | 64 |
EmptyResourcesStorage resourcesStorage = new EmptyResourcesStorage(); |
59 | 65 |
return resourcesStorage; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataManager.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.gvsig.fmap.dal.DataFactory; |
25 | 25 |
import org.gvsig.fmap.dal.DataManager; |
26 |
import org.gvsig.fmap.dal.DataParameters; |
|
27 | 26 |
import org.gvsig.fmap.dal.DataServerExplorer; |
28 | 27 |
import org.gvsig.fmap.dal.DataServerExplorerFactory; |
29 | 28 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
... | ... | |
34 | 33 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
35 | 34 |
import org.gvsig.fmap.dal.DataTypes; |
36 | 35 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
36 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager.AddDatabaseWorkspaceListener; |
|
37 | 37 |
|
38 | 38 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
39 | 39 |
import org.gvsig.fmap.dal.OpenErrorHandler; |
... | ... | |
97 | 97 |
import org.gvsig.tools.identitymanagement.UnauthorizedException; |
98 | 98 |
import org.gvsig.tools.persistence.PersistenceManager; |
99 | 99 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
100 |
import org.gvsig.tools.script.Script; |
|
101 |
import org.gvsig.tools.script.ScriptManager; |
|
100 | 102 |
import org.gvsig.tools.service.spi.Services; |
103 |
import org.gvsig.tools.util.Callable; |
|
104 |
import org.gvsig.tools.util.Invocable; |
|
101 | 105 |
import org.slf4j.Logger; |
102 | 106 |
import org.slf4j.LoggerFactory; |
103 | 107 |
|
... | ... | |
159 | 163 |
private List<DataProfile> dataProfiles; |
160 | 164 |
|
161 | 165 |
private final Map<String, DatabaseWorkspaceManager> databaseWorkspaces = new HashMap<>(); |
166 |
|
|
167 |
private final Map<String,AddDatabaseWorkspaceListener> addDatabaseWorkspaceListeners = new HashMap<>(); |
|
162 | 168 |
|
163 | 169 |
public DefaultDataManager() { |
164 | 170 |
this.registers = new Registers(); |
... | ... | |
1047 | 1053 |
this.databaseWorkspaces.put(databaseWorkspace.getId(),databaseWorkspace); |
1048 | 1054 |
StoresRepository repo = databaseWorkspace.getStoresRepository(); |
1049 | 1055 |
this.getStoresRepository().addRepository(repo); |
1056 |
|
|
1057 |
for (AddDatabaseWorkspaceListener listener : this.addDatabaseWorkspaceListeners.values()) { |
|
1058 |
if( listener!=null ) { |
|
1059 |
try { |
|
1060 |
listener.onAddDatabaseWorkspace(databaseWorkspace); |
|
1061 |
} catch(Throwable th) { |
|
1062 |
LOGGER.warn("Problems calling databaseworkspace listener '"+listener.getName()+"'.",th); |
|
1063 |
} |
|
1064 |
} |
|
1065 |
} |
|
1066 |
try { |
|
1067 |
ResourcesStorage resources = databaseWorkspace.getResourcesStorage(); |
|
1068 |
ScriptManager scriptManager = ToolsLocator.getScriptManager(); |
|
1069 |
Script script = scriptManager.loadScript(resources, "OnConnectToWorkspace.script"); |
|
1070 |
if( script != null ) { |
|
1071 |
script.invokeFunction("main", new Object[] {databaseWorkspace}); |
|
1072 |
} |
|
1073 |
} catch(Throwable th) { |
|
1074 |
LOGGER.warn("Problems executing 'OnConnectToWorkspace.script' from workspace '"+databaseWorkspace.getId()+"'.",th); |
|
1075 |
} |
|
1050 | 1076 |
} |
1077 |
|
|
1078 |
@Override |
|
1079 |
public void addDatabaseWorkspaceListener(AddDatabaseWorkspaceListener listener) { |
|
1080 |
this.addDatabaseWorkspaceListeners.put(listener.getName(), listener); |
|
1081 |
} |
|
1051 | 1082 |
|
1052 | 1083 |
@Override |
1053 | 1084 |
public DatabaseWorkspaceManager getDatabaseWorkspace(String name) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataServerExplorerPool.java | ||
---|---|---|
37 | 37 |
return this.pool.isEmpty(); |
38 | 38 |
} |
39 | 39 |
|
40 |
public DataServerExplorerPoolEntry createEntry(String name, String description, DataServerExplorerParameters explorer) { |
|
41 |
DefaultDataServerExplorerPoolEntry entry = new DefaultDataServerExplorerPoolEntry(name, description, explorer); |
|
42 |
return entry; |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
40 | 46 |
public void add(String name, DataServerExplorerParameters explorer) { |
41 | 47 |
this.add(name, null, explorer); |
42 | 48 |
} |
43 | 49 |
|
50 |
@Override |
|
44 | 51 |
public void add(String name, String description, DataServerExplorerParameters explorer) { |
45 |
DefaultDataServerExplorerPoolEntry newexplorer = new DefaultDataServerExplorerPoolEntry(name, description, explorer);
|
|
52 |
DataServerExplorerPoolEntry newexplorer = createEntry(name, description, explorer);
|
|
46 | 53 |
DataServerExplorerPoolEntry existent = this.get(name); |
47 | 54 |
if( existent!=null ) { |
48 | 55 |
newexplorer.copyTo(existent); |
... | ... | |
51 | 58 |
} |
52 | 59 |
} |
53 | 60 |
|
61 |
@Override |
|
54 | 62 |
public void remove(DataServerExplorerPoolEntry entry) { |
55 | 63 |
this.remove(entry.getName()); |
56 | 64 |
} |
57 | 65 |
|
66 |
@Override |
|
58 | 67 |
public void remove(int explorerIndex) { |
59 | 68 |
this.pool.remove(explorerIndex); |
60 | 69 |
} |
61 | 70 |
|
71 |
@Override |
|
62 | 72 |
public void remove(String name) { |
63 | 73 |
if( StringUtils.isBlank(name) ) { |
64 | 74 |
return; |
... | ... | |
71 | 81 |
} |
72 | 82 |
} |
73 | 83 |
|
84 |
@Override |
|
74 | 85 |
public int size() { |
75 | 86 |
return this.pool.size(); |
76 | 87 |
} |
77 | 88 |
|
89 |
@Override |
|
78 | 90 |
public DataServerExplorerPoolEntry get(int index) { |
79 | 91 |
return (DataServerExplorerPoolEntry) this.pool.get(index); |
80 | 92 |
} |
81 | 93 |
|
94 |
@Override |
|
82 | 95 |
public DataServerExplorerPoolEntry get(String name) { |
83 | 96 |
if( StringUtils.isBlank(name) ) { |
84 | 97 |
return null; |
... | ... | |
92 | 105 |
return null; |
93 | 106 |
} |
94 | 107 |
|
108 |
@Override |
|
95 | 109 |
public Iterator iterator() { |
96 | 110 |
return this.pool.iterator(); |
97 | 111 |
} |
98 | 112 |
|
113 |
@Override |
|
99 | 114 |
public void saveToState(PersistentState state) throws PersistenceException { |
100 | 115 |
state.set("pool", pool); |
101 | 116 |
} |
102 | 117 |
|
118 |
@Override |
|
103 | 119 |
public void loadFromState(PersistentState state) throws PersistenceException { |
104 | 120 |
List l = state.getList("pool"); |
105 | 121 |
this.pool = new ArrayList(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataServerExplorerPoolEntry.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
} |
39 | 39 |
|
40 |
@Override |
|
40 | 41 |
public String getName() { |
41 | 42 |
return this.name; |
42 | 43 |
} |
43 | 44 |
|
45 |
@Override |
|
44 | 46 |
public void copyTo(DataServerExplorerPoolEntry target) { |
45 | 47 |
DefaultDataServerExplorerPoolEntry other = (DefaultDataServerExplorerPoolEntry)target; |
46 | 48 |
other.name = this.name; |
... | ... | |
48 | 50 |
other.explorer = this.explorer; |
49 | 51 |
} |
50 | 52 |
|
53 |
@Override |
|
51 | 54 |
public DataServerExplorerParameters getExplorerParameters() { |
52 | 55 |
return this.explorer; |
53 | 56 |
} |
54 | 57 |
|
58 |
@Override |
|
55 | 59 |
public String getDescription() { |
56 | 60 |
return this.description; |
57 | 61 |
} |
58 | 62 |
|
63 |
@Override |
|
59 | 64 |
public void saveToState(PersistentState state) throws PersistenceException { |
60 | 65 |
state.set("name", this.name); |
61 | 66 |
state.set("description", this.description); |
62 | 67 |
state.set("explorer", this.explorer); |
63 | 68 |
} |
64 | 69 |
|
70 |
@Override |
|
65 | 71 |
public void loadFromState(PersistentState state) throws PersistenceException { |
66 | 72 |
this.description = state.getString("description"); |
67 | 73 |
this.name = state.getString("name"); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDatabaseWorkspaceManager.java | ||
---|---|---|
11 | 11 |
import org.apache.commons.lang3.mutable.MutableObject; |
12 | 12 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
13 | 13 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
14 |
import org.gvsig.expressionevaluator.SymbolTable; |
|
15 | 14 |
import org.gvsig.expressionevaluator.spi.AbstractSymbolTable; |
16 | 15 |
import org.gvsig.fmap.dal.DALLocator; |
17 | 16 |
import org.gvsig.fmap.dal.DataManager; |
... | ... | |
652 | 651 |
} |
653 | 652 |
} |
654 | 653 |
|
654 |
@Override |
|
655 |
public ResourcesStorage getResourcesStorage() { |
|
656 |
try { |
|
657 |
DataManager dataManager = DALLocator.getDataManager(); |
|
658 |
DataServerExplorer server = dataManager.openServerExplorer( |
|
659 |
this.serverParameters.getProviderName(), |
|
660 |
this.serverParameters |
|
661 |
); |
|
662 |
ResourcesStorage resourcesStorage = server.getResourcesStorage(); |
|
663 |
return resourcesStorage; |
|
664 |
} catch (Exception ex) { |
|
665 |
LOGGER.warn("Can't get resorces storage.",ex); |
|
666 |
return null; |
|
667 |
} |
|
668 |
} |
|
669 |
|
|
655 | 670 |
|
656 | 671 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCServerExplorerBase.java | ||
---|---|---|
27 | 27 |
import java.util.ArrayList; |
28 | 28 |
import java.util.Arrays; |
29 | 29 |
import java.util.List; |
30 |
import java.util.logging.Level; |
|
30 | 31 |
import org.apache.commons.lang3.BooleanUtils; |
31 | 32 |
import org.apache.commons.lang3.ObjectUtils; |
32 | 33 |
import org.apache.commons.lang3.StringUtils; |
... | ... | |
441 | 442 |
return theResourcesStorage; |
442 | 443 |
} |
443 | 444 |
|
444 |
|
|
445 |
public ResourcesStorage getResourcesStorage() { |
|
446 |
JDBCStoreParameters params; |
|
447 |
try { |
|
448 |
params = this.getOpenParameters(); |
|
449 |
JDBCResourcesStorage theResourcesStorage = new JDBCResourcesStorage( |
|
450 |
null, |
|
451 |
params, |
|
452 |
"$SERVVER$" |
|
453 |
); |
|
454 |
return theResourcesStorage; |
|
455 |
} catch (DataException ex) { |
|
456 |
return null; |
|
457 |
} |
|
458 |
} |
|
459 |
|
|
445 | 460 |
@Override |
446 | 461 |
public ResourcesStorage getResourcesStorage(DataStoreParameters parameters) { |
447 | 462 |
if( parameters == null ) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/fmap/dal/swing/jdbc/JDBCConnectionDialog.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal.swing.jdbc; |
2 | 2 |
|
3 | 3 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
4 |
import org.gvsig.tools.util.LabeledValue; |
|
4 | 5 |
|
5 | 6 |
/** |
6 | 7 |
* |
... | ... | |
11 | 12 |
public String getConnectionName(); |
12 | 13 |
|
13 | 14 |
public JDBCServerExplorerParameters getServerExplorerParameters(); |
15 |
|
|
16 |
public LabeledValue<JDBCServerExplorerParameters> getLabeledServerExplorerParameters(); |
|
14 | 17 |
|
15 | 18 |
public boolean isCanceled(); |
16 | 19 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/fmap/dal/swing/jdbc/JDBCConnectionPanel.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
4 | 4 |
import org.gvsig.tools.swing.api.Component; |
5 |
import org.gvsig.tools.util.LabeledValue; |
|
5 | 6 |
|
6 | 7 |
|
7 | 8 |
|
... | ... | |
12 | 13 |
} |
13 | 14 |
|
14 | 15 |
public void setServerExplorerParameters(JDBCServerExplorerParameters parameters); |
16 |
public void setLabeledServerExplorerParameters(LabeledValue<JDBCServerExplorerParameters> parameters); |
|
15 | 17 |
public JDBCServerExplorerParameters getServerExplorerParameters(); |
18 |
public LabeledValue<JDBCServerExplorerParameters> getLabeledServerExplorerParameters(); |
|
16 | 19 |
public void delete(); |
17 | 20 |
public void clear(); |
18 | 21 |
public String getConnectionName(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/jdbc/DefaultJDBCConnectionDialogView.xml | ||
---|---|---|
24 | 24 |
</at> |
25 | 25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
26 | 26 |
</super> |
27 |
<at name="id">/home/jjdelcerro/datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geodb.app/org.gvsig.geodb.app.mainplugin/src/main/java/org/gvsig/geodb/vectorialdb/wizard/VectorialDBConnectionParamsDialogView.xml</at>
|
|
27 |
<at name="id">/home/jjdelcerro/datos/devel/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/jdbc/DefaultJDBCConnectionDialogView.xml</at>
|
|
28 | 28 |
<at name="rowspecs">CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE</at> |
29 | 29 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE</at> |
30 | 30 |
<at name="components"> |
... | ... | |
35 | 35 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
36 | 36 |
<at name="cellconstraints"> |
37 | 37 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
38 |
<at name="column">5</at>
|
|
38 |
<at name="column">7</at>
|
|
39 | 39 |
<at name="row">4</at> |
40 | 40 |
<at name="colspan">1</at> |
41 | 41 |
<at name="rowspan">1</at> |
... | ... | |
53 | 53 |
<at name="classname">javax.swing.JButton</at> |
54 | 54 |
<at name="properties"> |
55 | 55 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
56 |
<at name="text">Delete</at> |
|
57 |
<at name="height">22</at> |
|
58 |
<at name="width">68</at> |
|
59 |
<at name="name">btnDelete</at> |
|
60 |
<at name="actionCommand">Delete</at> |
|
61 | 56 |
<at name="border"> |
62 | 57 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
63 | 58 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
... | ... | |
78 | 73 |
</at> |
79 | 74 |
</object> |
80 | 75 |
</at> |
81 |
</object> |
|
82 |
</at> |
|
83 |
</object> |
|
84 |
</at> |
|
85 |
</object> |
|
86 |
</at> |
|
87 |
</item> |
|
88 |
<item > |
|
89 |
<at name="value"> |
|
90 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
91 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
92 |
<at name="cellconstraints"> |
|
93 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
94 |
<at name="column">7</at> |
|
95 |
<at name="row">4</at> |
|
96 |
<at name="colspan">1</at> |
|
97 |
<at name="rowspan">1</at> |
|
98 |
<at name="halign">default</at> |
|
99 |
<at name="valign">default</at> |
|
100 |
<at name="insets" object="insets">0,0,0,0</at> |
|
101 |
</object> |
|
102 |
</at> |
|
103 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
104 |
</super> |
|
105 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
106 |
<at name="beanclass">javax.swing.JButton</at> |
|
107 |
<at name="beanproperties"> |
|
108 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
109 |
<at name="classname">javax.swing.JButton</at> |
|
110 |
<at name="properties"> |
|
111 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
76 |
<at name="actionCommand">Acept</at> |
|
77 |
<at name="name">btnAcept</at> |
|
78 |
<at name="width">63</at> |
|
112 | 79 |
<at name="text">Acept</at> |
113 | 80 |
<at name="height">22</at> |
114 |
<at name="width">63</at> |
|
115 |
<at name="name">btnAcept</at> |
|
116 |
<at name="actionCommand">Acept</at> |
|
117 |
<at name="border"> |
|
118 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
119 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
120 |
<at name="name">border</at> |
|
121 |
</super> |
|
122 |
<at name="borders"> |
|
123 |
<object classname="java.util.LinkedList"> |
|
124 |
<item > |
|
125 |
<at name="value"> |
|
126 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
127 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
128 |
<at name="name">border</at> |
|
129 |
</super> |
|
130 |
</object> |
|
131 |
</at> |
|
132 |
</item> |
|
133 |
</object> |
|
134 |
</at> |
|
135 |
</object> |
|
136 |
</at> |
|
137 | 81 |
</object> |
138 | 82 |
</at> |
139 | 83 |
</object> |
... | ... | |
165 | 109 |
<at name="classname">javax.swing.JButton</at> |
166 | 110 |
<at name="properties"> |
167 | 111 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
168 |
<at name="text">Cancel</at> |
|
169 |
<at name="height">22</at> |
|
170 |
<at name="width">70</at> |
|
171 |
<at name="name">btnCancel</at> |
|
172 |
<at name="actionCommand">Cancel</at> |
|
173 | 112 |
<at name="border"> |
174 | 113 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
175 | 114 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
... | ... | |
190 | 129 |
</at> |
191 | 130 |
</object> |
192 | 131 |
</at> |
132 |
<at name="actionCommand">Cancel</at> |
|
133 |
<at name="name">btnCancel</at> |
|
134 |
<at name="width">70</at> |
|
135 |
<at name="text">Cancel</at> |
|
136 |
<at name="height">22</at> |
|
193 | 137 |
</object> |
194 | 138 |
</at> |
195 | 139 |
</object> |
... | ... | |
221 | 165 |
<at name="classname">javax.swing.JPanel</at> |
222 | 166 |
<at name="properties"> |
223 | 167 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
224 |
<at name="height">160</at> |
|
225 |
<at name="width">395</at> |
|
226 | 168 |
<at name="name">containerJDBCConnectionPanel</at> |
169 |
<at name="width">911</at> |
|
170 |
<at name="height">442</at> |
|
227 | 171 |
</object> |
228 | 172 |
</at> |
229 | 173 |
</object> |
... | ... | |
237 | 181 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
238 | 182 |
<at name="cellconstraints"> |
239 | 183 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
240 |
<at name="column">3</at>
|
|
184 |
<at name="column">5</at>
|
|
241 | 185 |
<at name="row">4</at> |
242 | 186 |
<at name="colspan">1</at> |
243 | 187 |
<at name="rowspan">1</at> |
... | ... | |
255 | 199 |
<at name="classname">javax.swing.JButton</at> |
256 | 200 |
<at name="properties"> |
257 | 201 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
258 |
<at name="text">Advanced...</at> |
|
259 |
<at name="height">22</at> |
|
260 |
<at name="width">98</at> |
|
261 |
<at name="name">btnAdvanced</at> |
|
262 |
<at name="actionCommand">Advanced...</at> |
|
263 | 202 |
<at name="border"> |
264 | 203 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
265 | 204 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
... | ... | |
280 | 219 |
</at> |
281 | 220 |
</object> |
282 | 221 |
</at> |
222 |
<at name="actionCommand">More...</at> |
|
223 |
<at name="name">btnMore</at> |
|
224 |
<at name="width">72</at> |
|
225 |
<at name="text">More...</at> |
|
226 |
<at name="height">22</at> |
|
283 | 227 |
</object> |
284 | 228 |
</at> |
285 | 229 |
</object> |
... | ... | |
294 | 238 |
<at name="classname">com.jeta.forms.gui.form.GridView</at> |
295 | 239 |
<at name="properties"> |
296 | 240 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
297 |
<at name="name"></at> |
|
241 |
<at name="border"> |
|
242 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
243 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
244 |
<at name="name">border</at> |
|
245 |
</super> |
|
246 |
<at name="borders"> |
|
247 |
<object classname="java.util.LinkedList"/> |
|
248 |
</at> |
|
249 |
</object> |
|
250 |
</at> |
|
251 |
<at name="name"/> |
|
298 | 252 |
<at name="fill"> |
299 | 253 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
300 | 254 |
<at name="name">fill</at> |
... | ... | |
327 | 281 |
</at> |
328 | 282 |
</object> |
329 | 283 |
</at> |
330 |
<at name="border"> |
|
331 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
332 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
333 |
<at name="name">border</at> |
|
334 |
</super> |
|
335 |
<at name="borders"> |
|
336 |
<object classname="java.util.LinkedList"/> |
|
337 |
</at> |
|
338 |
</object> |
|
339 |
</at> |
|
340 | 284 |
</object> |
341 | 285 |
</at> |
342 | 286 |
</object> |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/jdbc/DefaultJDBCConnectionDialogView.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
public class DefaultJDBCConnectionDialogView extends JPanel |
18 | 18 |
{ |
19 |
JButton btnDelete = new JButton(); |
|
20 | 19 |
JButton btnAcept = new JButton(); |
21 | 20 |
JButton btnCancel = new JButton(); |
22 | 21 |
JPanel containerJDBCConnectionPanel = new JPanel(); |
23 |
JButton btnAdvanced = new JButton();
|
|
22 |
JButton btnMore = new JButton();
|
|
24 | 23 |
|
25 | 24 |
/** |
26 | 25 |
* Default constructor |
... | ... | |
116 | 115 |
CellConstraints cc = new CellConstraints(); |
117 | 116 |
jpanel1.setLayout(formlayout1); |
118 | 117 |
|
119 |
btnDelete.setActionCommand("Delete"); |
|
120 |
btnDelete.setName("btnDelete"); |
|
121 |
btnDelete.setText("Delete"); |
|
122 |
jpanel1.add(btnDelete,cc.xy(5,4)); |
|
123 |
|
|
124 | 118 |
btnAcept.setActionCommand("Acept"); |
125 | 119 |
btnAcept.setName("btnAcept"); |
126 | 120 |
btnAcept.setText("Acept"); |
... | ... | |
134 | 128 |
containerJDBCConnectionPanel.setName("containerJDBCConnectionPanel"); |
135 | 129 |
jpanel1.add(containerJDBCConnectionPanel,cc.xywh(2,2,8,1)); |
136 | 130 |
|
137 |
btnAdvanced.setActionCommand("Advanced...");
|
|
138 |
btnAdvanced.setName("btnAdvanced");
|
|
139 |
btnAdvanced.setText("Advanced...");
|
|
140 |
jpanel1.add(btnAdvanced,cc.xy(3,4));
|
|
131 |
btnMore.setActionCommand("More...");
|
|
132 |
btnMore.setName("btnMore");
|
|
133 |
btnMore.setText("More...");
|
|
134 |
jpanel1.add(btnMore,cc.xy(5,4));
|
|
141 | 135 |
|
142 | 136 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10 },new int[]{ 1,2,3,4,5 }); |
143 | 137 |
return jpanel1; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/jdbc/DefaultJDBCConnectionDialog.java | ||
---|---|---|
26 | 26 |
import java.awt.BorderLayout; |
27 | 27 |
import java.awt.event.ActionEvent; |
28 | 28 |
import java.awt.event.ActionListener; |
29 |
import java.awt.event.ItemEvent; |
|
30 |
import java.awt.event.ItemListener; |
|
31 |
import java.io.File; |
|
32 |
import java.io.FileInputStream; |
|
33 |
import java.io.FileOutputStream; |
|
34 |
import java.io.InputStream; |
|
35 |
import java.io.OutputStream; |
|
36 |
import java.util.Objects; |
|
37 |
import javax.swing.DefaultComboBoxModel; |
|
38 |
import javax.swing.JOptionPane; |
|
39 |
import javax.swing.filechooser.FileFilter; |
|
40 |
import org.apache.commons.io.IOUtils; |
|
41 |
import org.apache.commons.lang3.ArrayUtils; |
|
42 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
|
43 |
import org.gvsig.fmap.dal.DALLocator; |
|
44 |
import org.gvsig.fmap.dal.DataManager; |
|
45 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
|
46 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
|
29 | 47 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
30 | 48 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
31 | 49 |
import org.gvsig.fmap.dal.swing.dataStoreParameters.DataStoreParametersPanel; |
... | ... | |
40 | 58 |
import org.slf4j.Logger; |
41 | 59 |
import org.slf4j.LoggerFactory; |
42 | 60 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionDialog; |
61 |
import org.gvsig.tools.folders.FoldersManager; |
|
62 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
63 |
import org.gvsig.tools.persistence.PersistentState; |
|
64 |
import org.gvsig.tools.swing.api.DropDown; |
|
65 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
66 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
67 |
import org.gvsig.tools.util.LabeledValue; |
|
68 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
43 | 69 |
|
44 | 70 |
|
45 | 71 |
|
46 | 72 |
|
73 |
@SuppressWarnings("UseSpecificCatch") |
|
47 | 74 |
public class DefaultJDBCConnectionDialog extends DefaultJDBCConnectionDialogView implements JDBCConnectionDialog { |
48 | 75 |
|
49 | 76 |
private static final long serialVersionUID = -5493563028200403559L; |
... | ... | |
53 | 80 |
|
54 | 81 |
private boolean isCanceled = false; |
55 | 82 |
private JDBCConnectionPanel jdbcServerExplorer; |
83 |
private DropDown ddnMore; |
|
56 | 84 |
|
57 | 85 |
public DefaultJDBCConnectionDialog() { |
58 | 86 |
initComponents(); |
59 | 87 |
} |
60 | 88 |
|
61 | 89 |
private void initComponents() { |
62 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
63 |
this.btnAdvanced.setText(i18nManager.getTranslation("advanced")); |
|
64 |
this.btnAdvanced.addActionListener(new ActionListener() { |
|
65 |
@Override |
|
66 |
public void actionPerformed(ActionEvent ae) { |
|
67 |
doAdvanced(); |
|
68 |
} |
|
69 |
}); |
|
70 |
this.btnAcept.setText(i18nManager.getTranslation("ok")); |
|
90 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
91 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
92 |
this.btnAcept.setText(i18n.getTranslation("ok")); |
|
71 | 93 |
this.btnAcept.addActionListener(new ActionListener() { |
72 | 94 |
@Override |
73 | 95 |
public void actionPerformed(ActionEvent ae) { |
74 | 96 |
doAcept(); |
75 | 97 |
} |
76 | 98 |
}); |
77 |
this.btnCancel.setText(i18nManager.getTranslation("cancel"));
|
|
99 |
this.btnCancel.setText(i18n.getTranslation("cancel")); |
|
78 | 100 |
this.btnCancel.addActionListener(new ActionListener() { |
79 | 101 |
@Override |
80 | 102 |
public void actionPerformed(ActionEvent ae) { |
81 | 103 |
doCancel(); |
82 | 104 |
} |
83 | 105 |
}); |
84 |
|
|
85 |
this.btnDelete.setText(i18nManager.getTranslation("del")); |
|
86 |
this.btnDelete.addActionListener(new ActionListener() { |
|
106 |
DefaultComboBoxModel<LabeledValue<String>> model = new DefaultComboBoxModel<>(); |
|
107 |
model.addElement(new LabeledValueImpl<>(i18n.getTranslation("advanced"), "advanced")); |
|
108 |
model.addElement(new LabeledValueImpl<>(i18n.getTranslation("delete"), "delete")); |
|
109 |
model.addElement(new LabeledValueImpl<>(i18n.getTranslation("load"), "load")); |
|
110 |
model.addElement(new LabeledValueImpl<>(i18n.getTranslation("save"), "save")); |
|
111 |
this.ddnMore = toolsSwingManager.createDropDown(this.btnMore); |
|
112 |
this.ddnMore.setModel(model); |
|
113 |
this.ddnMore.addItemListener(new ItemListener() { |
|
87 | 114 |
@Override |
88 |
public void actionPerformed(ActionEvent ae) { |
|
89 |
doDelete(); |
|
115 |
public void itemStateChanged(ItemEvent e) { |
|
116 |
LabeledValue<String> selectedItem = (LabeledValue<String>) ddnMore.getSelectedItem(); |
|
117 |
switch(selectedItem.getValue()) { |
|
118 |
case "advanced": |
|
119 |
doAdvanced(); |
|
120 |
break; |
|
121 |
case "delete": |
|
122 |
doDelete(); |
|
123 |
break; |
|
124 |
case "load": |
|
125 |
doLoad(); |
|
126 |
break; |
|
127 |
case "save": |
|
128 |
doSave(); |
|
129 |
break; |
|
130 |
} |
|
90 | 131 |
} |
91 | 132 |
}); |
133 |
|
|
92 | 134 |
this.jdbcServerExplorer = DALSwingLocator.getSwingManager().createJDBCConnectionPanel(); |
93 | 135 |
this.containerJDBCConnectionPanel.setLayout(new BorderLayout()); |
94 | 136 |
this.containerJDBCConnectionPanel.add( |
... | ... | |
96 | 138 |
BorderLayout.CENTER |
97 | 139 |
); |
98 | 140 |
} |
141 |
|
|
142 |
protected void doLoad() { |
|
143 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
144 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
145 |
FoldersManager folderManager = ToolsLocator.getFoldersManager(); |
|
146 |
DataManager dataManager = DALLocator.getDataManager(); |
|
147 |
|
|
148 |
File initialPath = folderManager.getLastPath("CONNECTIONS", null); |
|
149 |
File[] f = dialogs.showChooserDialog( |
|
150 |
i18n.getTranslation("_Load_connection"), |
|
151 |
FileDialogChooser.OPEN_DIALOG, |
|
152 |
FileDialogChooser.FILES_ONLY, |
|
153 |
false, |
|
154 |
initialPath, |
|
155 |
new FileFilter() { |
|
156 |
@Override |
|
157 |
public boolean accept(File f) { |
|
158 |
return Objects.toString(f,"").toLowerCase().endsWith(".gvdbcon"); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public String getDescription() { |
|
163 |
return "Database connection (gvdbcon)"; |
|
164 |
} |
|
165 |
}, |
|
166 |
true |
|
167 |
); |
|
168 |
if( ArrayUtils.isEmpty(f) || f[0]==null ) { |
|
169 |
return; |
|
170 |
} |
|
171 |
folderManager.setLastPath("CONNECTIONS", f[0].getParentFile()); |
|
172 |
InputStream in = null; |
|
173 |
try { |
|
174 |
in = new FileInputStream(f[0]); |
|
175 |
PersistenceManager persistence = ToolsLocator.getPersistenceManager(); |
|
176 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) persistence.getObject(in); |
|
177 |
LabeledValueImpl<JDBCServerExplorerParameters> parameters = new LabeledValueImpl<>( |
|
178 |
entry.getName(), |
|
179 |
(JDBCServerExplorerParameters)entry.getExplorerParameters() |
|
180 |
); |
|
181 |
this.jdbcServerExplorer.setLabeledServerExplorerParameters(parameters); |
|
182 |
} catch(Throwable th) { |
|
183 |
LOG.warn("Problems loading connection",th); |
|
184 |
dialogs.messageDialog( |
|
185 |
i18n.getTranslation("_Problems_loading_the_connection"), |
|
186 |
i18n.getTranslation("_Load_connection"), |
|
187 |
JOptionPane.WARNING_MESSAGE |
|
188 |
); |
|
189 |
// return; |
|
190 |
} finally { |
|
191 |
IOUtils.closeQuietly(in); |
|
192 |
} |
|
193 |
} |
|
99 | 194 |
|
195 |
protected void doSave() { |
|
196 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
197 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
198 |
FoldersManager folderManager = ToolsLocator.getFoldersManager(); |
|
199 |
DataManager dataManager = DALLocator.getDataManager(); |
|
200 |
|
|
201 |
LabeledValue<JDBCServerExplorerParameters> parameters = this.getLabeledServerExplorerParameters(); |
|
202 |
if( parameters == null || parameters.getValue()==null ) { |
|
203 |
dialogs.messageDialog( |
|
204 |
i18n.getTranslation("_There_is_no_connection_to_save"), |
|
205 |
i18n.getTranslation("_Save_connection"), |
|
206 |
JOptionPane.INFORMATION_MESSAGE |
|
207 |
); |
|
208 |
return; |
|
209 |
} |
|
210 |
File initialPath = folderManager.getLastPath("CONNECTIONS", null); |
|
211 |
File[] f = dialogs.showChooserDialog( |
|
212 |
i18n.getTranslation("_Save_connection"), |
|
213 |
FileDialogChooser.SAVE_DIALOG, |
|
214 |
FileDialogChooser.FILES_ONLY, |
|
215 |
false, |
|
216 |
initialPath, |
|
217 |
new FileFilter() { |
|
218 |
@Override |
|
219 |
public boolean accept(File f) { |
|
220 |
return Objects.toString(f,"").toLowerCase().endsWith(".gvdbcon"); |
|
221 |
} |
|
222 |
|
|
223 |
@Override |
|
224 |
public String getDescription() { |
|
225 |
return "Database connection (gvdbcon)"; |
|
226 |
} |
|
227 |
}, |
|
228 |
true |
|
229 |
); |
|
230 |
if( ArrayUtils.isEmpty(f) || f[0]==null ) { |
|
231 |
return; |
|
232 |
} |
|
233 |
folderManager.setLastPath("CONNECTIONS", f[0].getParentFile()); |
|
234 |
|
|
235 |
File paramsFile = f[0]; |
|
236 |
if( !f[0].toString().toLowerCase().endsWith(".gvdbcon") ) { |
|
237 |
paramsFile = new File(f[0].toString()+".gvdbcon"); |
|
238 |
} |
|
239 |
|
|
240 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
|
241 |
DataServerExplorerPoolEntry entry = pool.createEntry( |
|
242 |
parameters.getLabel(), |
|
243 |
null, |
|
244 |
parameters.getValue() |
|
245 |
); |
|
246 |
|
|
247 |
OutputStream out = null; |
|
248 |
try { |
|
249 |
out = new FileOutputStream(paramsFile); |
|
250 |
PersistenceManager persistence = ToolsLocator.getPersistenceManager(); |
|
251 |
PersistentState state = persistence.getState(entry); |
|
252 |
persistence.saveState(state, out); |
|
253 |
} catch(Throwable th) { |
|
254 |
LOG.warn("Problems saving connection",th); |
|
255 |
dialogs.messageDialog( |
|
256 |
i18n.getTranslation("_Problems_saving_the_connection"), |
|
257 |
i18n.getTranslation("_Save_connection"), |
|
258 |
JOptionPane.WARNING_MESSAGE |
|
259 |
); |
|
260 |
// return; |
|
261 |
} finally { |
|
262 |
IOUtils.closeQuietly(out); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
100 | 266 |
protected void doAdvanced() { |
101 | 267 |
JDBCServerExplorerParameters myParams = this.getServerExplorerParameters(); |
102 | 268 |
try { |
... | ... | |
146 | 312 |
} |
147 | 313 |
|
148 | 314 |
@Override |
315 |
public LabeledValue<JDBCServerExplorerParameters> getLabeledServerExplorerParameters() { |
|
316 |
return this.jdbcServerExplorer.getLabeledServerExplorerParameters(); |
|
317 |
} |
|
318 |
|
|
319 |
@Override |
|
149 | 320 |
public String getConnectionName() { |
150 | 321 |
return this.jdbcServerExplorer.getConnectionName(); |
151 | 322 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/jdbc/DefaultJDBCConnectionPanel.java | ||
---|---|---|
6 | 6 |
import java.awt.event.ItemEvent; |
7 | 7 |
import java.awt.event.ItemListener; |
8 | 8 |
import java.io.File; |
9 |
import java.util.Iterator;
|
|
9 |
import java.util.Objects;
|
|
10 | 10 |
import javax.swing.ComboBoxModel; |
11 | 11 |
import javax.swing.JComponent; |
12 | 12 |
import javax.swing.JLabel; |
... | ... | |
14 | 14 |
import javax.swing.SwingUtilities; |
15 | 15 |
import javax.swing.plaf.basic.BasicHTML; |
16 | 16 |
import javax.swing.text.View; |
17 |
import org.apache.commons.io.FilenameUtils; |
|
17 | 18 |
import org.apache.commons.lang3.ArrayUtils; |
18 | 19 |
import org.apache.commons.lang3.StringUtils; |
19 | 20 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
31 | 32 |
import org.gvsig.tools.i18n.I18nManager; |
32 | 33 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
33 | 34 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
35 |
import org.gvsig.tools.util.LabeledValue; |
|
36 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
34 | 37 |
import org.slf4j.Logger; |
35 | 38 |
import org.slf4j.LoggerFactory; |
36 | 39 |
|
... | ... | |
49 | 52 |
return this; |
50 | 53 |
} |
51 | 54 |
|
52 |
private static class ServerExplorerParametersComboItem { |
|
55 |
// private static class ServerExplorerParametersComboItem { |
|
56 |
// |
|
57 |
// private JDBCServerExplorerParameters params; |
|
58 |
// private String label; |
|
59 |
// |
|
60 |
// public ServerExplorerParametersComboItem(String label, JDBCServerExplorerParameters params) { |
|
61 |
// this.params = params; |
|
62 |
// this.label = label; |
|
63 |
// } |
|
64 |
// |
|
65 |
// public ServerExplorerParametersComboItem(JDBCServerExplorerParameters params) { |
|
66 |
// this(params.getExplorerName(), params); |
|
67 |
// } |
|
68 |
// |
|
69 |
// @Override |
|
70 |
// public String toString() { |
|
71 |
// return this.label; |
|
72 |
// } |
|
73 |
// |
|
74 |
// public JDBCServerExplorerParameters getParams() { |
|
75 |
// return this.params; |
|
76 |
// } |
|
77 |
// |
|
78 |
// public String getLabel() { |
|
79 |
// return this.label; |
|
80 |
// } |
|
81 |
// } |
|
53 | 82 |
|
54 |
private JDBCServerExplorerParameters params; |
|
55 |
private String label; |
|
56 |
|
|
57 |
public ServerExplorerParametersComboItem(String label, JDBCServerExplorerParameters params) { |
|
58 |
this.params = params; |
|
59 |
this.label = label; |
|
60 |
} |
|
61 |
|
|
62 |
public ServerExplorerParametersComboItem(JDBCServerExplorerParameters params) { |
|
63 |
this(params.getExplorerName(), params); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public String toString() { |
|
68 |
return this.label; |
|
69 |
} |
|
70 |
|
|
71 |
public JDBCServerExplorerParameters getParams() { |
|
72 |
return this.params; |
|
73 |
} |
|
74 |
|
|
75 |
public String getLabel() { |
|
76 |
return this.label; |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 | 83 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
81 | 84 |
public DefaultJDBCConnectionPanel() { |
82 | 85 |
initComponents(); |
... | ... | |
163 | 166 |
this.lblPassword.setText(i18nManager.getTranslation("_Password")); |
164 | 167 |
this.lblFoother.setText("<html>"+i18nManager.getTranslation("_JDBCConecctionPanel_foother")+"</html>"); |
165 | 168 |
} |
169 |
|
|
170 |
@Override |
|
171 |
public void setLabeledServerExplorerParameters(LabeledValue<JDBCServerExplorerParameters> parameters) { |
|
172 |
if( parameters == null ) { |
|
173 |
return; |
|
174 |
} |
|
175 |
if( parameters.getValue()!=null ) { |
|
176 |
this.setServerExplorerParameters(parameters.getValue()); |
|
177 |
} |
|
178 |
if( !StringUtils.isBlank(parameters.getLabel()) ) { |
|
179 |
this.cboConnections.setSelectedItem(parameters.getLabel()); |
|
180 |
} |
|
181 |
} |
|
166 | 182 |
|
167 | 183 |
@Override |
168 | 184 |
public void setServerExplorerParameters(JDBCServerExplorerParameters parameters) { |
... | ... | |
217 | 233 |
|
218 | 234 |
@Override |
219 | 235 |
public JDBCServerExplorerParameters getServerExplorerParameters() { |
236 |
LabeledValue<JDBCServerExplorerParameters> labeledConnection = this.getLabeledServerExplorerParameters(); |
|
237 |
if( labeledConnection==null ) { |
|
238 |
return null; |
|
239 |
} |
|
240 |
return labeledConnection.getValue(); |
|
241 |
} |
|
242 |
|
|
243 |
@Override |
|
244 |
public LabeledValue<JDBCServerExplorerParameters> getLabeledServerExplorerParameters() { |
|
220 | 245 |
JDBCServerExplorerParameters params; |
221 | 246 |
JDBCServerExplorerParameters connector = this.getConnector(); |
222 | 247 |
if( connector==null ) { |
... | ... | |
248 | 273 |
params.setPassword(s); |
249 | 274 |
} |
250 | 275 |
|
251 |
if ( this.getConnectionName() != null ) { |
|
252 |
DataManager dataManager = DALLocator.getDataManager(); |
|
253 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
|
254 |
pool.add(this.getConnectionName(), params); |
|
276 |
String name = this.getConnectionName(); |
|
277 |
if ( StringUtils.isBlank(name) ) { |
|
278 |
if( params instanceof FilesystemStoreParameters ) { |
|
279 |
File f = ((FilesystemStoreParameters) params).getFile(); |
|
280 |
if( f!=null ) { |
|
281 |
name = FilenameUtils.getBaseName(f.getPath()); |
|
282 |
} |
|
283 |
} |
|
284 |
if( StringUtils.isBlank(name) ) { |
|
285 |
StringBuilder builder = new StringBuilder(); |
|
286 |
builder.append(Objects.toString(params.getHost(),"")); |
|
287 |
if( builder.length()>0 && !builder.toString().endsWith("-")) { |
|
288 |
builder.append("-"); |
|
289 |
} |
|
290 |
builder.append(Objects.toString(params.getPort(),"")); |
|
291 |
if( builder.length()>0 && !builder.toString().endsWith("-")) { |
|
292 |
builder.append("-"); |
|
293 |
} |
|
294 |
builder.append(Objects.toString(params.getDBName(),"")); |
|
295 |
name = builder.toString(); |
|
296 |
} |
|
255 | 297 |
} |
256 |
return params; |
|
298 |
if( StringUtils.isBlank(name) ) { |
|
299 |
name = getUniqueEntryName("Connection"); |
|
300 |
} else { |
|
301 |
name = getUniqueEntryName(name); |
|
302 |
} |
|
303 |
|
|
304 |
DataManager dataManager = DALLocator.getDataManager(); |
|
305 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
|
306 |
pool.add(name, params); |
|
307 |
return new LabeledValueImpl<>(name,params); |
|
257 | 308 |
} |
309 |
|
|
310 |
private String getUniqueEntryName(String name) { |
|
311 |
DataManager dataManager = DALLocator.getDataManager(); |
|
312 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
|
313 |
String baseName = name; |
|
314 |
for (int i = 0; i < 1000; i++) { |
|
315 |
if( !pool.contains(name) ) { |
|
316 |
return name; |
|
317 |
} |
|
318 |
name = baseName+"-"+i; |
|
319 |
} |
|
320 |
return name + System.currentTimeMillis(); |
|
321 |
} |
|
258 | 322 |
|
259 | 323 |
protected void setConnectionName(String connectionName) { |
260 | 324 |
JTextField txtConnections = (JTextField) this.cboConnections.getEditor().getEditorComponent(); |
... | ... | |
269 | 333 |
} |
270 | 334 |
|
271 | 335 |
protected JDBCServerExplorerParameters getConnector() { |
272 |
ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnectors.getSelectedItem(); |
|
273 |
JDBCServerExplorerParameters value = item.getParams(); |
|
274 |
return value; |
|
336 |
LabeledValue<JDBCServerExplorerParameters> item = (LabeledValue<JDBCServerExplorerParameters>) this.cboConnectors.getSelectedItem(); |
|
337 |
if( item == null ) { |
|
338 |
return null; |
|
339 |
} |
|
340 |
return item.getValue(); |
|
275 | 341 |
} |
276 | 342 |
|
277 | 343 |
protected String getConnectorName() { |
... | ... | |
310 | 376 |
} |
311 | 377 |
|
312 | 378 |
private void onChangeConnector() { |
313 |
ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnectors.getSelectedItem();
|
|
379 |
LabeledValue<JDBCServerExplorerParameters> item = (LabeledValue<JDBCServerExplorerParameters>) this.cboConnectors.getSelectedItem();
|
|
314 | 380 |
if( item==null ) { |
315 | 381 |
return; |
316 | 382 |
} |
317 |
JDBCServerExplorerParameters connector = item.getParams();
|
|
383 |
JDBCServerExplorerParameters connector = item.getValue();
|
|
318 | 384 |
|
319 | 385 |
if ( connector == null ) { |
320 | 386 |
return; |
... | ... | |
323 | 389 |
} |
324 | 390 |
|
325 | 391 |
private void onChangeConnection() { |
326 |
Object item = this.cboConnections.getSelectedItem(); |
|
327 |
if ( item instanceof ServerExplorerParametersComboItem ) { |
|
328 |
JDBCServerExplorerParameters connection = ((ServerExplorerParametersComboItem) item).getParams(); |
|
329 |
if ( connection == null ) { |
|
330 |
return; |
|
331 |
} |
|
332 |
this.setServerExplorerParameters(connection); |
|
392 |
LabeledValue<JDBCServerExplorerParameters> item = (LabeledValue<JDBCServerExplorerParameters>) this.cboConnections.getSelectedItem(); |
|
393 |
if( item == null ) { |
|
394 |
return; |
|
333 | 395 |
} |
396 |
JDBCServerExplorerParameters connection = item.getValue(); |
|
397 |
if ( connection == null ) { |
|
398 |
return; |
|
399 |
} |
|
400 |
this.setServerExplorerParameters(connection); |
|
334 | 401 |
} |
335 | 402 |
|
336 | 403 |
|
... | ... | |
340 | 407 |
code = explorerParameters.toString(); |
341 | 408 |
ComboBoxModel model = this.cboConnectors.getModel(); |
342 | 409 |
for ( int i = 0; i < model.getSize(); i++ ) { |
343 |
ServerExplorerParametersComboItem x = (ServerExplorerParametersComboItem) model.getElementAt(i);
|
|
344 |
if ( x.getParams()!=null && x.getParams().getExplorerName().equalsIgnoreCase(explorerParameters.getExplorerName()) ) {
|
|
410 |
LabeledValue<JDBCServerExplorerParameters> x = (LabeledValue<JDBCServerExplorerParameters>) model.getElementAt(i);
|
|
411 |
if ( x!=null && x.getValue()!=null && x.getValue().getExplorerName().equalsIgnoreCase(explorerParameters.getExplorerName()) ) {
|
|
345 | 412 |
return i; |
346 | 413 |
} |
347 | 414 |
} |
... | ... | |
361 | 428 |
private void fillConnectors() { |
362 | 429 |
DataManager dataManager = DALLocator.getDataManager(); |
363 | 430 |
|
364 |
ServerExplorerParametersComboItem last = null;
|
|
431 |
LabeledValue<JDBCServerExplorerParameters> last = null;
|
|
365 | 432 |
this.cboConnectors.removeAllItems(); |
366 |
this.cboConnectors.addItem(new ServerExplorerParametersComboItem("",null));
|
|
433 |
this.cboConnectors.addItem(new LabeledValueImpl("",(JDBCServerExplorerParameters)null));
|
|
367 | 434 |
|
368 | 435 |
for (DataFactory factory : dataManager.getServerExplorerRegister() ) { |
369 | 436 |
if( factory.isHidden() ) { |
... | ... | |
376 | 443 |
last == null ) { |
377 | 444 |
// Si es el proveedor generico de JDBC, lo guarda para |
378 | 445 |
// a?adirlo al final del combo. |
379 |
last = new ServerExplorerParametersComboItem(
|
|
446 |
last = new LabeledValueImpl(
|
|
380 | 447 |
factory.getDescription(), |
381 | 448 |
(JDBCServerExplorerParameters) params |
382 | 449 |
); |
383 | 450 |
} else { |
384 | 451 |
this.cboConnectors.addItem( |
385 |
new ServerExplorerParametersComboItem(
|
|
452 |
new LabeledValueImpl(
|
|
386 | 453 |
factory.getDescription(), |
387 | 454 |
(JDBCServerExplorerParameters) params |
388 | 455 |
) |
... | ... | |
400 | 467 |
DataManager dataManager = DALLocator.getDataManager(); |
401 | 468 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
402 | 469 |
|
403 |
DataServerExplorerParameters params; |
|
404 | 470 |
this.cboConnections.removeAllItems(); |
405 |
Iterator it = pool.iterator(); |
|
406 |
while ( it.hasNext() ) { |
|
407 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) it.next(); |
|
471 |
for (DataServerExplorerPoolEntry entry : pool) { |
|
408 | 472 |
if ( entry.getExplorerParameters() instanceof JDBCServerExplorerParameters ) { |
409 | 473 |
if( this.connectorFilter==null || this.connectorFilter.accept((JDBCServerExplorerParameters) entry.getExplorerParameters()) ) { |
410 | 474 |
JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) entry.getExplorerParameters(); |
411 | 475 |
this.cboConnections.addItem( |
412 |
new ServerExplorerParametersComboItem(entry.getName(), dbParams)
|
|
476 |
new LabeledValueImpl<>(entry.getName(), dbParams)
|
|
413 | 477 |
); |
414 | 478 |
} |
415 | 479 |
} |
... | ... | |
436 | 500 |
this.txtDataBase.setText(""); |
437 | 501 |
this.txtUsername.setText(""); |
438 | 502 |
this.txtPassword.setText(""); |
503 |
this.txtFile.setText(""); |
|
439 | 504 |
} |
440 | 505 |
|
441 | 506 |
private void onBrowseDatabase() { |
Also available in: Unified diff