gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.swing / org.gvsig.vcsgis.swing.impl / src / main / java / org / gvsig / vcsgis / swing / impl / export / VCSGisJExportImpl.java @ 3459
History | View | Annotate | Download (21.4 KB)
1 |
/*
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2020 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
18 |
*
|
19 |
* For any additional information, do not hesitate to contact us
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
21 |
*/
|
22 |
package org.gvsig.vcsgis.swing.impl.export; |
23 |
|
24 |
import java.awt.Cursor; |
25 |
import java.awt.Dimension; |
26 |
import java.awt.event.ActionEvent; |
27 |
import java.sql.Timestamp; |
28 |
import java.util.Date; |
29 |
import javax.swing.ComboBoxModel; |
30 |
import javax.swing.JComponent; |
31 |
import javax.swing.SwingUtilities; |
32 |
import javax.swing.event.ChangeEvent; |
33 |
import javax.swing.event.DocumentEvent; |
34 |
import javax.swing.event.DocumentListener; |
35 |
import org.apache.commons.lang3.StringUtils; |
36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
37 |
import org.gvsig.fmap.dal.feature.FeatureType; |
38 |
import org.gvsig.tools.ToolsLocator; |
39 |
import org.gvsig.tools.dataTypes.DataTypeUtils; |
40 |
import org.gvsig.tools.dispose.DisposeUtils; |
41 |
import org.gvsig.tools.i18n.I18nManager; |
42 |
import org.gvsig.tools.swing.api.Component; |
43 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
44 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
45 |
import org.gvsig.tools.swing.api.pickercontroller.DatePickerController; |
46 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
47 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
48 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
49 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
50 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
51 |
import org.gvsig.tools.util.LabeledValue; |
52 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
53 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_CANT_CHECKOUT; |
54 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
55 |
import org.gvsig.vcsgis.lib.VCSGisRevision; |
56 |
import org.gvsig.vcsgis.lib.VCSGisRuntimeException; |
57 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
58 |
import org.gvsig.vcsgis.swing.VCSGisJExport; |
59 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
60 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
61 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
62 |
import org.gvsig.vcsgis.swing.impl.VCSGisEntitySelectorController; |
63 |
import static org.gvsig.vcsgis.swing.impl.VCSGisEntitySelectorController.REMOTE_ENTITIES; |
64 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.notInSwingThreadInvokeLater; |
65 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.showAuthenticationErrors; |
66 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.showAuthenticationRequiredMessage; |
67 |
import org.gvsig.vcsgis.swing.impl.revisions.VCSGisRevisionPickerControllerImpl; |
68 |
import org.slf4j.LoggerFactory; |
69 |
|
70 |
/**
|
71 |
*
|
72 |
* @author gvSIG Team
|
73 |
*/
|
74 |
public class VCSGisJExportImpl extends VCSGisJExportView |
75 |
implements Component, VCSGisJExport { |
76 |
|
77 |
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(VCSGisJExportImpl.class); |
78 |
|
79 |
private Dialog dialog; |
80 |
|
81 |
private PickerController<VCSGisWorkspace> workspacePicker;
|
82 |
private DatePickerController efectivePicker;
|
83 |
private VCSGisEntitySelectorController entitySelector;
|
84 |
private VCSGisRevisionPickerControllerImpl revisionPicker;
|
85 |
private boolean processing; |
86 |
private TaskStatusController taskStatusController;
|
87 |
private String searchedTable; |
88 |
private boolean existsInDataBaseSearchedTable; |
89 |
|
90 |
public VCSGisJExportImpl() {
|
91 |
translate(); |
92 |
processing = false;
|
93 |
initComponents(); |
94 |
} |
95 |
|
96 |
private void initComponents() { |
97 |
//TODO: remove next line in next build (>3208)
|
98 |
this.btnEffectiveDate.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
99 |
|
100 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
101 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
102 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
103 |
VCSGisSwingServices services = swingManager.getDefaultServices(); |
104 |
|
105 |
this.workspacePicker = swingManager.createWorkspacePickerController(
|
106 |
cboWorkspaces, |
107 |
btnInitWorkspace |
108 |
); |
109 |
|
110 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
111 |
doChangeWorkspace(); |
112 |
doUpdateEnableComponents(); |
113 |
}); |
114 |
|
115 |
this.taskStatusController = taskStatusManager.createTaskStatusController(
|
116 |
this.lblStatusTitle,
|
117 |
this.lblStatusMessages,
|
118 |
this.pbStatus
|
119 |
); |
120 |
this.taskStatusController.setShowCancelButton(false); |
121 |
this.taskStatusController.setShowRemoveTaskButton(false); |
122 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager());
|
123 |
SwingUtilities.invokeLater(() -> {
|
124 |
this.taskStatusController.setVisible(false); |
125 |
}); |
126 |
|
127 |
this.entitySelector = VCSGisEntitySelectorController.create(lstTables, txtFilter, btnTable);
|
128 |
this.entitySelector.setFilter(REMOTE_ENTITIES);
|
129 |
this.entitySelector.setViewFilter(REMOTE_ENTITIES);
|
130 |
this.entitySelector.setChecksEnabled(false); |
131 |
this.entitySelector.addActionListener((ActionEvent e) -> { |
132 |
doChangeTable(); |
133 |
doChangeTableName(); |
134 |
}); |
135 |
this.entitySelector.addChangeListener((ChangeEvent e) -> { |
136 |
doUpdateEnableComponents(); |
137 |
}); |
138 |
|
139 |
this.rdbEffectiveDate.addActionListener((ActionEvent e) -> { |
140 |
doUpdateEnableComponents(); |
141 |
}); |
142 |
|
143 |
this.rdbRevision.addActionListener((ActionEvent e) -> { |
144 |
doUpdateEnableComponents(); |
145 |
}); |
146 |
|
147 |
|
148 |
this.efectivePicker = toolsSwingManager.createDatePickerController(txtEffectiveDate, btnEffectiveDate);
|
149 |
this.efectivePicker.addChangeListener((ChangeEvent e) -> { |
150 |
doChangeTableName(); |
151 |
}); |
152 |
|
153 |
this.revisionPicker = new VCSGisRevisionPickerControllerImpl(txtRevision, btnRevision); |
154 |
this.revisionPicker.addChangeListener((ChangeEvent e) -> { |
155 |
doChangeTableName(); |
156 |
}); |
157 |
|
158 |
ComboBoxModel<LabeledValue> viewDocumentsModel = services.getViewDocumentsComboBoxModel();
|
159 |
cboView.setModel(viewDocumentsModel); |
160 |
cboView.addActionListener((ActionEvent e) -> {
|
161 |
doUpdateEnableComponents(); |
162 |
}); |
163 |
|
164 |
this.rdbDontAddToProject.addActionListener((ActionEvent e) -> { |
165 |
doUpdateEnableComponents(); |
166 |
}); |
167 |
|
168 |
this.rdbAddLayerToView.addActionListener((ActionEvent e) -> { |
169 |
doUpdateEnableComponents(); |
170 |
}); |
171 |
|
172 |
this.rdbAddTableToProject.addActionListener((ActionEvent e) -> { |
173 |
doUpdateEnableComponents(); |
174 |
}); |
175 |
|
176 |
this.txtTableName.getDocument().addDocumentListener(new DocumentListener() { |
177 |
@Override
|
178 |
public void changedUpdate(DocumentEvent e) { |
179 |
doUpdateEnableComponents(); |
180 |
} |
181 |
|
182 |
@Override
|
183 |
public void removeUpdate(DocumentEvent e) { |
184 |
doUpdateEnableComponents(); |
185 |
} |
186 |
|
187 |
@Override
|
188 |
public void insertUpdate(DocumentEvent e) { |
189 |
doUpdateEnableComponents(); |
190 |
} |
191 |
}); |
192 |
|
193 |
this.setPreferredSize(new Dimension(520, 400)); |
194 |
doUpdateEnableComponents(); |
195 |
|
196 |
} |
197 |
|
198 |
@Override
|
199 |
public JComponent asJComponent() { |
200 |
return this; |
201 |
} |
202 |
|
203 |
@Override
|
204 |
public void setDialog(Dialog dialog) { |
205 |
this.dialog = dialog;
|
206 |
this.doUpdateEnableComponents();
|
207 |
} |
208 |
|
209 |
private void doChangeWorkspace() { |
210 |
try {
|
211 |
VCSGisWorkspace ws = this.getWorkspace();
|
212 |
if (ws == null) { |
213 |
this.entitySelector.setWorkspace(ws);
|
214 |
this.revisionPicker.setWorkspace(ws);
|
215 |
return;
|
216 |
} |
217 |
if (ws.authenticate(null)) { |
218 |
this.entitySelector.setWorkspace(ws);
|
219 |
this.revisionPicker.setWorkspace(ws);
|
220 |
|
221 |
Thread task = new Thread( |
222 |
() -> { |
223 |
try {
|
224 |
LOGGER.info("Entro en el thread");
|
225 |
processing = true;
|
226 |
doUpdateEnableComponents(); |
227 |
ws.getRepositoryEntities(); |
228 |
} catch (Exception ex) { |
229 |
LOGGER.warn("Can't retrieve repository entities", ex);
|
230 |
} finally {
|
231 |
LOGGER.info("Salgo del thread");
|
232 |
processing = false;
|
233 |
doUpdateEnableComponents(); |
234 |
} |
235 |
}, |
236 |
"VCSGisExportGetRepositoryEntities"
|
237 |
); |
238 |
this.processing = true; |
239 |
LOGGER.info("Creando thread");
|
240 |
doUpdateEnableComponents(); |
241 |
task.start(); |
242 |
|
243 |
return;
|
244 |
} |
245 |
showAuthenticationRequiredMessage("_VCS_Checkout");
|
246 |
this.workspacePicker.set(null); |
247 |
doChangeWorkspace(); |
248 |
} catch (VCSGisRuntimeException e1) {
|
249 |
LOGGER.warn("Can't set workspace.", e1);
|
250 |
if (showAuthenticationErrors("_VCS_Checkout", e1)) { |
251 |
this.workspacePicker.set(null); |
252 |
doChangeWorkspace(); |
253 |
} |
254 |
} catch (Exception e2) { |
255 |
LOGGER.warn("Can't set workspace.", e2);
|
256 |
} |
257 |
|
258 |
|
259 |
|
260 |
|
261 |
// VCSGisWorkspace workspace = this.getWorkspace();
|
262 |
// if (workspace == null) {
|
263 |
// return;
|
264 |
// }
|
265 |
// this.entitySelector.setWorkspace(workspace);
|
266 |
// this.revisionPicker.setWorkspace(workspace);
|
267 |
//
|
268 |
// Thread task = new Thread(
|
269 |
// () -> {
|
270 |
// try {
|
271 |
// LOGGER.info("Entro en el thread");
|
272 |
// processing = true;
|
273 |
// doUpdateEnableComponents();
|
274 |
// workspace.getRepositoryEntities();
|
275 |
// }catch (Exception ex){
|
276 |
// LOGGER.warn("Can't retrieve repository entities", ex);
|
277 |
// }finally{
|
278 |
// LOGGER.info("Salgo del thread");
|
279 |
// processing = false;
|
280 |
// doUpdateEnableComponents();
|
281 |
// }
|
282 |
// },
|
283 |
// "VCSGisExportGetRepositoryEntities"
|
284 |
// );
|
285 |
// this.processing = true;
|
286 |
// LOGGER.info("Creando thread");
|
287 |
// doUpdateEnableComponents();
|
288 |
// task.start();
|
289 |
} |
290 |
|
291 |
private void doChangeTable() { |
292 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity();
|
293 |
this.revisionPicker.setEntity(selectedTable);
|
294 |
this.efectivePicker.set(null); |
295 |
this.txtTableName.setText(""); |
296 |
} |
297 |
|
298 |
private void doChangeTableName() { |
299 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity();
|
300 |
if(selectedTable == null){ |
301 |
this.txtTableName.setText(""); |
302 |
return;
|
303 |
} |
304 |
String suffix;
|
305 |
Timestamp timestamp;
|
306 |
if(rdbEffectiveDate.isSelected() && this.efectivePicker.get() != null){ |
307 |
timestamp = DataTypeUtils.toTimestamp(this.efectivePicker.get());
|
308 |
suffix = timestamp.toString(); |
309 |
} else if(rdbRevision.isSelected() && revisionPicker.get() != null){ |
310 |
VCSGisRevision revision = revisionPicker.get(); |
311 |
suffix = "r"+revision.getNumber()+" "+revision.getRevisionDate().toString(); |
312 |
} else {
|
313 |
timestamp = DataTypeUtils.toTimestamp(new Date()); |
314 |
suffix = timestamp.toString(); |
315 |
} |
316 |
this.txtTableName.setText(normalizeTableName(selectedTable.getEntityName() + "_" + suffix)); |
317 |
} |
318 |
|
319 |
@Override
|
320 |
public VCSGisWorkspace getWorkspace() {
|
321 |
return this.workspacePicker.get(); |
322 |
} |
323 |
|
324 |
@Override
|
325 |
public VCSGisEntity getTable() {
|
326 |
return this.entitySelector.getSelectedEntity(); |
327 |
} |
328 |
|
329 |
private void doUpdateEnableComponents() { |
330 |
if (notInSwingThreadInvokeLater(this::doUpdateEnableComponents)) { |
331 |
return;
|
332 |
} |
333 |
try {
|
334 |
boolean isProcessing = this.processing || this.entitySelector.isProcessing(); |
335 |
|
336 |
this.workspacePicker.setEnabled(!isProcessing);
|
337 |
|
338 |
VCSGisWorkspace workspace = getWorkspace(); |
339 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity();
|
340 |
|
341 |
String tableName = this.txtTableName.getText(); |
342 |
|
343 |
boolean exists = workspace != null |
344 |
&& selectedTable != null
|
345 |
&& existsInDataBase(); |
346 |
|
347 |
boolean isThereTableSelected = !isProcessing && workspace != null |
348 |
&& (selectedTable != null);
|
349 |
|
350 |
boolean canExport = isThereTableSelected
|
351 |
&& StringUtils.isNotBlank(tableName) |
352 |
&& !exists |
353 |
&& workspace.getEntity(tableName) == null;
|
354 |
|
355 |
if(exists){
|
356 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
357 |
showMessage( |
358 |
i18n.getTranslation("_Table_already_exists_in_working_copy"),
|
359 |
i18n.getTranslation("_You_can_rename_the_table")
|
360 |
); |
361 |
setVisibleStatus(true);
|
362 |
} else {
|
363 |
showMessage("", ""); |
364 |
setVisibleStatus(true);
|
365 |
} |
366 |
|
367 |
LOGGER.info("canExport = "+canExport+", processing = "+processing+", ws = "+workspace); |
368 |
|
369 |
this.entitySelector.setEnabled(!isProcessing && workspace != null); |
370 |
|
371 |
this.rdbRevision.setEnabled(isThereTableSelected);
|
372 |
this.revisionPicker.setEnabled(isThereTableSelected && this.rdbRevision.isSelected()); |
373 |
|
374 |
this.rdbEffectiveDate.setEnabled(isThereTableSelected);
|
375 |
this.efectivePicker.setEnabled(isThereTableSelected && this.rdbEffectiveDate.isSelected()); |
376 |
|
377 |
this.rdbDontAddToProject.setEnabled(canExport);
|
378 |
this.rdbAddTableToProject.setEnabled(canExport);
|
379 |
if (canExport) {
|
380 |
if (isLayer(selectedTable)) {
|
381 |
this.rdbAddLayerToView.setEnabled(canExport);
|
382 |
this.cboView.setEnabled(canExport && this.rdbAddLayerToView.isSelected()); |
383 |
} else {
|
384 |
this.rdbAddLayerToView.setEnabled(false); |
385 |
this.cboView.setEnabled(false); |
386 |
} |
387 |
} else {
|
388 |
this.rdbAddLayerToView.setEnabled(false); |
389 |
this.cboView.setEnabled(false); |
390 |
} |
391 |
|
392 |
// this.workspacePicker.setEnabled(!isProcessing);
|
393 |
this.entitySelector.setEnabled(!isProcessing && workspace != null); |
394 |
this.lblTableName.setEnabled(isThereTableSelected);
|
395 |
this.txtTableName.setEnabled(isThereTableSelected);
|
396 |
LOGGER.info("isProcessing = "+isProcessing+", processing = "+processing+", ws = "+workspace); |
397 |
|
398 |
this.pbStatus.setVisible(isProcessing);
|
399 |
this.lblStatusTitle.setVisible(isProcessing);
|
400 |
|
401 |
if (dialog != null) { |
402 |
LabeledValue selectedView = (LabeledValue) cboView.getSelectedItem(); |
403 |
boolean dontAddNothing = rdbDontAddToProject.isSelected();
|
404 |
boolean addLayerToView = rdbAddLayerToView.isSelected() && selectedView != null && selectedView.getValue() != null; |
405 |
boolean addTableToProject = rdbAddTableToProject.isSelected();
|
406 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK,
|
407 |
canExport && (dontAddNothing || (addLayerToView || addTableToProject)) |
408 |
); |
409 |
} |
410 |
} catch (VCSGisRuntimeException e1) {
|
411 |
LOGGER.warn("Can't updating components.", e1);
|
412 |
if (showAuthenticationErrors("_VCS_Export", e1)) { |
413 |
this.workspacePicker.set(null); |
414 |
doChangeWorkspace(); |
415 |
doUpdateEnableComponents(); |
416 |
} |
417 |
} catch (Exception e2) { |
418 |
LOGGER.warn("Can't updating components.", e2);
|
419 |
} |
420 |
} |
421 |
|
422 |
private boolean isLayer(VCSGisEntity entity) { |
423 |
return !StringUtils.isBlank(entity.getGeometryFieldName());
|
424 |
} |
425 |
|
426 |
private boolean isLayer(FeatureStore store) { |
427 |
FeatureType ft = store.getDefaultFeatureTypeQuietly(); |
428 |
if(ft == null){ |
429 |
return false; |
430 |
} |
431 |
return ft.getDefaultGeometryAttribute()!=null; |
432 |
} |
433 |
|
434 |
@Override
|
435 |
public int export() { |
436 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
437 |
|
438 |
VCSGisEntity entity = entitySelector.getSelectedEntity(); |
439 |
final VCSGisWorkspace workspace = this.getWorkspace(); |
440 |
|
441 |
VCSGisRevision revision = this.revisionPicker.get();
|
442 |
if (workspace != null && entity != null) { |
443 |
try {
|
444 |
processing = true;
|
445 |
doUpdateEnableComponents(); |
446 |
|
447 |
showMessage(i18n.getTranslation("_Processing"), null); |
448 |
int res; // = ERR_OK; |
449 |
String tableName = this.txtTableName.getText(); |
450 |
|
451 |
res = workspace.export(entity.getEntityName(), |
452 |
tableName, |
453 |
(revision == null) ? null : revision.getRevisionCode(), |
454 |
DataTypeUtils.toTimestamp(efectivePicker.get()), |
455 |
null
|
456 |
); |
457 |
postExport(res, tableName); |
458 |
showMessage(i18n.getTranslation("_Ended_process"), null); |
459 |
return res;
|
460 |
} finally {
|
461 |
processing = false;
|
462 |
doUpdateEnableComponents(); |
463 |
} |
464 |
} |
465 |
return ERR_CANT_CHECKOUT;
|
466 |
} |
467 |
|
468 |
private void translate() { |
469 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
470 |
swingManager.translate(this.lblWorkspace);
|
471 |
swingManager.translate(this.lblTable);
|
472 |
swingManager.translate(this.rdbEffectiveDate);
|
473 |
swingManager.translate(this.rdbRevision);
|
474 |
swingManager.translate(this.rdbDontAddToProject);
|
475 |
swingManager.translate(this.rdbAddLayerToView);
|
476 |
swingManager.translate(this.rdbAddTableToProject);
|
477 |
swingManager.translate(this.lblTableName);
|
478 |
swingManager.translate(this.lblAddTableToProject);
|
479 |
} |
480 |
|
481 |
@Override
|
482 |
public boolean isProcessing() { |
483 |
return this.processing; |
484 |
} |
485 |
|
486 |
private void postExport(int checkoutStatus, String tableName) { |
487 |
if (notInSwingThreadInvokeLater(() -> {
|
488 |
postExport(checkoutStatus, tableName); |
489 |
})) { |
490 |
return;
|
491 |
} |
492 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
493 |
VCSGisSwingServices services = swingManager.getDefaultServices(); |
494 |
final VCSGisWorkspace workspace = this.getWorkspace(); |
495 |
|
496 |
if (checkoutStatus == ERR_OK) {
|
497 |
FeatureStore store = workspace.openFeatureStore(tableName); |
498 |
if (!rdbDontAddToProject.isSelected()) {
|
499 |
if (rdbAddLayerToView.isSelected()) {
|
500 |
if (isLayer(store)) {
|
501 |
String newLayerName = tableName;
|
502 |
services.addLayerToView(store, (LabeledValue) cboView.getSelectedItem(), newLayerName); |
503 |
} |
504 |
} |
505 |
if (rdbAddTableToProject.isSelected()) {
|
506 |
String newLayerName = this.txtTableName.getText(); |
507 |
services.addTableToProject(workspace, store, newLayerName); |
508 |
} |
509 |
} |
510 |
this.setVisibleStatus(false); |
511 |
} else {
|
512 |
this.setVisibleStatus(true); |
513 |
} |
514 |
searchedTable = null;
|
515 |
this.doUpdateEnableComponents();
|
516 |
|
517 |
} |
518 |
|
519 |
public void setVisibleStatus(boolean visible) { |
520 |
if (notInSwingThreadInvokeLater(() -> {
|
521 |
setVisibleStatus(visible); |
522 |
})) { |
523 |
return;
|
524 |
} |
525 |
this.lblStatusTitle.setVisible(visible);
|
526 |
this.pbStatus.setVisible(visible);
|
527 |
this.lblStatusMessages.setVisible(true); |
528 |
} |
529 |
|
530 |
private void showMessage(String message, String toolTipText) { |
531 |
if (notInSwingThreadInvokeLater(() -> {
|
532 |
showMessage(message, toolTipText); |
533 |
})) { |
534 |
return;
|
535 |
} |
536 |
this.lblStatusMessages.setText(message);
|
537 |
this.lblStatusMessages.setToolTipText(toolTipText);
|
538 |
} |
539 |
|
540 |
private boolean existsInDataBase() { |
541 |
String tableName = this.txtTableName.getText(); |
542 |
if (StringUtils.isBlank(tableName)) {
|
543 |
return true; |
544 |
} |
545 |
if(StringUtils.equalsIgnoreCase(tableName, searchedTable)){
|
546 |
return existsInDataBaseSearchedTable;
|
547 |
} |
548 |
VCSGisWorkspace ws = getWorkspace(); |
549 |
FeatureStore store = null;
|
550 |
try {
|
551 |
store = ws.openFeatureStore(tableName); |
552 |
searchedTable = tableName; |
553 |
existsInDataBaseSearchedTable = (store != null);
|
554 |
return existsInDataBaseSearchedTable;
|
555 |
} catch (Exception ex) { |
556 |
return false; |
557 |
} finally {
|
558 |
DisposeUtils.disposeQuietly(store); |
559 |
} |
560 |
} |
561 |
|
562 |
private String normalizeTableName(String tableName){ |
563 |
return tableName.replaceAll("[-:]", "").replaceAll("[ .]", "_").toUpperCase(); |
564 |
} |
565 |
|
566 |
} |