Ejemplo n.º 1
0
  /**
   * This method checks if the current server is valid. If it is valid then it checks if there is
   * authentication required
   *
   * @return true if the server exists and can be accessed
   */
  protected boolean canAccessServer() {
    // Try reading the public.serv file to see if we need a username/proj
    JTextField projFld = null;
    JTextField userFld = null;
    JComponent contents = null;
    JLabel label = null;
    boolean firstTime = true;
    while (true) {
      int status = checkIfServerIsOk();
      if (status == STATUS_OK) {
        break;
      }
      if (status == STATUS_ERROR) {
        setState(STATE_UNCONNECTED);
        return false;
      }
      if (projFld == null) {
        projFld = new JTextField("", 10);
        userFld = new JTextField("", 10);
        GuiUtils.tmpInsets = GuiUtils.INSETS_5;
        contents =
            GuiUtils.doLayout(
                new Component[] {
                  GuiUtils.rLabel("User ID:"), userFld, GuiUtils.rLabel("Project #:"), projFld,
                },
                2,
                GuiUtils.WT_N,
                GuiUtils.WT_N);
        label = new JLabel(" ");
        contents = GuiUtils.topCenter(label, contents);
        contents = GuiUtils.inset(contents, 5);
      }
      String lbl =
          (firstTime
              ? "The server: " + getServer() + " requires a user ID & project number for access"
              : "Authentication for server: " + getServer() + " failed. Please try again");
      label.setText(lbl);

      if (!GuiUtils.showOkCancelDialog(null, "ADDE Project/User name", contents, null)) {
        setState(STATE_UNCONNECTED);
        return false;
      }
      firstTime = false;
      String userName = userFld.getText().trim();
      String project = projFld.getText().trim();
      if ((userName.length() > 0) && (project.length() > 0)) {
        passwords.put(getServer(), new String[] {userName, project});
      }
    }
    return true;
  }
Ejemplo n.º 2
0
    /**
     * Set the projection from the dialog properties
     *
     * @param projClass projection class
     * @param proj projection
     */
    private void setProjFromDialog(ProjectionClass projClass, ProjectionImpl proj) {
      proj.setName(nameTF.getText().trim());

      for (int i = 0; i < projClass.paramList.size(); i++) {
        ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i);
        // fetch the value from the projection object
        try {
          String valstr = pp.getTextField().getText();
          Double valdub = new Double(valstr);
          Object[] args = {valdub};
          if (debugBeans) {
            System.out.println("Projection setProjFromDialog invoke writer on " + pp);
          }
          pp.writer.invoke(proj, args);
        } catch (Exception ee) {
          System.err.println(
              "ProjectionManager: setProjParams failed "
                  + " invoking write "
                  + pp.name
                  + " class "
                  + projClass);
          continue;
        }
      }
    }