1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import wx
20
21 from timelinelib.db.utils import safe_locking
22 from timelinelib.repositories.dbwrapper import DbWrapperEventRepository
23 from timelinelib.wxgui.dialogs.editcontainer.view import EditContainerDialog
24 from timelinelib.wxgui.dialogs.editevent.controller import EditEventDialogController
25 from timelinelib.wxgui.framework import Dialog
26 from timelinelib.wxgui.utils import _set_focus_and_select
27 from timelinelib.wxgui.dialogs.duplicateevent.view import DuplicateEventDialog
28
29
31
32 """
33 <BoxSizerVertical>
34 <StaticBoxSizerVertical label="$(properties_label)" border="ALL" proportion="1">
35 <FlexGridSizer name="grid_sizer" columns="2" growableColumns="1" border="ALL" proportion="1">
36 %s
37 </FlexGridSizer>
38 </StaticBoxSizerVertical>
39 <CheckBox
40 name="add_more_checkbox"
41 label="$(add_more_label)"
42 border="LEFT|RIGHT|BOTTOM"
43 />
44 <BoxSizerHorizontal border="LEFT|RIGHT|BOTTOM">
45 <TwoStateButton
46 initial_state_label="$(enlarge)"
47 second_state_label="$(reduce)"
48 event_EVT_INITIAL_STATE_CLICKED="on_enlarge_click"
49 event_EVT_SECOND_STATE_CLICKED="on_reduce_click"
50 />
51 <Spacer />
52 <Button
53 name="duplicate"
54 label="$(duplicate_label)"
55 event_EVT_BUTTON="on_duplicate"
56 />
57 <StretchSpacer />
58 <DialogButtonsOkCancelSizer
59 event_EVT_BUTTON__ID_OK="on_ok_clicked"
60 />
61 </BoxSizerHorizontal>
62 </BoxSizerVertical>
63 """
64
65 TIME_DETAILS_ROW = """
66 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(when_label)" />
67 <BoxSizerHorizontal>
68 <PeriodPicker
69 name="period_picker"
70 time_type="$(time_type)"
71 config="$(config)"
72 />
73 </BoxSizerHorizontal>
74 """
75
76 CHECKBOX_ROW = """
77 <Spacer />
78 <FlexGridSizer rows="1">
79 <CheckBox
80 name="fuzzy_checkbox"
81 label="$(fuzzy_checkbox_text)"
82 />
83 <CheckBox
84 name="locked_checkbox"
85 event_EVT_CHECKBOX="on_locked_checkbox_changed"
86 label="$(locked_checkbox_text)"
87 />
88 <CheckBox
89 name="ends_today_checkbox"
90 label="$(ends_today_checkbox_text)"
91 />
92 </FlexGridSizer>
93 """
94
95 TEXT_FIELD_ROW = """
96 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(text_label)" />
97 <TextCtrl name="name" />
98 """
99
100 CATEGORY_LISTBOX_ROW = """
101 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(category_label)" />
102 <CategoryChoice
103 name="category_choice"
104 allow_add="True"
105 allow_edit="True"
106 timeline="$(db)"
107 align="ALIGN_LEFT"
108 />
109 """
110
111 CONTAINER_LISTBOX_ROW = """
112 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(container_label)" />
113 <ContainerChoice
114 name="container_choice"
115 event_EVT_CONTAINER_CHANGED="on_container_changed"
116 db="$(db)"
117 align="ALIGN_LEFT"
118 />
119 """
120
121 NOTEBOOK_ROW = """
122 <Spacer />
123 <Notebook name="notebook" style="BK_DEFAULT">
124 <DescriptionEditor
125 name="description"
126 notebookLabel="$(page_description)"
127 editor="$(self)"
128 proportion="1"
129 />
130 <IconEditor
131 name="icon"
132 notebookLabel="$(page_icon)"
133 editor="$(self)"
134 proportion="1"
135 />
136 <AlertEditor
137 name="alert"
138 notebookLabel="$(page_alert)"
139 editor="$(self)"
140 proportion="1"
141 />
142 <HyperlinkEditor
143 name="hyperlink"
144 notebookLabel="$(page_hyperlink)"
145 editor="$(self)"
146 proportion="1"
147 />
148 <ProgressEditor
149 name="progress"
150 notebookLabel="$(page_progress)"
151 editor="$(self)"
152 proportion="1"
153 />
154 <ColorEditor
155 name="default_color"
156 notebookLabel="$(color)"
157 editor="$(self)"
158 proportion="1"
159 />
160 </Notebook>
161 """
162
163 - def __init__(self, parent, config, title, db, start=None, end=None, event=None):
164 self.parent = parent
165 self.timeline = db
166 self.config = config
167 self.start = start
168 self.event = event
169 self._insert_rows_in_correct_order_in_xml()
170 Dialog.__init__(self, EditEventDialogController, parent, {
171 "self": self,
172 "db": db,
173 "time_type": db.get_time_type(),
174 "config": config,
175 "properties_label": _("Event Properties"),
176 "when_label": _("When:"),
177 "fuzzy_checkbox_text": _("Fuzzy"),
178 "locked_checkbox_text": _("Locked"),
179 "ends_today_checkbox_text": _("Ends today"),
180 "text_label": _("Text:"),
181 "category_label": _("Category:"),
182 "container_label": _("Container:"),
183 "page_description": _("Description"),
184 "page_icon": _("Icon"),
185 "page_alert": _("Alert"),
186 "page_hyperlink": _("Hyperlink"),
187 "page_progress": _("Progress"),
188 "color": _("Default color"),
189 "add_more_label": _("Add more events after this one"),
190 "enlarge": _("&Enlarge"),
191 "reduce": _("&Reduce"),
192 "duplicate_label": _("Save and Duplicate"),
193 }, title=title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
194 self.controller.on_init(
195 config,
196 db.get_time_type(),
197 DbWrapperEventRepository(db),
198 db,
199 start,
200 end,
201 event)
202 self._make_row_with_notebook_growable()
203 self.SetMinSize((800, -1))
204 self.Fit()
205 self.SetMinSize(self.GetSize())
206
209
211 return self.period_picker.GetValue()
212
215
218
221
224
227
230
232 return self.fuzzy_checkbox.GetValue()
233
236
238 return self.locked_checkbox.GetValue()
239
242
245
247 return self.ends_today_checkbox.GetValue()
248
251
254
257
260
263
266
269
272
274 event_data = {}
275 for data_id, editor in self._get_event_data():
276 data = editor.get_data()
277 if data is not None:
278 event_data[data_id] = editor.get_data()
279 return event_data
280
282 for data_id, editor in self._get_event_data():
283 if data_id in event_data:
284 data = event_data[data_id]
285 if data is not None:
286 editor.set_data(data)
287
289 for _, editor in self._get_event_data():
290 editor.clear_data()
291
293 return self.add_more_checkbox.GetValue()
294
296 self.add_more_checkbox.Show(value)
297 self.add_more_checkbox.SetValue(False)
298 self.SetSizerAndFit(self.GetSizer())
299
301 control = {
302 "0": self.period_picker,
303 "1": self.fuzzy_checkbox,
304 "2": self.name,
305 "3": self.category_choice,
306 "4": self.container_choice,
307 ":": self.notebook,
308 }[self.config.event_editor_tab_order[0]]
309 _set_focus_and_select(control)
310
312 self._display_invalid_input(message, self.period_picker)
313
317
319 return [
320 ("description", self.description),
321 ("alert", self.alert),
322 ("icon", self.icon),
323 ("hyperlink", self.hyperlink),
324 ("progress", self.progress),
325 ("default_color", self.default_color)
326 ]
327
339
341 self.grid_sizer.AddGrowableRow(self.config.event_editor_tab_order.index(":"))
342
343
352
353 def edit_function():
354 dialog = create_event_editor()
355 dialog.ShowModal()
356 dialog.Destroy()
357 safe_locking(edit_controller, edit_function)
358
359
364
365 def edit_function():
366 dialog = create_event_editor()
367 dialog.ShowModal()
368 dialog.Destroy()
369 safe_locking(edit_controller, edit_function)
370