Search in sources :

Example 1 with SortableTableModel

use of pcgen.gui2.util.table.SortableTableModel in project pcgen by PCGen.

the class SpellBooksTab method initComponents.

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }
    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter"));
    filterBar.addDisplayableFilter(qFilterButton);
    FlippingSplitPane upperPane = new FlippingSplitPane("SpellBooksTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(new JLabel(LanguageBundle.getString("InfoSpells.set.auto.book")));
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(defaultBookCombo);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(addButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);
    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeButton);
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);
    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellBooksBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) SuperNode(pcgen.facade.core.SpellSupportFacade.SuperNode) JLabel(javax.swing.JLabel) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) FilterBar(pcgen.gui2.filter.FilterBar) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel)

Example 2 with SortableTableModel

use of pcgen.gui2.util.table.SortableTableModel in project pcgen by PCGen.

the class SpellsKnownTab method initComponents.

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }
    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter"));
    filterBar.addDisplayableFilter(qFilterButton);
    FlippingSplitPane upperPane = new FlippingSplitPane("SpellsKnownTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(autoKnownBox);
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    //box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(slotsBox);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(addButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);
    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(4));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeButton);
        hbox.add(Box.createHorizontalStrut(10));
        JButton spellSheetButton = new JButton(LanguageBundle.getString("InfoSpells.select.spellsheet"));
        spellSheetButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                selectSpellSheetButton();
            }
        });
        hbox.add(spellSheetButton);
        hbox.add(Box.createHorizontalStrut(3));
        String text = PCGenSettings.getSelectedSpellSheet();
        if (text != null) {
            text = new File(text).getName();
        }
        spellSheetField.setEditable(false);
        spellSheetField.setText(text);
        spellSheetField.setToolTipText(text);
        hbox.add(spellSheetField);
        hbox.add(Box.createHorizontalStrut(3));
        previewSpellsButton = new JButton(Icons.PrintPreview16.getImageIcon());
        hbox.add(previewSpellsButton);
        hbox.add(Box.createHorizontalStrut(3));
        exportSpellsButton = new JButton(Icons.Print16.getImageIcon());
        hbox.add(exportSpellsButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);
    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellsKnownBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) SuperNode(pcgen.facade.core.SpellSupportFacade.SuperNode) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) FilterBar(pcgen.gui2.filter.FilterBar) ActionListener(java.awt.event.ActionListener) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel) File(java.io.File)

Example 3 with SortableTableModel

use of pcgen.gui2.util.table.SortableTableModel in project pcgen by PCGen.

the class SpellsPreparedTab method initComponents.

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }
    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter"));
    filterBar.addDisplayableFilter(qFilterButton);
    FlippingSplitPane upperPane = new FlippingSplitPane("SpellsPreparedTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        addMMSpellButton.setHorizontalTextPosition(SwingConstants.LEADING);
        hbox.add(addMMSpellButton);
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(slotsBox);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(addSpellButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);
    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(4));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeSpellButton);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel(LanguageBundle.getString("InfoPreparedSpells.preparedList")));
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(spellListField);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(addSpellListButton);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(removeSpellListButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);
    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellsPreparedBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) SuperNode(pcgen.facade.core.SpellSupportFacade.SuperNode) JLabel(javax.swing.JLabel) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) FilterBar(pcgen.gui2.filter.FilterBar) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel)

Example 4 with SortableTableModel

use of pcgen.gui2.util.table.SortableTableModel in project pcgen by PCGen.

the class JTableEx method setAutoCreateRowSorter.

@Override
public void setAutoCreateRowSorter(boolean autoCreateRowSorter) {
    boolean oldValue = this.sortingEnabled;
    this.sortingEnabled = autoCreateRowSorter;
    if (sortingEnabled) {
        TableModel model = getModel();
        if (model instanceof SortableTableModel) {
            setRowSorter(new SortableTableRowSorter((SortableTableModel) dataModel));
        } else {
            setRowSorter(new TableRowSorter(model));
        }
    }
    firePropertyChange("autoCreateRowSorter", oldValue, autoCreateRowSorter);
}
Also used : SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter)

Example 5 with SortableTableModel

use of pcgen.gui2.util.table.SortableTableModel in project pcgen by PCGen.

the class JTableEx method setModel.

@Override
public void setModel(TableModel dataModel) {
    if (dataModel == null) {
        throw new IllegalArgumentException("Cannot set a null TableModel");
    }
    if (this.dataModel != dataModel) {
        TableModel old = this.dataModel;
        if (old != null) {
            old.removeTableModelListener(this);
        }
        this.dataModel = dataModel;
        dataModel.addTableModelListener(this);
        tableChanged(new TableModelEvent(dataModel, TableModelEvent.HEADER_ROW));
        firePropertyChange("model", old, dataModel);
        if (getAutoCreateRowSorter()) {
            if (dataModel instanceof SortableTableModel) {
                super.setRowSorter(new SortableTableRowSorter((SortableTableModel) dataModel));
            } else {
                super.setRowSorter(new TableRowSorter(dataModel));
            }
        }
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter)

Aggregations

SortableTableModel (pcgen.gui2.util.table.SortableTableModel)5 SortableTableRowSorter (pcgen.gui2.util.table.SortableTableRowSorter)5 Box (javax.swing.Box)3 JPanel (javax.swing.JPanel)3 JScrollPane (javax.swing.JScrollPane)3 CharacterFacade (pcgen.facade.core.CharacterFacade)3 SuperNode (pcgen.facade.core.SpellSupportFacade.SuperNode)3 FilterBar (pcgen.gui2.filter.FilterBar)3 SearchFilterPanel (pcgen.gui2.filter.SearchFilterPanel)3 FlippingSplitPane (pcgen.gui2.tools.FlippingSplitPane)3 JCheckBox (javax.swing.JCheckBox)2 JLabel (javax.swing.JLabel)2 TableModel (javax.swing.table.TableModel)2 TableRowSorter (javax.swing.table.TableRowSorter)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 JButton (javax.swing.JButton)1 JComboBox (javax.swing.JComboBox)1 TableModelEvent (javax.swing.event.TableModelEvent)1