コード例 #1
0
    /** 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;
    }
コード例 #2
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  /** Write file with position and size of the login box */
  public static void writePersistence() {

    Messages.postDebug("LoginBox", "LoginBox.writePersistence");
    // If the panel has not been created, don't try to write a file
    if (position == null) return;

    String filepath = FileUtil.savePath("USER/PERSISTENCE/LoginPanel");

    FileWriter fw;
    PrintWriter os;
    try {
      File file = new File(filepath);
      fw = new FileWriter(file);
      os = new PrintWriter(fw);
      os.println("Login Panel");

      os.println(height);
      os.println(width);
      double xd = position.getX();
      int xi = (int) xd;
      os.println(xi);
      double yd = position.getY();
      int yi = (int) yd;
      os.println(yi);

      os.close();
    } catch (Exception er) {
      Messages.postError("Problem creating  " + filepath);
      Messages.writeStackTrace(er);
    }
  }
コード例 #3
0
ファイル: XMLToolPanel.java プロジェクト: timburrow/ovj3
  public void buildPanel() {
    String path = FileUtil.getLayoutPath(layoutDir, fname);
    if (path == null) {
      Messages.postError("Could not open xml file:" + fname);
      return;
    }
    removeAll();
    try {
      LayoutBuilder.build(pane, vnmrIf, path);
    } catch (Exception e) {
      String strError = "Error building file: " + path;
      Messages.postError(strError);
      Messages.writeStackTrace(e);
      return;
    }

    if (bScrollBar) {
      spane =
          new JScrollPane(
              pane,
              JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      add(spane);
    } else {
      spane = null;
      add(pane);
    }
    paramsLayout.preferredLayoutSize(pane);
  }
コード例 #4
0
ファイル: WPart11Dialog.java プロジェクト: timburrow/ovj3
    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);
      }
    }
コード例 #5
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  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();
  }
コード例 #6
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  protected void setTrays() {
    String strPath = FileUtil.openPath(TRAYINFO);
    if (strPath == null) return;

    setTrayPresent(strPath);
    setTrayActive(m_strDir);
    repaint();
  }
コード例 #7
0
ファイル: WGlobal.java プロジェクト: timburrow/OpenVnmrJ
  public static String getSbin() {
    String strSbin = "/usr/varian/sbin/";
    if (Util.iswindows()) {
      strSbin = "/vnmr/bin/";
    } else {
      UNFile file = new UNFile(strSbin);
      if (!file.exists()) strSbin = FileUtil.sysdir() + "/bin/";
    }

    return strSbin;
  }
コード例 #8
0
ファイル: WPart11Dialog.java プロジェクト: timburrow/ovj3
    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();
      }
    }
コード例 #9
0
    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);
    }
コード例 #10
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  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;
  }
コード例 #11
0
ファイル: WPart11Dialog.java プロジェクト: timburrow/ovj3
    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);
    }
コード例 #12
0
ファイル: WPart11Dialog.java プロジェクト: timburrow/ovj3
  /**
   * 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);
  }
コード例 #13
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  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);
    }
  }
コード例 #14
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);
      }
    }
コード例 #15
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  protected static boolean unixPassword(String strUser, char[] password) {
    password = getPassword(password);
    boolean bSu = true;
    String strSu;
    PrintWriter fout = null;

    if (!Util.iswindows()) {
      String filepath = FileUtil.savePath("USER/PERSISTENCE/passwd");
      if (filepath == null) {
        filepath = FileUtil.savePath("USER/PERSISTENCE/tmp_passwd");
      }
      try {
        fout = new PrintWriter(new FileWriter(filepath));
        if (fout != null) fout.println(String.valueOf(password));
      } catch (IOException er) {
      } finally {
        try {
          if (fout != null) fout.close();
        } catch (Exception e) {
        }
      }

      /**
       * ******** String strPath = new StringBuffer().append(LOGIN).append(" ").append(
       * strUser).append(" \"").append(String.valueOf( password)).append("\"").toString(); ********
       */
      String strPath =
          new StringBuffer()
              .append(LOGIN)
              .append(" ")
              .append(strUser)
              .append(" \"")
              .append(filepath)
              .append("\"")
              .toString();
      String[] cmd = {WGlobal.SHTOOLCMD, WGlobal.SHTOOLOPTION, strPath};
      WMessage objMessage = WUtil.runScript(cmd, false);
      bSu = objMessage.isNoError();
      strSu = objMessage.getMsg();
    } else {
      String strQuotes = "\"\"";
      if (password.length == 0) strQuotes = "\"";
      String cmd =
          new StringBuffer()
              .append(LOGIN_WIN)
              .append(" ")
              .append(strUser)
              .append(" ")
              .append(strQuotes)
              .append(String.valueOf(password))
              .append(strQuotes)
              .toString();
      WMessage objMessage = WUtil.runScript(cmd, false);
      bSu = objMessage.isNoError();
      strSu = objMessage.getMsg();
    }
    if (bSu) {
      if (strSu != null) strSu = strSu.toLowerCase();
      if (strSu == null
          || strSu.trim().equals("")
          || strSu.indexOf("killed") >= 0
          || strSu.indexOf("error") >= 0) bSu = false;
    }

    return bSu;
  }
コード例 #16
0
ファイル: VTabbedToolPanel.java プロジェクト: timburrow/ovj3
  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();
  }
