Search in sources :

Example 1 with DynamicTableColumnModel

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

the class JTreeViewTable method createTableColumnModel.

private DynamicTableColumnModel createTableColumnModel(TreeView<?> startingView, DataView<?> dataView) {
    @SuppressWarnings("unchecked") ListMap<Visibility, TableColumn, List<TableColumn>> listMap = CollectionMaps.createListMap(HashMap.class, ArrayList.class);
    int index = 1;
    for (DataViewColumn column : dataView.getDataColumns()) {
        TableColumn tableColumn = new TableColumn(index++);
        tableColumn.setHeaderValue(column.getName());
        Visibility vis = column.getVisibility();
        listMap.add(vis, tableColumn);
    }
    List<TableColumn> columns = listMap.get(Visibility.ALWAYS_VISIBLE);
    if (columns == null) {
        columns = Collections.emptyList();
    }
    PrefTableColumnModel model = new PrefTableColumnModel(this.viewModel.getDataView().getPrefsKey(), columns.size() + 1);
    TableColumn viewColumn = new TableColumn();
    viewColumn.setHeaderValue(startingView.getViewName());
    viewColumn.setIdentifier(TREE_VIEW_COL_PREFS_KEY);
    model.addColumn(viewColumn, true, 150);
    for (TableColumn column : columns) {
        model.addColumn(column, true, 75);
    }
    columns = listMap.get(Visibility.INITIALLY_VISIBLE);
    if (columns != null) {
        for (TableColumn column : columns) {
            model.addColumn(column, true, 75);
        }
    }
    columns = listMap.get(Visibility.INITIALLY_INVISIBLE);
    if (columns != null) {
        for (TableColumn column : columns) {
            model.addColumn(column, false, 75);
        }
    }
    return model;
}
Also used : PrefTableColumnModel(pcgen.gui2.tools.PrefTableColumnModel) DataViewColumn(pcgen.gui2.util.treeview.DataViewColumn) Visibility(pcgen.gui2.util.treeview.DataViewColumn.Visibility) ArrayList(java.util.ArrayList) List(java.util.List) TableColumn(javax.swing.table.TableColumn)

Example 2 with DynamicTableColumnModel

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

the class DomainInfoTab method createDomainColumnModel.

