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); }
private void newLabel(String s) { StringTokenizer tkn = new StringTokenizer(s, "\n"); num_lines = tkn.countTokens(); lines = new String[num_lines]; line_widths = new int[num_lines]; for (int i = 0; i < num_lines; i++) { lines[i] = tkn.nextToken(); } }
/** * Gets the keyword telling where to place the login frame. * The "title" is a series of tokens of the form: * <pre> * autodir h1freq traymax [help:path] [nextloc:loc] [frameBounds:keyword] * <pre> * @param title The "title" passed in. * @return The frame location keyword. */ private String getFrameBounds(String title) { String bounds = null; StringTokenizer tok = new QuotedStringTokenizer(title); while (tok.hasMoreTokens()) { String strValue = tok.nextToken(); if (strValue.startsWith("frameBounds:")) { bounds = strValue.substring(12); } } return bounds; }
/** * Get the "next sample" string from the given "title". * The "title" is a series of tokens of the form: * <pre> * autodir h1freq traymax [help:path] [nextloc:loc] [frameBounds:keyword] * <pre> * @param title The "title" passed in. * @return The next available sample location, or null. */ protected String getSampleName(String title) { String name = null; StringTokenizer tok = new QuotedStringTokenizer(title); while (tok.hasMoreTokens()) { String strValue = tok.nextToken(); if (strValue.startsWith("nextloc:")) { name = strValue.substring(8); } } return name; }
/** * Set the helpfile string from the given "title". * The "title" is a series of tokens of the form: * <pre> * autodir h1freq traymax [help:path] [nextloc:loc] * <pre> * @param title The "title" passed in. * @return The path to the help file, or null. */ protected String getHelpFile(String title) { StringTokenizer tok = new QuotedStringTokenizer(title); String path = null; while (tok.hasMoreTokens()) { String strValue = tok.nextToken(); if (strValue.startsWith("help:")) { path = strValue.substring(5); } } return path; }
/** Reads the file, and sets the label and the values in the hashmap. */ protected void setHM(String strPath, HashMap hmPnl) { BufferedReader reader = WFileUtil.openReadFile(strPath); boolean bFileEmpty = true; boolean bPart11Pnl = isPart11Pnl(); boolean bDefaultFile = isDefaultFile(); // if the file is empty, then create an empty set of textfields. if (reader == null) { // displayNewTxf("",""); return; } String strLine = null; StringTokenizer strTok; try { // read the file, and create a new set of textfields, // with the values from the file. while ((strLine = reader.readLine()) != null) { String strLabel = ""; String strValue = ""; bFileEmpty = false; if (strLine.startsWith("#") || strLine.startsWith("@") || strLine.startsWith("%") || strLine.startsWith("\"@")) continue; if (strLine.startsWith("\"")) strTok = new StringTokenizer(strLine, "\""); else strTok = new StringTokenizer(strLine, File.pathSeparator + ",\n"); if (!strTok.hasMoreTokens()) continue; strLabel = strTok.nextToken(); // the format for the part11 Default file is a little different // only parse out the part11Dir, and don't display other defaults if (bPart11Pnl && bDefaultFile) { if (!strLabel.equalsIgnoreCase("part11Dir")) continue; } if (strTok.hasMoreTokens()) { while (strTok.hasMoreTokens()) { strValue += strTok.nextToken(); if (strTok.hasMoreTokens()) strValue += " "; } } // append "/data/$name" to part11Dir if (bPart11Pnl && bDefaultFile && strLabel.equalsIgnoreCase("part11Dir")) { StringBuffer sbDir = new StringBuffer(strValue); if (sbDir.lastIndexOf(File.separator) < sbDir.length() - 1) sbDir.append(File.separator); sbDir.append("data" + File.separator + "$"); sbDir.append(WGlobal.NAME); strValue = sbDir.toString(); } // displayNewTxf(strLabel, strValue); if (strLabel != null && strLabel.trim().length() > 0) hmPnl.put(strLabel, strValue); } reader.close(); } catch (Exception e) { Messages.writeStackTrace(e); // e.printStackTrace(); Messages.postDebug(e.toString()); } }
public void propertyChange(PropertyChangeEvent e) { String strPropName = e.getPropertyName(); if (strPropName.equals(WGlobal.USER_CHANGE)) { String strName = (String) e.getNewValue(); String strAccount = null; VDetailArea objDetailArea = m_adminIF.getDetailArea1(); if (objDetailArea != null) strAccount = objDetailArea.getItemValue("itype"); if (strAccount == null) strAccount = ""; strAccount = strAccount.trim(); String strDir = getPathDir() + strName; if (this instanceof DisplayTemplate) { if (strAccount.equals(Global.IMGIF)) strDir = strDir + ".img"; else if (strAccount.equals(Global.WALKUPIF)) strDir = strDir + ".walkup"; } String strPath = FileUtil.openPath(strDir); boolean bDefaultFile = false; if (strPath == null) { strPath = FileUtil.openPath(getDefaultFile(strAccount)); bDefaultFile = true; } clear(this); layoutUIComponents(strPath, bDefaultFile); } else if (strPropName.indexOf(WGlobal.IMGDIR) >= 0) { String strName = (String) e.getNewValue(); StringTokenizer strTokenizer = new StringTokenizer(strPropName); String strInterface = null; boolean bDefaultFile = false; if (strTokenizer.hasMoreTokens()) strTokenizer.nextToken(); if (strTokenizer.hasMoreTokens()) strInterface = strTokenizer.nextToken(); if (strInterface == null) strInterface = ""; strInterface = strInterface.trim(); String strDir = getPathDir() + strName; if (this instanceof DisplayTemplate) { if (strInterface.equals(WGlobal.IMGDIR)) strDir = strDir + ".img"; else if (strInterface.equals(WGlobal.WALKUPDIR)) strDir = strDir + ".walkup"; } String strPath = FileUtil.openPath(strDir); if (strPath == null) { String strAccount = Global.WALKUPIF; if (strInterface.equals(WGlobal.IMGDIR)) strAccount = Global.IMGIF; else if (strInterface.equals(WGlobal.WALKUPDIR)) strAccount = Global.WALKUPIF; strPath = FileUtil.openPath(getDefaultFile(strAccount)); bDefaultFile = true; } clear(this); layoutUIComponents(strPath, bDefaultFile); } else if (strPropName.indexOf(WGlobal.SAVEUSER_NOERROR) >= 0) { Object objValue = e.getNewValue(); String strName = ""; if (objValue instanceof String) strName = (String) objValue; else if (objValue instanceof WItem) strName = ((WItem) objValue).getText(); VDetailArea objDetail = m_adminIF.getDetailArea1(); String strAccount = null; if (objDetail != null) strAccount = objDetail.getItemValue("itype"); if (strAccount == null) strAccount = ""; strAccount = strAccount.trim(); String strDir = getPathDir() + strName; if (this instanceof DisplayTemplate) { if (strAccount.equals(Global.IMGIF)) strDir = strDir + ".img"; else if (strAccount.equals(Global.WALKUPIF)) strDir = strDir + ".walkup"; } TextFieldValues objTxf = getTxfValues(); writeFile(strName, strDir, objTxf.getTxfLabel(), objTxf.getTxfValue()); } else if (strPropName.indexOf(WGlobal.DELETE_USER) >= 0) { clear(this); String strPath = FileUtil.openPath(getDefaultFile("")); layoutUIComponents(strPath, true); } }