コード例 #17
0
ファイル: VTabbedToolPanel.java プロジェクト: timburrow/ovj3
    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);
    }
コード例 #18
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  /**
   * 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();
  }
コード例 #19
0
    /**
     * 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);
      }
    }
コード例 #20
0
ファイル: WGlobal.java プロジェクト: timburrow/OpenVnmrJ
/**
 * Title: WGlobal Description: This file has the global variables implemented for the Wanda
 * interface. Copyright: Copyright (c) 2002
 */
public class WGlobal {
  public static final String AREA1 = "Area1";
  public static final String AREA2 = "Area2";
  public static final String INFODIR = "Infodir";
  public static final String BUILD = "Build";
  public static final String WRITE = "Write";
  public static final String CLEAR = "Clear";
  public static final String ALL = "All";
  public static final String SET_VISIBLE = "Set visible";
  public static final String SAVEUSER = vnmr.util.Util.getLabel("_admin_Save_User");
  public static final String SAVEGROUP = "Save Group";
  public static final String SAVEUSER_NOERROR = "Save User No Error";
  public static final String USER_CHANGE = "User Change";
  public static final String GROUP_CHANGE = "Group Change";
  public static final String DELETE_USER = "******";
  public static final String ITEM_LIST = "Item List";
  public static final String ACTIVATE = "Activate Account";
  public static final String BGCOLOR = "BgColor";
  public static final String FONTSCOLORS = "Fonts Colors";
  public static final String SEPERATOR = "_";
  public static final String SUDO = getSudo();
  public static final String SHTOOLCMD = System.getProperty("shtoolcmd");
  public static final String SHTOOLOPTION = System.getProperty("shtooloption");
  public static final String NAME = "accname";
  public static final String FULLNAME = "name";
  public static final String PART11 = "part11";
  public static final String ITEM_AREA1 = "Item" + SEPERATOR + AREA1;
  public static final String ITEM_AREA2 = "Item" + SEPERATOR + AREA2;
  public static final String DETAIL_AREA1 = "Detail" + SEPERATOR + AREA1;
  public static final String DETAIL_AREA2 = "Detail" + SEPERATOR + AREA2;
  public static final String ADMIN_BGCOLOR = "Wanda" + BGCOLOR;
  public static final String PANELLEVEL = "30";
  public static final String IMGDIR = FileUtil.sysdir() + File.separator + Global.IMAGING;
  public static final String WALKUPDIR = FileUtil.sysdir();
  public static final String LCDIR = FileUtil.sysdir() + File.separator + Global.LC;
  public static final String SBIN = getSbin();
  public static final String OPT_PER_FILE = "USER/PERSISTENCE/AdminOptions"; // persistence file
  public static final String TRASHCAN_FILE = "SYSTEM/PROFILES/trashcan";

  /** label for admin interface */
  public static String ADMINIFLBL = Util.getLabel("_Global_Administrative", Global.ADMINIF);
  /** label for walkup interface */
  public static String WALKUPIFLBL = Util.getLabel("_Global_Walkup", Global.WALKUPIF);
  /** label for imaging interface */
  public static String IMGIFLBL = Util.getLabel("_Global_Imaging", Global.IMGIF);
  /** label for lc interface */
  public static String LCIFLBL = Util.getLabel("_Global_LCIF", Global.LCIF);

  /** The array of requried fields for a user. */
  public static final String[] USR_REQ_FIELDS = {
    NAME, "home", "userdir", "sysdir", "datadir", "itype"
  };
  // "sysdir", "datadir", "appdir", "itype"};
  public static final String[] USR_PART11_REQ_FIELDS = {
    NAME, "home", "name", "userdir", "sysdir", "datadir", "itype"
  };
  // "sysdir", "datadir", "appdir", "itype"};
  public static final String[] USR_REQ_FIELDS_WIN = {
    NAME, "home", "userdir", "sysdir", "datadir", "itype"
  };
  public static final String[] USR_PART11_REQ_FIELDS_WIN = {
    NAME, "home", "name", "userdir", "sysdir", "datadir", "itype"
  };

  public static String getPropName(String strLabel) {
    String strPropName = strLabel;
    String strTmp = strLabel.toLowerCase();

    if (strTmp.startsWith("fonts")) strPropName = FONTSCOLORS;

    return strPropName;
  }

  public static String getSbin() {
    String strSbin = "/usr/varian/sbin/";
    if (Util.iswindows()) {
      strSbin = "/vnmr/bin/";
    } else {
      UNFile file = new UNFile(strSbin);
      if (!file.exists()) strSbin = FileUtil.sysdir() + "/bin/";
    }

    return strSbin;
  }

  public static String getSudo() {
    // Default to /usr/bin
    String strSudo = "/usr/bin/sudo ";

    if (Util.iswindows()) strSudo = "";

    UNFile file = new UNFile("/usr/bin/sudo");
    if (!file.exists()) {
      // If no /usr/bin/sudo, then try /usr/local/bin
      file = new UNFile("/usr/local/bin/sudo");
      if (file.exists()) strSudo = "/usr/local/bin/sudo ";
    }
    // Messages.postDebug("SUDO path=" + strSudo);
    return strSudo;
  }

  private WGlobal() {
    // not meant to be used.
  }
}