source: src/main/java/genius/gui/session/SessionConfigPanel.java@ 346

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

Initial import : Genius 9.0.0

File size: 2.7 KB
Line 
1package genius.gui.session;
2
3import java.awt.event.ActionEvent;
4import java.awt.event.ActionListener;
5
6import javax.swing.JButton;
7import javax.swing.event.ListDataEvent;
8import javax.swing.event.ListDataListener;
9
10import genius.core.repository.DomainRepItem;
11import genius.core.repository.MultiPartyProtocolRepItem;
12import genius.gui.deadline.DeadlinePanel;
13import genius.gui.panels.CheckboxPanel;
14import genius.gui.panels.ComboboxSelectionPanel;
15import genius.gui.panels.VflowPanelWithBorder;
16import genius.gui.renderer.RepItemListCellRenderer;
17
18/**
19 * Panel that allows the user to set up the (multilateral) session settings
20 */
21@SuppressWarnings("serial")
22public 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}
Note: See TracBrowser for help on using the repository browser.