public boolean createFromTraits(List<TraitData> traits) { int selRow = -1; if (selectTraitDialog == null) { selectTraitDialog = new SelectTraitDialog(frame); } if (traits == null || traits.size() == 0) { int result = selectTraitDialog.showDialog(options.traits, null); if (result != JOptionPane.CANCEL_OPTION) { TraitData trait = selectTraitDialog.getTrait(); String name = trait.getName(); if (selectTraitDialog.getMakeCopy()) { name = selectTraitDialog.getName(); } selRow = options.createPartitionForTraits(name, trait); } else { return false; } } else { if (traits.size() > 1) { // a set of traits have been passed to the function int result = selectTraitDialog.showDialog(null, null); if (result != JOptionPane.CANCEL_OPTION) { String name = selectTraitDialog.getName(); selRow = options.createPartitionForTraits(name, traits); } else { return false; } } else { selRow = options.createPartitionForTraits(traits.get(0).getName(), traits); } } modelsChanged(); dataTableModel.fireTableDataChanged(); if (selRow != -1) { dataTable.getSelectionModel().setSelectionInterval(selRow, selRow); } fireDataChanged(); repaint(); return true; }
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(); } }); }