Revision 9521 org.gvsig.online/trunk/org.gvsig.online/org.gvsig.online.app/org.gvsig.online.app.mainplugin/src/main/java/org/gvsig/online/app/mainplugin/addlayer/AbstractWizardOnline.java
AbstractWizardOnline.java | ||
---|---|---|
36 | 36 |
import org.gvsig.fmap.mapcontext.MapContext; |
37 | 37 |
import org.gvsig.geodb.TableInfo; |
38 | 38 |
import org.gvsig.geodb.TableInfoController; |
39 |
import static org.gvsig.online.lib.api.OnlineManager.ERR_OK; |
|
40 | 39 |
import org.gvsig.online.lib.api.workingcopy.OnlineEntity; |
41 | 40 |
import org.gvsig.online.lib.api.workingcopy.OnlineWorkingcopy; |
42 | 41 |
import org.gvsig.online.swing.api.OnlineEntitySelectorController; |
... | ... | |
45 | 44 |
import static org.gvsig.online.swing.api.OnlineEntitySelectorController.ACTION_END_PROCESSING_ID; |
46 | 45 |
import static org.gvsig.online.swing.api.OnlineEntitySelectorController.ACTION_RELOAD_ID; |
47 | 46 |
import static org.gvsig.online.swing.api.OnlineEntitySelectorController.ACTION_SELECT_ID; |
47 |
import org.gvsig.online.swing.api.OnlineJDownload; |
|
48 | 48 |
import org.gvsig.online.swing.api.OnlineJInitWorkingcopy; |
49 | 49 |
import org.gvsig.online.swing.api.OnlineSwingLocator; |
50 | 50 |
import org.gvsig.online.swing.api.OnlineSwingManager; |
... | ... | |
225 | 225 |
toolsSwingManager.translate(this.view.lblTable); |
226 | 226 |
toolsSwingManager.translate(this.view.cboWorkspaces); |
227 | 227 |
toolsSwingManager.translate(this.view.btnAddWorkspace); |
228 |
toolsSwingManager.translate(this.view.btnCheckout);
|
|
228 |
toolsSwingManager.translate(this.view.btnDownload);
|
|
229 | 229 |
toolsSwingManager.translate(this.view.btnInitWorkspace); |
230 |
toolsSwingManager.translate(this.view.chkMaintainStructureInToC); |
|
230 |
// toolsSwingManager.translate(this.view.chkMaintainStructureInToC);
|
|
231 | 231 |
toolsSwingManager.translate(this.view.btnTablesCheckAll); |
232 | 232 |
toolsSwingManager.translate(this.view.btnTablesUncheckAll); |
233 | 233 |
toolsSwingManager.translate(this.view.btnTablesCollapseAll); |
234 | 234 |
toolsSwingManager.translate(this.view.btnTablesExpandAll); |
235 |
toolsSwingManager.translate(this.view.chkCheckScale); |
|
236 |
toolsSwingManager.translate(this.view.chkAddToCWhenLoadingAll); |
|
235 |
// toolsSwingManager.translate(this.view.chkCheckScale);
|
|
236 |
// toolsSwingManager.translate(this.view.chkAddToCWhenLoadingAll);
|
|
237 | 237 |
toolsSwingManager.translate(this.view.tabTableInfo); |
238 | 238 |
toolsSwingManager.translate(this.view.lblVisible); |
239 |
toolsSwingManager.translate(this.view.btnConnectToModel); |
|
239 |
// toolsSwingManager.translate(this.view.btnConnectToModel);
|
|
240 | 240 |
|
241 | 241 |
this.view.btnInitWorkspace.setText(toHTML(this.view.btnInitWorkspace.getText())); |
242 | 242 |
|
... | ... | |
305 | 305 |
doShowInitWorkspace(); |
306 | 306 |
}); |
307 | 307 |
|
308 |
this.view.btnCheckout.addActionListener((ActionEvent e) -> { |
|
309 |
doCheckout(); |
|
308 |
this.view.btnDownload.setEnabled(true); |
|
309 |
this.view.btnDownload.addActionListener((ActionEvent e) -> { |
|
310 |
doDownload(); |
|
310 | 311 |
}); |
311 | 312 |
|
312 | 313 |
// this.view.btnConnectToModel.addActionListener((ActionEvent e) -> { |
... | ... | |
320 | 321 |
|
321 | 322 |
this.clearTables(); |
322 | 323 |
|
323 |
this.view.chkMaintainStructureInToC.setVisible(false); |
|
324 |
this.view.chkMaintainStructureInToC.setSelected(true); |
|
324 |
// this.view.chkMaintainStructureInToC.setVisible(false); |
|
325 |
// this.view.chkMaintainStructureInToC.setSelected(true); |
|
326 |
// |
|
327 |
// this.view.chkCheckScale.setSelected(true); |
|
328 |
// |
|
329 |
// this.view.chkAddToCWhenLoadingAll.setSelected(true); |
|
325 | 330 |
|
326 |
this.view.chkCheckScale.setSelected(true); |
|
327 |
|
|
328 |
this.view.chkAddToCWhenLoadingAll.setSelected(true); |
|
329 |
|
|
330 | 331 |
this.setLayout(new BorderLayout()); |
331 | 332 |
this.add(this.view, BorderLayout.CENTER); |
332 | 333 |
|
... | ... | |
336 | 337 |
|
337 | 338 |
protected abstract boolean requireGeometry(); |
338 | 339 |
|
339 |
protected boolean maintainStructureInToC() { |
|
340 |
return this.view.chkMaintainStructureInToC.isSelected(); |
|
341 |
} |
|
340 |
// protected boolean maintainStructureInToC() { |
|
341 |
// return this.view.chkMaintainStructureInToC.isSelected(); |
|
342 |
// } |
|
343 |
// |
|
344 |
// protected void setVisibleMaintainStructureInToC(boolean visible) { |
|
345 |
// this.view.chkMaintainStructureInToC.setVisible(visible); |
|
346 |
// } |
|
342 | 347 |
|
343 |
protected void setVisibleMaintainStructureInToC(boolean visible) { |
|
344 |
this.view.chkMaintainStructureInToC.setVisible(visible); |
|
345 |
} |
|
346 |
|
|
347 | 348 |
protected Collection<TableInfo> getTablesInformation() { |
348 | 349 |
this.updateTableInfoFromUI(); |
349 | 350 |
if( this.tablesInfo == null ) { |
... | ... | |
507 | 508 |
boolean theProcessing = this.processing || this.entitySelector.isProcessing(); |
508 | 509 |
|
509 | 510 |
OnlineWorkingcopy ws = getWorkspace(); |
511 |
this.view.btnDownload.setEnabled(ws!=null); |
|
510 | 512 |
if(entity == null){ |
511 |
this.view.btnCheckout.setEnabled(false); |
|
512 | 513 |
this.tableInfoController.setEnabled(false); |
513 | 514 |
} else if(entity instanceof OnlineEntity){ |
514 |
this.view.btnCheckout.setEnabled(false); |
|
515 | 515 |
this.tableInfoController.setEditable(!theProcessing && ws != null); |
516 | 516 |
this.tableInfoController.setEnabled(ws != null); |
517 | 517 |
} else { //Entidad de repositorio |
518 |
this.view.btnCheckout.setEnabled(!theProcessing && ws != null); |
|
519 | 518 |
this.tableInfoController.setEnabled(false); |
520 | 519 |
} |
521 | 520 |
|
... | ... | |
526 | 525 |
this.view.btnTablesExpandAll.setEnabled(this.entitySelector.isEnabled()); |
527 | 526 |
this.workspacePicker.setEnabled(!theProcessing); |
528 | 527 |
this.view.btnInitWorkspace.setEnabled(!theProcessing); |
529 |
// this.view.txtRepositoryInfo.setEnabled(!theProcessing && ws != null); |
|
530 | 528 |
this.setVisibleStatus(theProcessing); |
531 | 529 |
this.checkFinishable(); |
532 | 530 |
} |
... | ... | |
553 | 551 |
switch (dialogInitWorkspace.getAction()) { |
554 | 552 |
case WindowManager_v2.BUTTON_OK: |
555 | 553 |
int r = panelInitWorkspace.actionPerformed(); |
556 |
if (r != 0) { |
|
554 |
if (r == 0) { |
|
555 |
this.workspacePicker = swingManager.createPickerWorkspaceController( |
|
556 |
this.view.cboWorkspaces, |
|
557 |
this.view.btnAddWorkspace |
|
558 |
); |
|
559 |
} else { |
|
557 | 560 |
String message = "_Cant_initialize_workingcopy_{0}"; |
558 | 561 |
|
559 | 562 |
StringBuilder compoundMessage = new StringBuilder(); |
... | ... | |
615 | 618 |
} |
616 | 619 |
} |
617 | 620 |
|
618 |
private void doCheckout() {
|
|
621 |
private void doDownload() {
|
|
619 | 622 |
OnlineWorkingcopy workspace = getWorkspace(); |
620 | 623 |
if (workspace == null) { |
621 | 624 |
return; |
622 | 625 |
} |
623 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
|
|
626 |
WindowManager_v2 winmgr = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
|
|
624 | 627 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
625 |
OnlineEntity rEntity = this.entitySelector.getSelectedEntity(); |
|
626 |
if(rEntity== null || rEntity instanceof OnlineEntity){ |
|
627 |
return; |
|
628 |
} |
|
629 |
final String entityName = rEntity.getEntityName(); |
|
630 |
Thread task = new Thread(() -> { |
|
631 |
try { |
|
632 |
processing = true; |
|
633 |
doUpdateComponents(); |
|
634 |
|
|
635 |
showMessage(i18n.getTranslation("_Checking_out")); |
|
636 |
int res = workspace.download( |
|
637 |
entityName, |
|
638 |
null, |
|
639 |
this.getTaskStatusController().getSimpleTaskStatus() |
|
640 |
); |
|
641 |
if (res != ERR_OK) { |
|
642 |
LOGGER.warn("_Cant_checkout_table"); |
|
643 |
dialogs.messageDialog( |
|
644 |
i18n.getTranslation("_Cant_checkout_table") + "\n" + workspace.getErrorMessage(res), |
|
645 |
i18n.getTranslation("_Add_table"), |
|
646 |
JOptionPane.WARNING_MESSAGE |
|
647 |
); |
|
648 |
return; |
|
649 |
} |
|
650 |
downloadAndRegisterResources(entityName); |
|
651 |
showMessage(i18n.getTranslation("_Checkout_finished")); |
|
652 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(entityName); |
|
653 |
TableInfo tableInfo = new OnlineTableInfo(workspace.getWorkspaceEntity(entityName), parameters, this.requireGeometry(), false); |
|
654 |
this.tablesInfo.put(tableInfo.getId(), tableInfo); |
|
655 |
doPostCheckout(entityName); |
|
656 |
} catch (Exception e) { |
|
657 |
LOGGER.warn("_Cant_add_table"); |
|
658 |
dialogs.messageDialog( |
|
659 |
i18n.getTranslation("_Cant_add_table") + "\n" + e.getMessage(), |
|
660 |
i18n.getTranslation("_Add_table"), |
|
661 |
JOptionPane.WARNING_MESSAGE |
|
662 |
); |
|
663 |
} finally { |
|
664 |
processing = false; |
|
665 |
doUpdateComponents(); |
|
628 |
OnlineSwingManager onlineSwingManager = OnlineSwingLocator.getOnlineSwingManager(); |
|
629 |
|
|
630 |
OnlineJDownload panel = onlineSwingManager.createDownloadPanel(workspace, null, null); |
|
631 |
Dialog dialog = winmgr.createDialog( |
|
632 |
panel.asJComponent(), |
|
633 |
i18n.getTranslation("_Online_Download"), |
|
634 |
i18n.getTranslation("_Online_Download"), |
|
635 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
636 |
); |
|
637 |
dialog.addActionListener((ActionEvent e) -> { |
|
638 |
if( dialog.getAction()==WindowManager_v2.BUTTON_OK ) { |
|
639 |
panel.actionPerformed(); |
|
666 | 640 |
} |
667 |
}, "OnlineAddTableCheckout"); |
|
668 |
processing = true; |
|
669 |
doUpdateComponents(); |
|
670 |
task.start(); |
|
641 |
}); |
|
642 |
dialog.show(WindowManager.MODE.DIALOG); |
|
671 | 643 |
} |
672 | 644 |
|
673 |
private void doPostCheckout(String entityName) { |
|
674 |
if (notInSwingThreadInvokeLater(() -> { doPostCheckout(entityName); })) { |
|
675 |
return; |
|
676 |
} |
|
677 |
OnlineWorkingcopy workspace = getWorkspace(); |
|
678 |
if (workspace == null) { |
|
679 |
return; |
|
680 |
} |
|
681 |
|
|
682 |
doChangeWorkspace(); |
|
683 |
this.entitySelector.setSelectedEntity(workspace.getWorkspaceEntity(entityName)); |
|
684 |
doChangeTableSelected(); |
|
685 |
} |
|
686 |
|
|
687 | 645 |
private void showMessage(String message) { |
688 | 646 |
if( notInSwingThreadInvokeLater(() -> {showMessage(message);}) ) { |
689 | 647 |
return; |
... | ... | |
776 | 734 |
|
777 | 735 |
} |
778 | 736 |
|
779 |
protected boolean getCheckScale() { |
|
780 |
return this.view.chkCheckScale.isSelected(); |
|
781 |
} |
|
737 |
// protected boolean getCheckScale() { |
|
738 |
// return this.view.chkCheckScale.isSelected(); |
|
739 |
// } |
|
740 |
// |
|
741 |
// protected boolean getAddToCWhenLoadingAll() { |
|
742 |
// return this.view.chkAddToCWhenLoadingAll.isSelected(); |
|
743 |
// } |
|
782 | 744 |
|
783 |
protected boolean getAddToCWhenLoadingAll() { |
|
784 |
return this.view.chkAddToCWhenLoadingAll.isSelected(); |
|
785 |
} |
|
786 |
|
|
787 | 745 |
protected String getCategory(OnlineEntity entity) { |
788 | 746 |
return this.entitySelector.getCategory(entity); |
789 | 747 |
} |
Also available in: Unified diff