public char[] askPassword() { char[] password = null; final JDialog dlg = new JDialog(frm, "Password", true); final JPasswordField jpf = new JPasswordField(15); final JButton[] btns = {new JButton("Enter"), new JButton("Cancel")}; for (int i = 0; i < btns.length; i++) { btns[i].addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dlg.setVisible(false); } }); } Object[] prts = new Object[] {"Please input a password:"******"Invalid password, passwords must be " + PASSWORD_MIN + " characters long"); System.exit(1); } return password; }
public void setVisible(boolean bShow, String title) { if (bShow) { String strDir = ""; String strFreq = ""; String strTraynum = ""; m_strHelpFile = getHelpFile(title); String strSampleName = getSampleName(title); String frameBounds = getFrameBounds(title); StringTokenizer tok = new QuotedStringTokenizer(title); if (tok.hasMoreTokens()) strDir = tok.nextToken(); if (tok.hasMoreTokens()) strFreq = tok.nextToken(); if (tok.hasMoreTokens()) strTraynum = tok.nextToken(); else { try { Integer.parseInt(strDir); // if strdir is number, then strdir is empty, and the // strfreq is the number strTraynum = strFreq; strFreq = strDir; strDir = ""; } catch (Exception e) { } } try { setTitle(gettitle(strFreq)); m_lblSampleName.setText("3"); boolean bVast = isVast(strTraynum); CardLayout layout = (CardLayout) m_pnlSampleName.getLayout(); if (!bVast) { if (strSampleName == null) { strSampleName = getSampleName(strDir, strTraynum); } m_lblSampleName.setText(strSampleName); layout.show(m_pnlSampleName, OTHER); } else { m_strDir = strDir; setTrays(); layout.show(m_pnlSampleName, VAST); m_trayTimer.start(); } boolean bSample = bVast || !strSampleName.trim().equals(""); m_pnlSampleName.setVisible(bSample); m_lblLogin.setForeground(getBackground()); m_lblLogin.setVisible(false); m_passwordField.setText(""); m_passwordField.setCaretPosition(0); } catch (Exception e) { Messages.writeStackTrace(e); } setBounds(frameBounds); ExpPanel exp = Util.getActiveView(); if (exp != null) exp.waitLogin(true); } writePersistence(); setVisible(bShow); }
/** Clears all the data previously entered in the form. */ public void clear() { usernameField.setText(""); displayNameField.setText(""); passField.setText(""); retypePassField.setText(""); emailField.setText(""); errorPane.setText(""); remove(errorPane); }
private void jbInit() throws Exception { this.getContentPane().setLayout(null); Bienvenue.setFont(new java.awt.Font("Garamond", 1, 24)); Bienvenue.setForeground(SystemColor.textHighlight); Bienvenue.setRequestFocusEnabled(true); Bienvenue.setVerifyInputWhenFocusTarget(true); Bienvenue.setText("Bienvenue dans JChat"); Bienvenue.setBounds(new Rectangle(125, 28, 305, 44)); Pseudo_L.setFont(new java.awt.Font("Dialog", 1, 14)); Pseudo_L.setText("Pseudonyme :"); Pseudo_L.setBounds(new Rectangle(75, 94, 128, 28)); nom.setText(""); nom.setBounds(new Rectangle(229, 95, 108, 24)); pwd.setText(""); pwd.setBounds(new Rectangle(230, 135, 108, 25)); pwd_L.setFont(new java.awt.Font("Dialog", 1, 14)); pwd_L.setText("Mot de passe :"); pwd_L.setBounds(new Rectangle(76, 133, 122, 31)); gestionnaire_B gestionnaire = new gestionnaire_B(); Connect.addActionListener(gestionnaire); Connect.setBackground(new Color(239, 240, 234)); Connect.setBounds(new Rectangle(281, 251, 142, 30)); Connect.setText("Connexion"); Connect.setIcon(new ImageIcon(image_c)); Annuler.addActionListener(gestionnaire); Annuler.setBackground(new Color(239, 240, 234)); Annuler.setBounds(new Rectangle(104, 252, 140, 29)); Annuler.setText("Annuler"); Annuler.setIcon(new ImageIcon(image_d)); this.getContentPane().setBackground(new Color(239, 240, 234)); this.setForeground(new Color(239, 240, 234)); this.setTitle("Interface de connexion des clients au serveur de chat"); jLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); jLabel1.setText("Adresse du serveur :"); jLabel1.setBounds(new Rectangle(75, 176, 156, 26)); jTextField1.setBounds(new Rectangle(230, 176, 108, 25)); Icon siegle = new ImageIcon(image); siegle_L = new JLabel("", siegle, SwingConstants.LEFT); siegle_L.setBounds(new Rectangle(0, 1, 76, 105)); this.getContentPane().add(jLabel1, null); this.getContentPane().add(pwd_L, null); this.getContentPane().add(Pseudo_L, null); this.getContentPane().add(jTextField1, null); this.getContentPane().add(nom, null); this.getContentPane().add(pwd, null); this.getContentPane().add(Bienvenue, null); this.getContentPane().add(Connect, null); this.getContentPane().add(Annuler, null); this.getContentPane().add(siegle_L, null); this.setSize(new Dimension(439, 321)); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }
// These is some wierd problem such that sometimes, the vnmrj command // area gets the focus and these items in the login box do not get // the focus. Even clicking in these items does not bring focus to // them. Issuing requestFocus() does not bring focus to them. // I can however, determing if either the operator entry box or // the password box has focus and if neither does, I can unshow and // reshow the panel and that fixes the focus. So, I have added this // to the mouseClicked action. If neither has focus, it will // take focus with setVisible false then true. public void mouseClicked(MouseEvent e) { boolean pfocus = m_passwordField.hasFocus(); boolean ofocus = comboTextField.hasFocus(); if (!pfocus && !ofocus) { setVisible(false); setVisible(true); } }
protected void setPref() { Color color = DisplayOptions.getColor("PlainText"); Font font = DisplayOptions.getFont("PlainText"); m_lblUsername.setForeground(color); m_lblUsername.setFont(font); m_lblPassword.setForeground(color); m_lblPassword.setFont(font); m_cmbUser.getEditor().getEditorComponent().setForeground(color); m_cmbUser.getEditor().getEditorComponent().setFont(font); m_passwordField.setForeground(color); m_passwordField.setFont(font); color = DisplayOptions.getColor("Heading3"); font = DisplayOptions.getFont("Heading3"); m_lblSampleName.setForeground(color); m_pnlTrays.setBorder( BorderDeli.createBorder("Empty", "Sample Trays", "Bottom", "Center", color, font)); VBox.setforeground(color); VBox.setfont(font); }
/** * Checks the passwords of the user * * @param e The ActionEvent for this action. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); // checks if the user has a unix password, if it matches, then logs the user // in the interface, otherwise checks for the vnmrj password, // if neither password matches, then the user is not logged in the interface if (cmd.equalsIgnoreCase("enter")) enterLogin(); else if (cmd.equalsIgnoreCase("cancel")) { m_passwordField.setText(""); m_lblLogin.setForeground(getBackground()); // setVisible(false); } else if (cmd.equalsIgnoreCase("help")) displayHelp(); }
private void copyFile() throws Exception { // Load the JDBC driver Class.forName(((String) jcboDriver.getSelectedItem()).trim()); System.out.println("Driver loaded"); // Establish a connection Connection conn = DriverManager.getConnection( ((String) jcboURL.getSelectedItem()).trim(), jtfUsername.getText().trim(), String.valueOf(jtfPassword.getPassword()).trim()); System.out.println("Database connected"); // Read each line from the text file and insert it to the table insertRows(conn); }
/** * Parses the given http response. * * @param response the http response to parse * @return the new account */ private NewAccount parseHttpResponse(String response) { NewAccount newAccount = null; try { JSONObject jsonObject = (JSONObject) JSONValue.parseWithException(response); boolean isSuccess = (Boolean) jsonObject.get("success"); if (isSuccess) { newAccount = new NewAccount( (String) jsonObject.get("sip_address"), passField.getPassword(), null, (String) jsonObject.get("outbound_proxy")); String xcapRoot = (String) jsonObject.get("xcap_root"); // as sip2sip adds @sip2sip.info at the end of the // xcap_uri but doesn't report it in resullt after // creating account, we add it String domain = null; int delimIndex = newAccount.getUserName().indexOf("@"); if (delimIndex != -1) { domain = newAccount.getUserName().substring(delimIndex); } if (domain != null) { if (xcapRoot.endsWith("/")) xcapRoot = xcapRoot.substring(0, xcapRoot.length() - 1) + domain; else xcapRoot += domain; } newAccount.setXcapRoot(xcapRoot); } else { showErrorMessage((String) jsonObject.get("error_message")); } } catch (Throwable e1) { if (logger.isInfoEnabled()) logger.info("Failed Json parsing.", e1); } return newAccount; }
public String getPassword() { return new String(pass.getPassword()); }
protected void enterLogin() { char[] password = m_passwordField.getPassword(); String strUser = (String) m_cmbUser.getSelectedItem(); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean blogin = WUserUtil.isOperatorNameok(strUser, false); if (blogin) { blogin = vnmrjPassword(strUser, password); if (!blogin) blogin = unixPassword(strUser, password); } if (blogin) { m_lblLogin.setForeground(Color.black); m_lblLogin.setText("Login Successful"); m_lblLogin.setVisible(true); // Get the Email column string for access to the operator data String emStr = vnmr.util.Util.getLabel("_admin_Email"); String stremail = WUserUtil.getOperatordata(strUser, emStr); // Get the Panel Level column string for access to the operator data String plStr = vnmr.util.Util.getLabel("_admin_Panel_Level"); String strPanel = WUserUtil.getOperatordata(strUser, plStr); if (stremail == null || stremail.equals("null")) stremail = ""; try { Integer.parseInt(strPanel); } catch (Exception e) { strPanel = WGlobal.PANELLEVEL; } m_trayTimer.stop(); Messages.postDebug(" Login: "******"appdir('reset','") .append(strUser) .append("','") .append(stremail) .append("',") .append(strPanel) .append(")") .toString()); exp.sendToVnmr("vnmrjcmd('util', 'bgReady')\n"); } setVisible(false); // Save the current position and size of this panel in case it // was changed Dimension size = getSize(); width = size.width; height = size.height; position = getLocation(); writePersistence(); // Call the macro to update this operator's // ExperimentSelector_operatorName.xml file // from the protocols themselves. This macro will // cause an update of the ES when it is finished // Util.getAppIF().sendToVnmr("updateExpSelector"); // I am not sure why we need to force updates since updateExpSelector // should have caused an update by writing to ES_op.xml file. // However, it works better if we do the force update. // ExpSelector.setForceUpdate(true); } else { m_lblLogin.setForeground(DisplayOptions.getColor("Error")); // m_lblLogin.setText("<HTML>Incorrect username/password <p> Please try again </HTML>"); m_lblLogin.setVisible(true); } setCursor(Cursor.getDefaultCursor()); }
public Design() throws Exception { super.setBackground(Color.BLACK); this.setTitle(""); con = getContentPane(); con.setLayout(null); dim = tk.getDefaultToolkit().getScreenSize(); this.setTitle("Customer Peer Login"); l1 = new JLabel(new ImageIcon("plain.jpg")); l1.setBounds(0, 0, 400, 400); con.add(l1); l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black)); title = new JLabel("CUSTOMER PEER LOGIN "); title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20)); title.setForeground(Color.red); title.setBounds(80, 30, 300, 30); l1.add(title); l4 = new JLabel("CMACHINE NAME"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.BLUE); l4.setBounds(70, 100, 160, 20); // l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green)); l1.add(l4); jtf2 = new JTextField(); jtf2.setBounds(250, 100, 100, 20); jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf2); l2 = new JLabel("CUSER LOGIN"); l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l2.setForeground(Color.blue); l2.setBounds(70, 150, 120, 20); l1.add(l2); jtf1 = new JTextField(); jtf1.setBounds(250, 150, 100, 20); jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf1); l3 = new JLabel("CPASSWORD"); l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l3.setForeground(Color.blue); l3.setBounds(70, 200, 120, 20); l1.add(l3); jptf1 = new JPasswordField(); jptf1.setBounds(250, 200, 100, 20); jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jptf1); JLabel l4 = new JLabel("DAgent"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.blue); l4.setBounds(70, 250, 120, 20); l1.add(l4); box = new JComboBox(); box.setBounds(250, 250, 100, 20); box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(box); b2 = new JButton("Register"); b2.setBounds(50, 300, 100, 20); l1.add(b2); b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); b3 = new JButton("Login"); b3.setBounds(150, 300, 100, 20); b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b3); b1 = new JButton("Cancel"); b1.setBounds(250, 300, 100, 20); b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b1); b1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { dispose(); } }); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:agent"); } catch (Exception exp) { } try { Statement satem = conn.createStatement(); ResultSet rsatem = satem.executeQuery("select * from Dagent"); while (rsatem.next()) { String namem = rsatem.getString("uname"); box.addItem(namem); } } catch (Exception expo1) { } b2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { exp.printStackTrace(); } try { packet p = new packet(); p.setaction("Creg"); p.setCuser(username); p.setCpass(password); p.setCmname(mechine); p.setCDpeer(dname); Socket soc = new Socket(servermachine, porte); ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream()); out.writeObject(p); ObjectInputStream in = new ObjectInputStream(soc.getInputStream()); packet rpac = (packet) in.readObject(); if (rpac.getaction().equals("ok")) { JOptionPane.showMessageDialog(null, "Sucessfully Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } else { JOptionPane.showMessageDialog(null, "Already Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); b3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String Dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + Dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { } try { packet p1 = new packet(); p1.setaction("clogin"); p1.setCuser(username); p1.setCpass(password); p1.setCmname(mechine); p1.setCDpeer(Dname); Socket soc1 = new Socket(servermachine, porte); ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream()); out1.writeObject(p1); ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream()); packet rpac1 = (packet) in1.readObject(); if (rpac1.getaction().equals("ok")) { int port1 = 0; try { int portm = rpac1.getCport(); System.out.println("XXXXXXX" + portm); // JOptionPane.showMessageDialog(null,"Sucessfully Started"); new Listen(portm); new process(username, portm); dispose(); } catch (Exception exp) { } } else { JOptionPane.showMessageDialog( null, "Enter valid username and password", "Server reply", 2); jtf1.setText(""); jtf2.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); setSize(400, 400); show(); setLocation(150, 100); setResizable(false); }
public LoginPanel(Image img, ActionListener listener) { super(null); this.listener = listener; if (img == null) { InputStream inData = getClass().getResourceAsStream("/resources/background.gif"); BufferedImage back = null; if (inData != null) try { back = ImageIO.read(inData); } catch (IOException e) { loger.finest("LoginPanel class can't get the background image"); } this.background = back; } setLayout(null); JPanel logingPanel = new JPanel(); loginTitle = new JLabel("Autentificare"); logingPanel.setSize(250, 150); logingPanel.setBorder(new javax.swing.border.LineBorder(Color.black, 2)); logingPanel.setLayout(null); loginTitle.setBounds(3, 0, logingPanel.getWidth(), 20); logingPanel.add(loginTitle); JLabel loginUser = new JLabel("Utilizator"); loginUser.setBounds( 80 - loginUser.getPreferredSize().width, 40, loginUser.getPreferredSize().width, loginUser.getPreferredSize().height); logingPanel.add(loginUser); user = new JTextField(10); user.setBounds(85, 40, user.getPreferredSize().width, user.getPreferredSize().height); // user.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(user); JLabel loginPass = new JLabel("Parola"); loginPass.setBounds( 80 - loginPass.getPreferredSize().width, 80, loginPass.getPreferredSize().width, loginPass.getPreferredSize().height); logingPanel.add(loginPass); // JTextField pass = new JTextField(10); pass = new JPasswordField(10); pass.setBounds(85, 80, pass.getPreferredSize().width, pass.getPreferredSize().height); pass.addKeyListener(this); // pass.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(pass); JButton loginButton = new JButton("Start"); loginButton.setActionCommand("LOGIN"); loginButton.setBounds( 60, 110, loginButton.getPreferredSize().width, loginButton.getPreferredSize().height); // loginButton.setOpaque(false); loginButton.setFocusPainted(false); // loginButton.setContentAreaFilled(false); // loginButton.setBorderPainted(false); loginButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); loginButton.addActionListener(listener); logingPanel.add(loginButton); add(logingPanel); }
/** * Creates this account on the server. * * @return the created account */ public NewAccount createAccount() { // Check if the two passwords match. String pass1 = new String(passField.getPassword()); String pass2 = new String(retypePassField.getPassword()); if (!pass1.equals(pass2)) { showErrorMessage( IppiAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.NOT_SAME_PASSWORD")); return null; } NewAccount newAccount = null; try { StringBuilder registerLinkBuilder = new StringBuilder(registerLink); registerLinkBuilder .append(URLEncoder.encode("email", "UTF-8")) .append("=") .append(URLEncoder.encode(emailField.getText(), "UTF-8")) .append("&") .append(URLEncoder.encode("password", "UTF-8")) .append("=") .append(URLEncoder.encode(new String(passField.getPassword()), "UTF-8")) .append("&") .append(URLEncoder.encode("display_name", "UTF-8")) .append("=") .append(URLEncoder.encode(displayNameField.getText(), "UTF-8")) .append("&") .append(URLEncoder.encode("username", "UTF-8")) .append("=") .append(URLEncoder.encode(usernameField.getText(), "UTF-8")) .append("&") .append(URLEncoder.encode("user_agent", "UTF-8")) .append("=") .append(URLEncoder.encode("sip-communicator.org", "UTF-8")); URL url = new URL(registerLinkBuilder.toString()); URLConnection conn = url.openConnection(); // If this is not an http connection we have nothing to do here. if (!(conn instanceof HttpURLConnection)) { return null; } HttpURLConnection httpConn = (HttpURLConnection) conn; int responseCode = httpConn.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String str; StringBuffer stringBuffer = new StringBuffer(); while ((str = in.readLine()) != null) { stringBuffer.append(str); } if (logger.isInfoEnabled()) logger.info("JSON response to create account request: " + stringBuffer.toString()); newAccount = parseHttpResponse(stringBuffer.toString()); } } catch (MalformedURLException e1) { if (logger.isInfoEnabled()) logger.info("Failed to create URL with string: " + registerLink, e1); } catch (IOException e1) { if (logger.isInfoEnabled()) logger.info("Failed to open connection.", e1); } return newAccount; }
protected Settings initSettings(String fileName) { // TODO Why try to load settings from current directory before using root? // This caused a bug in Eclipse: // https://sourceforge.net/tracker/?func=detail&atid=737763&aid=2620284&group_id=136013 File settingsFile = new File(fileName).exists() ? new File(fileName) : null; try { if (settingsFile == null) { settingsFile = new File(new File(getRoot()), DEFAULT_SETTINGS_FILE); if (!settingsFile.exists()) { settingsFile = new File(new File(System.getProperty("user.home", ".")), DEFAULT_SETTINGS_FILE); lastSettingsLoad = 0; } } else { settingsFile = new File(fileName); if (!settingsFile.getAbsolutePath().equals(this.settingsFile)) { lastSettingsLoad = 0; } } if (!settingsFile.exists()) { if (settingsDocument == null) { log.info("Creating new settings at [" + settingsFile.getAbsolutePath() + "]"); settingsDocument = SoapuiSettingsDocumentConfig.Factory.newInstance(); setInitialImport(true); } lastSettingsLoad = System.currentTimeMillis(); } else if (settingsFile.lastModified() > lastSettingsLoad) { settingsDocument = SoapuiSettingsDocumentConfig.Factory.parse(settingsFile); byte[] encryptedContent = settingsDocument.getSoapuiSettings().getEncryptedContent(); if (encryptedContent != null) { char[] password = null; if (this.password == null) { // swing element -!! uh! JPasswordField passwordField = new JPasswordField(); JLabel qLabel = new JLabel("Password"); JOptionPane.showConfirmDialog( null, new Object[] {qLabel, passwordField}, "Global Settings", JOptionPane.OK_CANCEL_OPTION); password = passwordField.getPassword(); } else { password = this.password.toCharArray(); } String encryptionAlgorithm = settingsDocument.getSoapuiSettings().getEncryptedContentAlgorithm(); byte[] data = OpenSSL.decrypt( StringUtils.isNullOrEmpty(encryptionAlgorithm) ? "des3" : encryptionAlgorithm, password, encryptedContent); try { settingsDocument = SoapuiSettingsDocumentConfig.Factory.parse(new String(data, "UTF-8")); } catch (Exception e) { log.warn("Wrong password."); JOptionPane.showMessageDialog( null, "Wrong password, creating backup settings file [ " + settingsFile.getAbsolutePath() + ".bak.xml. ]\nSwitch to default settings.", "Error - Wrong Password", JOptionPane.ERROR_MESSAGE); settingsDocument.save(new File(settingsFile.getAbsolutePath() + ".bak.xml")); throw e; } } log.info("initialized soapui-settings from [" + settingsFile.getAbsolutePath() + "]"); lastSettingsLoad = settingsFile.lastModified(); if (settingsWatcher == null) { settingsWatcher = new SettingsWatcher(); SoapUI.getSoapUITimer().scheduleAtFixedRate(settingsWatcher, 10000, 10000); } } } catch (Exception e) { log.warn("Failed to load settings from [" + e.getMessage() + "], creating new"); settingsDocument = SoapuiSettingsDocumentConfig.Factory.newInstance(); lastSettingsLoad = 0; } if (settingsDocument.getSoapuiSettings() == null) { settingsDocument.addNewSoapuiSettings(); settings = new XmlBeansSettingsImpl(null, null, settingsDocument.getSoapuiSettings()); initDefaultSettings(settings); } else { settings = new XmlBeansSettingsImpl(null, null, settingsDocument.getSoapuiSettings()); } this.settingsFile = settingsFile.getAbsolutePath(); if (!settings.isSet(WsdlSettings.EXCLUDED_TYPES)) { StringList list = new StringList(); list.add("schema@http://www.w3.org/2001/XMLSchema"); settings.setString(WsdlSettings.EXCLUDED_TYPES, list.toXml()); } if (settings .getString(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1) .equals(HttpSettings.HTTP_VERSION_0_9)) { settings.setString(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1); } setIfNotSet(WsdlSettings.NAME_WITH_BINDING, true); setIfNotSet(WsdlSettings.NAME_WITH_BINDING, 500); setIfNotSet(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1); setIfNotSet(HttpSettings.MAX_TOTAL_CONNECTIONS, 2000); setIfNotSet(HttpSettings.RESPONSE_COMPRESSION, true); setIfNotSet(HttpSettings.LEAVE_MOCKENGINE, true); setIfNotSet(UISettings.AUTO_SAVE_PROJECTS_ON_EXIT, true); setIfNotSet(UISettings.SHOW_DESCRIPTIONS, true); setIfNotSet(WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS, true); setIfNotSet(WsaSettings.USE_DEFAULT_RELATES_TO, true); setIfNotSet(WsaSettings.USE_DEFAULT_RELATIONSHIP_TYPE, true); setIfNotSet(UISettings.SHOW_STARTUP_PAGE, true); setIfNotSet(UISettings.GC_INTERVAL, "60"); setIfNotSet(WsdlSettings.CACHE_WSDLS, true); setIfNotSet(WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES, true); setIfNotSet(HttpSettings.RESPONSE_COMPRESSION, true); setIfNotSet(HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN, true); setIfNotSet(HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN, true); setIfNotSet(HttpSettings.LEAVE_MOCKENGINE, true); setIfNotSet(HttpSettings.START_MOCK_SERVICE, true); setIfNotSet(UISettings.AUTO_SAVE_INTERVAL, "0"); setIfNotSet(UISettings.GC_INTERVAL, "60"); setIfNotSet(UISettings.SHOW_STARTUP_PAGE, true); setIfNotSet(WsaSettings.SOAP_ACTION_OVERRIDES_WSA_ACTION, false); setIfNotSet(WsaSettings.USE_DEFAULT_RELATIONSHIP_TYPE, true); setIfNotSet(WsaSettings.USE_DEFAULT_RELATES_TO, true); setIfNotSet(WsaSettings.OVERRIDE_EXISTING_HEADERS, false); setIfNotSet(WsaSettings.ENABLE_FOR_OPTIONAL, false); setIfNotSet(VersionUpdateSettings.AUTO_CHECK_VERSION_UPDATE, true); if (!settings.isSet(ProxySettings.AUTO_PROXY) && !settings.isSet(ProxySettings.ENABLE_PROXY)) { settings.setBoolean(ProxySettings.AUTO_PROXY, true); settings.setBoolean(ProxySettings.ENABLE_PROXY, true); } boolean setWsiDir = false; String wsiLocationString = settings.getString(WSISettings.WSI_LOCATION, null); if (StringUtils.isNullOrEmpty(wsiLocationString)) { setWsiDir = true; } else { File wsiFile = new File(wsiLocationString); if (!wsiFile.exists()) { setWsiDir = true; } } if (setWsiDir) { String wsiDir = System.getProperty("wsi.dir", new File(".").getAbsolutePath()); settings.setString(WSISettings.WSI_LOCATION, wsiDir); } HttpClientSupport.addSSLListener(settings); return settings; }
editprof(String str, String user) { cp = getContentPane(); cp.setLayout(null); user1 = user; try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e) { } JTextField ft = new JTextField(); name1 = new JLabel("First Name"); try { r = new FileReader(user + "/First name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } name = new JTextField(); name.setText(ft.getText()); last1 = new JLabel("Enter Last Name"); try { r = new FileReader(user + "/last name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } last = new JTextField(); last.setText(ft.getText()); pass = new JLabel("Password"); try { r = new FileReader(user + "/password.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } pwd = new JPasswordField(); pwd.setText(ft.getText()); pwd.setEditable(false); email1 = new JLabel("Enter email address"); try { r = new FileReader(user + "/email.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } email = new JTextField(); email.setText(ft.getText()); addimage = new JButton("Add Image"); icon = new JLabel(); date1 = new JLabel("Date Of Birth"); date = new JComboBox(); for (int i = 1; i <= 31; i++) { date.addItem(i); } month = new JComboBox(); month.addItem("Jan"); month.addItem("Feb"); month.addItem("Mar"); month.addItem("Apr"); month.addItem("May"); month.addItem("Jun"); month.addItem("Jul"); month.addItem("Aug"); month.addItem("Sep"); month.addItem("Oct"); month.addItem("Nov"); month.addItem("Dec"); year = new JComboBox(); for (int j = 1900; j <= 2010; j++) { year.addItem(j); } sx = new JLabel("Gender"); gen = new JComboBox(); gen.addItem("Male"); gen.addItem("Female"); con1 = new JLabel("Country Name"); con = new JComboBox(); con.addItem(" Austrelia"); con.addItem(" America"); con.addItem(" Antartica"); con.addItem(" Africa"); con.addItem(" Canda"); con.addItem(" Corea"); con.addItem(" Chaina"); con.addItem(" Denmark"); con.addItem(" England"); con.addItem(" Franc"); con.addItem(" Hangery"); con.addItem(" Holand"); con.addItem(" Itali"); con.addItem(" India"); con.addItem(" Indonesia"); con.addItem(" Jermany"); con.addItem(" Japan"); con.addItem(" Korea"); con.addItem(" Kembridge"); con.addItem(" Merusalem"); con.addItem(" Noth America"); con.addItem(" Norvey"); con.addItem(" West Indies"); con.addItem(" Peru"); con.addItem(" Zimbawe"); about = new JLabel("About me"); try { r = new FileReader(user + "/about.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; main = new JTextArea(); main.setText(ft.getText()); JScrollPane jsp = new JScrollPane(main, v, h); allow = new JLabel("Allow To:"); JCheckBox c1 = new JCheckBox(" orkut Friends"); JCheckBox c2 = new JCheckBox("Collage Friends"); JCheckBox c3 = new JCheckBox("Business Partner"); JCheckBox c4 = new JCheckBox("Relatives"); col = new JLabel("Collage Name:"); try { r = new FileReader(user + "/Collage.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } col1 = new JTextField(); col1.setText(ft.getText()); try { r = new FileReader(user + "/UniverSity.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } uni = new JLabel("Univercity"); uni1 = new JTextField(); uni1.setText(ft.getText()); state1 = new JLabel("State Name"); try { r = new FileReader(user + "/state.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } state = new JTextField(); state.setText(ft.getText()); city = new JLabel("City"); try { r = new FileReader(user + "/City.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } city1 = new JTextField(); city1.setText(ft.getText()); try { r = new FileReader(user + "/imagepath.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } ImageIcon io = new ImageIcon(ft.getText()); icon.setIcon(io); next = new JButton("Update"); next.setBackground(Color.white); // adding to container name1.setBounds(10, 10, 130, 25); name.setBounds(150, 10, 130, 25); last1.setBounds(10, 40, 130, 25); last.setBounds(150, 40, 130, 25); email1.setBounds(10, 70, 130, 25); email.setBounds(150, 70, 130, 25); pass.setBounds(290, 70, 130, 25); pwd.setBounds(390, 70, 130, 25); addimage.setBounds(350, 440, 100, 25); icon.setBounds(490, 410, 100, 100); date1.setBounds(10, 100, 130, 25); date.setBounds(120, 100, 40, 25); month.setBounds(180, 100, 130, 25); year.setBounds(320, 100, 130, 25); sx.setBounds(10, 140, 130, 25); gen.setBounds(150, 140, 130, 25); about.setBounds(10, 180, 130, 25); jsp.setBounds(150, 180, 250, 80); allow.setBounds(10, 260, 130, 25); c1.setBounds(150, 260, 130, 25); c2.setBounds(290, 260, 130, 25); c3.setBounds(150, 290, 130, 25); c4.setBounds(290, 290, 130, 25); uni.setBounds(10, 330, 130, 25); uni1.setBounds(150, 330, 130, 25); col.setBounds(10, 360, 130, 25); col1.setBounds(150, 360, 130, 25); con1.setBounds(10, 390, 130, 25); con.setBounds(150, 390, 130, 25); state1.setBounds(10, 430, 130, 25); state.setBounds(150, 430, 130, 25); city.setBounds(10, 460, 130, 25); city1.setBounds(150, 460, 130, 25); next.setBounds(50, 490, 130, 25); cp.add(name); cp.add(name1); cp.add(last); cp.add(last1); cp.add(email); cp.add(email1); cp.add(addimage); cp.add(icon); cp.add(date1); cp.add(date); cp.add(month); cp.add(year); cp.add(about); cp.add(jsp); cp.add(sx); cp.add(gen); cp.add(allow); cp.add(c1); cp.add(c2); cp.add(c3); cp.add(c4); cp.add(next); cp.add(uni); cp.add(uni1); cp.add(col); cp.add(col1); cp.add(con); cp.add(con1); cp.add(state1); cp.add(state); cp.add(city); cp.add(city1); cp.add(next); cp.add(pwd); cp.add(pass); addimage.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { filepath = name.getText(); JFileChooser chooser = new JFileChooser(); while (true) { int val = chooser.showOpenDialog(editprof.this); File f = chooser.getSelectedFile(); String path = f.getPath(); String name = f.getName(); try { if (val == JFileChooser.CANCEL_OPTION || val == -1) { break; } else { image = new ImageIcon(path); icon.setIcon(image); w = new FileWriter(filepath + "/" + "imagePath.txt"); w.write(path + ""); w.close(); break; } } catch (Exception se) { } } } }); date.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { int str = (Integer) e.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "date.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); month.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e1) { String str = (String) e1.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "month.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); con.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { String str = (String) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "contry.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); year.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { int str = (Integer) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "year.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); gen.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e3) { String str = (String) e3.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "gender.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); next.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent se) { try { w = new FileWriter(name.getText() + "/" + "First name.txt"); w.write(name.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "last name.txt"); w.write(last.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "email.txt"); w.write(email.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "Collage.txt"); w.write(col1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "UniverSity.txt"); w.write(uni1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "state.txt"); w.write(state.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "City.txt"); w.write(city1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "about.txt"); w.write(main.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "password.txt"); w.write(pwd.getText()); w.close(); profile e1 = new profile("My Profile", user1); e1.setVisible(true); e1.setLocation(00, 00); e1.setSize(800, 800); setVisible(false); } catch (Exception be) { } } }); }
protected void dolayout(String strDir, String strFreq, String strTraynum) { // TopBar String strTitle = gettitle(strFreq); Color color = DisplayOptions.getColor("Heading3"); // Center Panel JPanel panelCenter = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); ImageIcon icon = getImageIcon(); // panelCenter.add(new JLabel(icon)); addComp(panelCenter, new JLabel(icon), gbc, 0, 0); strTitle = getSampleName(strDir, strTraynum); m_lblSampleName = new JLabel(strTitle); if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3"; Font font = m_lblSampleName.getFont(); font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300); m_lblSampleName.setFont(font); m_lblSampleName.setForeground(color); // panelCenter.add(m_lblSampleName); m_pnlSampleName = new JPanel(new CardLayout()); m_pnlSampleName.add(m_lblSampleName, OTHER); addComp(panelCenter, m_pnlSampleName, gbc, 1, 0); m_pnlSampleName.setVisible(false); m_pnlTrays = new JPanel(new GridLayout(1, 0)); // Vast panels VBox pnlVast1 = new VBox(m_pnlTrays, "1"); m_pnlTrays.add(pnlVast1); m_pnlVast[0] = pnlVast1; VBox pnlVast2 = new VBox(m_pnlTrays, "2"); m_pnlTrays.add(pnlVast2); m_pnlVast[1] = pnlVast2; VBox pnlVast3 = new VBox(m_pnlTrays, "3"); m_pnlTrays.add(pnlVast3); m_pnlVast[2] = pnlVast3; VBox pnlVast4 = new VBox(m_pnlTrays, "4"); m_pnlTrays.add(pnlVast4); m_pnlVast[3] = pnlVast4; VBox pnlVast5 = new VBox(m_pnlTrays, "5"); m_pnlTrays.add(pnlVast5); m_pnlVast[4] = pnlVast5; m_pnlSampleName.add(m_pnlTrays, VAST); // Login Panel JPanel panelThird = new JPanel(new BorderLayout()); JPanel panelLogin = new JPanel(new GridBagLayout()); gbc = new GridBagConstraints(); panelThird.add(panelLogin); Object[] aStrUser = getOperators(); m_cmbUser = new JComboBox(aStrUser); BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); m_cmbUser.setRenderer(renderer); m_cmbUser.setEditable(true); m_passwordField = new JPasswordField(); // *Warning, working around a Java problem* // When we went to the T3500 running Redhat 5.3, the JPasswordField // fields sometimes does not allow ANY entry of characters. Setting // the enableInputMethods() to true fixed this problem. There are // comments that indicate that this could cause the typed characters // to be visible. I have not found that to be a problem. // This may not be required in the future, or could cause characters // to become visible in the future if Java changes it's code. // GRS 8/20/09 m_passwordField.enableInputMethods(true); m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0); m_lblLogin.setVisible(false); okButton.setActionCommand("enter"); okButton.addActionListener(this); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); helpButton.setActionCommand("help"); helpButton.addActionListener(this); m_passwordField.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin(); } }); // These is some wierd problem such that sometimes, the vnmrj command // area gets the focus and these items in the login box do not get // the focus. Even clicking in these items does not bring focus to // them. Issuing requestFocus() does not bring focus to them. // I can however, determing if either the operator entry box or // the password box has focus and if neither does, I can unshow and // reshow the panel and that fixes the focus. So, I have added this // to the mouseClicked action. If neither has focus, it will // take focus with setVisible false then true. comboTextField = m_cmbUser.getEditor().getEditorComponent(); m_passwordField.addMouseListener(this); comboTextField.addMouseListener(this); m_lblUsername = new JLabel(Util.getLabel("_Operator")); addComp(panelLogin, m_lblUsername, gbc, 0, 0); addComp(panelLogin, m_cmbUser, gbc, 1, 0); m_lblPassword = new JLabel(Util.getLabel("_Password")); addComp(panelLogin, m_lblPassword, gbc, 0, 1); addComp(panelLogin, m_passwordField, gbc, 1, 1); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; addComp(panelLogin, m_lblLogin, gbc, 2, 0); setPref(); Container container = getContentPane(); JPanel panelLoginBox = new JPanel(new BorderLayout()); panelLoginBox.add(panelCenter, BorderLayout.CENTER); panelLoginBox.add(panelThird, BorderLayout.SOUTH); container.add(panelLoginBox, BorderLayout.CENTER); }