use of pcgen.facade.core.GameModeDisplayFacade in project pcgen by PCGen.
the class AdvancedSourceSelectionPanel method setSourceSelection.
public void setSourceSelection(SourceSelectionFacade sources) {
if (sources == null || sources.getGameMode() == null) {
Logging.errorPrint("Invalid source selection " + sources + "- ignoring.");
return;
}
GameModeFacade selectedGame = sources.getGameMode().get();
for (int i = 0; i < gameModeList.getModel().getSize(); i++) {
GameModeDisplayFacade gmdf = (GameModeDisplayFacade) gameModeList.getModel().getElementAt(i);
if (gmdf.getGameMode() == selectedGame) {
gameModeList.setSelectedItem(gmdf);
}
}
List<CampaignFacade> wrap = new ArrayList<>(ListFacades.wrap(sources.getCampaigns()));
wrap.sort(Comparators.toStringIgnoreCaseCollator());
selectedCampaigns.setContents(wrap);
}
use of pcgen.facade.core.GameModeDisplayFacade in project pcgen by PCGen.
the class AdvancedSourceSelectionPanel method initDefaults.
private void initDefaults() {
String defaultGame = context.initProperty(PROP_SELECTED_GAME, "");
GameModeDisplayFacade modeDisplay = null;
if (StringUtils.isNotEmpty(defaultGame)) {
for (int i = 0; i < gameModeList.getModel().getSize(); i++) {
GameModeDisplayFacade game = (GameModeDisplayFacade) gameModeList.getModel().getElementAt(i);
if (defaultGame.equals(game.getGameMode().toString())) {
gameModeList.setSelectedIndex(i);
modeDisplay = game;
}
}
}
if (modeDisplay == null && gameModeList.getModel().getSize() > 0) {
gameModeList.setSelectedIndex(0);
modeDisplay = (GameModeDisplayFacade) gameModeList.getSelectedItem();
}
}
use of pcgen.facade.core.GameModeDisplayFacade 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);
}
Aggregations