public void valueChanged(ListSelectionEvent e) {

    boolean isAdjusting = e.getValueIsAdjusting();
    if (isAdjusting) return;

    searchButton.setEnabled(
        ((networkSelectionModel.isSelectionEmpty()) && (localSelectionModel.isSelectionEmpty()))
            ? false
            : true);

    ListSelectionModel lsm = (ListSelectionModel) e.getSource();
    if (lsm == localSelectionModel) {
      networkSelectionModel.removeListSelectionListener(this);
      networkList.clearSelection();
      networkSelectionModel.addListSelectionListener(this);
      String localSelection = (String) localList.getSelectedValue();
      if (localSelection != null) {
        if ("local archive".equalsIgnoreCase(localSelection)) {
          rightPanelLayout.show(rPanel, SEARCH_RESULT_PANEL);
        } else if ("local directory".equalsIgnoreCase(localSelection)) {
          rightPanelLayout.show(rPanel, DIRECTORY_PANEL);
        }
        networkSelectionModel.clearSelection();
        resetSearchLabels();
      }
    } else if (lsm == networkSelectionModel) {
      rightPanelLayout.show(rPanel, SEARCH_RESULT_PANEL);
      localSelectionModel.removeListSelectionListener(this);
      localList.clearSelection();
      localSelectionModel.addListSelectionListener(this);
      updateSearchLabels((ImageServerNodeDescription) networkList.getSelectedValue());

    } else {
      if (lsm.isSelectionEmpty()) {
        if (e.getSource() == treeTable.getSelectionModel()) openArchiveButton.setEnabled(false);
        else openDirButton.setEnabled(false);
      } else {
        if (e.getSource() == treeTable.getSelectionModel()) openArchiveButton.setEnabled(true);
        else openDirButton.setEnabled(true);
      }
    }
  }
예제 #2
0
 /**
  * Returns the code for the selected object, or {@code null} if none.
  *
  * @return
  */
 public String getSelectedCode() {
   final Code code = (Code) liste.getSelectedValue();
   return (code != null) ? code.code : null;
 }
  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();
    }
  }