Ejemplo n.º 1
0
    protected void buildPanel(String strPath) {
      BufferedReader reader = WFileUtil.openReadFile(strPath);
      String strLine;

      if (reader == null) return;

      try {
        while ((strLine = reader.readLine()) != null) {
          if (strLine.startsWith("#") || strLine.startsWith("%") || strLine.startsWith("@"))
            continue;

          StringTokenizer sTokLine = new StringTokenizer(strLine, ":");

          // first token is the label e.g. Password Length
          if (sTokLine.hasMoreTokens()) {
            createLabel(sTokLine.nextToken(), this);
          }

          // second token is the value
          String strValue = sTokLine.hasMoreTokens() ? sTokLine.nextToken() : "";
          if (strValue.equalsIgnoreCase("yes") || strValue.equalsIgnoreCase("no"))
            createChkBox(strValue, this);
          else createTxf(strValue, this);
        }
      } catch (Exception e) {
        Messages.writeStackTrace(e);
        // e.printStackTrace();
        Messages.postDebug(e.toString());
      }
    }
Ejemplo n.º 2
0
 private String subString(String s, String m, String d) {
   String r = "";
   StringTokenizer tok = new StringTokenizer(s, " \t\':+-*/\"/()=,\0", true);
   while (tok.hasMoreTokens()) {
     String t = tok.nextToken();
     if (t.equals(m)) r += d;
     else r += t;
   }
   return r;
 }
Ejemplo n.º 3
0
 /** Update state from Infostat. */
 public void updateStatus(String msg) {
   // Messages.postDebug("VLcStatusChart.updateStatus(" + msg + ")");/*CMP*/
   if (msg == null) {
     return;
   }
   StringTokenizer tok = new StringTokenizer(msg);
   if (tok.hasMoreTokens()) {
     String key = tok.nextToken();
     String val = "";
     if (tok.hasMoreTokens()) {
       val = tok.nextToken("").trim(); // Get remainder of msg
     }
     if (key.equals(statkey)) {
       if (val != null && !val.equals("-")) {
         valstr = val;
         setState(state);
       }
       /*System.out.println("Chart: statkey=" + statkey
       + ", val=" + val);/*CMP*/
     }
     if (key.equals(statpar)) {
       if (val != null && !val.equals("-")) {
         /*System.out.println("Chart statpar=" + statpar
         + ", value=" + value);/*CMP*/
         setState(state);
       }
     }
     if (key.equals(statset)) {
       if (val != null && !val.equals("-")) {
         setval = val;
         try {
           String num = val.substring(0, val.indexOf(' '));
           setStatusValue(Double.parseDouble(num));
         } catch (NumberFormatException nfe) {
           Messages.postDebug("VLcStatusChart.updateStatus(): " + "Non-numeric value: " + msg);
         } catch (StringIndexOutOfBoundsException sioobe) {
           setStatusValue(0); // No value found
         }
         /*System.out.println("Chart statset=" + statset
         + ", setval=" + setval);/*CMP*/
         setState(state);
       }
     }
   }
   repaint();
 }
Ejemplo n.º 4
0
  /**
   * Creates the components based on the information in each line.
   *
   * @param sTokLine the tokens in a line.
   *     <p>The file is of the following format: auditDir:/vnmr/part11/auditTrails:system
   *     part11Dir:/vnmr/part11/data:system part11Dir:/vnmr/part11/data:system
   *     file:standard:cmdHistory:yes file:standard:fid:yes file:standard:procpar:yes
   *     file:standard:conpar:yes
   *     <p>Based on this format, the line is parsed as follows: 1) if the line starts with the
   *     keyword 'file', then it skips over the first two tokens in the line which are 'file' and
   *     'standard', and the third token in the line is the label of the item, and the fourth token
   *     in the line corresponds to the value of the checkbox. 2) if the line doesnot start with the
   *     keyword 'file', then the second and the fourth tokens are skipped, first token in the line
   *     is the label of the item, and the third token is the value of the textfield.
   */
  protected void createJComps(StringTokenizer sTokLine) {
    boolean bFile = false;
    boolean bMode = false;
    JComponent compValue = null;
    boolean bDir = false;

    for (int i = 0; sTokLine.hasMoreTokens(); i++) {
      String strTok = sTokLine.nextToken();
      if (i == 0) {
        bFile = strTok.equalsIgnoreCase("file") ? true : false;
        bMode = strTok.equalsIgnoreCase("dataType") ? true : false;
        bDir = false;
        if (strTok.equalsIgnoreCase("dir")) bDir = true;

        // Case 2, create a label for the first token.
        if (!bFile && !bDir) createLabel(strTok, m_pnlDisplay);
      } else {
        // Case 1 => file:standard:conpar:yes
        if (bFile) {
          // skip over the first tokenwhich is the keyword 'file'
          if (i == 1) continue;
          // else check for checkbox value.
          else if (strTok.equalsIgnoreCase("yes") || strTok.equalsIgnoreCase("no"))
            compValue = createChkBox(strTok, m_pnlDisplay);
          // else create a label.
          else createLabel(strTok, m_pnlDisplay);
        }
        // Case 2 => part11Dir:/vnmr/part11/data:system Or dataType:Non-FDA
        else if (!bDir) {
          if (i == 1) {
            // create a combobox
            if (bMode) compValue = createCombo(strTok, m_pnlDisplay);
            // create a textfield and sets it's value.
            else compValue = createTxf(strTok, m_pnlDisplay);
          }
        }
      }
    }
    m_aListComp.add(compValue);
  }
