示例#1
1
  /**
   * Returns the value of the component
   *
   * @param nLineInd index of the line in the file.
   */
  protected String getValue(int nLineInd) {
    JComponent comp = null;
    String strValue = null;

    // Get the component corresponding to the line of the file from the list.
    if (nLineInd < m_aListComp.size()) {
      comp = (JComponent) m_aListComp.get(nLineInd);
    }

    if (comp == null) return strValue;

    // Get the value of the component
    if (comp instanceof JTextField) strValue = ((JTextField) comp).getText();
    else if (comp instanceof JCheckBox) strValue = ((JCheckBox) comp).isSelected() ? "yes" : "no";
    else if (comp instanceof JComboBox) strValue = (String) ((JComboBox) comp).getSelectedItem();

    // if the value is of the form: $home, then parse the value
    /*if (strValue.indexOf('$') >= 0)
    {
        String strNewValue = WFileUtil.parseValue(strValue, new HashMap());
        if (strNewValue != null && strNewValue.trim().length() > 0)
            strValue = strNewValue;
    }*/

    return strValue;
  }
示例#2
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();
      }
    }
示例#3
0
 /**
  * Gets the list of the vnmrj users(operators) for the current unix user logged in
  *
  * @return the list of vnmrj users
  */
 protected Object[] getOperators() {
   String strUser = System.getProperty("user.name");
   User user = LoginService.getDefault().getUser(strUser);
   ArrayList<String> aListOperators = user.getOperators();
   if (aListOperators == null || aListOperators.isEmpty())
     aListOperators = new ArrayList<String>();
   Collections.sort(aListOperators);
   if (aListOperators.contains(strUser)) aListOperators.remove(strUser);
   aListOperators.add(0, strUser);
   return (aListOperators.toArray());
 }
示例#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);
  }
示例#5
0
  public void buildConfig() {
    BufferedReader in = WFileUtil.openReadFile(m_strPath);
    String strLine = null;

    if (in == null) {
      Messages.postError("Error opening file " + m_strPath);
      return;
    }

    try {
      m_pnlDisplay.removeAll();
      m_pnlDisplay.setLayout(new WGridLayout(0, 2));
      m_aListComp.clear();
      while ((strLine = in.readLine()) != null) {
        if (strLine.startsWith("#") || strLine.startsWith("%") || strLine.startsWith("@")) continue;
        StringTokenizer sTokLine = new StringTokenizer(strLine, File.pathSeparator);
        createJComps(sTokLine);
      }
      setVisible(true);
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
    }
  }