Revision 43355 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/exportto/swing/prov/jdbc/panel/SelectTableNamePanel.java
SelectTableNamePanel.java | ||
---|---|---|
26 | 26 |
import java.awt.event.ActionListener; |
27 | 27 |
import java.util.Iterator; |
28 | 28 |
import java.util.List; |
29 |
import java.util.logging.Level; |
|
29 | 30 |
|
30 | 31 |
import javax.swing.DefaultListModel; |
31 | 32 |
import javax.swing.JComponent; |
... | ... | |
44 | 45 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
45 | 46 |
import org.gvsig.fmap.dal.DALLocator; |
46 | 47 |
import org.gvsig.fmap.dal.DataManager; |
48 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
49 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
50 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
51 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
47 | 52 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
48 | 53 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
49 | 54 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
... | ... | |
67 | 72 |
private final ExporttoJDBCOptions provider; |
68 | 73 |
|
69 | 74 |
private FillTablesListTask task = null; |
75 |
private SQLBuilder sqlbuilder; |
|
70 | 76 |
|
71 | 77 |
private static class TableItem { |
72 | 78 |
|
... | ... | |
79 | 85 |
} |
80 | 86 |
|
81 | 87 |
public TableItem(JDBCStoreParameters params) { |
82 |
this(params.getSchema() + "." + params.getTable(), params); |
|
88 |
this( StringUtils.isEmpty(params.getSchema())? |
|
89 |
params.getTable() : params.getSchema() + "." + params.getTable(), |
|
90 |
params); |
|
83 | 91 |
} |
84 | 92 |
|
85 | 93 |
@Override |
... | ... | |
206 | 214 |
); |
207 | 215 |
} |
208 | 216 |
String schema = this.getSchema(); |
209 |
if (schema == null) { |
|
210 |
throw new ExporttoPanelValidationException( |
|
211 |
i18nManager.getTranslation( |
|
212 |
"_The_name_of_schema_cannot_be_empty" |
|
213 |
) |
|
214 |
); |
|
217 |
if( sqlbuilder.supportSchemas() ) { |
|
218 |
if (schema == null) { |
|
219 |
throw new ExporttoPanelValidationException( |
|
220 |
i18nManager.getTranslation( |
|
221 |
"_The_name_of_schema_cannot_be_empty" |
|
222 |
) |
|
223 |
); |
|
224 |
} |
|
215 | 225 |
} |
216 | 226 |
if (this.rdoCreateTable.isSelected()) { |
217 | 227 |
String tablename_tr = tablename; |
... | ... | |
244 | 254 |
ListModel model = this.lstTables.getModel(); |
245 | 255 |
for (int i = 0; i < model.getSize(); i++) { |
246 | 256 |
TableItem item = (TableItem) model.getElementAt(i); |
247 |
if (schema.equals(item.getParams().getSchema())
|
|
248 |
&& tablename.equals(item.getParams().getTable())) {
|
|
257 |
if ( StringUtils.equals(schema,item.getParams().getSchema())
|
|
258 |
&& StringUtils.equals(tablename,item.getParams().getTable())) {
|
|
249 | 259 |
String msg = i18nManager.getTranslation( |
250 | 260 |
"_La_tabla_{0}_{1}_ya_existe_en_la_base_de_datos_Seleccione_la_opcion_de_insertar_registros_en_una_tabla_existente_para_a?adir_los_datos_a_esta_o_indique_otro_nombre", |
251 | 261 |
new String[]{schema, tablename} |
... | ... | |
259 | 269 |
|
260 | 270 |
@Override |
261 | 271 |
public void enterPanel() { |
272 |
JDBCServerExplorerParameters explorerParameters = provider.getExplorerParameters(); |
|
273 |
if (explorerParameters != null) { |
|
274 |
try { |
|
275 |
DataManager dataManager = DALLocator.getDataManager(); |
|
276 |
JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer( |
|
277 |
explorerParameters.getExplorerName(), |
|
278 |
explorerParameters |
|
279 |
); |
|
280 |
this.sqlbuilder = explorer.createSQLBuilder(); |
|
281 |
} catch (Exception ex) { |
|
282 |
throw new RuntimeException("Can't retrieve the sqlbuilder", ex); |
|
283 |
} |
|
284 |
} |
|
262 | 285 |
this.fillTablesList(); |
263 | 286 |
} |
264 | 287 |
|
... | ... | |
325 | 348 |
|
326 | 349 |
@Override |
327 | 350 |
public void run() { |
328 |
txtSchema.setText(explorer.createSQLBuilder().default_schema()); |
|
351 |
if( sqlbuilder.supportSchemas() ) { |
|
352 |
txtSchema.setText(sqlbuilder.default_schema()); |
|
353 |
} else { |
|
354 |
txtSchema.setText(""); |
|
355 |
txtSchema.setEnabled(false); |
|
356 |
} |
|
329 | 357 |
} |
330 | 358 |
}); |
331 | 359 |
|
Also available in: Unified diff