Revision 44821 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geodb.app/org.gvsig.geodb.app.mainplugin/src/main/java/org/gvsig/geodb/databaseworkspace/ConnectToDatabaseWorkspacePanel.java

View differences:

ConnectToDatabaseWorkspacePanel.java
43 43
        return true;
44 44
    }
45 45

  
46
    public void disconnect() {
47
      String id = this.getID();
48
      DataManager dataManager = DALLocator.getDataManager();
49
      DatabaseWorkspaceManager workspace = dataManager.getDatabaseWorkspace(id);
50
      if( workspace!=null ) {
51
        workspace.disconnect();
52
      }
53
    }
54
    
46 55
    private void initComponents() {
47 56
        this.connectionPicker = DALSwingLocator.getSwingManager().createJDBCConnectionPickerController(
48 57
                this.cboConnection,
......
76 85
    }
77 86

  
78 87
    private void doUpdateEnableComponents() {
88
        DataManager dataManager = DALLocator.getDataManager();
89

  
79 90
        boolean theEnabled = this.getConnection() != null;
80 91
        if( dialog!=null ) {
81
            this.dialog.setButtonEnabled(WindowManager_v2.BUTTONS_OK, theEnabled);
92
            this.dialog.setButtonEnabled(
93
                    WindowManager_v2.BUTTON_OK, 
94
                    theEnabled
95
            );
96
            String id = this.getID();
97
            this.dialog.setButtonEnabled(
98
                    WindowManager_v2.BUTTON_APPLY, 
99
                    dataManager.getDatabaseWorkspace(id)!=null
100
            );
82 101
        }
83 102
    }
103
    
84 104
    private void doUpdateStoresRepositoryInfo() {
85
        if( this.getConnection()==null ) {
86
            return;
105
        if( this.getConnection()!=null ) {
106
          DataManager dataManager = DALLocator.getDataManager();
107
          JDBCServerExplorerParameters conn = getConnection();
108
          DatabaseWorkspaceManager workspace = dataManager.createDatabaseWorkspaceManager(conn);
109
          String id = workspace.get(CONFIG_NAME_STORESREPOSITORYID);
110
          String label = workspace.get(CONFIG_NAME_STORESREPOSITORYLABEL);
111
          this.txtID.setText(StringUtils.defaultIfBlank(id, ""));
112
          this.txtLabel.setText(StringUtils.defaultIfBlank(label, ""));
113
          this.connectionPicker.set(conn);
114
        } else {
115
          this.txtID.setText("");
116
          this.txtLabel.setText("");
117
          this.connectionPicker.set(null);
87 118
        }
88
        DataManager dataManager = DALLocator.getDataManager();
89
        JDBCServerExplorerParameters conn = getConnection();
90
        DatabaseWorkspaceManager workspace = dataManager.createDatabaseWorkspaceManager(conn);
91
        String id = workspace.get(CONFIG_NAME_STORESREPOSITORYID);
92
        String label = workspace.get(CONFIG_NAME_STORESREPOSITORYLABEL);
93
        this.txtID.setText(StringUtils.defaultIfBlank(id, ""));
94
        this.txtLabel.setText(StringUtils.defaultIfBlank(label, ""));
95
        this.connectionPicker.set(conn);
96 119
        this.doUpdateEnableComponents();
97 120
    }
98 121
    
122
    public String getID() {
123
      return this.txtID.getText();
124
    }
99 125
    
126
    public String getLabel() {
127
      return this.txtLabel.getText();
128
    }
129
    
100 130
    void setDialog(Dialog dialog) {
101 131
       this.dialog = dialog;
102 132
       this.doUpdateEnableComponents();

Also available in: Unified diff