Revision 3458 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
VCSGisJExportImpl.java | ||
---|---|---|
53 | 53 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_CANT_CHECKOUT; |
54 | 54 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
55 | 55 |
import org.gvsig.vcsgis.lib.VCSGisRevision; |
56 |
import org.gvsig.vcsgis.lib.VCSGisRuntimeException; |
|
56 | 57 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
57 | 58 |
import org.gvsig.vcsgis.swing.VCSGisJExport; |
58 | 59 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
... | ... | |
61 | 62 |
import org.gvsig.vcsgis.swing.impl.VCSGisEntitySelectorController; |
62 | 63 |
import static org.gvsig.vcsgis.swing.impl.VCSGisEntitySelectorController.REMOTE_ENTITIES; |
63 | 64 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.notInSwingThreadInvokeLater; |
65 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.showAuthenticationsErrors; |
|
64 | 66 |
import org.gvsig.vcsgis.swing.impl.revisions.VCSGisRevisionPickerControllerImpl; |
65 | 67 |
import org.slf4j.LoggerFactory; |
66 | 68 |
|
... | ... | |
270 | 272 |
if (notInSwingThreadInvokeLater(this::doUpdateEnableComponents)) { |
271 | 273 |
return; |
272 | 274 |
} |
273 |
boolean isProcessing = this.processing || this.entitySelector.isProcessing(); |
|
275 |
try { |
|
276 |
boolean isProcessing = this.processing || this.entitySelector.isProcessing(); |
|
274 | 277 |
|
275 |
this.workspacePicker.setEnabled(!isProcessing); |
|
278 |
this.workspacePicker.setEnabled(!isProcessing);
|
|
276 | 279 |
|
277 |
VCSGisWorkspace workspace = getWorkspace(); |
|
278 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity(); |
|
280 |
VCSGisWorkspace workspace = getWorkspace();
|
|
281 |
VCSGisEntity selectedTable = this.entitySelector.getSelectedEntity();
|
|
279 | 282 |
|
280 |
String tableName = this.txtTableName.getText(); |
|
283 |
String tableName = this.txtTableName.getText();
|
|
281 | 284 |
|
282 |
boolean exists = workspace != null |
|
283 |
&& selectedTable != null |
|
284 |
&& existsInDataBase(); |
|
285 |
|
|
286 |
boolean isThereTableSelected = !isProcessing && workspace != null |
|
287 |
&& (selectedTable != null); |
|
285 |
boolean exists = workspace != null |
|
286 |
&& selectedTable != null |
|
287 |
&& existsInDataBase(); |
|
288 | 288 |
|
289 |
boolean canExport = isThereTableSelected |
|
290 |
&& StringUtils.isNotBlank(tableName) |
|
291 |
&& !exists |
|
292 |
&& workspace.getEntity(tableName) == null; |
|
293 |
|
|
294 |
if(exists){ |
|
295 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
296 |
showMessage( |
|
297 |
i18n.getTranslation("_Table_already_exists_in_working_copy"), |
|
298 |
i18n.getTranslation("_You_can_rename_the_table") |
|
299 |
); |
|
300 |
setVisibleStatus(true); |
|
301 |
} else { |
|
302 |
showMessage("", ""); |
|
303 |
setVisibleStatus(true); |
|
304 |
} |
|
305 |
|
|
306 |
LOGGER.info("canExport = "+canExport+", processing = "+processing+", ws = "+workspace); |
|
289 |
boolean isThereTableSelected = !isProcessing && workspace != null |
|
290 |
&& (selectedTable != null); |
|
307 | 291 |
|
308 |
this.entitySelector.setEnabled(!isProcessing && workspace != null); |
|
292 |
boolean canExport = isThereTableSelected |
|
293 |
&& StringUtils.isNotBlank(tableName) |
|
294 |
&& !exists |
|
295 |
&& workspace.getEntity(tableName) == null; |
|
309 | 296 |
|
310 |
this.rdbRevision.setEnabled(isThereTableSelected); |
|
311 |
this.revisionPicker.setEnabled(isThereTableSelected && this.rdbRevision.isSelected()); |
|
297 |
if(exists){ |
|
298 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
299 |
showMessage( |
|
300 |
i18n.getTranslation("_Table_already_exists_in_working_copy"), |
|
301 |
i18n.getTranslation("_You_can_rename_the_table") |
|
302 |
); |
|
303 |
setVisibleStatus(true); |
|
304 |
} else { |
|
305 |
showMessage("", ""); |
|
306 |
setVisibleStatus(true); |
|
307 |
} |
|
312 | 308 |
|
313 |
this.rdbEffectiveDate.setEnabled(isThereTableSelected); |
|
314 |
this.efectivePicker.setEnabled(isThereTableSelected && this.rdbEffectiveDate.isSelected()); |
|
309 |
LOGGER.info("canExport = "+canExport+", processing = "+processing+", ws = "+workspace); |
|
315 | 310 |
|
316 |
this.rdbDontAddToProject.setEnabled(canExport); |
|
317 |
this.rdbAddTableToProject.setEnabled(canExport); |
|
318 |
if (canExport) { |
|
319 |
if (isLayer(selectedTable)) { |
|
320 |
this.rdbAddLayerToView.setEnabled(canExport); |
|
321 |
this.cboView.setEnabled(canExport && this.rdbAddLayerToView.isSelected()); |
|
311 |
this.entitySelector.setEnabled(!isProcessing && workspace != null); |
|
312 |
|
|
313 |
this.rdbRevision.setEnabled(isThereTableSelected); |
|
314 |
this.revisionPicker.setEnabled(isThereTableSelected && this.rdbRevision.isSelected()); |
|
315 |
|
|
316 |
this.rdbEffectiveDate.setEnabled(isThereTableSelected); |
|
317 |
this.efectivePicker.setEnabled(isThereTableSelected && this.rdbEffectiveDate.isSelected()); |
|
318 |
|
|
319 |
this.rdbDontAddToProject.setEnabled(canExport); |
|
320 |
this.rdbAddTableToProject.setEnabled(canExport); |
|
321 |
if (canExport) { |
|
322 |
if (isLayer(selectedTable)) { |
|
323 |
this.rdbAddLayerToView.setEnabled(canExport); |
|
324 |
this.cboView.setEnabled(canExport && this.rdbAddLayerToView.isSelected()); |
|
325 |
} else { |
|
326 |
this.rdbAddLayerToView.setEnabled(false); |
|
327 |
this.cboView.setEnabled(false); |
|
328 |
} |
|
322 | 329 |
} else { |
323 | 330 |
this.rdbAddLayerToView.setEnabled(false); |
324 | 331 |
this.cboView.setEnabled(false); |
325 | 332 |
} |
326 |
} else { |
|
327 |
this.rdbAddLayerToView.setEnabled(false); |
|
328 |
this.cboView.setEnabled(false); |
|
329 |
} |
|
330 | 333 |
|
331 |
// this.workspacePicker.setEnabled(!isProcessing); |
|
332 |
this.entitySelector.setEnabled(!isProcessing && workspace != null); |
|
333 |
this.lblTableName.setEnabled(isThereTableSelected); |
|
334 |
this.txtTableName.setEnabled(isThereTableSelected); |
|
335 |
LOGGER.info("isProcessing = "+isProcessing+", processing = "+processing+", ws = "+workspace); |
|
334 |
// this.workspacePicker.setEnabled(!isProcessing);
|
|
335 |
this.entitySelector.setEnabled(!isProcessing && workspace != null);
|
|
336 |
this.lblTableName.setEnabled(isThereTableSelected);
|
|
337 |
this.txtTableName.setEnabled(isThereTableSelected);
|
|
338 |
LOGGER.info("isProcessing = "+isProcessing+", processing = "+processing+", ws = "+workspace);
|
|
336 | 339 |
|
337 |
this.pbStatus.setVisible(isProcessing); |
|
338 |
this.lblStatusTitle.setVisible(isProcessing); |
|
340 |
this.pbStatus.setVisible(isProcessing);
|
|
341 |
this.lblStatusTitle.setVisible(isProcessing);
|
|
339 | 342 |
|
340 |
if (dialog != null) { |
|
341 |
LabeledValue selectedView = (LabeledValue) cboView.getSelectedItem(); |
|
342 |
boolean dontAddNothing = rdbDontAddToProject.isSelected(); |
|
343 |
boolean addLayerToView = rdbAddLayerToView.isSelected() && selectedView != null && selectedView.getValue() != null; |
|
344 |
boolean addTableToProject = rdbAddTableToProject.isSelected(); |
|
345 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, |
|
346 |
canExport && (dontAddNothing || (addLayerToView || addTableToProject)) |
|
347 |
); |
|
343 |
if (dialog != null) { |
|
344 |
LabeledValue selectedView = (LabeledValue) cboView.getSelectedItem(); |
|
345 |
boolean dontAddNothing = rdbDontAddToProject.isSelected(); |
|
346 |
boolean addLayerToView = rdbAddLayerToView.isSelected() && selectedView != null && selectedView.getValue() != null; |
|
347 |
boolean addTableToProject = rdbAddTableToProject.isSelected(); |
|
348 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, |
|
349 |
canExport && (dontAddNothing || (addLayerToView || addTableToProject)) |
|
350 |
); |
|
351 |
} |
|
352 |
} catch (VCSGisRuntimeException e1) { |
|
353 |
LOGGER.warn("Can't updating components.", e1); |
|
354 |
if (showAuthenticationsErrors("_VCS_Export", e1)) { |
|
355 |
this.workspacePicker.set(null); |
|
356 |
doChangeWorkspace(); |
|
357 |
doUpdateEnableComponents(); |
|
358 |
} |
|
359 |
} catch (Exception e2) { |
|
360 |
LOGGER.warn("Can't updating components.", e2); |
|
348 | 361 |
} |
349 | 362 |
} |
350 | 363 |
|
Also available in: Unified diff