public void selectionChanged() { int[] selRows = dataTable.getSelectedRows(); boolean hasSelection = (selRows != null && selRows.length != 0); frame.dataSelectionChanged(hasSelection); boolean canUnlink = options.dataPartitions.size() > 1 && hasSelection; boolean canLink = options.dataPartitions.size() > 1 && hasSelection && selRows.length > 1; unlinkModelsAction.setEnabled(canUnlink); linkModelsAction.setEnabled(canLink); unlinkClocksAction.setEnabled(canUnlink); linkClocksAction.setEnabled(canLink); unlinkTreesAction.setEnabled(canUnlink); linkTreesAction.setEnabled(canLink); viewPartitionAction.setEnabled(options.dataPartitions.size() > 1 && hasSelection); }
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); button = new JButton(viewPartitionAction); controlPanel1.add(new JLabel(" ")); viewPartitionAction.setEnabled(false); PanelUtils.setupComponent(button); controlPanel1.add(button); button = new JButton(createTraitPartitionAction); controlPanel1.add(new JLabel(" ")); PanelUtils.setupComponent(button); controlPanel1.add(button); // 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 if (frame.setupStarBEAST(useStarBEASTCheck.isSelected()) == false) { useStarBEASTCheck.setSelected(false); // go back to unchecked } dataTableModel.fireTableDataChanged(); } }); }