private JPanel createLeftPanel() {

    ImageViewerClientNode ivcn = ImageViewerClientNode.getInstance();
    String[] localListArray =
        (ivcn.hasLocalArchive())
            ? (new String[] {"Local archive", "Local directory"})
            : (new String[] {"Local directory"});
    localList = new JXList(localListArray);
    localList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    localSelectionModel = localList.getSelectionModel();
    localSelectionModel.addListSelectionListener(this);
    JScrollPane localListScrollPane =
        new JScrollPane(
            localList,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    localListScrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    localListScrollPane.setPreferredSize(new Dimension(194, 300));
    localList.setSelectionForeground(Color.white);
    localList.setSelectionBackground(Color.darkGray);
    localList.setBackground(ROW_COLOR1); // Color.darkGray);
    localList.setForeground(Color.white);

    List<ImageServerNodeDescription> nodes =
        ImageViewerClientNode.getInstance().getQueryableNodes();
    networkList = (nodes != null) ? (new JXList(nodes.toArray())) : (new JXList());
    networkList.setCellRenderer(new NodeDescriptionRenderer());
    networkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    networkSelectionModel = networkList.getSelectionModel();
    networkSelectionModel.addListSelectionListener(this);
    JScrollPane networkListScrollPane =
        new JScrollPane(
            networkList,
            JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    networkListScrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    networkListScrollPane.setPreferredSize(new Dimension(194, 300));
    networkList.setSelectionForeground(Color.white);
    networkList.setSelectionBackground(Color.darkGray);
    networkList.setBackground(ROW_COLOR1); // Color.darkGray);
    networkList.setForeground(Color.white);

    JPanel listPanel = new JPanel(new BorderLayout(0, 5));
    JOutlookBar job = new JOutlookBar();
    job.addTab(
        "Local resources",
        new ImageIcon("resources/icons/swing/computer.png"),
        localListScrollPane);
    job.addTab(
        "Network resources",
        new ImageIcon("resources/icons/swing/network.png"),
        networkListScrollPane);
    job.setUI((TabbedPaneUI) (new ImageViewerOutlookBarUI()));

    listPanel.add(job, BorderLayout.CENTER);
    listPanel.add(refreshButton, BorderLayout.SOUTH);
    listPanel.setBorder(new EmptyBorder(0, 0, 0, 5));
    return listPanel;
  }
  private void createArchiveTreeTable() {

    List l = ivcn.localFindAll();
    treeTable = new JXTreeTable(studyList);
    treeTable.setHorizontalScrollEnabled(true);
    treeTable.setRootVisible(false);
    treeTable.setShowsRootHandles(true);
    treeTable.setShowHorizontalLines(true);
    treeTable.setShowVerticalLines(true);
    treeTable.setColumnMargin(1);
    treeTable.setColumnControlVisible(false);
    treeTable.setRolloverEnabled(true);
    treeTable.setScrollsOnExpand(true);
    treeTable.setTreeCellRenderer(new TreeTableCellRenderer());
    treeTable.setAutoCreateColumnsFromModel(false);
    treeTable.setColumnFactory(
        new ColumnFactory() {
          public void configureColumnWidths(JXTable table, TableColumnExt columnExt) {}
        });
    // treeTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    ListSelectionModel lsm = treeTable.getSelectionModel();
    lsm.addListSelectionListener(this);

    CompoundHighlighter cp = new CompoundHighlighter();
    cp.addHighlighter(new AlternateRowHighlighter(ROW_COLOR1, ROW_COLOR2, Color.white));
    cp.addHighlighter(new HierarchicalColumnHighlighter(COL_COLOR1, Color.white));

    treeTable.setHighlighters(cp);
    for (int i = 0; i < ARCHIVE_COLUMN_WIDTH.length; i++) {
      TableColumn column = treeTable.getColumnModel().getColumn(i);
      column.setPreferredWidth(ARCHIVE_COLUMN_WIDTH[i]);
      column.setHeaderRenderer(new TableHeaderRenderer(Color.black));
    }
  }
  public OpenDialogPanel() {

    super(new BorderLayout());
    setPreferredSize(new Dimension(1000, 450));
    setBorder(new EmptyBorder(5, 5, 5, 5));
    ivcn = ImageViewerClientNode.getInstance();

    openArchiveButton.setActionCommand("open");
    openArchiveButton.addActionListener(this);
    closeArchiveButton.setActionCommand("close");
    closeArchiveButton.addActionListener(this);
    openDirButton.setActionCommand("open");
    openDirButton.addActionListener(this);
    closeDirButton.setActionCommand("close");
    closeDirButton.addActionListener(this);
    refreshButton.setActionCommand("refreshNetwork");
    refreshButton.addActionListener(this);

    openAsComboBox.setSelectedItem("DICOM");

    createArchiveTreeTable();
    rPanel = createRightPanel();
    lPanel = createLeftPanel();
    add(rPanel, BorderLayout.CENTER);
    add(lPanel, BorderLayout.WEST);
    setOpaque(false);
    setSize(1000, 450);
  }
  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();
    }
  }