public DynamicTableColumnModel createDomainColumnModel() {
    PrefTableColumnModel model = new PrefTableColumnModel("DomainList", 1);
    TableColumn column = new TableColumn(0);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_domains"));
    model.addColumn(column, true, 150);
    column = new TableColumn(1);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_descrip"));
    model.addColumn(column, false, 150);
    column = new TableColumn(2);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_source"));
    model.addColumn(column, true, 150);
    return model;
}
Also used : PrefTableColumnModel(pcgen.gui2.tools.PrefTableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 3 with DynamicTableColumnModel

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

the class EquipInfoTab method createEquipmentColumnModel.

private DynamicTableColumnModel createEquipmentColumnModel() {
    PrefTableColumnModel model = new PrefTableColumnModel("EquipList", 1);
    TableColumn column = new TableColumn(0);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_nameLabel"));
    model.addColumn(column, true, 150);
    column = new TableColumn(1);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_type"));
    model.addColumn(column, true, 75);
    column = new TableColumn(2);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_equipLocationAbbrev"));
    model.addColumn(column, true, 75);
    column = new TableColumn(3);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_equipQuantityAbbrev"));
    model.addColumn(column, true, 75);
    column = new TableColumn(4);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_equipWeightAbbrev"));
    model.addColumn(column, true, 75);
    column = new TableColumn(5);
    //$NON-NLS-1$
    column.setHeaderValue(LanguageBundle.getString("in_descrip"));
    model.addColumn(column, false, 75);
    return model;
}
Also used : PrefTableColumnModel(pcgen.gui2.tools.PrefTableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 4 with DynamicTableColumnModel

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

the class AdvancedSourceSelectionPanel method initComponents.

private void initComponents() {
    FlippingSplitPane mainPane = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, "advSrcMain");
    FlippingSplitPane topPane = new FlippingSplitPane("advSrcTop");
    topPane.setResizeWeight(0.6);
    JPanel panel = new JPanel(new BorderLayout());
    //$NON-NLS-1$
    panel.add(new JLabel(LanguageBundle.getString("in_src_gameLabel")), BorderLayout.WEST);
    FacadeComboBoxModel<GameModeDisplayFacade> gameModes = new FacadeComboBoxModel<>();
    gameModes.setListFacade(FacadeFactory.getGameModeDisplays());
    gameModeList.setModel(gameModes);
    gameModeList.addActionListener(this);
    panel.add(gameModeList, BorderLayout.CENTER);
    FilterBar<Object, CampaignFacade> bar = new FilterBar<>(false);
    bar.add(panel, BorderLayout.WEST);
    bar.addDisplayableFilter(new SearchFilterPanel());
    panel = new JPanel(new BorderLayout());
    panel.add(bar, BorderLayout.NORTH);
    availableTable.setDisplayableFilter(bar);
    availableTable.setTreeViewModel(availTreeViewModel);
    availableTable.getSelectionModel().addListSelectionListener(this);
    availableTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) availableTable.getColumnModel()).getAvailableColumns().get(2).setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    JScrollPane pane = new JScrollPane(availableTable);
    pane.setPreferredSize(new Dimension(600, 310));
    panel.add(pane, BorderLayout.CENTER);
    Box box = Box.createHorizontalBox();
    unloadAllButton.setAction(new UnloadAllAction());
    box.add(unloadAllButton);
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    addButton.setAction(new AddAction());
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    panel.add(box, BorderLayout.SOUTH);
    topPane.setLeftComponent(panel);
    JPanel selPanel = new JPanel(new BorderLayout());
    FilterBar<Object, CampaignFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    selectedTable.setDisplayableFilter(filterBar);
    selectedTable.setTreeViewModel(selTreeViewModel);
    selectedTable.getSelectionModel().addListSelectionListener(this);
    selectedTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) selectedTable.getColumnModel()).getAvailableColumns().get(2).setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    JScrollPane scrollPane = new JScrollPane(selectedTable);
    scrollPane.setPreferredSize(new Dimension(300, 350));
    selPanel.add(scrollPane, BorderLayout.CENTER);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    removeButton.setAction(new RemoveAction());
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);
    topPane.setRightComponent(selPanel);
    mainPane.setTopComponent(topPane);
    linkAction.install();
    infoPane.setPreferredSize(new Dimension(800, 150));
    mainPane.setBottomComponent(infoPane);
    mainPane.setResizeWeight(0.7);
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DynamicTableColumnModel(pcgen.gui2.util.table.DynamicTableColumnModel) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) Dimension(java.awt.Dimension) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) CampaignFacade(pcgen.facade.core.CampaignFacade) FacadeComboBoxModel(pcgen.gui2.util.FacadeComboBoxModel) TableCellUtilities(pcgen.gui2.util.table.TableCellUtilities) GameModeDisplayFacade(pcgen.facade.core.GameModeDisplayFacade) FilterBar(pcgen.gui2.filter.FilterBar) BorderLayout(java.awt.BorderLayout) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

TableColumn (javax.swing.table.TableColumn)3 PrefTableColumnModel (pcgen.gui2.tools.PrefTableColumnModel)3 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Box (javax.swing.Box)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 EmptyBorder (javax.swing.border.EmptyBorder)1 CampaignFacade (pcgen.facade.core.CampaignFacade)1 GameModeDisplayFacade (pcgen.facade.core.GameModeDisplayFacade)1 FilterBar (pcgen.gui2.filter.FilterBar)1 SearchFilterPanel (pcgen.gui2.filter.SearchFilterPanel)1 FlippingSplitPane (pcgen.gui2.tools.FlippingSplitPane)1 FacadeComboBoxModel (pcgen.gui2.util.FacadeComboBoxModel)1 DynamicTableColumnModel (pcgen.gui2.util.table.DynamicTableColumnModel)1 TableCellUtilities (pcgen.gui2.util.table.TableCellUtilities)1