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 @ 3630
History | View | Annotate | Download (22.9 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.VCSGisEntitySelectorController; |
63 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_BEGIN_PROCESSING_ID; |
64 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_END_PROCESSING_ID; |
65 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_RELOAD_ID; |
66 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_SELECT_ID; |
67 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.REMOTE_ENTITIES; |
68 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.notInSwingThreadInvokeLater; |
69 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.showAuthenticationErrors; |
70 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.showAuthenticationRequiredMessage; |
71 |
import org.gvsig.vcsgis.swing.impl.revisions.VCSGisRevisionPickerControllerImpl; |
72 |
import org.slf4j.LoggerFactory; |
73 |
|
74 |
/**
|
75 |
*
|
76 |
* @author gvSIG Team
|
77 |
*/
|
78 |
public class VCSGisJExportImpl extends VCSGisJExportView |
79 |
implements Component, VCSGisJExport { |
80 |
|
81 |
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(VCSGisJExportImpl.class); |
82 |
|
83 |
private Dialog dialog; |
84 |
|
85 |
private PickerController<VCSGisWorkspace> workspacePicker;
|
86 |
private DatePickerController efectivePicker;
|
87 |
private VCSGisEntitySelectorController entitySelector;
|
88 |
private VCSGisRevisionPickerControllerImpl revisionPicker;
|
89 |
private boolean processing; |
90 |
private TaskStatusController taskStatusController;
|
91 |
private String searchedTable; |
92 |
private boolean existsInDataBaseSearchedTable; |
93 |
|
94 |
public VCSGisJExportImpl() {
|
95 |
translate(); |
96 |
processing = false;
|
97 |
initComponents(); |
98 |
} |
99 |
|
100 |
private void initComponents() { |
101 |
//TODO: remove next line in next build (>3208)
|
102 |
this.btnEffectiveDate.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
103 |
|
104 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
105 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
106 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
107 |
VCSGisSwingServices services = swingManager.getDefaultServices(); |
108 |
|
109 |
this.workspacePicker = swingManager.createWorkspacePickerController(
|
110 |
cboWorkspaces, |
111 |
btnInitWorkspace |
112 |
); |
113 |
|
114 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
115 |
doChangeWorkspace(); |
116 |
doUpdateComponents(); |
117 |
}); |
118 |
|
119 |
this.taskStatusController = taskStatusManager.createTaskStatusController(
|
120 |
this.lblStatusTitle,
|
121 |
this.lblStatusMessages,
|
122 |
this.pbStatus
|
123 |
); |
124 |
this.taskStatusController.setShowCancelButton(false); |
125 |
this.taskStatusController.setShowRemoveTaskButton(false); |
126 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager());
|
127 |
SwingUtilities.invokeLater(() -> {
|
128 |
this.taskStatusController.setVisible(false); |
129 |
}); |
130 |
|
131 |
this.entitySelector = VCSGisSwingLocator.getVCSGisSwingManager().createEntitySelectorController(lstTables, txtFilter, btnTable);
|
132 |
this.entitySelector.setFilter(REMOTE_ENTITIES);
|
133 |
this.entitySelector.setViewFilter(REMOTE_ENTITIES);
|
134 |
this.entitySelector.setChecksEnabled(false); |
135 |
this.entitySelector.addActionListener((ActionEvent e) -> { |
136 |
switch(e.getID()){
|
137 |
case ACTION_RELOAD_ID:
|
138 |
case ACTION_BEGIN_PROCESSING_ID:
|
139 |
case ACTION_END_PROCESSING_ID:
|
140 |
doUpdateComponents(); |
141 |
break;
|
142 |
case ACTION_SELECT_ID:
|
143 |
doChangeTable(); |
144 |
doChangeTableName(); |
145 |
break;
|
146 |
} |
147 |
}); |
148 |
this.entitySelector.addChangeListener((ChangeEvent e) -> { |
149 |
doUpdateComponents(); |
150 |
}); |
151 |
|
152 |
this.rdbEffectiveDate.addActionListener((ActionEvent e) -> { |
153 |
doUpdateComponents(); |
154 |
}); |
155 |
|
156 |
this.rdbRevision.addActionListener((ActionEvent e) -> { |
157 |
doUpdateComponents(); |
158 |
}); |
159 |
|
160 |
|
161 |
this.efectivePicker = toolsSwingManager.createDatePickerController(txtEffectiveDate, btnEffectiveDate);
|
162 |
this.efectivePicker.addChangeListener((ChangeEvent e) -> { |
163 |
doChangeTableName(); |
164 |
}); |
165 |
|
166 |
this.revisionPicker = new VCSGisRevisionPickerControllerImpl(txtRevision, btnRevision); |
167 |
this.revisionPicker.addChangeListener((ChangeEvent e) -> { |
168 |
doChangeTableName(); |
169 |
}); |
170 |
|
171 |
ComboBoxModel<LabeledValue> viewDocumentsModel = services.getViewDocumentsComboBoxModel();
|
172 |
cboView.setModel(viewDocumentsModel); |
173 |
cboView.addActionListener((ActionEvent e) -> {
|
174 |
doUpdateComponents(); |
175 |
}); |
176 |
|
177 |
this.rdbDontAddToProject.addActionListener((ActionEvent e) -> { |
178 |
doUpdateComponents(); |
179 |
}); |
180 |
|
181 |
this.rdbAddLayerToView.addActionListener((ActionEvent e) -> { |
182 |
doUpdateComponents(); |
183 |
}); |
184 |
|
185 |
this.rdbAddTableToProject.addActionListener((ActionEvent e) -> { |
186 |
doUpdateComponents(); |
187 |
}); |
188 |
|
189 |
this.txtTableName.getDocument().addDocumentListener(new DocumentListener() { |
190 |
@Override
|
191 |
public void changedUpdate(DocumentEvent e) { |
192 |
doUpdateComponents(); |
193 |
} |
194 |
|
195 |
@Override
|
196 |
public void removeUpdate(DocumentEvent e) { |
197 |
doUpdateComponents(); |
198 |
} |
199 |
|
200 |
@Override
|
201 |
public void insertUpdate(DocumentEvent e) { |
202 |
doUpdateComponents(); |
203 |
} |
204 |
}); |
205 |
|
206 |
this.setPreferredSize(new Dimension(520, 400)); |
207 |
doUpdateComponents(); |
208 |
|
209 |
} |
210 |
|
211 |
@Override
|
212 |
public JComponent asJComponent() { |
213 |
return this; |
214 |
} |
215 |
|
216 |
@Override
|
217 |
public void setDialog(Dialog dialog) { |
218 |
this.dialog = dialog;
|
219 |
this.doUpdateComponents();
|
220 |
} |
221 |
|
222 |
private void doChangeWorkspace() { |
223 |
try {
|
224 |
VCSGisWorkspace ws = this.getWorkspace();
|
225 |
if (ws == null) { |
226 |
this.entitySelector.setWorkspace(ws);
|
227 |
this.revisionPicker.setWorkspace(ws);
|
228 |
return;
|
229 |
} |
230 |
if (ws.authenticate(null)) { |
231 |
this.entitySelector.setWorkspace(ws);
|
232 |
this.revisionPicker.setWorkspace(ws);
|
233 |
|
234 |
Thread task = new Thread( |
235 |
() -> { |
236 |
try {
|
237 |
LOGGER.info("Entro en el thread");
|
238 |
processing = true;
|
239 |
doUpdateComponents(); |
240 |
ws.getRepositoryEntities(); |
241 |
} catch (Exception ex) { |
242 |
LOGGER.warn("Can't retrieve repository entities", ex);
|
243 |
} finally {
|
244 |
LOGGER.info("Salgo del thread");
|
245 |
processing = false;
|
246 |
doUpdateComponents(); |
247 |
} |
248 |
}, |
249 |
"VCSGisExportGetRepositoryEntities"
|
250 |
); |
251 |
this.processing = true; |
252 |
LOGGER.info("Creando thread");
|
253 |
doUpdateComponents(); |
254 |
task.start(); |
255 |
|
256 |
return;
|
257 |
} |
258 |
showAuthenticationRequiredMessage("_VCS_Checkout");
|
259 |
this.workspacePicker.set(null); |
260 |
doChangeWorkspace(); |
261 |
} catch (VCSGisRuntimeException e1) {
|
262 |
LOGGER.warn("Can't set workspace.", e1);
|
263 |
if (showAuthenticationErrors("_VCS_Checkout", e1)) { |
264 |
this.workspacePicker.set(null); |
265 |
doChangeWorkspace(); |
266 |
} |
267 |
} catch (Exception e2) { |
268 |
LOGGER.warn("Can't set workspace.", e2);
|
269 |
} |
270 |
|
271 |
|
272 |
|
273 |
|
274 |
// VCSGisWorkspace workspace = this.getWorkspace();
|
275 |
// if (workspace == null) {
|
276 |
// return;
|
277 |
// }
|
278 |
// this.entitySelector.setWorkspace(workspace);
|
279 |
// this.revisionPicker.setWorkspace(workspace);
|
280 |
//
|
281 |
// Thread task = new Thread(
|
282 |
// () -> {
|
283 |
// try {
|
284 |
// LOGGER.info("Entro en el thread");
|
285 |
// processing = true;
|
286 |
// doUpdateEnableComponents();
|
287 |
// workspace.getRepositoryEntities();
|
288 |
// }catch (Exception ex){
|
289 |
// LOGGER.warn("Can't retrieve repository entities", ex);
|
290 |
// }finally{
|
291 |
// LOGGER.info("Salgo del thread");
|
292 |
// processing = false;
|
293 |
// doUpdateEnableComponents();
|
294 |
// }
|
295 |
// },
|
296 |
// "VCSGisExportGetRepositoryEntities"
|
297 |
// );
|
298 |
// this.processing = true;
|
299 |
// LOGGER.info("Creando thread");
|
300 |
// doUpdateEnableComponents();
|
301 |
// task.start();
|
302 |
} |
303 |
|
304 |
private void doChangeTable() { |
305 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity();
|
306 |
this.revisionPicker.setEntity(selectedTable);
|
307 |
this.efectivePicker.set(null); |
308 |
this.txtTableName.setText(""); |
309 |
} |
310 |
|
311 |
private void doChangeTableName() { |
312 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity();
|
313 |
if(selectedTable == null){ |
314 |
this.txtTableName.setText(""); |
315 |
return;
|
316 |
} |
317 |
String suffix;
|
318 |
Timestamp timestamp;
|
319 |
if(rdbEffectiveDate.isSelected() && this.efectivePicker.get() != null){ |
320 |
timestamp = DataTypeUtils.toTimestamp(this.efectivePicker.get());
|
321 |
suffix = timestamp.toString(); |
322 |
} else if(rdbRevision.isSelected() && revisionPicker.get() != null){ |
323 |
VCSGisRevision revision = revisionPicker.get(); |
324 |
suffix = "r"+revision.getNumber()+" "+revision.getRevisionDate().toString(); |
325 |
} else {
|
326 |
timestamp = DataTypeUtils.toTimestamp(new Date()); |
327 |
suffix = timestamp.toString(); |
328 |
} |
329 |
this.txtTableName.setText(normalizeTableName(selectedTable.getEntityName() + "_" + suffix)); |
330 |
} |
331 |
|
332 |
@Override
|
333 |
public VCSGisWorkspace getWorkspace() {
|
334 |
return this.workspacePicker.get(); |
335 |
} |
336 |
|
337 |
@Override
|
338 |
public VCSGisEntity getTable() {
|
339 |
return this.entitySelector.getSelectedEntity(); |
340 |
} |
341 |
|
342 |
private void doUpdateComponents() { |
343 |
if (notInSwingThreadInvokeLater(this::doUpdateComponents)) { |
344 |
return;
|
345 |
} |
346 |
try {
|
347 |
boolean isProcessing = this.processing || this.entitySelector.isProcessing(); |
348 |
|
349 |
this.workspacePicker.setEnabled(!isProcessing);
|
350 |
|
351 |
VCSGisWorkspace workspace = getWorkspace(); |
352 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity();
|
353 |
|
354 |
String tableName = this.txtTableName.getText(); |
355 |
|
356 |
boolean exists = workspace != null |
357 |
&& selectedTable != null
|
358 |
&& existsInDataBase(); |
359 |
|
360 |
boolean isThereTableSelected = !isProcessing && workspace != null |
361 |
&& (selectedTable != null);
|
362 |
|
363 |
boolean canExport = isThereTableSelected
|
364 |
&& StringUtils.isNotBlank(tableName) |
365 |
&& !exists |
366 |
&& workspace.getEntity(tableName) == null;
|
367 |
|
368 |
if(exists){
|
369 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
370 |
showMessage( |
371 |
i18n.getTranslation("_Table_already_exists_in_working_copy"),
|
372 |
i18n.getTranslation("_You_can_rename_the_table")
|
373 |
); |
374 |
setVisibleStatus(true);
|
375 |
} else {
|
376 |
showMessage("", ""); |
377 |
setVisibleStatus(true);
|
378 |
} |
379 |
|
380 |
LOGGER.info("canExport = "+canExport+", processing = "+processing+", ws = "+workspace); |
381 |
|
382 |
this.entitySelector.setEnabled(!isProcessing && workspace != null); |
383 |
|
384 |
this.rdbRevision.setEnabled(isThereTableSelected);
|
385 |
this.revisionPicker.setEnabled(isThereTableSelected && this.rdbRevision.isSelected()); |
386 |
|
387 |
this.rdbEffectiveDate.setEnabled(isThereTableSelected);
|
388 |
this.efectivePicker.setEnabled(isThereTableSelected && this.rdbEffectiveDate.isSelected()); |
389 |
|
390 |
this.rdbDontAddToProject.setEnabled(canExport);
|
391 |
this.rdbAddTableToProject.setEnabled(canExport);
|
392 |
if (canExport) {
|
393 |
if (isLayer(selectedTable)) {
|
394 |
this.rdbAddLayerToView.setEnabled(canExport);
|
395 |
// this.cboView.setEnabled(canExport && this.rdbAddLayerToView.isSelected());
|
396 |
|
397 |
if (this.cboView.getModel().getSize() > 0) { |
398 |
this.rdbAddLayerToView.setSelected(canExport && !this.rdbDontAddToProject.isSelected()); |
399 |
this.cboView.setEnabled(canExport && this.rdbAddLayerToView.isSelected()); |
400 |
if (this.cboView.getModel().getSize() == 2) { |
401 |
this.cboView.setSelectedIndex(1); |
402 |
} else {
|
403 |
this.cboView.setSelectedIndex(0); |
404 |
} |
405 |
} else {
|
406 |
this.rdbAddLayerToView.setSelected(false); |
407 |
this.cboView.setEnabled(false); |
408 |
this.cboView.setSelectedIndex(0); |
409 |
} |
410 |
|
411 |
} else {
|
412 |
if(!this.rdbDontAddToProject.isSelected()){ |
413 |
this.rdbAddTableToProject.setSelected(true); |
414 |
} |
415 |
this.rdbAddLayerToView.setEnabled(false); |
416 |
this.cboView.setEnabled(false); |
417 |
this.cboView.setSelectedIndex(0); |
418 |
} |
419 |
} else {
|
420 |
this.rdbAddLayerToView.setEnabled(false); |
421 |
this.cboView.setEnabled(false); |
422 |
} |
423 |
|
424 |
// this.workspacePicker.setEnabled(!isProcessing);
|
425 |
this.entitySelector.setEnabled(!isProcessing && workspace != null); |
426 |
this.lblTableName.setEnabled(isThereTableSelected);
|
427 |
this.txtTableName.setEnabled(isThereTableSelected);
|
428 |
LOGGER.info("isProcessing = "+isProcessing+", processing = "+processing+", ws = "+workspace); |
429 |
|
430 |
this.pbStatus.setVisible(isProcessing);
|
431 |
this.lblStatusTitle.setVisible(isProcessing);
|
432 |
|
433 |
if (dialog != null) { |
434 |
LabeledValue selectedView = (LabeledValue) cboView.getSelectedItem(); |
435 |
boolean dontAddNothing = rdbDontAddToProject.isSelected();
|
436 |
boolean addLayerToView = rdbAddLayerToView.isSelected() && selectedView != null && selectedView.getValue() != null; |
437 |
boolean addTableToProject = rdbAddTableToProject.isSelected();
|
438 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK,
|
439 |
canExport && (dontAddNothing || (addLayerToView || addTableToProject)) |
440 |
); |
441 |
} |
442 |
} catch (VCSGisRuntimeException e1) {
|
443 |
LOGGER.warn("Can't updating components.", e1);
|
444 |
if (showAuthenticationErrors("_VCS_Export", e1)) { |
445 |
this.workspacePicker.set(null); |
446 |
doChangeWorkspace(); |
447 |
doUpdateComponents(); |
448 |
} |
449 |
} catch (Exception e2) { |
450 |
LOGGER.warn("Can't updating components.", e2);
|
451 |
} |
452 |
} |
453 |
|
454 |
private boolean isLayer(VCSGisEntity entity) { |
455 |
return !StringUtils.isBlank(entity.getGeometryFieldName());
|
456 |
} |
457 |
|
458 |
private boolean isLayer(FeatureStore store) { |
459 |
FeatureType ft = store.getDefaultFeatureTypeQuietly(); |
460 |
if(ft == null){ |
461 |
return false; |
462 |
} |
463 |
return ft.getDefaultGeometryAttribute()!=null; |
464 |
} |
465 |
|
466 |
@Override
|
467 |
public int export() { |
468 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
469 |
|
470 |
VCSGisEntity entity = entitySelector.getSelectedEntity(); |
471 |
final VCSGisWorkspace workspace = this.getWorkspace(); |
472 |
|
473 |
VCSGisRevision revision = this.revisionPicker.get();
|
474 |
if (workspace != null && entity != null) { |
475 |
try {
|
476 |
processing = true;
|
477 |
doUpdateComponents(); |
478 |
|
479 |
showMessage(i18n.getTranslation("_Processing"), null); |
480 |
int res; // = ERR_OK; |
481 |
String tableName = this.txtTableName.getText(); |
482 |
|
483 |
res = workspace.export(entity.getEntityName(), |
484 |
tableName, |
485 |
(revision == null) ? null : revision.getRevisionCode(), |
486 |
DataTypeUtils.toTimestamp(efectivePicker.get()), |
487 |
null
|
488 |
); |
489 |
postExport(res, tableName); |
490 |
showMessage(i18n.getTranslation("_Ended_process"), null); |
491 |
return res;
|
492 |
} finally {
|
493 |
processing = false;
|
494 |
doUpdateComponents(); |
495 |
} |
496 |
} |
497 |
return ERR_CANT_CHECKOUT;
|
498 |
} |
499 |
|
500 |
private void translate() { |
501 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
502 |
swingManager.translate(this.lblWorkspace);
|
503 |
swingManager.translate(this.lblTable);
|
504 |
swingManager.translate(this.rdbEffectiveDate);
|
505 |
swingManager.translate(this.rdbRevision);
|
506 |
swingManager.translate(this.rdbDontAddToProject);
|
507 |
swingManager.translate(this.rdbAddLayerToView);
|
508 |
swingManager.translate(this.rdbAddTableToProject);
|
509 |
swingManager.translate(this.lblTableName);
|
510 |
swingManager.translate(this.lblAddTableToProject);
|
511 |
} |
512 |
|
513 |
@Override
|
514 |
public boolean isProcessing() { |
515 |
return this.processing; |
516 |
} |
517 |
|
518 |
private void postExport(int checkoutStatus, String tableName) { |
519 |
if (notInSwingThreadInvokeLater(() -> {
|
520 |
postExport(checkoutStatus, tableName); |
521 |
})) { |
522 |
return;
|
523 |
} |
524 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
525 |
VCSGisSwingServices services = swingManager.getDefaultServices(); |
526 |
final VCSGisWorkspace workspace = this.getWorkspace(); |
527 |
|
528 |
if (checkoutStatus == ERR_OK) {
|
529 |
FeatureStore store = workspace.openFeatureStore(tableName); |
530 |
if (!rdbDontAddToProject.isSelected()) {
|
531 |
if (rdbAddLayerToView.isSelected()) {
|
532 |
if (isLayer(store)) {
|
533 |
String newLayerName = tableName;
|
534 |
services.addLayerToView(store, (LabeledValue) cboView.getSelectedItem(), newLayerName); |
535 |
} |
536 |
} |
537 |
if (rdbAddTableToProject.isSelected()) {
|
538 |
String newLayerName = this.txtTableName.getText(); |
539 |
services.addTableToProject(workspace, store, newLayerName); |
540 |
} |
541 |
} |
542 |
this.setVisibleStatus(false); |
543 |
} else {
|
544 |
this.setVisibleStatus(true); |
545 |
} |
546 |
searchedTable = null;
|
547 |
this.doUpdateComponents();
|
548 |
|
549 |
} |
550 |
|
551 |
public void setVisibleStatus(boolean visible) { |
552 |
if (notInSwingThreadInvokeLater(() -> {
|
553 |
setVisibleStatus(visible); |
554 |
})) { |
555 |
return;
|
556 |
} |
557 |
this.lblStatusTitle.setVisible(visible);
|
558 |
this.pbStatus.setVisible(visible);
|
559 |
this.lblStatusMessages.setVisible(true); |
560 |
} |
561 |
|
562 |
private void showMessage(String message, String toolTipText) { |
563 |
if (notInSwingThreadInvokeLater(() -> {
|
564 |
showMessage(message, toolTipText); |
565 |
})) { |
566 |
return;
|
567 |
} |
568 |
this.lblStatusMessages.setText(message);
|
569 |
this.lblStatusMessages.setToolTipText(toolTipText);
|
570 |
} |
571 |
|
572 |
private boolean existsInDataBase() { |
573 |
String tableName = this.txtTableName.getText(); |
574 |
if (StringUtils.isBlank(tableName)) {
|
575 |
return true; |
576 |
} |
577 |
if(StringUtils.equalsIgnoreCase(tableName, searchedTable)){
|
578 |
return existsInDataBaseSearchedTable;
|
579 |
} |
580 |
VCSGisWorkspace ws = getWorkspace(); |
581 |
FeatureStore store = null;
|
582 |
try {
|
583 |
store = ws.openFeatureStore(tableName); |
584 |
searchedTable = tableName; |
585 |
existsInDataBaseSearchedTable = (store != null);
|
586 |
return existsInDataBaseSearchedTable;
|
587 |
} catch (Exception ex) { |
588 |
return false; |
589 |
} finally {
|
590 |
DisposeUtils.disposeQuietly(store); |
591 |
} |
592 |
} |
593 |
|
594 |
private String normalizeTableName(String tableName){ |
595 |
return tableName.replaceAll("[-:]", "").replaceAll("[ .]", "_").toUpperCase(); |
596 |
} |
597 |
|
598 |
} |