Beispiel #1
0
/**
 * 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.
  }
}
Beispiel #2
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());
  }