Exemple #1
0
  /** 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);
    }
  }
Exemple #2
0
  protected String getSampleName(String strDir, String strTray) {
    String strSampleName = "";
    String strSample;
    int nTray = 0;
    try {
      nTray = Integer.parseInt(strTray);
    } catch (Exception e) {
    }

    if (nTray <= 0) return strSampleName;

    String cmd =
        "SELECT loc_,studystatus from study WHERE (autodir=\'"
            + strDir
            + "\') AND (hostname=\'"
            + getHost()
            + "\')";
    // NB: bArrSample[0] is not used; array implicitly initialized false
    boolean[] bArrSample = new boolean[nTray + 1];
    m_dbResult = null;

    try {
      m_dbResult = getdbmanager().executeQuery(cmd);
    } catch (Exception e) {
      return strSampleName;
    }
    if (m_dbResult == null) return strSampleName;

    try {
      while (m_dbResult.next()) {
        strSample = m_dbResult.getString(1);
        int nSample = 0;
        nSample = Integer.parseInt(strSample);
        try {
          bArrSample[nSample] = true;
        } catch (IndexOutOfBoundsException ioobe) {
          Messages.postDebug("getSampleName: index out of bounds: " + nSample);
        }
      }
      for (int i = 1; i < bArrSample.length; i++) {
        if (!bArrSample[i]) {
          strSampleName = String.valueOf(i);
          break;
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
    }
    return strSampleName;
  }
Exemple #3
0
  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();
  }
Exemple #4
0
 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);
 }
Exemple #5
0
  protected void setTrayPresent(String strPath) {
    String strzone = "zones";
    BufferedReader reader = WFileUtil.openReadFile(strPath);
    if (reader == null) return;

    String strLine;
    try {
      // if the zones are set to 0, then there is no tray present
      // set rackInfo(1,zones) 3 => tray 1 present
      // set rackInfo(2,zones) 0 => tray 2 not present
      while ((strLine = reader.readLine()) != null) {
        int index = strLine.indexOf(strzone);
        if (index < 0) continue;

        String strTray = strLine.substring(index - 2, index - 1);
        int nTray = 0;
        try {
          nTray = Integer.parseInt(strTray);
        } catch (Exception e) {
        }

        if (nTray <= 0) continue;

        int nZone = 0;
        try {
          strTray = strLine.substring(index + strzone.length() + 2, strLine.length());
          nZone = Integer.parseInt(strTray);
        } catch (Exception e) {
        }

        Color colorbg = Color.white;
        String strTooltip = TRAY;
        if (nZone <= 0) {
          colorbg = Color.black;
          strTooltip = NOTRAY;
        }
        VBox pnlVast = m_pnlVast[nTray - 1];
        pnlVast.setbackground(colorbg);
        pnlVast.setToolTipText(Util.getTooltipString(strTooltip));
      }
      reader.close();
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
    }
  }
Exemple #6
0
  protected void setTrayActive(String strDir) {
    String strTray;
    String strStudy;
    String strActive = "Active";
    String cmd =
        "SELECT vrack_,studystatus from study WHERE (autodir=\'"
            + strDir
            + "\') AND (hostname=\'"
            + getHost()
            + "\')";
    m_dbResult = null;

    try {
      m_dbResult = getdbmanager().executeQuery(cmd);
    } catch (Exception e) {
      return;
    }
    if (m_dbResult == null) return;

    int nTray = 0;
    try {
      while (m_dbResult.next()) {
        strTray = m_dbResult.getString(1);
        strStudy = m_dbResult.getString(2);
        if (strStudy != null && strStudy.equalsIgnoreCase(strActive)) {
          try {
            nTray = Integer.parseInt(strTray);
          } catch (Exception e) {
          }

          if (nTray > 0) {
            m_pnlVast[nTray - 1].setbackground(Color.blue);
            m_pnlVast[nTray - 1].setToolTipText(Util.getTooltipString(TRAYACTIVE));
            break;
          }
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
    }
  }
Exemple #7
0
  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;
  }
Exemple #8
0
  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);
    }
  }
Exemple #9
0
  /**
   * 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();
  }
Exemple #10
0
  protected void enterLogin() {
    char[] password = m_passwordField.getPassword();
    String strUser = (String) m_cmbUser.getSelectedItem();
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    boolean blogin = WUserUtil.isOperatorNameok(strUser, false);
    if (blogin) {
      blogin = vnmrjPassword(strUser, password);
      if (!blogin) blogin = unixPassword(strUser, password);
    }
    if (blogin) {
      m_lblLogin.setForeground(Color.black);
      m_lblLogin.setText("Login Successful");
      m_lblLogin.setVisible(true);
      // Get the Email column string for access to the operator data
      String emStr = vnmr.util.Util.getLabel("_admin_Email");
      String stremail = WUserUtil.getOperatordata(strUser, emStr);

      // Get the Panel Level column string for access to the operator data
      String plStr = vnmr.util.Util.getLabel("_admin_Panel_Level");
      String strPanel = WUserUtil.getOperatordata(strUser, plStr);

      if (stremail == null || stremail.equals("null")) stremail = "";
      try {
        Integer.parseInt(strPanel);
      } catch (Exception e) {
        strPanel = WGlobal.PANELLEVEL;
      }
      m_trayTimer.stop();
      Messages.postDebug(" Login: "******"appdir('reset','")
                .append(strUser)
                .append("','")
                .append(stremail)
                .append("',")
                .append(strPanel)
                .append(")")
                .toString());
        exp.sendToVnmr("vnmrjcmd('util', 'bgReady')\n");
      }
      setVisible(false);

      // Save the current position and size of this panel in case it
      // was changed
      Dimension size = getSize();
      width = size.width;
      height = size.height;
      position = getLocation();
      writePersistence();

      // Call the macro to update this operator's
      // ExperimentSelector_operatorName.xml file
      // from the protocols themselves.  This macro will
      // cause an update of the ES when it is finished

      // Util.getAppIF().sendToVnmr("updateExpSelector");

      // I am not sure why we need to force updates since updateExpSelector
      // should have caused an update by writing to ES_op.xml file.
      // However, it works better if we do the force update.
      // ExpSelector.setForceUpdate(true);
    } else {
      m_lblLogin.setForeground(DisplayOptions.getColor("Error"));
      // m_lblLogin.setText("<HTML>Incorrect username/password <p> Please try again </HTML>");
      m_lblLogin.setVisible(true);
    }
    setCursor(Cursor.getDefaultCursor());
  }