47 |
47 |
48 private Command newDayCommand = new Command() { |
48 private Command newDayCommand = new Command() { |
49 public void menuSelected(MenuItem selectedItem) { |
49 public void menuSelected(MenuItem selectedItem) { |
50 EditDayDialog dialog = null; |
50 EditDayDialog dialog = null; |
51 try { |
51 try { |
52 dialog = new EditDayDialog(thisObject, EditState.CREATE, null); |
52 dialog = new EditDayDialog(thisObject, null); |
53 } catch (Exception e) { |
53 } catch (Exception e) { |
54 e.printStackTrace(); |
54 e.printStackTrace(); |
55 } |
55 } |
56 getMainWindow().addWindow(dialog); |
56 getMainWindow().addWindow(dialog); |
57 } |
57 } |
58 }; |
58 }; |
59 private Command newTaskCommand = new Command() { |
59 private Command newTaskCommand = new Command() { |
60 public void menuSelected(MenuItem selectedItem) { |
60 public void menuSelected(MenuItem selectedItem) { |
61 EditTaskDialog dialog = null; |
61 EditTaskDialog dialog = null; |
62 try { |
62 try { |
63 dialog = new EditTaskDialog(thisObject, EditState.CREATE, null); |
63 dialog = new EditTaskDialog(thisObject, null); |
64 } catch (Exception e) { |
64 } catch (Exception e) { |
65 e.printStackTrace(); |
65 e.printStackTrace(); |
66 } |
66 } |
67 getMainWindow().addWindow(dialog); |
67 getMainWindow().addWindow(dialog); |
68 } |
68 } |
69 }; |
69 }; |
70 private Command newWorkCommand = new Command() { |
70 private Command newWorkCommand = new Command() { |
71 public void menuSelected(MenuItem selectedItem) { |
71 public void menuSelected(MenuItem selectedItem) { |
72 EditWorkDialog dialog = null; |
72 EditWorkDialog dialog = null; |
73 try { |
73 try { |
74 dialog = new EditWorkDialog(thisObject, EditState.CREATE, null); |
74 dialog = new EditWorkDialog(thisObject, null); |
|
75 } catch (Exception e) { |
|
76 e.printStackTrace(); |
|
77 } |
|
78 getMainWindow().addWindow(dialog); |
|
79 } |
|
80 }; |
|
81 private Command editDayCommand = new Command() { |
|
82 public void menuSelected(MenuItem selectedItem) { |
|
83 EditDayDialog dialog = null; |
|
84 Day day = EM.find(Day.class, dayTable.getValue()); |
|
85 if(day == null) |
|
86 return; |
|
87 try { |
|
88 dialog = new EditDayDialog(thisObject, day); |
|
89 } catch (Exception e) { |
|
90 e.printStackTrace(); |
|
91 } |
|
92 getMainWindow().addWindow(dialog); |
|
93 } |
|
94 }; |
|
95 private Command editTaskCommand = new Command() { |
|
96 public void menuSelected(MenuItem selectedItem) { |
|
97 EditTaskDialog dialog = null; |
|
98 Task task = EM.find(Task.class, taskTable.getValue()); |
|
99 if(task == null) |
|
100 return; |
|
101 try { |
|
102 dialog = new EditTaskDialog(thisObject, task); |
|
103 } catch (Exception e) { |
|
104 e.printStackTrace(); |
|
105 } |
|
106 getMainWindow().addWindow(dialog); |
|
107 } |
|
108 }; |
|
109 private Command editWorkCommand = new Command() { |
|
110 public void menuSelected(MenuItem selectedItem) { |
|
111 EditWorkDialog dialog = null; |
|
112 Work work = EM.find(Work.class, workTable.getValue()); |
|
113 if(work == null) |
|
114 return; |
|
115 try { |
|
116 dialog = new EditWorkDialog(thisObject, work); |
75 } catch (Exception e) { |
117 } catch (Exception e) { |
76 e.printStackTrace(); |
118 e.printStackTrace(); |
77 } |
119 } |
78 getMainWindow().addWindow(dialog); |
120 getMainWindow().addWindow(dialog); |
79 } |
121 } |
92 vlMain.setSizeFull(); |
134 vlMain.setSizeFull(); |
93 vlMain.setMargin(true); |
135 vlMain.setMargin(true); |
94 vlMain.setSpacing(true); |
136 vlMain.setSpacing(true); |
95 tabSheet.addTab(vlMain, "Main page", null); |
137 tabSheet.addTab(vlMain, "Main page", null); |
96 |
138 |
97 MenuBar menubar = new MenuBar(); |
139 MenuBar menuBar = new MenuBar(); |
98 MenuItem file = menubar.addItem("File", null); |
140 MenuItem file = menuBar.addItem("File", null); |
99 MenuItem newItem = file.addItem("New", null); |
141 MenuItem newItem = file.addItem("New", null); |
100 newItem.addItem("Day...", newDayCommand); |
142 newItem.addItem("Day...", newDayCommand); |
101 newItem.addItem("Task...", newTaskCommand); |
143 newItem.addItem("Task...", newTaskCommand); |
102 newItem.addItem("Work...", newWorkCommand); |
144 newItem.addItem("Work...", newWorkCommand); |
103 vlMain.addComponent(menubar); |
145 MenuItem edit = menuBar.addItem("Edit", null); |
|
146 edit.addItem("Day...", editDayCommand); |
|
147 edit.addItem("Task...", editTaskCommand); |
|
148 edit.addItem("Work...", editWorkCommand); |
|
149 vlMain.addComponent(menuBar); |
104 |
150 |
105 LocalEntityProvider dayProvider = new CachingLocalEntityProvider(Day.class); |
151 LocalEntityProvider dayProvider = new CachingLocalEntityProvider(Day.class); |
106 dayProvider.setEntityManager(EM); |
152 dayProvider.setEntityManager(EM); |
107 JPAContainer<Day> dayContainer = new JPAContainer(Day.class); |
153 JPAContainer<Day> dayContainer = new JPAContainer(Day.class); |
108 dayContainer.setEntityProvider(dayProvider); |
154 dayContainer.setEntityProvider(dayProvider); |
145 workProvider.setEntityManager(EM); |
198 workProvider.setEntityManager(EM); |
146 JPAContainer<Task> workContainer = new JPAContainer(Work.class); |
199 JPAContainer<Task> workContainer = new JPAContainer(Work.class); |
147 workContainer.setEntityProvider(workProvider); |
200 workContainer.setEntityProvider(workProvider); |
148 |
201 |
149 workTable = new Table(); |
202 workTable = new Table(); |
150 workTable.setSelectable(true); |
203 workTable.setSelectable(false); |
151 workTable.setEditable(false); |
204 workTable.setEditable(false); |
152 workTable.setImmediate(true); |
205 workTable.setImmediate(true); |
153 workTable.setSizeFull(); |
206 workTable.setSizeFull(); |
154 workTable.setContainerDataSource(workContainer); |
207 workTable.setContainerDataSource(workContainer); |
155 workTable.setVisibleColumns(new String[]{ |
208 workTable.setVisibleColumns(new String[]{ |