public void setData(java.util.List<O> elements, boolean selected){ for (int i=getRowCount()-1; i>=0; i--){ removeRow(i); } for (O element : elements){ addRow(new Object[]{selected, element}); } }
public List<O> getAllValues() { return getModel().getAllValues(); }
public List<O> getFilteredValues() { List<O> axioms = new ArrayList<O>(); for (int i=0; i<getRowCount(); i++){ if (getValueAt(i, 0).equals(Boolean.TRUE)){ axioms.add((O)getValueAt(i, 1)); } } return axioms; }
public void stateChanged(ChangeEvent event) { for (int i=0; i<getModel().getRowCount(); i++){ getModel().setValueAt(checkAllCheckbox.isSelected(), i, 0); } notifyCheckSelectionChanged(); } };
public static void main(String[] args) { CheckTable<String> table = new CheckTable<>("things"); // @@TODO ensure empty table still works CheckTableModel<String> model = table.getModel(); // @@TODO ensure changes to the model directly affect the view List<String> data = new ArrayList<>(); data.add("one"); data.add("two"); data.add("three"); data.add("long long long line of text that should still fit in the box"); data.add("<html>some hmtl with <br><br>linebreaks and <p>paragraphs etc</p></html>"); model.setData(data, false); model.addColumn("more", new String[]{"a", "nother column full of stuff", "fffrrr"}); final JScrollPane scroller = new JScrollPane(table); JComponent holder = new JPanel(new BorderLayout()); holder.add(scroller, BorderLayout.CENTER); holder.add(new JCheckBox("check"), BorderLayout.NORTH); JOptionPane optionPane = new JOptionPane(holder, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dlg = createDialog(null, "test CheckTable", optionPane); dlg.setVisible(true); System.exit(0); }
public void update() { final Set<OWLAxiom> axiomsFromKit = filterModel.getUnfilteredAxioms(getModel().getSourceOntologies()); if (unfilteredAxioms == null || !unfilteredAxioms.equals(axiomsFromKit)){ unfilteredAxioms = axiomsFromKit; list.getModel().setData(new ArrayList<>(unfilteredAxioms), true); list.checkAll(true); } }
public List<O> getFilteredValues() { return getModel().getFilteredValues(); }
public CheckTable(String name) { super(new CheckTableModel<O>(name)); setShowGrid(true); setIntercellSpacing(new Dimension(0, 3)); final JTableHeader header = getTableHeader(); header.setReorderingAllowed(false); header.addMouseListener(checkAllMouseListener); checkAllCheckbox = new JCheckBox(); checkAllCheckbox.setSelected(defaultSelected); checkAllCheckbox.addChangeListener(checkAllActionListener); getInputMap().put(KeyStroke.getKeyStroke("SPACE"), "checkSelection"); getActionMap().put("checkSelection", new AbstractAction(){ public void actionPerformed(ActionEvent event) { checkSelection(); } }); getDefaultEditor(Boolean.class).addCellEditorListener(checkEditorListener); }
public static void main(String[] args) { CheckTable<String> table = new CheckTable<String>("things"); // @@TODO ensure empty table still works CheckTableModel<String> model = table.getModel(); // @@TODO ensure changes to the model directly affect the view List<String> data = new ArrayList<String>(); data.add("one"); data.add("two"); data.add("three"); data.add("long long long line of text that should still fit in the box"); data.add("<html>some hmtl with <br><br>linebreaks and <p>paragraphs etc</p></html>"); model.setData(data, false); model.addColumn("more", new String[]{"a", "nother column full of stuff", "fffrrr"}); final JScrollPane scroller = new JScrollPane(table); JComponent holder = new JPanel(new BorderLayout()); holder.add(scroller, BorderLayout.CENTER); holder.add(new JCheckBox("check"), BorderLayout.NORTH); JOptionPane optionPane = new JOptionPane(holder, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dlg = createDialog(null, "test CheckTable", optionPane); dlg.setVisible(true); System.exit(0); }
public void update() { final Set<OWLAxiom> axiomsFromKit = filterModel.getUnfilteredAxioms(getModel().getSourceOntologies()); if (unfilteredAxioms == null || !unfilteredAxioms.equals(axiomsFromKit)){ unfilteredAxioms = axiomsFromKit; list.getModel().setData(new ArrayList<OWLAxiom>(unfilteredAxioms), true); list.checkAll(true); } }
public List<O> getFilteredValues() { List<O> axioms = new ArrayList<>(); for (int i=0; i<getRowCount(); i++){ if (getValueAt(i, 0).equals(Boolean.TRUE)){ axioms.add((O)getValueAt(i, 1)); } } return axioms; }
public void stateChanged(ChangeEvent event) { for (int i=0; i<getModel().getRowCount(); i++){ getModel().setValueAt(checkAllCheckbox.isSelected(), i, 0); } notifyCheckSelectionChanged(); } };
public List<O> getFilteredValues() { return getModel().getFilteredValues(); }
public CheckTable(String name) { super(new CheckTableModel<O>(name)); setShowGrid(true); setIntercellSpacing(new Dimension(0, 3)); final JTableHeader header = getTableHeader(); header.setReorderingAllowed(false); header.addMouseListener(checkAllMouseListener); checkAllCheckbox = new JCheckBox(); checkAllCheckbox.setSelected(defaultSelected); checkAllCheckbox.addChangeListener(checkAllActionListener); getInputMap().put(KeyStroke.getKeyStroke("SPACE"), "checkSelection"); getActionMap().put("checkSelection", new AbstractAction(){ /** * */ private static final long serialVersionUID = 6324092579357208331L; public void actionPerformed(ActionEvent event) { checkSelection(); } }); getDefaultEditor(Boolean.class).addCellEditorListener(checkEditorListener); }
public static void main(String[] args) { CheckTable<String> table = new CheckTable<String>("things"); // @@TODO ensure empty table still works CheckTableModel<String> model = table.getModel(); // @@TODO ensure changes to the model directly affect the view List<String> data = new ArrayList<String>(); data.add("one"); data.add("two"); data.add("three"); data.add("long long long line of text that should still fit in the box"); data.add("<html>some hmtl with <br><br>linebreaks and <p>paragraphs etc</p></html>"); model.setData(data, false); model.addColumn("more", new String[]{"a", "nother column full of stuff", "fffrrr"}); final JScrollPane scroller = new JScrollPane(table); JComponent holder = new JPanel(new BorderLayout()); holder.add(scroller, BorderLayout.CENTER); holder.add(new JCheckBox("check"), BorderLayout.NORTH); JOptionPane optionPane = new JOptionPane(holder, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dlg = createDialog(null, "test CheckTable", optionPane); dlg.setVisible(true); System.exit(0); }
public void update() { final Set<OWLAxiom> axiomsFromKit = filterModel.getUnfilteredAxioms(getModel().getSourceOntologies()); if (unfilteredAxioms == null || !unfilteredAxioms.equals(axiomsFromKit)){ unfilteredAxioms = axiomsFromKit; list.getModel().setData(new ArrayList<>(unfilteredAxioms), true); list.checkAll(true); } }
public void setData(java.util.List<O> elements, boolean selected){ for (int i=getRowCount()-1; i>=0; i--){ removeRow(i); } for (O element : elements){ addRow(new Object[]{selected, element}); } }
public List<O> getFilteredValues() { List<O> axioms = new ArrayList<O>(); for (int i=0; i<getRowCount(); i++){ if (getValueAt(i, 0).equals(Boolean.TRUE)){ axioms.add((O)getValueAt(i, 1)); } } return axioms; }
public void stateChanged(ChangeEvent event) { for (int i=0; i<getModel().getRowCount(); i++){ getModel().setValueAt(checkAllCheckbox.isSelected(), i, 0); } notifyCheckSelectionChanged(); } };