// A little method for get/update/refresh the connection data via a // gui dialog. The parameter >always< indicates the manner of user // interaction. If it true - the input dialog is shown, always. Otherwise // (if it false) the input dialog is shown, if no connection data are // available. // This code is global synchronized because only one thread can manipulate // the data. public synchronized boolean promptForConnectionData(boolean always) { boolean back = false; // default : data update cancelled if (!validData || always) { myDialog = new TConnectDialog(parent); myDialog.setHost(host); // check if user name exits if (user == null || user.length() == 0) { user = TMiscTool.getUserName(); } myDialog.setUser(user); if (password != null && !password.equals("")) { myDialog.setPasswd(password); } myDialog.setPlugin(plugin); myDialog.setPort(port); if (validData) { LOGGER.info("GIVE PASSWD FIELD FOCUS"); myDialog.setFocusElement(0); } int userClicked = myDialog.showDialog(); if (userClicked == TConnectDialog.CD_RESULT_OKAY) { // dialog contains valid data host = myDialog.getHost(); user = myDialog.getUser(); password = myDialog.getPasswd(); plugin = myDialog.getPlugin(); port = myDialog.getPort(); if (myDialog.hasUserEncoding()) { encoding = myDialog.getUserEncoding(); } caseInsensitive = myDialog.isCaseInsensitive(); keepAlive = myDialog.isKeepAliveSet(); validData = true; // hopefully back = true; // successful data update } } else { back = true; // successful data without dialog } return back; }
public TConnectionData(JFrame parent) { this( parent, "localhost", -1, TMiscTool.getUserName(), "", ConnectionPluginManager.LOCAL_PLUGIN); validData = false; // no valid data available }