1 | package geniusweb.domaineditor;
|
---|
2 |
|
---|
3 | import java.awt.BorderLayout;
|
---|
4 |
|
---|
5 | import javax.swing.JFrame;
|
---|
6 | import javax.swing.JMenu;
|
---|
7 | import javax.swing.JMenuBar;
|
---|
8 |
|
---|
9 | import geniusweb.actions.HelpAction;
|
---|
10 | import geniusweb.actions.LoadAction;
|
---|
11 | import geniusweb.actions.SaveAction;
|
---|
12 | import geniusweb.actions.SaveDomainAction;
|
---|
13 | import geniusweb.domaineditor.model.DomainModel;
|
---|
14 | import geniusweb.domaineditor.model.profile.LinearAdditiveUtilitySpaceModel;
|
---|
15 | import geniusweb.domaineditor.panels.profile.ProfileEditorPanel;
|
---|
16 | import tudelft.utilities.logging.Reporter;
|
---|
17 | import tudelft.utilities.mvc.panels.PopupReporter;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * A profile editor. Basically a container for a {@link ProfileEditorPanel} plus
|
---|
21 | * a menu bar. Contains components to edit domain, reservation bid, utilities
|
---|
22 | * etc.
|
---|
23 | */
|
---|
24 | @SuppressWarnings("serial")
|
---|
25 | public class ProfileEditor extends JFrame {
|
---|
26 | private final Reporter log;
|
---|
27 | private final LinearAdditiveUtilitySpaceModel model;
|
---|
28 | private static ProfileEditor instance = null;
|
---|
29 |
|
---|
30 | private ProfileEditor() {
|
---|
31 | log = new PopupReporter(this);
|
---|
32 | model = getSampleModel();
|
---|
33 | setLayout(new BorderLayout());
|
---|
34 | setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
---|
35 | Reporter log = new PopupReporter(this);
|
---|
36 |
|
---|
37 | getContentPane().add(new ProfileEditorPanel(model, log),
|
---|
38 | BorderLayout.CENTER);
|
---|
39 | setJMenuBar(menu());
|
---|
40 |
|
---|
41 | pack();
|
---|
42 | setVisible(true);
|
---|
43 | }
|
---|
44 |
|
---|
45 | private JMenuBar menu() {
|
---|
46 | JMenuBar mb = new JMenuBar();
|
---|
47 | JMenu filemenu = new JMenu("File");
|
---|
48 | filemenu.add(new LoadAction(log));
|
---|
49 | filemenu.add(new SaveAction(log));
|
---|
50 | filemenu.add(new SaveDomainAction(log));
|
---|
51 |
|
---|
52 | mb.add(filemenu);
|
---|
53 |
|
---|
54 | JMenu helpmenu = new JMenu("Help");
|
---|
55 | helpmenu.add(new HelpAction(log));
|
---|
56 | mb.add(helpmenu);
|
---|
57 | return mb;
|
---|
58 |
|
---|
59 | }
|
---|
60 |
|
---|
61 | private LinearAdditiveUtilitySpaceModel getSampleModel() {
|
---|
62 | DomainModel domain = new DomainModel(log);
|
---|
63 | LinearAdditiveUtilitySpaceModel lamodel = new LinearAdditiveUtilitySpaceModel(
|
---|
64 | domain, log);
|
---|
65 | return lamodel;
|
---|
66 | }
|
---|
67 |
|
---|
68 | public static void main(String[] args) {
|
---|
69 | getInstance();
|
---|
70 | }
|
---|
71 |
|
---|
72 | public static ProfileEditor getInstance() {
|
---|
73 | if (instance == null)
|
---|
74 | instance = new ProfileEditor();
|
---|
75 | return instance;
|
---|
76 | }
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * .
|
---|
80 | *
|
---|
81 | * @return Currently active model
|
---|
82 | */
|
---|
83 | public LinearAdditiveUtilitySpaceModel getModel() {
|
---|
84 | return model;
|
---|
85 | }
|
---|
86 | }
|
---|