source: domaineditor/src/main/java/geniusweb/domaineditor/ProfileEditor.java@ 50

Last change on this file since 50 was 50, checked in by bart, 2 years ago

Fixed small issues in domaineditor.

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