home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.netobjects.nfx.wizard.WizardPageView;
- import asp.wizard.util.DataSourceDesc;
- import asp.wizard.util.UiUtil;
- import com.sun.java.swing.AbstractButton;
- import com.sun.java.swing.ComboBoxModel;
- import com.sun.java.swing.JButton;
- import com.sun.java.swing.JComboBox;
- import java.util.Vector;
-
- public class WizardViewDbConnection extends WizardViewAbstract {
- private static WizardViewAbstract _instance = null;
- private WVPanelDbConnection _mainPanel;
-
- public static WizardViewAbstract getInstance() {
- if (_instance == null) {
- _instance = new WizardViewDbConnection();
- }
-
- return _instance;
- }
-
- protected void createMainPanel() {
- this._mainPanel = new WVPanelDbConnection();
- JButton btnConn = this._mainPanel._btnTestConn;
- ((AbstractButton)btnConn).addActionListener(new 1(this));
- }
-
- public WVPanelBase getMainPanel() {
- return this._mainPanel;
- }
-
- public void updateDataSources() {
- Vector dataSources = WizDbManager.getInstance().getDataSources();
- JComboBox cboOdbcDsn = this._mainPanel._cboOdbcDsn;
- cboOdbcDsn.removeAllItems();
- UiUtil.addItemToComboBox(dataSources, cboOdbcDsn);
- }
-
- private void testConnection() {
- ((WizardModelDbConnection)((WizardPageView)this).getModel()).testConnection();
- }
-
- public void setDSNName(String dsn) {
- JComboBox cboDsn = this._mainPanel._cboOdbcDsn;
- cboDsn.setSelectedItem("##");
- ComboBoxModel cm = cboDsn.getModel();
- int dsnIndex = UiUtil.getListModelIndexByString(cm, dsn);
- if (dsnIndex != -1) {
- cboDsn.setSelectedIndex(dsnIndex);
- }
-
- }
-
- public void setUserName(String userName) {
- this._mainPanel._txfUser.setText(userName);
- }
-
- public void setPassword(String password) {
- this._mainPanel._txfPwd.setText(password);
- }
-
- public void setGlobalConnection(int globalConnection) {
- }
-
- public int getOdbcType() {
- int result = -1;
- DataSourceDesc dsd = (DataSourceDesc)this._mainPanel._cboOdbcDsn.getSelectedItem();
- if (dsd.getType().toUpperCase().indexOf("ACCESS") > -1) {
- result = 0;
- } else if (dsd.getType().toUpperCase().indexOf("SQL SERVER") > -1) {
- result = 1;
- }
-
- return result;
- }
-
- public String getDSNName() {
- return this._mainPanel._cboOdbcDsn.getSelectedItem().toString();
- }
-
- public String getUserName() {
- return this._mainPanel._txfUser.getText();
- }
-
- public String getPassword() {
- return this._mainPanel._txfPwd.getText();
- }
-
- public int getGlobalConnection() {
- return 1;
- }
-
- // $FF: synthetic method
- static void access$0(WizardViewDbConnection $0) {
- $0.testConnection();
- }
- }
-