source: src/main/java/genius/gui/session/MediatorPanel.java@ 256

Last change on this file since 256 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 1.6 KB
Line 
1package genius.gui.session;
2
3import javax.swing.event.ListDataEvent;
4import javax.swing.event.ListDataListener;
5
6import genius.core.repository.PartyRepItem;
7import genius.gui.panels.ComboboxSelectionPanel;
8import genius.gui.panels.LabelAndComponent;
9import genius.gui.panels.SingleSelectionModel;
10import genius.gui.panels.TextModel;
11import genius.gui.panels.TextPanel;
12import genius.gui.panels.VflowPanelWithBorder;
13import genius.gui.renderer.RepItemListCellRenderer;
14
15/**
16 * The mediator selector panel for single session. Visible only when the
17 * strategy list is non-empty.
18 */
19@SuppressWarnings("serial")
20public class MediatorPanel extends VflowPanelWithBorder {
21
22 private SingleSelectionModel<PartyRepItem> partyModel;
23
24 public MediatorPanel(TextModel nameModel, SingleSelectionModel<PartyRepItem> partyModel) {
25 super("Mediator");
26 this.partyModel = partyModel;
27 final ComboboxSelectionPanel<PartyRepItem> mediatorcomb = new ComboboxSelectionPanel<>("Mediator Strategy",
28 partyModel);
29
30 mediatorcomb.setCellRenderer(new RepItemListCellRenderer());
31
32 add(new LabelAndComponent("Mediator ID", new TextPanel(nameModel)));
33 add(mediatorcomb);
34 updateVisibility();
35
36 connect();
37 }
38
39 private void connect() {
40 partyModel.addListDataListener(new ListDataListener() {
41
42 @Override
43 public void intervalRemoved(ListDataEvent e) {
44 updateVisibility();
45 }
46
47 @Override
48 public void intervalAdded(ListDataEvent e) {
49 updateVisibility();
50 }
51
52 @Override
53 public void contentsChanged(ListDataEvent e) {
54 updateVisibility();
55 }
56 });
57 }
58
59 private void updateVisibility() {
60 setVisible(!partyModel.getAllItems().isEmpty());
61 }
62
63}
Note: See TracBrowser for help on using the repository browser.