Ejemplo n.º 5
0
    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();
      }
    }
Ejemplo n.º 6
0
  /**
   * Save the data to the file. Read the data from the file, and copy everything to the
   * stringbuffer. The lines in the file are of the form:
   * auditDir:system:/vnmr/part11/auditTrails:system file:standard:text:yes Based on these formats,
   * get the value of either the directory or the checkbox from the corresponding components, and
   * replace that value in the stringbuffer.
   */
  protected void saveData() {
    BufferedReader reader = WFileUtil.openReadFile(m_strPath);
    String strLine = null;
    StringBuffer sbData = new StringBuffer();
    if (reader == null) return;

    int nLineInd = 0;
    try {
      while ((strLine = reader.readLine()) != null) {
        // if the line starts with a comment from sccs, add '#' to it,
        // to make it a comment
        if (strLine.startsWith("%") || strLine.startsWith("@")) strLine = "# " + strLine;

        if (strLine.startsWith("#")) {
          sbData.append(strLine + "\n");
          continue;
        }
        StringTokenizer sTok = new StringTokenizer(strLine, File.pathSeparator);
        boolean bFile = false;
        boolean bLineEnd = false;
        boolean bDir = false;

        for (int i = 0; sTok.hasMoreTokens(); i++) {
          String strValue = sTok.nextToken();
          if (i == 0) {
            bFile = strValue.equalsIgnoreCase("file") ? true : false;
            bDir = false;
            if (strValue.equalsIgnoreCase("dir")) bDir = true;
          } else {
            // Case => file:standard:procpar:yes
            // skip over 'standard', 'procpar',
            // and get the value 'yes' or 'no' from the checkbox
            if (bFile) {
              if (i == 3) {
                String strNewValue = getValue(nLineInd);
                if (strNewValue != null) strValue = strNewValue;
                bLineEnd = true;
              } else bLineEnd = false;
            } else if (bDir) {
              bLineEnd = false;
              if (i == 3) bLineEnd = true;
            }
            // Case => part11Dir:/vnmr/part11/data 0r
            // Case => dataType:FDA
            // skip over 'part11Dir'
            // and get the value of the directory from the textfield,
            // or from the combobox
            else {
              if (i == 1) {
                String strNewValue = getValue(nLineInd);
                if (strNewValue != null) strValue = strNewValue;
                bLineEnd = true;
              } else bLineEnd = false;
            }
          }
          // copy the value to the stringbuffer
          sbData.append(strValue);
          if (!bLineEnd) sbData.append(File.pathSeparator);
        }
        nLineInd++;
        sbData.append("\n");
      }
      // write the data to the file
      reader.close();
      BufferedWriter writer = WFileUtil.openWriteFile(m_strPath);
      WFileUtil.writeAndClose(writer, sbData);
      m_objTimer =
          new javax.swing.Timer(
              200,
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  VItemAreaIF.firePropertyChng(Global.PART11_CONFIG_FILE, "all", "");
                  m_objTimer.stop();
                }
              });
      m_objTimer.start();
    } catch (Exception e) {
      Messages.writeStackTrace(e);
      // e.printStackTrace();
      Messages.postDebug(e.toString());
    }
  }
Ejemplo n.º 7
0
    /** 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());
      }
    }
Ejemplo n.º 8
0
    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);
      }
    }