public AncestralStatesPanel(BeautiFrame parent) {

    super();

    this.frame = parent;

    partitionTableModel = new PartitionTableModel();
    partitionTable = new JTable(partitionTableModel);

    partitionTable.getTableHeader().setReorderingAllowed(false);
    partitionTable.getTableHeader().setResizingAllowed(false);
    //        modelTable.getTableHeader().setDefaultRenderer(
    //                new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    final TableColumnModel model = partitionTable.getColumnModel();
    final TableColumn tableColumn0 = model.getColumn(0);

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(partitionTable);

    partitionTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    partitionTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    JScrollPane scrollPane =
        new JScrollPane(
            partitionTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setOpaque(false);

    JPanel panel = new JPanel(new BorderLayout(0, 0));
    panel.setOpaque(false);
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setMinimumSize(new Dimension(MINIMUM_TABLE_WIDTH, 0));

    optionsPanelParent = new JPanel(new FlowLayout(FlowLayout.CENTER));
    optionsPanelParent.setOpaque(false);
    optionsBorder = new TitledBorder("Ancestral state options:");
    optionsPanelParent.setBorder(optionsBorder);

    setCurrentPartition(null);

    JScrollPane scrollPane2 =
        new JScrollPane(
            optionsPanelParent,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane2.setOpaque(false);
    scrollPane2.setBorder(null);
    scrollPane2.getViewport().setOpaque(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, scrollPane2);
    splitPane.setDividerLocation(MINIMUM_TABLE_WIDTH);
    splitPane.setContinuousLayout(true);
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    splitPane.setOpaque(false);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    add(splitPane, BorderLayout.CENTER);
  }
Пример #2
0
  public InputPanel(
      final TreeSpaceFrame parent, final TreeSpaceDocument document, final Action addDataAction) {

    this.frame = parent;
    this.document = document;

    dataTableModel = new DataTableModel();
    dataTable = new JTable(dataTableModel);

    dataTable.getTableHeader().setReorderingAllowed(false);
    //        dataTable.getTableHeader().setDefaultRenderer(
    //                new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    TableColumn col = dataTable.getColumnModel().getColumn(0);
    col.setCellRenderer(new MultiLineTableCellRenderer());

    dataTable.setRowHeight(dataTable.getRowHeight() * 2);

    dataTable.setDragEnabled(false);
    dataTable.setTransferHandler(new FSTransfer());

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(dataTable);

    dataTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    dataTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              editSelection();
            }
          }
        });

    scrollPane =
        new JScrollPane(
            dataTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setOpaque(false);

    //        JToolBar toolBar1 = new JToolBar();
    //        toolBar1.setFloatable(false);
    //        toolBar1.setOpaque(false);
    //        toolBar1.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));

    //        JButton button = new JButton(unlinkModelsAction);
    //        unlinkModelsAction.setEnabled(false);
    //        PanelUtils.setupComponent(button);
    //        toolBar1.add(button);

    ActionPanel actionPanel1 = new ActionPanel(true);
    actionPanel1.setAddAction(addDataAction);
    actionPanel1.setRemoveAction(removeAction);

    removeAction.setEnabled(false);

    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.setOpaque(false);
    controlPanel1.add(actionPanel1);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    //        add(toolBar1, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(controlPanel1, BorderLayout.SOUTH);

    document.addListener(
        new TreeSpaceDocument.Listener() {
          public void dataChanged() {
            dataTableModel.fireTableDataChanged();
          }

          public void settingsChanged() {}
        });
  }
Пример #3
0
  public DataPanel(
      BeautiFrame parent,
      Action importDataAction,
      Action removeDataAction /*, Action importTraitsAction*/) {

    this.frame = parent;

    dataTableModel = new DataTableModel();
    dataTable = new JTable(dataTableModel);

    dataTable.getTableHeader().setReorderingAllowed(false);
    dataTable
        .getTableHeader()
        .setDefaultRenderer(new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    TableColumn col = dataTable.getColumnModel().getColumn(5);
    ComboBoxRenderer comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    //        col = dataTable.getColumnModel().getColumn(5);
    //        comboBoxRenderer = new ComboBoxRenderer();
    //        comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    //        col.setCellRenderer(comboBoxRenderer);

    col = dataTable.getColumnModel().getColumn(6);
    comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    col = dataTable.getColumnModel().getColumn(7);
    comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(dataTable);

    dataTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    dataTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              showAlignment();
            }
          }
        });

    scrollPane =
        new JScrollPane(
            dataTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setOpaque(false);

    JToolBar toolBar1 = new JToolBar();
    toolBar1.setFloatable(false);
    toolBar1.setOpaque(false);
    toolBar1.setLayout(new BoxLayout(toolBar1, BoxLayout.X_AXIS));

    JButton button = new JButton(unlinkModelsAction);
    unlinkModelsAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkModelsAction);
    linkModelsAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    toolBar1.addSeparator();

    button = new JButton(unlinkClocksAction);
    unlinkClocksAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkClocksAction);
    linkClocksAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    toolBar1.addSeparator();

    button = new JButton(unlinkTreesAction);
    unlinkTreesAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkTreesAction);
    linkTreesAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    // too crowded on the toolbar  - just double click to show
    //            button = new JButton(showAction);
    //            showAction.setEnabled(false);
    //            PanelUtils.setupComponent(button);
    //            toolBar1.add(button);

    ActionPanel actionPanel1 = new ActionPanel(false);
    actionPanel1.setAddAction(importDataAction);
    actionPanel1.setRemoveAction(removeDataAction);
    removeDataAction.setEnabled(false);

    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.setOpaque(false);
    controlPanel1.add(actionPanel1);

    controlPanel1.add(new JLabel("   "));
    PanelUtils.setupComponent(createImportTraitButton);
    controlPanel1.add(createImportTraitButton);

    //        controlPanel1.add(new JLabel(" or "));
    //
    //        button = new JButton(importTraitsAction);
    //        PanelUtils.setupComponent(button);
    //        controlPanel1.add(button);

    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.setOpaque(false);
    panel1.add(useStarBEASTCheck, BorderLayout.NORTH);
    panel1.add(toolBar1, BorderLayout.SOUTH);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    add(panel1, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(controlPanel1, BorderLayout.SOUTH);

    useStarBEASTCheck.setEnabled(false);
    useStarBEASTCheck.setToolTipText(STARBEASTOptions.CITATION);
    useStarBEASTCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(
              ActionEvent e) { // wrong listener Issue 397: *BEAST in BEAUti is broken
            frame.setupStarBEAST(useStarBEASTCheck.isSelected());
            dataTableModel.fireTableDataChanged();
          }
        });
  }