/** Returns the value in the proper format: "value". */ protected String getValue(String strUser, String strValue) { ArrayList aListValues = WUtil.strToAList(strValue); String strNewValue = ""; if (strValue == null || strValue.trim().length() <= 0) return ""; String strPath = FileUtil.openPath("SYSPROF" + File.separator + strUser) + File.pathSeparator + FileUtil.openPath("USRPROF" + File.separator + strUser); HashMap hmUser = WFileUtil.getHashMap(strPath); for (int i = 0; i < aListValues.size(); i++) { strNewValue = (String) aListValues.get(i); if (strNewValue == null) strNewValue = ""; // if the value is of the form: $home, then parse the value if (hmUser != null && strNewValue.indexOf('$') >= 0) { strValue = WFileUtil.parseValue(strNewValue, hmUser); if (strValue != null && strValue.trim().length() > 0) strNewValue = strValue; } } return strNewValue; }
protected void setData(String strChecksum) { String strValue = (String) m_cmbPath.getSelectedItem(); if (strValue == null || strValue.equals("")) return; m_cmbChecksum.removeAllItems(); String strPath = strValue.substring(strValue.lastIndexOf("/") + 1); strPath = UtilB.unixPathToWindows(FileUtil.SYS_VNMR + "/p11/checksums/" + strPath); strPath = FileUtil.openPath(strPath); if (strPath != null) { File file = new File(strPath); String[] files = file.list(); int nSize = files.length; for (int i = 0; i < nSize; i++) { String strfile = files[i]; m_cmbChecksum.addItem(strfile); } int nIndex = strChecksum.lastIndexOf("/"); if (nIndex < 0) nIndex = strChecksum.lastIndexOf(File.separator); if (nIndex + 1 < strChecksum.length()) strChecksum = strChecksum.substring(nIndex + 1); m_cmbChecksum.setSelectedItem(strChecksum); } }
protected String gettitle(String strFreq) { StringBuffer sbufTitle = new StringBuffer().append("VnmrJ "); String strPath = FileUtil.openPath(FileUtil.SYS_VNMR + "/vnmrrev"); BufferedReader reader = WFileUtil.openReadFile(strPath); String strLine; String strtype = ""; if (reader == null) return sbufTitle.toString(); try { while ((strLine = reader.readLine()) != null) { strtype = strLine; } strtype = strtype.trim(); if (strtype.equals("merc")) strtype = "Mercury"; else if (strtype.equals("mercvx")) strtype = "Mercury-Vx"; else if (strtype.equals("mercplus")) strtype = "MERCURY plus"; else if (strtype.equals("inova")) strtype = "INOVA"; String strHostName = m_strHostname; if (strHostName == null) strHostName = ""; sbufTitle.append(" ").append(strHostName); sbufTitle.append(" ").append(strtype); sbufTitle.append(" - ").append(strFreq); reader.close(); } catch (Exception e) { // e.printStackTrace(); Messages.logError(e.toString()); } return sbufTitle.toString(); }
protected void setTrays() { String strPath = FileUtil.openPath(TRAYINFO); if (strPath == null) return; setTrayPresent(strPath); setTrayActive(m_strDir); repaint(); }
protected void buildPanel(String strPath) { strPath = FileUtil.openPath(strPath); ArrayList aListPath = new ArrayList(); BufferedReader reader = WFileUtil.openReadFile(strPath); if (reader == null) return; String strLine; try { while ((strLine = reader.readLine()) != null) { StringTokenizer strTok = new StringTokenizer(strLine, ":"); if (strTok.countTokens() < 4) continue; boolean bChecksum = false; boolean bShow = false; String strDir = strTok.nextToken(); String strChecksum = strTok.nextToken(); if (strChecksum.equalsIgnoreCase("checksum")) bChecksum = true; if (bChecksum && (strDir.equals("file") || strDir.equals("dir"))) { String strValue = strTok.nextToken(); String strShow = strTok.nextToken(); if (strShow.equalsIgnoreCase("yes")) bShow = true; if (bShow) aListPath.add(strValue); } } m_cmbPath = new JComboBox(aListPath.toArray()); JPanel pnlDisplay = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0.2, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); pnlDisplay.add(m_cmbPath, gbc); gbc.gridx = 1; pnlDisplay.add(m_cmbChecksum, gbc); add(pnlDisplay, BorderLayout.NORTH); add(m_txaChecksum, BorderLayout.CENTER); } catch (Exception e) { e.printStackTrace(); } }
public DisplayTemplate(String strDir, String strDefDirFile) { setLayout(m_gbl); m_gbc.anchor = GridBagConstraints.NORTHWEST; m_gbc.fill = GridBagConstraints.HORIZONTAL; m_strPathDir = strDir; m_strDefDirFile = strDefDirFile; setLayout(new BorderLayout()); m_pnlDisplay = new JPanel(m_gbl); JScrollPane spDisplay = new JScrollPane(m_pnlDisplay); add(spDisplay, BorderLayout.CENTER); JComponent pnlTool = getToolBar(); add(pnlTool, BorderLayout.NORTH); layoutUIComponents(FileUtil.openPath(m_strDefDirFile), true); VItemArea1.addChangeListener(this); VUserToolBar.addChangeListener(this); }
protected void checksumValidation() { String strValue = (String) m_cmbPath.getSelectedItem(); int nIndex = strValue.lastIndexOf("/"); if (nIndex < 0) nIndex = strValue.lastIndexOf(File.separator); String strPath = strValue.substring(nIndex + 1); strPath = new StringBuffer() .append(FileUtil.SYS_VNMR) .append("/p11/checksums/") .append(strPath) .append("/") .append(m_cmbChecksum.getSelectedItem()) .toString(); strPath = UtilB.unixPathToWindows(strPath); strPath = FileUtil.openPath(strPath); if (strPath == null) return; String[] cmd = { WGlobal.SHTOOLCMD, WGlobal.SHTOOLOPTION, WGlobal.SUDO + WGlobal.SBIN + "chchsums " + strPath }; runScript(cmd, m_txaChecksum); }
/** * Builds the components from the file and displays it. * * @param strFile the file to be read. */ public void build(int nType, String strFile, String strhelpfile) { m_nType = nType; m_strPath = (strFile != null) ? FileUtil.openPath(strFile) : ""; m_strHelpFile = strhelpfile; boolean bValidate = false; boolean bChecksum = false; if (nType == CONFIG) { setTitle("Configuration"); buildConfig(); } else { JComponent compDisplay = null; if (nType == DEFAULT) { m_pnlAccPolicy = new AccPolicyPanel(m_strPath); compDisplay = m_pnlAccPolicy; setTitle("Password Configuration"); } else if (nType == CHECKSUM) { m_pnlChecksum = new ChecksumPanel(m_strPath); compDisplay = m_pnlChecksum; setTitle("Checksum Configuration"); bValidate = true; bChecksum = true; } else { setTitle("Perform System Validation"); compDisplay = new JTextArea(); ((JTextArea) compDisplay).setEditable(false); bValidate = true; doBlink(); } m_pnlDisplay.removeAll(); m_pnlDisplay.setLayout(new BorderLayout()); m_pnlDisplay.add(compDisplay, BorderLayout.CENTER); setVisible(true); } validateButton.setVisible(bValidate); // abandonButton.setVisible(!bValidate); setAbandonEnabled(bValidate); m_btnChecksum.setVisible(bChecksum); }
protected static boolean vnmrjPassword(String strUser, char[] password) { boolean blogin = false; try { PasswordService objPassword = PasswordService.getInstance(); String encrPassword = objPassword.encrypt(new String(password)); if (pwprops == null) { String strPath = FileUtil.openPath(WUserUtil.PASSWORD); if (strPath == null) return blogin; pwprops = new Properties(); FileInputStream fis = new FileInputStream(strPath); pwprops.load(fis); fis.close(); } String stoPassword = pwprops.getProperty(strUser); if (encrPassword.equals(stoPassword)) blogin = true; } catch (Exception e) { // e.printStackTrace(); Messages.writeStackTrace(e); } return blogin; }
protected void setVast() { String strPath = FileUtil.openPath("SYSTEM/asm/gilsonNumber"); if (strPath == null) return; BufferedReader reader = WFileUtil.openReadFile(strPath); if (reader == null) return; String strLine; int i = 0; try { while ((strLine = reader.readLine()) != null) { strLine = strLine.trim(); if (i == 0 || !m_aStrVast[i - 1].equals(strLine)) { m_aStrVast[i] = strLine; i = i + 1; } } reader.close(); } catch (Exception e) { // e.printStackTrace(); Messages.writeStackTrace(e); } }
public void fill() { int i; boolean bSameFile = true; File fd = null; VToolPanel toolPanel = null; String toolPanelFile = FileUtil.openPath("INTERFACE/TabbedToolPanel.xml"); if (toolPanelFile != null) fd = new File(toolPanelFile); if (fd != null && fd.exists()) { bSameFile = false; if (buildFile != null && buildFile.equals(toolPanelFile)) { if (fd.lastModified() == dateOfbuildFile) // same file bSameFile = true; } } if (bSameFile) { for (i = 0; i < objList.size(); i++) { JComponent obj = (JComponent) objList.get(i); if (obj != null) { if (obj instanceof VToolPanel) toolPanel = (VToolPanel) obj; else { if (obj instanceof StatusListenerIF) ExpPanel.addStatusListener((StatusListenerIF) obj); else if (obj instanceof ExpListenerIF) ExpPanel.addExpListener((ExpListenerIF) obj); } } } if (toolPanel != null) toolPanel.fill(); return; } for (i = 0; i < objList.size(); i++) { for (i = 0; i < objList.size(); i++) { JComponent obj = (JComponent) objList.get(i); if (obj != null) { if (obj instanceof VToolPanel) toolPanel = (VToolPanel) obj; } } } if (toolPanel != null) toolPanel.clearAll(); buildFile = toolPanelFile; if (fd != null) dateOfbuildFile = fd.lastModified(); clearPanel(); try { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setValidating(false); // set to true if we get DOCTYPE spf.setNamespaceAware(false); // set to true with referencing SAXParser parser = spf.newSAXParser(); if (toolPanelFile == null) { /* get VToolPanel only */ String key = "Locator"; PushpinIF pObj; Constructor c = (Constructor) getTool(key); Object[] vargs = new Object[1]; vargs[0] = sshare; if (c != null) { JComponent comp = (JComponent) c.newInstance(vargs); if (comp instanceof VToolPanel) { toolList.add(comp); } tabbedToolPanel.add(comp); objList.add(comp); if (!(comp instanceof PushpinIF)) { pObj = new PushpinObj(comp, pinPanel); // pObj.setTitle("Tool Panel"); pObj.showPushPin(false); pObj.showTitle(false); // pObj.alwaysShowTab(true); } else pObj = (PushpinIF) comp; pObj.setContainer(pinPanel); pObj.setSuperContainer(pinPanel); addTabComp(pObj); panes.put(key, pObj); // panes.put(key,comp); keys.add(key); vpInfo.add("all"); for (i = 0; i < nviews; i++) tp_paneInfo[i].put(key, "yes"); } } else { parser.parse(new File(toolPanelFile), new MySaxHandler()); } } catch (ParserConfigurationException pce) { System.out.println("The underlying parser does not support the " + "requested feature(s)."); } catch (FactoryConfigurationError fce) { System.out.println("Error occurred obtaining SAX Parser Factory."); } catch (Exception e) { e.printStackTrace(); } for (i = 0; i < toolList.size(); i++) ((VToolPanel) toolList.get(i)).fill(); }
public void startElement(String uri, String localName, String qName, Attributes attr) { // System.out.println("Start of Element '"+qName+"'"); // int numOfAttr = attr.getLength(); // System.out.println(" Number of Attributes is "+numOfAttr); // for (int i=0; i<numOfAttr; i++) { // System.out.println(" with attr["+i+"]='"+attr.getValue(i)+"'"); // } if (!qName.equals("tool")) return; boolean bScroll = true; PushpinIF pObj = null; lastName = attr.getValue("name"); String helplink = attr.getValue("helplink"); Constructor c = (Constructor) getTool(lastName); Object[] vargs; String toolFile; if (lastName.equals("XMLToolPanel")) { lastName = attr.getValue("label"); lastName = Util.getLabelString(lastName); String scroll = attr.getValue("scrollbar"); if (scroll != null) { if (scroll.equalsIgnoreCase("no")) bScroll = false; } vargs = new Object[3]; vargs[0] = sshare; vargs[1] = lastName; toolFile = attr.getValue("file"); vargs[2] = toolFile; String f = "LAYOUT" + File.separator + "toolPanels" + File.separator + toolFile; toolFile = FileUtil.openPath(f); if (toolFile == null) return; } else { vargs = new Object[1]; vargs[0] = sshare; } if (c != null) { try { lastComp = (JComponent) c.newInstance(vargs); if (lastComp instanceof VToolPanel) { toolList.add(lastComp); pObj = (PushpinIF) lastComp; } objList.add(lastComp); } catch (Exception e) { lastComp = new JLabel(lastName); } } else { lastComp = new JLabel(lastName); } String vps = attr.getValue("viewport"); if (lastComp != null && (lastComp instanceof XMLToolPanel)) ((XMLToolPanel) lastComp).setScrollAble(bScroll); if (pObj == null) { PushpinObj nObj = new PushpinObj(lastComp, pinPanel); pObj = nObj; pObj.setTitle(lastName); pObj.showPushPin(true); pObj.showTitle(true); pObj.setTabOnTop(true); } pObj.setName(lastName); addTabComp(pObj); pObj.setContainer(pinPanel); pObj.setSuperContainer(pinPanel); panes.put(lastName, pObj); // panes.put(lastName, lastComp); keys.add(lastName); vpInfo.add(vps); }
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); } }
/** * Write the file by writing the values from the labels, and the values list. * * @param strFile the file to be written. * @param aListLabels arraylist of texfields of labels. * @param aListValues arraylist of texfields of values. */ protected void writeFile( String strUser, String strFile, ArrayList aListLabels, ArrayList aListValues) { String strPath = FileUtil.openPath(strFile); String strLabel = ""; String strValue = ""; StringBuffer sbValues = new StringBuffer(); JTextField txfLabel = null; JTextField txfValue = null; boolean bNewFile = false; int nFDAMode = Util.getPart11Mode(); // if it's the part11 pnl and the mode is nonFDA, // then don't write the file for this panel // the other way is not true. if (this instanceof DisplayParentDirectory) { if ((isPart11Pnl() && nFDAMode == Util.NONFDA)) { return; } } if (strPath == null) { strPath = FileUtil.savePath(strFile); bNewFile = true; } if (strPath == null || aListLabels == null) return; if (aListValues == null) aListValues = new ArrayList(); // Get the list of the textfields for values and labels. int nLblSize = aListLabels.size(); int nValueSize = aListValues.size(); ArrayList<String> labelList = new ArrayList<String>(); // Get the value from each textfield, and add it to the buffer. for (int i = 0; i < nLblSize; i++) { txfLabel = (JTextField) aListLabels.get(i); txfValue = (i < nValueSize) ? (JTextField) aListValues.get(i) : null; strLabel = (txfLabel != null) ? txfLabel.getText() : null; strValue = (txfValue != null) ? txfValue.getText() : ""; // We need to be sure they don't have two data directories with // the same labels. Save the label list if we are writing to // the "data" file. if (strFile.indexOf("data") != -1) { if (labelList.contains(strLabel)) { Messages.postError( "The Data Directory specifications " + "must not have duplicate Label names. " + "The Label \"" + strLabel + "\" is duplicated. " + "Skipping the second instance. Please " + "specify a new Label."); continue; } else labelList.add(strLabel); } if (strLabel == null || strLabel.trim().length() <= 0 || strValue.equals(INFOSTR)) continue; // for user template tab, don't need to parse the value if (!(this instanceof DisplayTemplate)) strValue = getValue(strUser, strValue); strLabel = strLabel.trim(); if (strValue != null) strValue = strValue.trim(); // sbValues.append("\""); sbValues.append(strLabel); // sbValues.append("\" "); sbValues.append(File.pathSeparator); sbValues.append(strValue); sbValues.append("\n"); } if (Util.isPart11Sys()) writeAuditTrail(strPath, strUser, sbValues); // write the data to the file. BufferedWriter writer = WFileUtil.openWriteFile(strPath); WFileUtil.writeAndClose(writer, sbValues); // if it's a template file, then make it writable for everyone. if (bNewFile) { String strCmd = "chmod 755 "; if (this instanceof DisplayTemplate) strCmd = "chmod 777 "; if (Util.iswindows()) strPath = UtilB.windowsPathToUnix(strPath); String[] cmd = {WGlobal.SHTOOLCMD, WGlobal.SHTOOLOPTION, strCmd + strPath}; WUtil.runScriptInThread(cmd); } }
/** * Read position and size of the login box from a given abstract path. * * @param abstractPath The path to the file. */ public void readPersistence(String abstractPath) { String filepath = FileUtil.openPath(abstractPath); if (filepath != null) { BufferedReader in; String line; try { File file = new File(filepath); in = new BufferedReader(new FileReader(file)); // File must start with 'Login Panel' if ((line = in.readLine()) != null) { if (!line.startsWith("Login Panel")) { Messages.postWarning("The " + filepath + " file is " + "corrupted and being removed"); // Remove the corrupted file. file.delete(); // Set the size and position to the full vnmrj frame setDefaultSizePosition(); return; } } String h = null, w = null, x = null, y = null; int xi, yi; if (in.ready()) h = in.readLine().trim(); if (in.ready()) w = in.readLine().trim(); if (in.ready()) x = in.readLine().trim(); if (in.ready()) y = in.readLine().trim(); in.close(); // Save width and height for later use also height = Integer.decode(h).intValue(); width = Integer.decode(w).intValue(); xi = Integer.decode(x).intValue(); yi = Integer.decode(y).intValue(); // Save point for later use also position = new Point(xi, yi); // Set them setSize(width, height); setLocation(position); // If we got what we need and set the size and position, // just return now. return; } // If an exception, continue below catch (Exception e) { } } // No file or an excpetion happened, set default size and position // Be sure the file is gone try { if (filepath != null) { File file = new File(filepath); if (file != null) file.delete(); } } // If an exception, just continue below catch (Exception e) { } // Set the size and position to the full vnmrj frame setDefaultSizePosition(); }