private void updateSearchLabels(ImageServerNodeDescription isnd) {

    if (isnd == null) return;
    List<String> requiredParams = isnd.getRequiredQueryParams();
    patientNameLabel.setForeground(
        requiredParams.contains(QueryParameters.PATIENT_NAME.toString()) ? Color.red : Color.white);
    patientIDLabel.setForeground(
        requiredParams.contains(QueryParameters.PATIENT_MRN.toString()) ? Color.red : Color.white);
    modalityLabel.setForeground(
        requiredParams.contains(QueryParameters.MODALITY.toString()) ? Color.red : Color.white);
    anatomyLabel.setForeground(
        requiredParams.contains(QueryParameters.BODY_PART.toString()) ? Color.red : Color.white);
    startDateLabel.setForeground(
        requiredParams.contains(QueryParameters.STUDY_BEGIN_DATE.toString())
            ? Color.red
            : Color.white);
    endDateLabel.setForeground(
        requiredParams.contains(QueryParameters.STUDY_END_DATE.toString())
            ? Color.red
            : Color.white);
  }
  public void actionPerformed(ActionEvent e) {

    // Spawn thread to handle the results and loading...

    if (e.getSource() == openAsComboBox) {
      String selection = (String) openAsComboBox.getSelectedItem();
      if ("Raw images".equals(selection)) {
        imageWidthTextField.setEnabled(true);
        imageHeightTextField.setEnabled(true);
        bitsAllocatedTextField.setEnabled(true);
        bitsStoredTextField.setEnabled(true);
        fileOffsetTextField.setEnabled(true);
        numImagesTextField.setEnabled(true);
        imageWidthLabel.setEnabled(true);
        imageHeightLabel.setEnabled(true);
        bitsAllocatedLabel.setEnabled(true);
        bitsStoredLabel.setEnabled(true);
        fileOffsetLabel.setEnabled(true);
        numImagesLabel.setEnabled(true);
      } else {
        imageWidthTextField.setEnabled(false);
        imageHeightTextField.setEnabled(false);
        bitsAllocatedTextField.setEnabled(false);
        bitsStoredTextField.setEnabled(false);
        fileOffsetTextField.setEnabled(false);
        numImagesTextField.setEnabled(false);
        imageWidthLabel.setEnabled(false);
        imageHeightLabel.setEnabled(false);
        bitsAllocatedLabel.setEnabled(false);
        bitsStoredLabel.setEnabled(false);
        fileOffsetLabel.setEnabled(false);
        numImagesLabel.setEnabled(false);
      }
    } else if ("open".equals(e.getActionCommand())) {
      if (e.getSource() == openArchiveButton) {
        TreeSelectionModel tsm = treeTable.getTreeSelectionModel();
        TreePath[] selectPaths = tsm.getSelectionPaths();
        StudyListTreeTableModel slttm = (StudyListTreeTableModel) treeTable.getTreeTableModel();

        // If it's a local archive, we don't need to do a move;
        // otherwise we execute a move thread and once that's
        // complete, invoke the openDialogArchive thread.

        if (!localSelectionModel.isSelectionEmpty()) {
          OpenDialogArchiveThread odat =
              new OpenDialogArchiveThread(
                  slttm.computeSeries(selectPaths), false); // openStudyCheckBox.isSelected());
          odat.start();
        } else {
          ImageServerNodeDescription isnd =
              (ImageServerNodeDescription) networkList.getSelectedValue();
          OpenDialogArchiveMoveThread odamt =
              ((isnd.getSupportedMoveScope() == Scope.SERIES)
                      || (isnd.getSupportedMoveScope() == Scope.INSTANCE))
                  ? new OpenDialogArchiveMoveThread(
                      isnd,
                      slttm.computeSeries(selectPaths),
                      false,
                      transferOnlyCheckBox.isSelected())
                  : // openStudyCheckBox.isSelected());
                  new OpenDialogArchiveMoveThread(
                      isnd,
                      slttm.computeStudies(selectPaths),
                      false,
                      transferOnlyCheckBox.isSelected()); // openStudyCheckBox.isSelected());
          odamt.start();
        }
      } else {
        TreeSelectionModel tsm = dirTreeTable.getTreeSelectionModel();
        TreePath[] selectPaths = tsm.getSelectionPaths();
        File[] selectedFiles = new File[selectPaths.length];
        for (int loop = 0; loop < selectPaths.length; loop++)
          selectedFiles[loop] = ((FileNode) (selectPaths[loop].getLastPathComponent())).getFile();

        // Ultimately need to make this part dependent or specific to
        // a given image reader...

        ArrayList<Integer> paramList = new ArrayList<Integer>();
        if (imageWidthTextField.isEnabled())
          paramList.add(Integer.parseInt(imageWidthTextField.getText()));
        if (imageHeightTextField.isEnabled())
          paramList.add(Integer.parseInt(imageHeightTextField.getText()));
        if (bitsAllocatedTextField.isEnabled())
          paramList.add(Integer.parseInt(bitsAllocatedTextField.getText()));
        if (bitsStoredTextField.isEnabled())
          paramList.add(Integer.parseInt(bitsStoredTextField.getText()));
        if (fileOffsetTextField.isEnabled())
          paramList.add(Integer.parseInt(fileOffsetTextField.getText()));
        if (numImagesTextField.isEnabled())
          paramList.add(Integer.parseInt(numImagesTextField.getText()));
        OpenDialogFileThread odft =
            new OpenDialogFileThread(
                selectedFiles,
                (String) openAsComboBox.getSelectedItem(),
                recurseCheckBox.isSelected(),
                false,
                paramList); // openStudyCheckBox.isSelected());
        odft.start();
      }

      if (closeOnOpenCheckBox.isSelected()) doClose();

    } else if ("search".equals(e.getActionCommand())) {

      if ((networkList.isSelectionEmpty()) && (localList.isSelectionEmpty())) return;

      try {

        String patientID = patientIDField.getText();
        String modality = modalityField.getText();
        Date startDate = startDatePicker.getDate();
        Date endDate = endDatePicker.getDate();
        ImageServerFindDescription isfd = new ImageServerFindDescription(patientID);

        if (startDate != null) isfd.setStartDate(startDate);
        if (endDate != null) isfd.setEndDate(endDate);
        isfd.setModality(modality);
        isfd.setResultScope(Scope.SERIES);
        String s = (String) localList.getSelectedValue();
        boolean isLocal = ((s != null) && ("local archive".equalsIgnoreCase(s)));
        if (!isLocal) {
          isfd.setNodeDescription((ImageServerNodeDescription) networkList.getSelectedValue());
          Boolean b =
              (Boolean)
                  ApplicationContext.getContext()
                      .getProperty(ApplicationContext.USE_XML_COMPRESSION);
          if ((b != null) && (b.booleanValue())) isfd.setCompression(Compression.GZIP);
        }
        treeTable.setEnabled(false);
        treeTable.setVisible(
            false); // Hack because the cleared treetable doesn't update the display correctly and
                    // has leftovers
        studyList.clear();
        searchButton.setEnabled(false);
        clearFieldButton.setEnabled(false);
        OpenDialogFindThread odft =
            new OpenDialogFindThread(
                isfd, treeTable, searchButton, clearFieldButton, resultsLabel, isLocal);
        odft.start();

      } catch (Exception exc) {
        exc.printStackTrace();
      }

    } else if ("refreshNetwork".equals(e.getActionCommand())) {
      boolean networkStatus = ImageViewerClientNode.getInstance().connect();
      if (networkStatus) {
        List<ImageServerNodeDescription> nodes =
            ImageViewerClientNode.getInstance().getQueryableNodes();
        if (nodes != null) networkList.setListData(nodes.toArray());
      }
    } else if ("clear".equals(e.getActionCommand())) {
      clearFields();
    } else if ("close".equals(e.getActionCommand())) {
      doClose();
    }
  }