1 | package genius.gui.session;
|
---|
2 |
|
---|
3 | import java.awt.event.ActionEvent;
|
---|
4 | import java.awt.event.ActionListener;
|
---|
5 |
|
---|
6 | import javax.swing.JButton;
|
---|
7 | import javax.swing.event.ListDataEvent;
|
---|
8 | import javax.swing.event.ListDataListener;
|
---|
9 |
|
---|
10 | import genius.core.repository.DomainRepItem;
|
---|
11 | import genius.core.repository.MultiPartyProtocolRepItem;
|
---|
12 | import genius.gui.deadline.DeadlinePanel;
|
---|
13 | import genius.gui.panels.CheckboxPanel;
|
---|
14 | import genius.gui.panels.ComboboxSelectionPanel;
|
---|
15 | import genius.gui.panels.VflowPanelWithBorder;
|
---|
16 | import genius.gui.renderer.RepItemListCellRenderer;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Panel that allows the user to set up the (multilateral) session settings
|
---|
20 | */
|
---|
21 | @SuppressWarnings("serial")
|
---|
22 | public class SessionConfigPanel extends VflowPanelWithBorder {
|
---|
23 |
|
---|
24 | private SessionModel model;
|
---|
25 | private BilateralOptionsPanel bilateralOptions;
|
---|
26 |
|
---|
27 | public SessionConfigPanel(SessionModel model) {
|
---|
28 | super("Multiparty Negotiation Session Setup");
|
---|
29 | this.model = model;
|
---|
30 |
|
---|
31 | initPanel();
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Load and set all the panel elements - buttons, comboboxes, etc.
|
---|
36 | */
|
---|
37 | private void initPanel() {
|
---|
38 | ComboboxSelectionPanel<MultiPartyProtocolRepItem> protocolcomb = new ComboboxSelectionPanel<>("Protocol",
|
---|
39 | model.getProtocolModel());
|
---|
40 | protocolcomb.setCellRenderer(new RepItemListCellRenderer());
|
---|
41 |
|
---|
42 | ComboboxSelectionPanel<DomainRepItem> domaincomb = new ComboboxSelectionPanel<>("Domain",
|
---|
43 | model.getDomainModel());
|
---|
44 |
|
---|
45 | MediatorPanel mediatorpanel = new MediatorPanel(model.getMediatorIdModel(), model.getMediatorModel());
|
---|
46 |
|
---|
47 | add(protocolcomb);
|
---|
48 | add(domaincomb);
|
---|
49 | add(mediatorpanel);
|
---|
50 |
|
---|
51 | add(new ParticipantsPanel(model.getParticipantModel(), model.getParticipantsModel()));
|
---|
52 | add(new DeadlinePanel(model.getDeadlineModel()));
|
---|
53 | add(new ComboboxSelectionPanel<>("Data persistency", model.getPersistentDatatypeModel()));
|
---|
54 | add(new CheckboxPanel("Enable System.out print", model.getPrintEnabled()));
|
---|
55 | add(new CheckboxPanel("Enable progress graph", model.getShowChart()));
|
---|
56 |
|
---|
57 | bilateralOptions = new BilateralOptionsPanel(model.getBilateralUtilUtilPlot(), model.getBilateralShowAllBids());
|
---|
58 | add(bilateralOptions);
|
---|
59 |
|
---|
60 | JButton start = new JButton("Start");
|
---|
61 | add(start);
|
---|
62 | start.addActionListener(new ActionListener() {
|
---|
63 | @Override
|
---|
64 | public void actionPerformed(ActionEvent e) {
|
---|
65 | model.modelIsComplete();
|
---|
66 | }
|
---|
67 | });
|
---|
68 |
|
---|
69 | model.getParticipantsModel().addListDataListener(new ListDataListener() {
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public void intervalRemoved(ListDataEvent e) {
|
---|
73 | updateVisibility();
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Override
|
---|
77 | public void intervalAdded(ListDataEvent e) {
|
---|
78 | updateVisibility();
|
---|
79 | }
|
---|
80 |
|
---|
81 | @Override
|
---|
82 | public void contentsChanged(ListDataEvent e) {
|
---|
83 | updateVisibility();
|
---|
84 | }
|
---|
85 | });
|
---|
86 | updateVisibility();
|
---|
87 | }
|
---|
88 |
|
---|
89 | private void updateVisibility() {
|
---|
90 | bilateralOptions.setVisible(model.getParticipantsModel().getSize() == 2);
|
---|
91 | }
|
---|
92 |
|
---|
93 | }
|
---|