* Setup of the dialog. Also starts the scanner and searches for scenarios.
*/
public LocalScenarioSetupDialog() {
super("Local Scenario");
JPanel content = new PanelWithBackground(IOManager.getAsImage(Places.GraphicsIcons, "misc/dialog.background.png"));
LocalClient.CONTEXT.addHandler(handler);
LocalClient.CONTEXT.send(Message.SETUP_GET_SCENARIOS_LIST.createNew());
JList<TitleListEntry> titleList = new JList<>();
titleList.setOpaque(false);
titleList.setBorder(CommonElements.createBorder("Scenarios"));
titleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
titleList.setModel(titleListModel);
titleList.setCellRenderer(new OurListCellRenderer(new OurListCellRenderer.ListCellInfoProvider() {
@Override
public String getToolTip(Object value) {
// cast to TitleListEntry, we know it's one
TitleListEntry entry = (TitleListEntry) value;
return String.format("%s", entry.title);
}
}));
// listen to the list and update the selected scenario upon selection
titleList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
Integer id = titleListModel.getElementAt(e.getFirstIndex()).id;
LocalClient.CONTEXT.send(Message.SETUP_GET_SCENARIO_INFO.createNew(id));
}
}
});
// layout - selectTree fixed width, infoPanel fixed height
content.setLayout(new MigLayout("wrap 1, fill", "", "[][fill, grow][]"));
content.add(makeMenuBar());
content.add(titleList, "width 200!, split 2");
content.add(makeMapPanel(), "grow");
content.add(makeInfoPanel(), "height 200!, growx");
setContent(content);
}