Exemplo n.º 1
0
 public AdminDialog() {
   super(MedSavantFrame.getInstance(), "Database Management", true);
   this.add(getAdminPanel());
   this.setResizable(false);
   this.pack();
   this.setLocationRelativeTo(MedSavantFrame.getInstance());
 }
 /**
  * Creates an IndividualSelector patient chooser with the option of selecting either a single
  * patient or multiple patients.
  *
  * @param onlyOnePatient True if only selecting an individual, false otherwise.
  */
 public IndividualSelector(boolean onlyOnePatient) {
   super(MedSavantFrame.getInstance(), true);
   this.onlyOnePatient = onlyOnePatient;
   setTitle(onlyOnePatient ? "Select Individual" : "Select Individual(s)");
   this.setPreferredSize(new Dimension(700, 600));
   this.setMinimumSize(new Dimension(700, 600));
   selectedHospitalIDs = new HashSet<String>();
   selectedRows = new HashSet<Integer>();
   initUI();
   refresh();
 }
Exemplo n.º 3
0
  private boolean validateAdminParams() {

    if (addressAdminField.getText().isEmpty()) {
      MedSavantFrame.getInstance().notificationMessage("Server address required");
      addressAdminField.requestFocus();
      return false;
    }

    if (portAdminField.getText().isEmpty()) {
      MedSavantFrame.getInstance().notificationMessage("Server port required");
      portAdminField.requestFocus();
      return false;
    }

    try {
      Integer.parseInt(portAdminField.getText());
    } catch (Exception e) {
      MedSavantFrame.getInstance().notificationMessage("Invalid port number");
      portAdminField.requestFocus();
      return false;
    }

    if (dbnameAdminField.getText().isEmpty()) {
      MedSavantFrame.getInstance().notificationMessage("Database name required");
      dbnameAdminField.requestFocus();
      return false;
    }

    if (userAdminField.getText().isEmpty()) {
      MedSavantFrame.getInstance().notificationMessage("Username required");
      userAdminField.requestFocus();
      return false;
    }

    if (passwordAdminField.getText().isEmpty()) {
      MedSavantFrame.getInstance().notificationMessage("Password required");
      passwordAdminField.requestFocus();
      return false;
    }

    return true;
  }
  private void initUI() {

    JPanel p = new JPanel();
    ViewUtil.applyVerticalBoxLayout(p);
    this.add(p);

    topPanel = ViewUtil.getClearPanel();
    middlePanel = ViewUtil.getClearPanel();
    bottomPanel = ViewUtil.getClearPanel();

    p.add(topPanel);
    p.add(middlePanel);
    p.add(bottomPanel);

    // Only display the bottom panel for multiple patient selection
    if (onlyOnePatient) {
      bottomPanel.setVisible(false);
    }

    // middle
    middlePanel.setLayout(new BorderLayout());

    individualsRetriever = new IndividualsReceiver();
    individualsSTP =
        new SearchableTablePanel(
            "Individuals",
            COLUMN_NAMES,
            COLUMN_CLASSES,
            HIDDEN_COLUMNS,
            true,
            true,
            Integer.MAX_VALUE,
            false,
            SearchableTablePanel.TableSelectionType.ROW,
            Integer.MAX_VALUE,
            individualsRetriever);
    individualsSTP.setExportButtonVisible(false);

    // If patients or cohorts are edited, update the searchabletable.
    CacheController.getInstance()
        .addListener(
            new Listener<ModificationType>() {
              @Override
              public void handleEvent(ModificationType event) {
                if (event == ModificationType.PATIENT || event == ModificationType.COHORT) {
                  if (!individualsSTP.isUpdating()) {
                    forceRefresh = true;
                    individualsSTP.forceRefreshData();
                  }
                }
              }
            });

    middlePanel.add(individualsSTP, BorderLayout.CENTER);

    // bottom
    ViewUtil.applyVerticalBoxLayout(bottomPanel);

    numselections = ViewUtil.getTitleLabel("0 individual(s) selected");

    JPanel text = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(text);

    JButton clearIndividuals =
        ViewUtil.getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE));
    clearIndividuals.setToolTipText("Clear selections");
    clearIndividuals.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            clearSelections();
          }
        });

    text.add(numselections);
    text.add(Box.createHorizontalStrut(5));
    text.add(clearIndividuals);
    bottomPanel.add(ViewUtil.centerHorizontally(text));

    final JButton addAllIndividuals = ViewUtil.getSoftButton("Add All");
    bottomPanel.add(addAllIndividuals);

    final JButton addIndividuals = ViewUtil.getSoftButton("Add Selected");
    bottomPanel.add(addIndividuals);

    final JButton removeIndividuals = ViewUtil.getSoftButton("Remove Selected");
    bottomPanel.add(removeIndividuals);

    final JButton removeAllIndividuals = ViewUtil.getSoftButton("Remove All");
    bottomPanel.add(removeAllIndividuals);

    JPanel buttons = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(buttons);

    buttons.add(addAllIndividuals);
    buttons.add(addIndividuals);
    buttons.add(removeIndividuals);
    buttons.add(removeAllIndividuals);

    JPanel windowControlPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(windowControlPanel);
    windowControlPanel.add(Box.createHorizontalGlue());

    JButton cancel = new JButton("Cancel");
    bottomPanel.add(ViewUtil.centerHorizontally(buttons));

    ok = new JButton("OK");
    bottomPanel.add(ViewUtil.alignRight(ok));
    ok.setEnabled(false);

    windowControlPanel.add(cancel);
    windowControlPanel.add(ok);

    bottomPanel.add(windowControlPanel);

    final JDialog instance = this;

    ok.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(true);
          }
        });

    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(false || hasMadeSelections);
          }
        });

    addIndividuals.setEnabled(false);
    removeIndividuals.setEnabled(false);

    individualsSTP
        .getTable()
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent lse) {
                if (!lse.getValueIsAdjusting()) {

                  int rows[] = individualsSTP.getTable().getSelectedRows();

                  boolean someSelection = rows.length > 0;

                  addIndividuals.setEnabled(someSelection);
                  removeIndividuals.setEnabled(someSelection);

                  if (someSelection) {
                    addIndividuals.setText("Add Selected (" + rows.length + ")");
                    removeIndividuals.setText("Remove Selected (" + rows.length + ")");
                  } else {
                    addIndividuals.setText("Add Selected");
                    removeIndividuals.setText("Remove Selected");
                  }

                  /* Close the dialog if only a single individual is requested. */
                  if (onlyOnePatient && rows.length == 1) {
                    selectedRows.clear();
                    selectedHospitalIDs.clear();

                    int realRow = individualsSTP.getActualRowAt(rows[0]);
                    selectedRows.add(realRow);
                    Object[] o = individualsRetriever.getIndividuals().get(realRow);
                    selectedHospitalIDs.add(o[INDEX_OF_HOSPITAL_ID].toString());

                    instance.setVisible(false);
                    setIndividualsChosen(true);

                    individualsSTP
                        .getTable()
                        .clearSelection(); // if errors crop up, this line may be causing
                    // ListSelectionEvents - can be removed
                  }
                }
              }
            });

    individualsSTP
        .getTable()
        .getModel()
        .addTableModelListener(
            new TableModelListener() {
              @Override
              public void tableChanged(TableModelEvent tme) {
                // addAllIndividuals.setText("Add All (" + stp.getTable().getModel().getRowCount() +
                // ")");
                // removeAllIndividuals.setText("Remove All (" +
                // stp.getTable().getModel().getRowCount() + ")");
              }
            });

    ActionListener addAction =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            addSelections(false);
          }
        };

    ActionListener addAllAction =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            addSelections(true);
          }
        };

    ActionListener removeAction =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            removeSelections(false);
          }
        };

    ActionListener removeAllAction =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            removeSelections(true);
          }
        };

    addIndividuals.addActionListener(addAction);
    addAllIndividuals.addActionListener(addAllAction);
    removeIndividuals.addActionListener(removeAction);
    removeAllIndividuals.addActionListener(removeAllAction);

    this.pack();
    this.setLocationRelativeTo(MedSavantFrame.getInstance());
  }
 @Override
 public void jobDone() {
   super.jobDone();
   MedSavantFrame.getInstance()
       .showNotficationMessage("GeneMANIA has finished downloading, and is ready to use.");
 }