diff options
author | Xisco Fauli <anistenis@gmail.com> | 2013-02-14 00:54:03 +0100 |
---|---|---|
committer | Xisco Fauli <anistenis@gmail.com> | 2013-02-14 00:55:16 +0100 |
commit | f4dc5247fca29f93a2d19b7e526d30d4b022b0ee (patch) | |
tree | ef3e16a913b302c14adaeddd8e477749d527f976 | |
parent | 0e34f7e99a096dc5d78931d0f1275d1ead32a711 (diff) |
fdo#38820: bye bye java agenda wizard
Hasta la vista, baby!
Change-Id: Idb6b5f383667960918a8f1b9db653edbfc89c232
11 files changed, 0 insertions, 5345 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.java b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.java deleted file mode 100644 index a022c34b2af2..000000000000 --- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.java +++ /dev/null | |||
@@ -1,2207 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | import java.util.*; | ||
21 | import com.sun.star.awt.TextEvent; | ||
22 | import com.sun.star.beans.PropertyValue; | ||
23 | import com.sun.star.container.NoSuchElementException; | ||
24 | import com.sun.star.container.XIndexAccess; | ||
25 | import com.sun.star.container.XNamed; | ||
26 | import com.sun.star.document.XDocumentProperties; | ||
27 | import com.sun.star.frame.XComponentLoader; | ||
28 | import com.sun.star.frame.XTerminateListener; | ||
29 | import com.sun.star.i18n.NumberFormatIndex; | ||
30 | import com.sun.star.lang.Locale; | ||
31 | import com.sun.star.lang.WrappedTargetException; | ||
32 | import com.sun.star.lang.XMultiServiceFactory; | ||
33 | import com.sun.star.table.XCell; | ||
34 | import com.sun.star.table.XTableRows; | ||
35 | import com.sun.star.text.*; | ||
36 | import com.sun.star.uno.Any; | ||
37 | import com.sun.star.uno.UnoRuntime; | ||
38 | import com.sun.star.util.XNumberFormatsSupplier; | ||
39 | import com.sun.star.util.XNumberFormatter; | ||
40 | import com.sun.star.util.XSearchDescriptor; | ||
41 | import com.sun.star.util.XSearchable; | ||
42 | import com.sun.star.wizards.common.FileAccess; | ||
43 | import com.sun.star.wizards.common.Helper; | ||
44 | import com.sun.star.wizards.common.JavaTools; | ||
45 | import com.sun.star.wizards.common.NumberFormatter; | ||
46 | import com.sun.star.wizards.common.PropertyNames; | ||
47 | import com.sun.star.wizards.document.OfficeDocument; | ||
48 | import com.sun.star.wizards.text.TextDocument; | ||
49 | import com.sun.star.wizards.text.TextSectionHandler; | ||
50 | import com.sun.star.wizards.ui.UnoDialog2; | ||
51 | import com.sun.star.wizards.ui.event.DataAware; | ||
52 | |||
53 | /** | ||
54 | * | ||
55 | * The classes here implement the whole document-functionality of the agenda wizard: | ||
56 | * the live-preview and the final "creation" of the document, when the user clicks "finish". <br/> | ||
57 | * <br/> | ||
58 | * <h2>Some terminology:<h2/> | ||
59 | * items are names or headings. we don't make any distinction. | ||
60 | * | ||
61 | * <br/> | ||
62 | * The Agenda Template is used as general "controller" of the whole document, whereas the | ||
63 | * two child-classes ItemsTable and TopicsTable control the item tables (note plural!) and the | ||
64 | * topics table (note singular). | ||
65 | * <br/> <br/> | ||
66 | * Other small classes are used to abstract the handling of cells and text and we | ||
67 | * try to use them as components. | ||
68 | * <br/><br/> | ||
69 | * We tried to keep the Agenda Template as flexible as possible, though there | ||
70 | * must be many limitations, because it is generated dynamically.<br/><br/> | ||
71 | * To keep the template flexible the following decisions were made:<br/> | ||
72 | * 1. Item tables.<br/> | ||
73 | * 1.a. there might be arbitrary number of Item tables.<br/> | ||
74 | * 1.b. Item tables design (bordewr, background) is arbitrary.<br/> | ||
75 | * 1.c. Items text styles are individual, and use stylelist styles with predefined names.<br/> | ||
76 | * As result the following limitations:<br/> | ||
77 | * Pairs of Name->value for each item.<br/> | ||
78 | * Tables contain *only* those pairs.<br/> | ||
79 | * 2. Topics table.<br/> | ||
80 | * 2.a. arbitrary structure.<br/> | ||
81 | * 2.b. design is arbitrary.<br/> | ||
82 | * As result the following limitations:<br/> | ||
83 | * No column merge is allowed.<br/> | ||
84 | * One compolsary Heading row.<br/> | ||
85 | * <br/><br/> | ||
86 | * To let the template be flexible, we use a kind of "detection": we look where | ||
87 | * the items are read the design of each table, reaplying it after writing the | ||
88 | * table. | ||
89 | * <br/><br/> | ||
90 | * A note about threads:<br/> | ||
91 | * Many methods here are synchronized, in order to avoid colission made by | ||
92 | * events fired too often. | ||
93 | * | ||
94 | */ | ||
95 | public class AgendaTemplate extends TextDocument implements TemplateConsts, DataAware.Listener | ||
96 | { | ||
97 | |||
98 | /** | ||
99 | * resources. | ||
100 | */ | ||
101 | AgendaWizardDialogResources resources; | ||
102 | /** | ||
103 | * data model. This keeps the status of the agenda document, and | ||
104 | * every redraw is done according to this data. | ||
105 | * Exception: topic data is written programatically, event-oriented. | ||
106 | */ | ||
107 | CGAgenda agenda; | ||
108 | /** | ||
109 | * the UNO Text Document serrvice | ||
110 | */ | ||
111 | Object document; | ||
112 | /** | ||
113 | * Service Factory | ||
114 | */ | ||
115 | XMultiServiceFactory docMSF; | ||
116 | /** | ||
117 | * The template-filename of the current template. | ||
118 | * Since we often re-link section and the break the link, | ||
119 | * inorder to restore them, we need a template to link to. | ||
120 | * This is practically an identicall copy of the current template. | ||
121 | */ | ||
122 | String template; | ||
123 | /** | ||
124 | * used for common operations on sections. | ||
125 | */ | ||
126 | TextSectionHandler textSectionHandler; | ||
127 | /** | ||
128 | * a component loader. | ||
129 | */ | ||
130 | XComponentLoader xComponentLoader; | ||
131 | /** | ||
132 | * an array containing all ItemTable object (which control each an Items | ||
133 | * Table in the document. | ||
134 | */ | ||
135 | ItemsTable[] itemsTables; | ||
136 | /** | ||
137 | * the controller of the topics table. | ||
138 | */ | ||
139 | Topics topics; | ||
140 | /** | ||
141 | * Stores reusable OOo Placeholder TextFields to insert to the document. | ||
142 | */ | ||
143 | Map<String, AgendaItem> itemsCache; | ||
144 | /** | ||
145 | * This map is used to find which tables contains a certain Item, so | ||
146 | * the keys are the different Items, the Objects are the ItemTable controllers. | ||
147 | * When an Item must be redrawn (because the user checked or uncheced it), | ||
148 | * the controller is retrieved from this Map, and a redraw is issued on this controller. | ||
149 | */ | ||
150 | Map<String, ItemsTable> itemsMap = new HashMap<String, ItemsTable>(11); | ||
151 | /** | ||
152 | * A temporary variable used to list all items and map them. | ||
153 | */ | ||
154 | List<XTextRange> _allItems = new ArrayList<XTextRange>(); | ||
155 | List<XTextRange> constItems = new ArrayList<XTextRange>(); | ||
156 | /** | ||
157 | * keep a reference on some static items in the document, | ||
158 | * so when their content is changed (through the user), we | ||
159 | * can just reference them and set their text. | ||
160 | */ | ||
161 | TextElement teTitle, teDate, teTime, teLocation; | ||
162 | XTextRange trTitle, trDate, trTime, trLocation; | ||
163 | |||
164 | TextElement teDateTitle, teTimeTitle, teLocationTitle, teTopics, teNum, teTopicHeader, teResponsibleHeader, teTimeHeader, teAdditionalInformation, teMinutesFor, teDiscussion, teConclusion, teToDo, teResponsibleParty, teDeadline; | ||
165 | |||
166 | XTextRange trDateTitle, trTimeTitle, trLocationTitle, trTopics, trNum, trTopicHeader, trResponsibleHeader, trTimeHeader, trAdditionalInformation, trMinutesFor, trDiscussion, trConclusion, trToDo, trResponsibleParty, trDeadline; | ||
167 | |||
168 | List<TextElement> teTopicList = new ArrayList<TextElement>(); | ||
169 | List<TextElement> teResponsibleList = new ArrayList<TextElement>(); | ||
170 | List<TextElement> teTimeList = new ArrayList<TextElement>(); | ||
171 | List<XTextRange> trTopicList = new ArrayList<XTextRange>(); | ||
172 | List<XTextRange> trResponsibleList = new ArrayList<XTextRange>(); | ||
173 | List<XTextRange> trTimeList = new ArrayList<XTextRange>(); | ||
174 | |||
175 | /** | ||
176 | * used to format the date / time. | ||
177 | */ | ||
178 | int dateFormat, timeFormat; | ||
179 | XNumberFormatter dateFormatter, timeFormatter; | ||
180 | /** | ||
181 | * used to transfare time from VCL to UNO. | ||
182 | */ | ||
183 | long docNullTime; | ||
184 | Calendar calendar; | ||
185 | /** | ||
186 | * used to set the document title property (step 6). | ||
187 | */ | ||
188 | private XDocumentProperties m_xDocProps; | ||
189 | |||
190 | /** | ||
191 | * loads the given template, and analyze its structure. | ||
192 | * @param templateURL | ||
193 | * @param topics | ||
194 | * @see #initialize() | ||
195 | * @see #initializeData(List) | ||
196 | */ | ||
197 | public void clearConstants() | ||
198 | { | ||
199 | teDateTitle = null; | ||
200 | teTimeTitle = null; | ||
201 | teLocationTitle = null; | ||
202 | teTopics = null; | ||
203 | teNum = null; | ||
204 | teAdditionalInformation = null; | ||
205 | teMinutesFor = null; | ||
206 | teDiscussion = null; | ||
207 | teConclusion = null; | ||
208 | teToDo = null; | ||
209 | teResponsibleParty = null; | ||
210 | teDeadline = null; | ||
211 | trDateTitle = null; | ||
212 | trTimeTitle = null; | ||
213 | trLocationTitle = null; | ||
214 | trTopics = null; | ||
215 | trNum = null; | ||
216 | trAdditionalInformation = null; | ||
217 | trMinutesFor = null; | ||
218 | trDiscussion = null; | ||
219 | trConclusion = null; | ||
220 | trToDo = null; | ||
221 | trResponsibleParty = null; | ||
222 | trDeadline = null; | ||
223 | } | ||
224 | |||
225 | public void clearTopicConstants() | ||
226 | { | ||
227 | teTopicList.clear(); | ||
228 | teResponsibleList.clear(); | ||
229 | teTimeList.clear(); | ||
230 | |||
231 | trTopicList.clear(); | ||
232 | trResponsibleList.clear(); | ||
233 | trTimeList.clear(); | ||
234 | } | ||
235 | |||
236 | public synchronized void load(String templateURL, List<PropertyValue[]> topics) | ||
237 | { | ||
238 | template = calcTemplateName(templateURL); | ||
239 | document = loadAsPreview(templateURL, false); | ||
240 | docMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, document); | ||
241 | xFrame.getComponentWindow().setEnable(false); | ||
242 | xTextDocument.lockControllers(); | ||
243 | initialize(); | ||
244 | initializeData(topics); | ||
245 | xTextDocument.unlockControllers(); | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * The agenda templates are in format of aw-XXX.ott | ||
250 | * the templates name is then XXX.ott. | ||
251 | * This method calculates it. | ||
252 | * @param url | ||
253 | * @return the template name without the "aw-" at the beginning. | ||
254 | */ | ||
255 | private String calcTemplateName(String url) | ||
256 | { | ||
257 | return FileAccess.connectURLs(FileAccess.getParentDir(url), FileAccess.getFilename(url).substring(3)); | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * synchronize the document to the model.<br/> | ||
262 | * this method rewrites all titles, item tables , and the topics table- | ||
263 | * thus synchronizing the document to the data model (CGAgenda). | ||
264 | * @param topicsData since the model does not contain Topics | ||
265 | * information (it is only actualized on save) the given list | ||
266 | * supplies this information. | ||
267 | */ | ||
268 | private void initializeData(List<PropertyValue[]> topicsData) | ||
269 | { | ||
270 | //I had to decrease the limit by one, since it affects the | ||
271 | //#additional-information# tag for some reason. During the tests, | ||
272 | //it was working perfectly this way as well. | ||
273 | for (int i = 0; i < itemsTables.length - 1; i++) | ||
274 | { | ||
275 | try | ||
276 | { | ||
277 | itemsTables[i].write(PropertyNames.EMPTY_STRING); | ||
278 | } | ||
279 | catch (Exception ex) | ||
280 | { | ||
281 | ex.printStackTrace(); | ||
282 | } | ||
283 | } | ||
284 | redrawTitle("txtTitle"); | ||
285 | redrawTitle("txtDate"); | ||
286 | redrawTitle("txtTime"); | ||
287 | redrawTitle("cbLocation"); | ||
288 | |||
289 | topics.writeAll(topicsData); | ||
290 | |||
291 | setTemplateTitle(agenda.cp_TemplateName); | ||
292 | |||
293 | } | ||
294 | |||
295 | /** | ||
296 | * redraws/rewrites the table which contains the given item | ||
297 | * This method is called when the user checks/unchecks an item. | ||
298 | * The table is being found, in which the item is, and redrawn. | ||
299 | * @param itemName | ||
300 | */ | ||
301 | public synchronized void redraw(String itemName) | ||
302 | { | ||
303 | try | ||
304 | { | ||
305 | // get the table in which the item is... | ||
306 | Object itemsTable = | ||
307 | itemsMap.get(itemName); | ||
308 | // rewrite the table. | ||
309 | ((ItemsTable) itemsTable).write(null); | ||
310 | } | ||
311 | catch (Exception e) | ||
312 | { | ||
313 | e.printStackTrace(); | ||
314 | } | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * update the documents title property to the given title | ||
319 | * @param newTitle new title. | ||
320 | */ | ||
321 | synchronized void setTemplateTitle(String newTitle) | ||
322 | { | ||
323 | m_xDocProps.setTitle(newTitle); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * constructor. The document is *not* loaded here. | ||
328 | * only some formal members are set. | ||
329 | * @param xmsf_ service factory. | ||
330 | * @param agenda_ the data model (CGAgenda) | ||
331 | * @param resources_ resources. | ||
332 | */ | ||
333 | AgendaTemplate(XMultiServiceFactory xmsf_, CGAgenda agenda_, AgendaWizardDialogResources resources_, XTerminateListener listener) | ||
334 | { | ||
335 | super(xmsf_, listener, "WIZARD_LIVE_PREVIEW"); | ||
336 | |||
337 | agenda = agenda_; | ||
338 | resources = resources_; | ||
339 | |||
340 | if (itemsCache == null) | ||
341 | { | ||
342 | initItemsCache(); | ||
343 | } | ||
344 | _allItems.clear(); | ||
345 | constItems.clear(); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * checks the data model if the | ||
350 | * item corresponding to the given string should be shown | ||
351 | * @param itemName a string representing an Item (name or heading). | ||
352 | * @return true if the model specifies that the item should be displayed. | ||
353 | */ | ||
354 | boolean isShowItem(String itemName) | ||
355 | { | ||
356 | if (itemName.equals(FILLIN_MEETING_TYPE)) | ||
357 | { | ||
358 | return agenda.cp_ShowMeetingType; | ||
359 | } | ||
360 | else if (itemName.equals(FILLIN_READ)) | ||
361 | { | ||
362 | return agenda.cp_ShowRead; | ||
363 | } | ||
364 | else if (itemName.equals(FILLIN_BRING)) | ||
365 | { | ||
366 | return agenda.cp_ShowBring; | ||
367 | } | ||
368 | else if (itemName.equals(FILLIN_NOTES)) | ||
369 | { | ||
370 | return agenda.cp_ShowNotes; | ||
371 | } | ||
372 | else if (itemName.equals(FILLIN_FACILITATOR)) | ||
373 | { | ||
374 | return agenda.cp_ShowFacilitator; | ||
375 | } | ||
376 | else if (itemName.equals(FILLIN_TIMEKEEPER)) | ||
377 | { | ||
378 | return agenda.cp_ShowTimekeeper; | ||
379 | } | ||
380 | else if (itemName.equals(FILLIN_NOTETAKER)) | ||
381 | { | ||
382 | return agenda.cp_ShowNotetaker; | ||
383 | } | ||
384 | else if (itemName.equals(FILLIN_PARTICIPANTS)) | ||
385 | { | ||
386 | return agenda.cp_ShowAttendees; | ||
387 | } | ||
388 | else if (itemName.equals(FILLIN_CALLED_BY)) | ||
389 | { | ||
390 | return agenda.cp_ShowCalledBy; | ||
391 | } | ||
392 | else if (itemName.equals(FILLIN_OBSERVERS)) | ||
393 | { | ||
394 | return agenda.cp_ShowObservers; | ||
395 | } | ||
396 | else if (itemName.equals(FILLIN_RESOURCE_PERSONS)) | ||
397 | { | ||
398 | return agenda.cp_ShowResourcePersons; | ||
399 | } | ||
400 | else | ||
401 | { | ||
402 | throw new IllegalArgumentException("No such item"); | ||
403 | } | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * itemsCache is a Map containing all agenda item. These are object which | ||
408 | * "write themselfs" to the table, given a table cursor. | ||
409 | * A cache is used in order to reuse the objects, instead of recreate them. | ||
410 | * This method fills the cache will all items objects (names and headings). | ||
411 | */ | ||
412 | private void initItemsCache() | ||
413 | { | ||
414 | itemsCache = new HashMap<String, AgendaItem>(11); | ||
415 | |||
416 | XMultiServiceFactory xmsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, document); | ||
417 | // Headings | ||
418 | |||
419 | itemsCache.put(FILLIN_MEETING_TYPE, | ||
420 | new AgendaItem(FILLIN_MEETING_TYPE, new TextElement(resources.itemMeetingType, STYLE_MEETING_TYPE), | ||
421 | new PlaceholderElement(STYLE_MEETING_TYPE_TEXT, resources.reschkMeetingTitle_value, resources.resPlaceHolderHint, xmsf))); | ||
422 | |||
423 | itemsCache.put(FILLIN_BRING, | ||
424 | new AgendaItem(FILLIN_BRING, new TextElement(resources.itemBring, STYLE_BRING), | ||
425 | new PlaceholderElement(STYLE_BRING_TEXT, resources.reschkBring_value, resources.resPlaceHolderHint, xmsf))); | ||
426 | |||
427 | itemsCache.put(FILLIN_READ, | ||
428 | new AgendaItem(FILLIN_READ, new TextElement(resources.itemRead, STYLE_READ), | ||
429 | new PlaceholderElement(STYLE_READ_TEXT, resources.reschkRead_value, resources.resPlaceHolderHint, xmsf))); | ||
430 | |||
431 | itemsCache.put(FILLIN_NOTES, | ||
432 | new AgendaItem(FILLIN_NOTES, new TextElement(resources.itemNote, STYLE_NOTES), | ||
433 | new PlaceholderElement(STYLE_NOTES_TEXT, resources.reschkNotes_value, resources.resPlaceHolderHint, xmsf))); | ||
434 | |||
435 | // Names | ||
436 | |||
437 | itemsCache.put(FILLIN_CALLED_BY, | ||
438 | new AgendaItem(FILLIN_CALLED_BY, new TextElement(resources.itemCalledBy, STYLE_CALLED_BY), | ||
439 | new PlaceholderElement(STYLE_CALLED_BY_TEXT, resources.reschkConvenedBy_value, resources.resPlaceHolderHint, xmsf))); | ||
440 | |||
441 | itemsCache.put(FILLIN_FACILITATOR, | ||
442 | new AgendaItem(FILLIN_FACILITATOR, new TextElement(resources.itemFacilitator, STYLE_FACILITATOR), | ||
443 | new PlaceholderElement(STYLE_FACILITATOR_TEXT, resources.reschkPresiding_value, resources.resPlaceHolderHint, xmsf))); | ||
444 | |||
445 | itemsCache.put(FILLIN_PARTICIPANTS, | ||
446 | new AgendaItem(FILLIN_PARTICIPANTS, new TextElement(resources.itemAttendees, STYLE_PARTICIPANTS), | ||
447 | new PlaceholderElement(STYLE_PARTICIPANTS_TEXT, resources.reschkAttendees_value, resources.resPlaceHolderHint, xmsf))); | ||
448 | |||
449 | itemsCache.put(FILLIN_NOTETAKER, | ||
450 | new AgendaItem(FILLIN_NOTETAKER, new TextElement(resources.itemNotetaker, STYLE_NOTETAKER), | ||
451 | new PlaceholderElement(STYLE_NOTETAKER_TEXT, resources.reschkNoteTaker_value, resources.resPlaceHolderHint, xmsf))); | ||
452 | |||
453 | itemsCache.put(FILLIN_TIMEKEEPER, | ||
454 | new AgendaItem(FILLIN_TIMEKEEPER, new TextElement(resources.itemTimekeeper, STYLE_TIMEKEEPER), | ||
455 | new PlaceholderElement(STYLE_TIMEKEEPER_TEXT, resources.reschkTimekeeper_value, resources.resPlaceHolderHint, xmsf))); | ||
456 | |||
457 | itemsCache.put(FILLIN_OBSERVERS, | ||
458 | new AgendaItem(FILLIN_OBSERVERS, new TextElement(resources.itemObservers, STYLE_OBSERVERS), | ||
459 | new PlaceholderElement(STYLE_OBSERVERS_TEXT, resources.reschkObservers_value, resources.resPlaceHolderHint, xmsf))); | ||
460 | |||
461 | itemsCache.put(FILLIN_RESOURCE_PERSONS, | ||
462 | new AgendaItem(FILLIN_RESOURCE_PERSONS, new TextElement(resources.itemResource, STYLE_RESOURCE_PERSONS), | ||
463 | new PlaceholderElement(STYLE_RESOURCE_PERSONS_TEXT, resources.reschkResourcePersons_value, resources.resPlaceHolderHint, xmsf))); | ||
464 | |||
465 | } | ||
466 | |||
467 | /** | ||
468 | * Initializes a template.<br/> | ||
469 | * This method does the following tasks:<br/> | ||
470 | * Get a Time and Date format for the document, and retrieve the null date of the document (which is | ||
471 | * document-specific).<br/> | ||
472 | * Initializes the Items Cache map. | ||
473 | * Analyses the document:<br/> | ||
474 | * -find all "fille-ins" (apear as >xxx< in the document). | ||
475 | * -analyze all items sections (and the tables in them). | ||
476 | * -locate the titles and actualize them | ||
477 | * -analyze the topics table | ||
478 | */ | ||
479 | private void initialize() | ||
480 | { | ||
481 | /* | ||
482 | * Get the default locale of the document, and create the date and time formatters. | ||
483 | */ | ||
484 | XMultiServiceFactory docMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, document); | ||
485 | try | ||
486 | { | ||
487 | clearConstants(); | ||
488 | clearTopicConstants(); | ||
489 | |||
490 | Object defaults = docMSF.createInstance("com.sun.star.text.Defaults"); | ||
491 | Locale l = (Locale) Helper.getUnoStructValue(defaults, "CharLocale"); | ||
492 | |||
493 | java.util.Locale jl = new java.util.Locale( | ||
494 | l.Language, l.Country, l.Variant); | ||
495 | |||
496 | calendar = Calendar.getInstance(jl); | ||
497 | |||
498 | XNumberFormatsSupplier nfs = UnoRuntime.queryInterface(XNumberFormatsSupplier.class, document); | ||
499 | Object formatSettings = nfs.getNumberFormatSettings(); | ||
500 | com.sun.star.util.Date date = (com.sun.star.util.Date) Helper.getUnoPropertyValue(formatSettings, "NullDate"); | ||
501 | |||
502 | calendar.set(date.Year, date.Month - 1, date.Day); | ||
503 | |||
504 | docNullTime = JavaTools.getTimeInMillis(calendar); | ||
505 | |||
506 | dateFormat = NumberFormatter.getNumberFormatterKey(nfs, NumberFormatIndex.DATE_SYSTEM_LONG); | ||
507 | timeFormat = NumberFormatter.getNumberFormatterKey(nfs, NumberFormatIndex.TIME_HHMM); | ||
508 | |||
509 | |||
510 | dateFormatter = NumberFormatter.createNumberFormatter(xMSF, nfs); | ||
511 | timeFormatter = NumberFormatter.createNumberFormatter(xMSF, nfs); | ||
512 | } | ||
513 | catch (Exception ex) | ||
514 | { | ||
515 | ex.printStackTrace(); | ||
516 | throw new NullPointerException("Fatal Error: could not initialize locale or date/time formats."); | ||
517 | } | ||
518 | |||
519 | /* | ||
520 | * get the document properties object. | ||
521 | */ | ||
522 | m_xDocProps = OfficeDocument.getDocumentProperties(document); | ||
523 | |||
524 | initItemsCache(); | ||
525 | initializeItems(); | ||
526 | initializeTitles(); | ||
527 | initializeConstantTitles(); | ||
528 | initializeConstantTopicTitles(); | ||
529 | initializeItemsSections(); | ||
530 | XMultiServiceFactory xMultiServiceFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, document); | ||
531 | textSectionHandler = new TextSectionHandler(xMultiServiceFactory, UnoRuntime.queryInterface(XTextDocument.class, document)); | ||
532 | initializeTopics(); | ||
533 | |||
534 | drawConstants(); | ||
535 | drawTopicConstants(); | ||
536 | |||
537 | _allItems.clear(); | ||
538 | constItems.clear(); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * locates the titles (name, location, date, time) and saves a reference to thier Text ranges. | ||
543 | * | ||
544 | */ | ||
545 | private void initializeTitles() | ||
546 | { | ||
547 | XTextRange item = null; | ||
548 | |||
549 | XMultiServiceFactory xmsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, document); | ||
550 | |||
551 | for (int i = 0; i < _allItems.size(); i++) | ||
552 | { | ||
553 | item = _allItems.get(i); | ||
554 | String text = item.getString().trim().toLowerCase(); | ||
555 | if (text.equals(FILLIN_TITLE)) | ||
556 | { | ||
557 | |||
558 | teTitle = new PlaceholderTextElement(item, resources.resPlaceHolderTitle, resources.resPlaceHolderHint, xmsf); | ||
559 | trTitle = item; | ||
560 | _allItems.remove(i--); | ||
561 | } | ||
562 | else if (text.equals(FILLIN_DATE)) | ||
563 | { | ||
564 | teDate = new PlaceholderTextElement(item, resources.resPlaceHolderDate, resources.resPlaceHolderHint, xmsf); | ||
565 | trDate = item; | ||
566 | _allItems.remove(i--); | ||
567 | } | ||
568 | else if (text.equals(FILLIN_TIME)) | ||
569 | { | ||
570 | teTime = new PlaceholderTextElement(item, resources.resPlaceHolderTime, resources.resPlaceHolderHint, xmsf); | ||
571 | trTime = item; | ||
572 | _allItems.remove(i--); | ||
573 | } | ||
574 | else if (text.equals(FILLIN_LOCATION)) | ||
575 | { | ||
576 | teLocation = new PlaceholderTextElement(item, resources.resPlaceHolderLocation, resources.resPlaceHolderHint, xmsf); | ||
577 | trLocation = item; | ||
578 | _allItems.remove(i--); | ||
579 | } | ||
580 | } | ||
581 | } | ||
582 | private void initializeConstantTitles() | ||
583 | { | ||
584 | XTextRange item = null; | ||
585 | |||
586 | XMultiServiceFactory xmsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, document); | ||
587 | |||
588 | for (int i = 0; i < constItems.size(); i++) | ||
589 | { | ||
590 | item = constItems.get(i); | ||
591 | String text = item.getString().trim().toLowerCase(); | ||
592 | if (text.equals(FILLIN_DATETITLE)) | ||
593 | { | ||
594 | teDateTitle = new PlaceholderTextElement(item, resources.resPlaceHolderDateTitle, resources.resPlaceHolderHint, xmsf); | ||
595 | trDateTitle = item; | ||
596 | constItems.remove(i--); | ||
597 | } | ||
598 | else if (text.equals(FILLIN_TIMETITLE)) | ||
599 | { | ||
600 | teTimeTitle = new PlaceholderTextElement(item, resources.resPlaceHolderTimeTitle, resources.resPlaceHolderHint, xmsf); | ||
601 | trTimeTitle = item; | ||
602 | constItems.remove(i--); | ||
603 | } | ||
604 | else if (text.equals(FILLIN_LOCATIONTITLE)) | ||
605 | { | ||
606 | teLocationTitle = new PlaceholderTextElement(item, resources.resPlaceHolderLocationTitle, resources.resPlaceHolderHint, xmsf); | ||
607 | trLocationTitle = item; | ||
608 | constItems.remove(i--); | ||
609 | } | ||
610 | else if (text.equals(FILLIN_TOPICS)) | ||
611 | { | ||
612 | teTopics = new PlaceholderTextElement(item, resources.resPlaceHolderTopics, resources.resPlaceHolderHint, xmsf); | ||
613 | trTopics = item; | ||
614 | constItems.remove(i--); | ||
615 | } | ||
616 | else if (text.equals(FILLIN_NUM)) | ||
617 | { | ||
618 | teNum = new PlaceholderTextElement(item, resources.resPlaceHolderNum, resources.resPlaceHolderHint, xmsf); | ||
619 | trNum = item; | ||
620 | constItems.remove(i--); | ||
621 | } | ||
622 | else if (text.equals(FILLIN_ADDITIONAL_INFORMATION)) | ||
623 | { | ||
624 | teAdditionalInformation = new PlaceholderTextElement(item, resources.resPlaceHolderAdditionalInformation, resources.resPlaceHolderHint, xmsf); | ||
625 | trAdditionalInformation = item; | ||
626 | constItems.remove(i--); | ||
627 | } | ||
628 | else if (text.equals(FILLIN_MINUTES_FOR)) | ||
629 | { | ||
630 | teMinutesFor = new PlaceholderTextElement(item, resources.resPlaceHolderMinutesFor, resources.resPlaceHolderHint, xmsf); | ||
631 | trMinutesFor = item; | ||
632 | constItems.remove(i--); | ||
633 | } | ||
634 | else if (text.equals(FILLIN_DISCUSSION)) | ||
635 | { | ||
636 | teDiscussion = new PlaceholderTextElement(item, resources.resPlaceHolderDiscussion, resources.resPlaceHolderHint, xmsf); | ||
637 | trDiscussion = item; | ||
638 | constItems.remove(i--); | ||
639 | } | ||
640 | else if (text.equals(FILLIN_CONCLUSION)) | ||
641 | { | ||
642 | teConclusion = new PlaceholderTextElement(item, resources.resPlaceHolderConclusion, resources.resPlaceHolderHint, xmsf); | ||
643 | trConclusion = item; | ||
644 | constItems.remove(i--); | ||
645 | } | ||
646 | else if (text.equals(FILLIN_TO_DO)) | ||
647 | { | ||
648 | teToDo = new PlaceholderTextElement(item, resources.resPlaceHolderToDo, resources.resPlaceHolderHint, xmsf); | ||
649 | trToDo = item; | ||
650 | constItems.remove(i--); | ||
651 | } | ||
652 | else if (text.equals(FILLIN_RESPONSIBLE_PARTY)) | ||
653 | { | ||
654 | teResponsibleParty = new PlaceholderTextElement(item, resources.resPlaceHolderResponsibleParty, resources.resPlaceHolderHint, xmsf); | ||
655 | trResponsibleParty = item; | ||
656 | constItems.remove(i--); | ||
657 | } | ||
658 | else if (text.equals(FILLIN_DEADLINE)) | ||
659 | { | ||
660 | teDeadline = new PlaceholderTextElement(item, resources.resPlaceHolderDeadline, resources.resPlaceHolderHint, xmsf); | ||
661 | trDeadline = item; | ||
662 | constItems.remove(i--); | ||
663 | } | ||
664 | } | ||
665 | } | ||
666 | |||
667 | private void initializeConstantTopicTitles() | ||
668 | { | ||
669 | XTextRange item = null; | ||
670 | |||
671 | XMultiServiceFactory xmsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, document); | ||
672 | |||
673 | for (int i = 0; i < constItems.size(); i++) | ||
674 | { | ||
675 | item = constItems.get(i); | ||
676 | String text = item.getString().trim().toLowerCase(); | ||
677 | |||
678 | if (text.equals(FILLIN_TOPIC)) | ||
679 | { | ||
680 | teTopicHeader = new PlaceholderTextElement(item, resources.resPlaceHolderTopic, resources.resPlaceHolderHint, xmsf); | ||
681 | trTopicHeader = item; | ||
682 | |||
683 | teTopicList.add(teTopicHeader); | ||
684 | trTopicList.add(trTopicHeader); | ||
685 | |||
686 | constItems.remove(i--); | ||
687 | } | ||
688 | else if (text.equals(FILLIN_RESPONSIBLE)) | ||
689 | { | ||
690 | teResponsibleHeader = new PlaceholderTextElement(item, resources.resPlaceHolderResponsible, resources.resPlaceHolderHint, xmsf); | ||
691 | trResponsibleHeader = item; | ||
692 | |||
693 | teResponsibleList.add(teResponsibleHeader); | ||
694 | trResponsibleList.add(trResponsibleHeader); | ||
695 | |||
696 | constItems.remove(i--); | ||
697 | } | ||
698 | else if (text.equals(FILLIN_TIME_HEADER)) | ||
699 | { | ||
700 | teTimeHeader = new PlaceholderTextElement(item, resources.resPlaceHolderTime, resources.resPlaceHolderHint, xmsf); | ||
701 | trTimeHeader = item; | ||
702 | |||
703 | teTimeList.add(teTimeHeader); | ||
704 | trTimeList.add(trTimeHeader); | ||
705 | |||
706 | constItems.remove(i--); | ||
707 | } | ||
708 | } | ||
709 | } | ||
710 | |||
711 | private void initializeTopics() | ||
712 | { | ||
713 | topics = new Topics(); | ||
714 | } | ||
715 | |||
716 | public void refreshTopicConstants() | ||
717 | { | ||
718 | constItems = searchFillInItems(1); | ||
719 | clearConstants(); | ||
720 | initializeConstantTopicTitles(); | ||
721 | drawTopicConstants(); | ||
722 | } | ||
723 | |||
724 | public void refreshConstants() | ||
725 | { | ||
726 | constItems = searchFillInItems(1); | ||
727 | clearTopicConstants(); | ||
728 | initializeConstantTitles(); | ||
729 | drawConstants(); | ||
730 | } | ||
731 | |||
732 | private void initializeItems() | ||
733 | { | ||
734 | _allItems = searchFillInItems(0); | ||
735 | constItems = searchFillInItems(1); | ||
736 | } | ||
737 | |||
738 | /** | ||
739 | * searches the document for items in the format ">*<" | ||
740 | * @return a vector containing the XTextRanges of the found items | ||
741 | */ | ||
742 | private List<XTextRange> searchFillInItems(int type) | ||
743 | { | ||
744 | try | ||
745 | { | ||
746 | XSearchable xSearchable = UnoRuntime.queryInterface(XSearchable.class, document); | ||
747 | XSearchDescriptor sd = xSearchable.createSearchDescriptor(); | ||
748 | if(type == 0) | ||
749 | { | ||
750 | sd.setSearchString("<[^>]+>"); | ||
751 | } | ||
752 | else if(type == 1) | ||
753 | { | ||
754 | sd.setSearchString("#[^#]+#"); | ||
755 | } | ||
756 | sd.setPropertyValue("SearchRegularExpression", Boolean.TRUE); | ||
757 | sd.setPropertyValue("SearchWords", Boolean.TRUE); | ||
758 | |||
759 | XIndexAccess ia = xSearchable.findAll(sd); | ||
760 | |||
761 | List<XTextRange> l = new ArrayList<XTextRange>(ia.getCount()); | ||
762 | for (int i = 0; i < ia.getCount(); i++) | ||
763 | { | ||
764 | try | ||
765 | { | ||
766 | l.add(UnoRuntime.queryInterface(XTextRange.class, ia.getByIndex(i))); | ||
767 | } | ||
768 | catch (Exception ex) | ||
769 | { | ||
770 | System.err.println("Nonfatal Error in finding fillins."); | ||
771 | } | ||
772 | } | ||
773 | return l; | ||
774 | } | ||
775 | catch (Exception ex) | ||
776 | { | ||
777 | ex.printStackTrace(); | ||
778 | throw new IllegalArgumentException("Fatal Error: Loading template failed: searching fillins failed"); | ||
779 | } | ||
780 | } | ||
781 | |||
782 | /** | ||
783 | * analyze the item sections in the template. delegates the analyze of each table to the | ||
784 | * ItemsTable class. | ||
785 | */ | ||
786 | private void initializeItemsSections() | ||
787 | { | ||
788 | String[] sections = getSections(document, TemplateConsts.SECTION_ITEMS); | ||
789 | |||
790 | // for each section - there is a table... | ||
791 | itemsTables = new ItemsTable[sections.length]; | ||
792 | |||
793 | for (int i = 0; i < itemsTables.length; i++) | ||
794 | { | ||
795 | try | ||
796 | { | ||
797 | itemsTables[i] = new ItemsTable(getSection(sections[i]), getTable(sections[i])); | ||
798 | } | ||
799 | catch (Exception ex) | ||
800 | { | ||
801 | ex.printStackTrace(); | ||
802 | throw new IllegalArgumentException("Fatal Error while initialilzing Template: items table in section " + sections[i]); | ||
803 | } | ||
804 | } | ||
805 | |||
806 | } | ||
807 | |||
808 | private String[] getSections(Object document, String s) | ||
809 | { | ||
810 | XTextSectionsSupplier xTextSectionsSupplier = UnoRuntime.queryInterface(XTextSectionsSupplier.class, document); | ||
811 | String[] allSections = xTextSectionsSupplier.getTextSections().getElementNames(); | ||
812 | return getNamesWhichStartWith(allSections, s); | ||
813 | } | ||
814 | |||
815 | Object getSection(String name) throws NoSuchElementException, WrappedTargetException | ||
816 | { | ||
817 | XTextSectionsSupplier xTextSectionsSupplier = UnoRuntime.queryInterface(XTextSectionsSupplier.class, document); | ||
818 | return ((Any) (xTextSectionsSupplier.getTextSections().getByName(name))).getObject(); | ||
819 | } | ||
820 | |||
821 | Object getTable(String name) throws NoSuchElementException, WrappedTargetException | ||
822 | { | ||
823 | XTextTablesSupplier xTextTablesSupplier = UnoRuntime.queryInterface(XTextTablesSupplier.class, document); | ||
824 | return ((Any) xTextTablesSupplier.getTextTables().getByName(name)).getObject(); | ||
825 | } | ||
826 | |||
827 | /** | ||
828 | * implementation of DataAware.Listener, is | ||
829 | * called when title/date/time or location are | ||
830 | * changed. | ||
831 | */ | ||
832 | public synchronized void eventPerformed(Object param) | ||
833 | { | ||
834 | TextEvent te = (TextEvent) param; | ||
835 | String controlName = (String) Helper.getUnoPropertyValue( | ||
836 | UnoDialog2.getModel(te.Source), | ||
837 | PropertyNames.PROPERTY_NAME); | ||
838 | redrawTitle(controlName); | ||
839 | } | ||
840 | |||
841 | private synchronized void redrawTitle(String controlName) | ||
842 | { | ||
843 | if (controlName.equals("txtTitle")) | ||
844 | { | ||
845 | writeTitle(teTitle, trTitle, agenda.cp_Title); | ||
846 | } | ||
847 | else if (controlName.equals("txtDate")) | ||
848 | { | ||
849 | writeTitle(teDate, trDate, getDateString(agenda.cp_Date)); | ||
850 | } | ||
851 | else if (controlName.equals("txtTime")) | ||
852 | { | ||
853 | writeTitle(teTime, trTime, getTimeString(agenda.cp_Time)); | ||
854 | } | ||
855 | else if (controlName.equals("cbLocation")) | ||
856 | { | ||
857 | writeTitle(teLocation, trLocation, agenda.cp_Location); | ||
858 | } | ||
859 | else | ||
860 | { | ||
861 | throw new IllegalArgumentException("No such title control..."); | ||
862 | } | ||
863 | } | ||
864 | |||
865 | public void drawConstants() | ||
866 | { | ||
867 | if(teDateTitle != null){ | ||
868 | writeTitle(teDateTitle, trDateTitle, resources.resPlaceHolderDateTitle); | ||
869 | } | ||
870 | if(teTimeTitle != null){ | ||
871 | writeTitle(teTimeTitle, trTimeTitle, resources.resPlaceHolderTimeTitle); | ||
872 | } | ||
873 | if(teLocationTitle != null){ | ||
874 | writeTitle(teLocationTitle, trLocationTitle, resources.resPlaceHolderLocationTitle); | ||
875 | } | ||
876 | if(teTopics != null){ | ||
877 | writeTitle(teTopics, trTopics, resources.resPlaceHolderTopics); | ||
878 | } | ||
879 | if(teNum != null){ | ||
880 | writeTitle(teNum, trNum, resources.resPlaceHolderNum); | ||
881 | } | ||
882 | if(teAdditionalInformation != null){ | ||
883 | writeTitle(teAdditionalInformation, trAdditionalInformation, resources.resPlaceHolderAdditionalInformation); | ||
884 | } | ||
885 | if(teMinutesFor != null){ | ||
886 | writeTitle(teMinutesFor, trMinutesFor, resources.resPlaceHolderMinutesFor); | ||
887 | } | ||
888 | if(teDiscussion != null){ | ||
889 | writeTitle(teDiscussion, trDiscussion, resources.resPlaceHolderDiscussion); | ||
890 | } | ||
891 | if(teConclusion != null){ | ||
892 | writeTitle(teConclusion, trConclusion, resources.resPlaceHolderConclusion); | ||
893 | } | ||
894 | if(teToDo != null){ | ||
895 | writeTitle(teToDo, trToDo, resources.resPlaceHolderToDo); | ||
896 | } | ||
897 | if(teResponsibleParty != null){ | ||
898 | writeTitle(teResponsibleParty, trResponsibleParty, resources.resPlaceHolderResponsibleParty); | ||
899 | } | ||
900 | if(teDeadline != null){ | ||
901 | writeTitle(teDeadline, trDeadline, resources.resPlaceHolderDeadline); | ||
902 | } | ||
903 | } | ||
904 | |||
905 | public void drawTopicConstants() | ||
906 | { | ||
907 | if(teTopicList != null){ | ||
908 | for(int i=0; i<teTopicList.size(); ++i){ | ||
909 | writeTitle(teTopicList.get(i), trTopicList.get(i), resources.resPlaceHolderTopic); | ||
910 | } | ||
911 | } | ||
912 | if(teResponsibleList != null){ | ||
913 | for(int i=0; i<teResponsibleList.size(); ++i){ | ||
914 | writeTitle(teResponsibleList.get(i), trResponsibleList.get(i), resources.resPlaceHolderResponsible); | ||
915 | } | ||
916 | } | ||
917 | if(teTimeList != null){ | ||
918 | for(int i=0; i<teTimeList.size(); ++i){ | ||
919 | writeTitle(teTimeList.get(i), trTimeList.get(i), resources.resPlaceHolderTimeHeader); | ||
920 | } | ||
921 | } | ||
922 | } | ||
923 | |||
924 | private void writeTitle(TextElement te, XTextRange tr, String text) | ||
925 | { | ||
926 | te.text = (text == null ? PropertyNames.EMPTY_STRING : text); | ||
927 | te.write(tr); | ||
928 | } | ||
929 | private static long DAY_IN_MILLIS = (24 * 60 * 60 * 1000); | ||
930 | |||
931 | private String getDateString(String d) | ||
932 | { | ||
933 | if (d == null || d.equals(PropertyNames.EMPTY_STRING)) | ||
934 | { | ||
935 | return PropertyNames.EMPTY_STRING; | ||
936 | } | ||
937 | int date = Integer.parseInt(d); | ||
938 | calendar.clear(); | ||
939 | calendar.set(date / 10000, | ||
940 | (date % 10000) / 100 - 1, | ||
941 | date % 100); | ||
942 | |||
943 | long date1 = JavaTools.getTimeInMillis(calendar); | ||
944 | /* | ||
945 | * docNullTime and date1 are in millis, but | ||
946 | * I need a day... | ||
947 | */ | ||
948 | double daysDiff = (date1 - docNullTime) / DAY_IN_MILLIS + 1; | ||
949 | |||
950 | return dateFormatter.convertNumberToString(dateFormat, daysDiff); | ||
951 | } | ||
952 | |||
953 | private String getTimeString(String s) | ||
954 | { | ||
955 | if (s == null || s.equals(PropertyNames.EMPTY_STRING)) | ||
956 | { | ||
957 | return PropertyNames.EMPTY_STRING; | ||
958 | } | ||
959 | int time = Integer.parseInt(s); | ||
960 | |||
961 | double t = ((double) (time / 1000000) / 24) + ((double) ((time % 1000000) / 1000) / (24 * 60)); | ||
962 | return timeFormatter.convertNumberToString(timeFormat, t); | ||
963 | } | ||
964 | |||
965 | /* ******************************************* | ||
966 | * F I N I S H | ||
967 | *********************************************/ | ||
968 | /** the user clicked finish **/ | ||
969 | public synchronized void finish(List<PropertyValue[]> topics) | ||
970 | { | ||
971 | createMinutes(topics); | ||
972 | deleteHiddenSections(); | ||
973 | textSectionHandler.removeAllTextSections(); | ||
974 | } | ||
975 | |||
976 | /** | ||
977 | * hidden sections exist when an item's section is hidden because the | ||
978 | * user specified not to display any items which it contains. | ||
979 | * When finishing the wizard removes this sections entireley from the document. | ||
980 | */ | ||
981 | private void deleteHiddenSections() | ||
982 | { | ||
983 | XTextSectionsSupplier xTextSectionsSupplier = UnoRuntime.queryInterface(XTextSectionsSupplier.class, document); | ||
984 | String[] allSections = xTextSectionsSupplier.getTextSections().getElementNames(); | ||
985 | try | ||
986 | { | ||
987 | for (int i = 0; i < allSections.length; i++) | ||
988 | { | ||
989 | Object section = getSection(allSections[i]); | ||
990 | boolean visible = ((Boolean) Helper.getUnoPropertyValue(section, "IsVisible")).booleanValue(); | ||
991 | if (!visible) | ||
992 | { | ||
993 | UnoRuntime.queryInterface(XTextContent.class, section).getAnchor().setString(PropertyNames.EMPTY_STRING); | ||
994 | } | ||
995 | } | ||
996 | } | ||
997 | catch (Exception ex) | ||
998 | { | ||
999 | ex.printStackTrace(); | ||
1000 | } | ||
1001 | } | ||
1002 | |||
1003 | /** | ||
1004 | * create the minutes for the given topics or remove the minutes section from the document. | ||
1005 | * If no topics are supplied, or the user | ||
1006 | * specified not to create minuts, the minutes section will be removed, | ||
1007 | * @param topicsData supplies PropertyValue arrays containing the values for the topics. | ||
1008 | */ | ||
1009 | public synchronized void createMinutes(List<PropertyValue[]> topicsData) | ||
1010 | { | ||
1011 | |||
1012 | // if the minutes section should be removed (the | ||
1013 | // user did not check "create minutes") | ||
1014 | if (!agenda.cp_IncludeMinutes || (topicsData.size() <= 1)) | ||
1015 | { | ||
1016 | try | ||
1017 | { | ||
1018 | Object minutesAllSection = getSection(SECTION_MINUTES_ALL); | ||
1019 | XTextSection xTextSection = UnoRuntime.queryInterface(XTextSection.class, minutesAllSection); | ||
1020 | xTextSection.getAnchor().setString(PropertyNames.EMPTY_STRING); | ||
1021 | } | ||
1022 | catch (Exception ex) | ||
1023 | { | ||
1024 | ex.printStackTrace(); | ||
1025 | } | ||
1026 | } | ||
1027 | // the user checked "create minutes" | ||
1028 | else | ||
1029 | { | ||
1030 | try | ||
1031 | { | ||
1032 | String itemText; | ||
1033 | XTextRange item; | ||
1034 | int topicStartTime = 0; | ||
1035 | try | ||
1036 | { | ||
1037 | topicStartTime = Integer.parseInt(agenda.cp_Time); | ||
1038 | } | ||
1039 | catch (Exception ex) | ||
1040 | { | ||
1041 | } | ||
1042 | |||
1043 | String time; | ||
1044 | |||
1045 | // first I replace the minutes titles... | ||
1046 | List<XTextRange> items = searchFillInItems(0); | ||
1047 | for (int itemIndex = 0; itemIndex < items.size(); itemIndex++) | ||
1048 | { | ||
1049 | item = items.get(itemIndex); | ||
1050 | itemText = item.getString().trim().toLowerCase(); | ||
1051 | |||
1052 | if (itemText.equals(FILLIN_MINUTES_TITLE)) | ||
1053 | { | ||
1054 | fillMinutesItem(item, agenda.cp_Title, resources.resPlaceHolderTitle); | ||
1055 | } | ||
1056 | else if (itemText.equals(FILLIN_MINUTES_LOCATION)) | ||
1057 | { | ||
1058 | fillMinutesItem(item, agenda.cp_Location, resources.resPlaceHolderLocation); | ||
1059 | } | ||
1060 | else if (itemText.equals(FILLIN_MINUTES_DATE)) | ||
1061 | { | ||
1062 | fillMinutesItem(item, getDateString(agenda.cp_Date), resources.resPlaceHolderDate); | ||
1063 | } | ||
1064 | else if (itemText.equals(FILLIN_MINUTES_TIME)) | ||
1065 | { | ||
1066 | fillMinutesItem(item, getTimeString(agenda.cp_Time), resources.resPlaceHolderTime); | ||
1067 | } | ||
1068 | |||
1069 | } | ||
1070 | |||
1071 | items.clear(); | ||
1072 | |||
1073 | /* | ||
1074 | * now add minutes for each topic. | ||
1075 | * The template contains *one* minutes section, so | ||
1076 | * we first use the one available, and then add a new one... | ||
1077 | * | ||
1078 | * topics data has *always* an empty topic at the end... | ||
1079 | */ | ||
1080 | for (int i = 0; i < topicsData.size() - 1; i++) | ||
1081 | { | ||
1082 | PropertyValue[] topic = topicsData.get(i); | ||
1083 | |||
1084 | items = searchFillInItems(0); | ||
1085 | for (int itemIndex = 0; itemIndex < items.size(); itemIndex++) | ||
1086 | { | ||
1087 | item = items.get(itemIndex); | ||
1088 | itemText = item.getString().trim().toLowerCase(); | ||
1089 | |||
1090 | if (itemText.equals(FILLIN_MINUTE_NUM)) | ||
1091 | { | ||
1092 | fillMinutesItem(item, topic[0].Value, PropertyNames.EMPTY_STRING); | ||
1093 | } | ||
1094 | else if (itemText.equals(FILLIN_MINUTE_TOPIC)) | ||
1095 | { | ||
1096 | fillMinutesItem(item, topic[1].Value, PropertyNames.EMPTY_STRING); | ||
1097 | } | ||
1098 | else if (itemText.equals(FILLIN_MINUTE_RESPONSIBLE)) | ||
1099 | { | ||
1100 | fillMinutesItem(item, topic[2].Value, PropertyNames.EMPTY_STRING); | ||
1101 | } | ||
1102 | else if (itemText.equals(FILLIN_MINUTE_TIME)) | ||
1103 | { | ||
1104 | int topicTime = 0; | ||
1105 | |||
1106 | try | ||
1107 | { | ||
1108 | topicTime = (new Integer((String) topic[3].Value)).intValue(); | ||
1109 | } | ||
1110 | catch (Exception ex) | ||
1111 | { | ||
1112 | } | ||
1113 | // if the topic has no time, we do not display any time here. | ||
1114 | if (topicTime == 0 || topicStartTime == 0) | ||
1115 | { | ||
1116 | time = (String) topic[3].Value; | ||
1117 | } | ||
1118 | else | ||
1119 | { | ||
1120 | time = getTimeString(String.valueOf(topicStartTime)) + " - "; | ||
1121 | topicStartTime += topicTime * 1000; | ||
1122 | time += getTimeString(String.valueOf(topicStartTime)); | ||
1123 | } | ||
1124 | fillMinutesItem(item, time, PropertyNames.EMPTY_STRING); | ||
1125 | } | ||
1126 | } | ||
1127 | |||
1128 | textSectionHandler.removeTextSectionbyName(SECTION_MINUTES); | ||
1129 | |||
1130 | // after the last section we do not insert a new one. | ||
1131 | if (i < topicsData.size() - 2) | ||
1132 | { | ||
1133 | textSectionHandler.insertTextSection(SECTION_MINUTES, template, false); | ||
1134 | } | ||
1135 | } | ||
1136 | } | ||
1137 | catch (Exception ex) | ||
1138 | { | ||
1139 | ex.printStackTrace(); | ||
1140 | } | ||
1141 | } | ||
1142 | } | ||
1143 | |||
1144 | /** | ||
1145 | * given a text range and a text, fills the given | ||
1146 | * text range with the given text. | ||
1147 | * If the given text is empty, uses a placeholder with the giveb placeholder text. | ||
1148 | * @param range text range to fill | ||
1149 | * @param text the text to fill to the text range object. | ||
1150 | * @param placeholder the placeholder text to use, if the text argument is empty (null or PropertyNames.EMPTY_STRING) | ||
1151 | */ | ||
1152 | private void fillMinutesItem(XTextRange range, Object text, String placeholder) | ||
1153 | { | ||
1154 | String paraStyle = (String) Helper.getUnoPropertyValue(range, "ParaStyleName"); | ||
1155 | range.setString((String) text); | ||
1156 | Helper.setUnoPropertyValue(range, "ParaStyleName", paraStyle); | ||
1157 | if (text == null || text.equals(PropertyNames.EMPTY_STRING)) | ||
1158 | { | ||
1159 | if (placeholder != null && !placeholder.equals(PropertyNames.EMPTY_STRING)) | ||
1160 | { | ||
1161 | XTextContent placeHolder = createPlaceHolder(docMSF, placeholder, resources.resPlaceHolderHint); | ||
1162 | try | ||
1163 | { | ||
1164 | range.getStart().getText().insertTextContent(range.getStart(), placeHolder, true); | ||
1165 | } | ||
1166 | catch (Exception ex) | ||
1167 | { | ||
1168 | ex.printStackTrace(); | ||
1169 | } | ||
1170 | } | ||
1171 | |||
1172 | } | ||
1173 | } | ||
1174 | |||
1175 | /** | ||
1176 | * creates a placeholder field with the given text and given hint. | ||
1177 | * @param xmsf service factory | ||
1178 | * @param ph place holder text | ||
1179 | * @param hint hint text | ||
1180 | * @return the place holder field. | ||
1181 | */ | ||
1182 | public static XTextContent createPlaceHolder(XMultiServiceFactory xmsf, String ph, String hint) | ||
1183 | { | ||
1184 | Object placeHolder; | ||
1185 | try | ||
1186 | { | ||
1187 | placeHolder = xmsf.createInstance("com.sun.star.text.TextField.JumpEdit"); | ||
1188 | } | ||
1189 | catch (Exception ex) | ||
1190 | { | ||
1191 | ex.printStackTrace(); | ||
1192 | return null; | ||
1193 | } | ||
1194 | Helper.setUnoPropertyValue(placeHolder, "PlaceHolder", ph); | ||
1195 | Helper.setUnoPropertyValue(placeHolder, "Hint", hint); | ||
1196 | Helper.setUnoPropertyValue(placeHolder, "PlaceHolderType", new Short(PlaceholderType.TEXT)); | ||
1197 | return UnoRuntime.queryInterface(XTextContent.class, placeHolder); | ||
1198 | |||
1199 | } | ||
1200 | |||
1201 | /* | ||
1202 | * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ | ||
1203 | * ================================= | ||
1204 | * The ItemTable class | ||
1205 | * ================================= | ||
1206 | * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ | ||
1207 | */ | ||
1208 | public class ItemsTable | ||
1209 | { | ||
1210 | |||
1211 | Object table; | ||
1212 | Object section; | ||
1213 | /** | ||
1214 | * the items in the table. | ||
1215 | */ | ||
1216 | List<AgendaItem> items = new ArrayList<AgendaItem>(6); | ||
1217 | |||
1218 | public ItemsTable(Object section_, Object table_) | ||
1219 | { | ||
1220 | |||
1221 | table = table_; | ||
1222 | section = section_; | ||
1223 | |||
1224 | AgendaItem ai; | ||
1225 | XTextRange item; | ||
1226 | String iText; | ||
1227 | |||
1228 | /* go through all <*> items in the document | ||
1229 | * and each one if it is in this table. | ||
1230 | * If they are, register them to belong here, notice their order | ||
1231 | * and remove them from the list of all <*> items, so the next | ||
1232 | * search will be faster. | ||
1233 | */ | ||
1234 | for (int i = 0; i < _allItems.size(); i++) | ||
1235 | { | ||
1236 | item = _allItems.get(i); | ||
1237 | Object t = Helper.getUnoPropertyValue(item, "TextTable"); | ||
1238 | if ((t instanceof Any) && ((Any) t).getObject() == table) | ||
1239 | { | ||
1240 | iText = item.getString().toLowerCase().trim(); | ||
1241 | ai = itemsCache.get(item.getString().toLowerCase().trim()); | ||
1242 | if (ai != null) | ||
1243 | { | ||
1244 | items.add(ai); | ||
1245 | _allItems.remove(i--); | ||
1246 | itemsMap.put(iText, this); | ||
1247 | } | ||
1248 | } | ||
1249 | } | ||
1250 | |||
1251 | } | ||
1252 | |||
1253 | /** | ||
1254 | * link the section to the template. this will restore the original table | ||
1255 | * with all the items.<br/> | ||
1256 | * then break the link, to make the section editable.<br/> | ||
1257 | * then, starting at cell one, write all items that should be visible. | ||
1258 | * then clear the rest and remove obsolete rows. | ||
1259 | * If no items are visible, hide the section. | ||
1260 | * @param dummy we need a param to make this an Implementation of AgendaElement. | ||
1261 | * @throws Exception | ||
1262 | */ | ||
1263 | public synchronized void write(Object dummy) throws Exception | ||
1264 | { | ||
1265 | synchronized(this) | ||
1266 | { | ||
1267 | String name = getName(section); | ||
1268 | |||
1269 | // link and unlink the section to the template. | ||
1270 | textSectionHandler.linkSectiontoTemplate(section, template, name); | ||
1271 | textSectionHandler.breakLinkOfTextSection(section); | ||
1272 | |||
1273 | // we need to get a new instance after linking. | ||
1274 | table = getTable(name); | ||
1275 | section = getSection(name); | ||
1276 | |||
1277 | XTextTable xTextTable = UnoRuntime.queryInterface(XTextTable.class, table); | ||
1278 | XTextTableCursor cursor = xTextTable.createCursorByCellName("A1"); | ||
1279 | AgendaItem ai; | ||
1280 | // should this section be visible? | ||
1281 | boolean visible = false; | ||
1282 | |||
1283 | // write items | ||
1284 | // =========== | ||
1285 | String cellName = PropertyNames.EMPTY_STRING; | ||
1286 | |||
1287 | /* now go through all items that belong to this | ||
1288 | * table. Check each one agains the model. If it should | ||
1289 | * be display, call it's write method. | ||
1290 | * All items are of type AgendaItem which means they write | ||
1291 | * two cells to the table: a title (text) and a placeholder. | ||
1292 | * see AgendaItem class below. | ||
1293 | */ | ||
1294 | for (int i = 0; i < items.size(); i++) | ||
1295 | { | ||
1296 | ai = items.get(i); | ||
1297 | if (isShowItem(ai.name)) | ||
1298 | { | ||
1299 | visible = true; | ||
1300 | ai.table = table; | ||
1301 | ai.write(cursor); | ||
1302 | // I store the cell name which was last written... | ||
1303 | cellName = cursor.getRangeName(); | ||
1304 | |||
1305 | cursor.goRight((short) 1, false); | ||
1306 | |||
1307 | } | ||
1308 | } | ||
1309 | |||
1310 | Helper.setUnoPropertyValue(section, "IsVisible", visible ? Boolean.TRUE : Boolean.FALSE); | ||
1311 | if (!visible) | ||
1312 | { | ||
1313 | return; | ||
1314 | /* remove obsolete rows | ||
1315 | * ==================== | ||
1316 | * if the cell that was last written is the current cell, | ||
1317 | * it means this is the end of the table, so we end here. | ||
1318 | * (because after getting the cellName above, I call the goRight method. | ||
1319 | * If it did not go right, it means its the last cell. | ||
1320 | */ | ||
1321 | } | ||
1322 | if (cellName.equals(cursor.getRangeName())) | ||
1323 | { | ||
1324 | return; | ||
1325 | /* | ||
1326 | * if not, we continue and clear all cells until we are at the end of the row. | ||
1327 | */ | ||
1328 | } | ||
1329 | Object cell; | ||
1330 | while ((!cellName.equals(cursor.getRangeName()) && (!cursor.getRangeName().startsWith("A")))) | ||
1331 | { | ||
1332 | cell = xTextTable.getCellByName(cursor.getRangeName()); | ||
1333 | UnoRuntime.queryInterface(XTextRange.class, cell).setString(PropertyNames.EMPTY_STRING); | ||
1334 | cellName = cursor.getRangeName(); | ||
1335 | cursor.goRight((short) 1, false); | ||
1336 | } | ||
1337 | |||
1338 | /* | ||
1339 | * again: if we are at the end of the table, end here. | ||
1340 | */ | ||
1341 | if (cellName.equals(cursor.getRangeName())) | ||
1342 | { | ||
1343 | return; | ||
1344 | } | ||
1345 | int rowIndex = getRowIndex(cursor); | ||
1346 | int rowsCount = getRowCount(UnoRuntime.queryInterface(XTextTable.class, table)); | ||
1347 | |||
1348 | /* now before deleteing i move the cursor up so it | ||
1349 | * does not disappear, because it will crash office. | ||
1350 | */ | ||
1351 | cursor.gotoStart(false); | ||
1352 | |||
1353 | if (rowsCount >= rowIndex) | ||
1354 | { | ||
1355 | removeTableRows(table, rowIndex - 1, (rowsCount - rowIndex) + 1); | ||
1356 | } | ||
1357 | } | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1361 | /* | ||
1362 | * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ | ||
1363 | * ================================= | ||
1364 | * The Topics class | ||
1365 | * ================================= | ||
1366 | * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ | ||
1367 | */ | ||
1368 | /** | ||
1369 | * This class handles the preview of the topics table. | ||
1370 | * You can call it the controller of the topics table. | ||
1371 | * It differs from ItemsTable in that it has no data model - | ||
1372 | * the update is done programttically.<br/> | ||
1373 | * <br/> | ||
1374 | * The decision to make this class a class by its own | ||
1375 | * was done out of logic reasons and not design/functionality reasons, | ||
1376 | * since there is anyway only one instance of this class at runtime | ||
1377 | * it could have also be implemented in the AgendaTemplate class | ||
1378 | * but for clarity and separation I decided to make a sub class for it. | ||
1379 | */ | ||
1380 | public class Topics | ||
1381 | { | ||
1382 | |||
1383 | /** | ||
1384 | * the topics table | ||
1385 | */ | ||
1386 | XTextTable table; | ||
1387 | /** | ||
1388 | * A List of Cell Formatters for the first row. | ||
1389 | */ | ||
1390 | List<TableCellFormatter> firstRowFormat = new ArrayList<TableCellFormatter>(); | ||
1391 | /** | ||
1392 | * A List of Cell Formatters for the last row. | ||
1393 | * (will contain them in reverse order) | ||
1394 | */ | ||
1395 | List<TableCellFormatter> lastRowFormat = new ArrayList<TableCellFormatter>(); | ||
1396 | /** | ||
1397 | * the format of the cell of each topic cell. | ||
1398 | */ | ||
1399 | List<TableCellFormatter> topicCellFormats = new ArrayList<TableCellFormatter>(); | ||
1400 | /** | ||
1401 | * for each topic cell there is | ||
1402 | * a member in this vector | ||
1403 | */ | ||
1404 | List<AgendaElement> topicCells = new ArrayList<AgendaElement>(); | ||
1405 | int rowsPerTopic; | ||
1406 | /** | ||
1407 | * fields which hold the number of the | ||
1408 | * fillins in the cells vectors. | ||
1409 | */ | ||
1410 | int numCell = -1; | ||
1411 | int topicCell = -1; | ||
1412 | int responsibleCell = -1; | ||
1413 | int timeCell = -1; | ||
1414 | /** | ||
1415 | * this is a list which traces which topics were written to the document | ||
1416 | * and which not. When a cell needs to be actualized, it is checked that the | ||
1417 | * whole topic is already present in the document, using this vector. | ||
1418 | * The vector contains nulls for topics which were not written, and | ||
1419 | * empty strings for topics which were written (though any other | ||
1420 | * object would also do - i check only if it is a null or not...); | ||
1421 | */ | ||
1422 | List<String> writtenTopics = new ArrayList<String>(); | ||
1423 | |||
1424 | /** | ||
1425 | * Analyze the structure of the Topics table. | ||
1426 | * The structure Must be as follows:<br> | ||
1427 | * -One Header Row. <br> | ||
1428 | * -arbitrary number of rows per topic <br> | ||
1429 | * -arbitrary content in the topics row <br> | ||
1430 | * -only soft formatting will be restored. <br> | ||
1431 | * -the topic rows must repeat three times. <br> | ||
1432 | * -in the topics rows, placeholders for number, topic, responsible, and duration | ||
1433 | * must be placed.<br> | ||
1434 | * <br> | ||
1435 | * A word about table format: to reconstruct the format of the | ||
1436 | * table we hold to the following formats: first row (header), topic, and last row. | ||
1437 | * We hold the format of the last row, because one might wish to give it | ||
1438 | * a special format, other than the one on the bottom of each topic. | ||
1439 | * The left and right borders of the whole table are, on the other side, | ||
1440 | * part of the topics rows format, and need not be preserved seperateley. | ||
1441 | */ | ||
1442 | public Topics() | ||
1443 | { | ||
1444 | Object t; | ||
1445 | |||
1446 | Map<String, AgendaElement> topicItems = new HashMap<String, AgendaElement>(4); | ||
1447 | |||
1448 | // This is the topics table. say hallo :-) | ||
1449 | try | ||
1450 | { | ||
1451 | t = getTable(SECTION_TOPICS); | ||
1452 | } | ||
1453 | catch (Exception ex) | ||
1454 | { | ||
1455 | ex.printStackTrace(); | ||
1456 | throw new IllegalArgumentException("Fatal error while loading template: table " + SECTION_TOPICS + " could not load."); | ||
1457 | } | ||
1458 | |||
1459 | // and this is the XTable. | ||
1460 | table = UnoRuntime.queryInterface(XTextTable.class, t); | ||
1461 | |||
1462 | /* first I store all <*> ranges | ||
1463 | * which are in the topics table. | ||
1464 | * I store each <*> range in this - the key | ||
1465 | * is the cell it is in. Later when analyzing the topic, | ||
1466 | * cell by cell, I check in this map to know | ||
1467 | * if a cell contains a <*> or not. | ||
1468 | */ | ||
1469 | HashMap<Object, XTextRange> items = new HashMap<Object, XTextRange>(); | ||
1470 | |||
1471 | XTextRange item; | ||
1472 | Object cell; | ||
1473 | for (int i = 0; i < _allItems.size(); i++) | ||
1474 | { | ||
1475 | item = _allItems.get(i); | ||
1476 | t = Helper.getUnoPropertyValue(item, "TextTable"); | ||
1477 | if ((t instanceof Any) && ((Any) t).getObject() == table) | ||
1478 | { | ||
1479 | cell = Helper.getUnoPropertyValue(item, "Cell"); | ||
1480 | items.put(((Any) cell).getObject(), item); | ||
1481 | } | ||
1482 | } | ||
1483 | |||
1484 | /* | ||
1485 | * in the topics table, there are always one | ||
1486 | * title row and three topics defined. | ||
1487 | * So no mutter how many rows a topic takes - we | ||
1488 | * can restore its structure and format. | ||
1489 | */ | ||
1490 | int rows = getRowCount(table); | ||
1491 | |||
1492 | rowsPerTopic = (rows - 1) / 3; | ||
1493 | |||
1494 | String firstCell = "A" + (1 + rowsPerTopic + 1); | ||
1495 | String afterLastCell = "A" + (1 + (rowsPerTopic * 2) + 1); | ||
1496 | |||
1497 | // go to the first row of the 2. topic | ||
1498 | XTextTableCursor cursor = table.createCursorByCellName(firstCell); | ||
1499 | XTextRange range; | ||
1500 | |||
1501 | // analyze the structure of the topic rows. | ||
1502 | while (!cursor.getRangeName().equals(afterLastCell)) | ||
1503 | { | ||
1504 | cell = table.getCellByName(cursor.getRangeName()); | ||
1505 | XTextRange xTextRange = UnoRuntime.queryInterface(XTextRange.class, cell); | ||
1506 | // first I store the content and para style of the cell | ||
1507 | AgendaElement ae = new TextElement(xTextRange); | ||
1508 | // if the cell contains a relevant <...> | ||
1509 | // i add the text element to the hash, | ||
1510 | // so it's text can be updated later. | ||
1511 | range = items.get(cell); | ||
1512 | if (range != null) | ||
1513 | { | ||
1514 | topicItems.put(xTextRange.getString().toLowerCase().trim(), ae); | ||
1515 | } | ||
1516 | |||
1517 | topicCells.add(ae); | ||
1518 | |||
1519 | // and store the format of the cell. | ||
1520 | topicCellFormats.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName()))); | ||
1521 | |||
1522 | // goto next cell. | ||
1523 | cursor.goRight((short) 1, false); | ||
1524 | } | ||
1525 | |||
1526 | /* | ||
1527 | * now - in which cell is every fillin? | ||
1528 | */ | ||
1529 | numCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_NUMBER)); | ||
1530 | topicCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_TOPIC)); | ||
1531 | responsibleCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_RESPONSIBLE)); | ||
1532 | timeCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_TIME)); | ||
1533 | |||
1534 | |||
1535 | |||
1536 | /* now that we know how the topics look like, | ||
1537 | * we get the format of the first and last rows. | ||
1538 | */ | ||
1539 | |||
1540 | // format of first row | ||
1541 | cursor.gotoStart(false); | ||
1542 | do | ||
1543 | { | ||
1544 | firstRowFormat.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName()))); | ||
1545 | cursor.goRight((short) 1, false); | ||
1546 | } | ||
1547 | while (!cursor.getRangeName().startsWith("A")); | ||
1548 | |||
1549 | // format of the last row | ||
1550 | cursor.gotoEnd(false); | ||
1551 | while (!cursor.getRangeName().startsWith("A")) | ||
1552 | { | ||
1553 | lastRowFormat.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName()))); | ||
1554 | cursor.goLeft((short) 1, false); | ||
1555 | } | ||
1556 | // we missed the A cell - so we have to add it also.. | ||
1557 | lastRowFormat.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName()))); | ||
1558 | |||
1559 | removeTableRows(table, 1 + rowsPerTopic, rows - rowsPerTopic - 1); | ||
1560 | |||
1561 | } | ||
1562 | |||
1563 | /** | ||
1564 | * @param topic the topic number to write | ||
1565 | * @param data the data of the topic. | ||
1566 | * @return the number of rows that have been added | ||
1567 | * to the table. 0 or a negative number: no rows added. | ||
1568 | */ | ||
1569 | private int write2(int topic, PropertyValue[] data) throws Exception | ||
1570 | { | ||
1571 | while (topic >= writtenTopics.size()) | ||
1572 | { | ||
1573 | writtenTopics.add(null); | ||
1574 | } | ||
1575 | writtenTopics.set(topic, PropertyNames.EMPTY_STRING); | ||
1576 | |||
1577 | // make sure threr are enough rows for me... | ||
1578 | int rows = getRowCount(table); | ||
1579 | int reqRows = 1 + (topic + 1) * rowsPerTopic; | ||
1580 | int firstRow = reqRows - rowsPerTopic + 1; | ||
1581 | int diff = reqRows - rows; | ||
1582 | if (diff > 0) | ||
1583 | { | ||
1584 | insertTableRows(table, rows, diff); // set the item's text... | ||
1585 | } | ||
1586 | setItemText(numCell, data[0].Value); | ||
1587 | setItemText(topicCell, data[1].Value); | ||
1588 | setItemText(responsibleCell, data[2].Value); | ||
1589 | setItemText(timeCell, data[3].Value); | ||
1590 | |||
1591 | // now write ! | ||
1592 | XTextTableCursor cursor = table.createCursorByCellName("A" + firstRow); | ||
1593 | |||
1594 | for (int i = 0; i < topicCells.size(); i++) | ||
1595 | { | ||
1596 | topicCells.get(i).write(table.getCellByName(cursor.getRangeName())); | ||
1597 | cursor.goRight((short) 1, false); | ||
1598 | } | ||
1599 | |||
1600 | // now format ! | ||
1601 | cursor.gotoCellByName("A" + firstRow, false); | ||
1602 | |||
1603 | formatTable(cursor, topicCellFormats, false); | ||
1604 | |||
1605 | return diff; | ||
1606 | |||
1607 | } | ||
1608 | |||
1609 | /** | ||
1610 | * check if the topic with the given index is written to the table. | ||
1611 | * @param topic the topic number (0 base) | ||
1612 | * @return true if the topic is already written to the table. False if not. | ||
1613 | * (false would mean new rows must be added to the table in order to | ||
1614 | * be able to write this topic). | ||
1615 | */ | ||
1616 | private boolean isWritten(int topic) | ||
1617 | { | ||
1618 | return (writtenTopics.size() > topic && writtenTopics.get(topic) != null); | ||
1619 | } | ||
1620 | |||
1621 | /** | ||
1622 | * rewrites a single cell containing. | ||
1623 | * This is used in order to refresh the topic/responsible/duration data in the | ||
1624 | * preview document, in response to a change in the gui (by the user). | ||
1625 | * Since the structure of the topics table is flexible, we don't reference a cell | ||
1626 | * number. Rather, we use "what" argument to specify which cell should be redrawn. | ||
1627 | * The Topics object, which analyzed the structure of the topics table appon | ||
1628 | * initialization, refreshes the approperiate cell. | ||
1629 | * @param topic index of the topic (0 based). | ||
1630 | * @param what 0 for num, 1 for topic, 2 for responsible, 3 for duration | ||
1631 | * @param data the row's data. | ||
1632 | * @throws Exception if something goes wrong (thow nothing should) | ||
1633 | */ | ||
1634 | public void writeCell(int topic, int what, PropertyValue[] data) throws Exception | ||
1635 | { | ||
1636 | // if the whole row should be written... | ||
1637 | if (!isWritten(topic)) | ||
1638 | { | ||
1639 | write(topic, data); | ||
1640 | // write only the "what" cell. | ||
1641 | } | ||
1642 | else | ||
1643 | { | ||
1644 | // calculate the table row. | ||
1645 | int firstRow = 1 + (topic * rowsPerTopic) + 1; | ||
1646 | // go to the first cell of this topic. | ||
1647 | XTextTableCursor cursor = table.createCursorByCellName("A" + firstRow); | ||
1648 | |||
1649 | TextElement te = null; | ||
1650 | int cursorMoves = 0; | ||
1651 | |||
1652 | switch (what) | ||
1653 | { | ||
1654 | case 0: | ||
1655 | te = setItemText(numCell, data[0].Value); | ||
1656 | cursorMoves = numCell; | ||
1657 | break; | ||
1658 | case 1: | ||
1659 | te = setItemText(topicCell, data[1].Value); | ||
1660 | cursorMoves = topicCell; | ||
1661 | break; | ||
1662 | case 2: | ||
1663 | te = setItemText(responsibleCell, data[2].Value); | ||
1664 | cursorMoves = responsibleCell; | ||
1665 | break; | ||
1666 | case 3: | ||
1667 | te = setItemText(timeCell, data[3].Value); | ||
1668 | cursorMoves = timeCell; | ||
1669 | break; | ||
1670 | } | ||
1671 | // move the cursor to the needed cell... | ||
1672 | if ( te != null) | ||
1673 | { | ||
1674 | cursor.goRight((short) cursorMoves, false); | ||
1675 | XCell xc = table.getCellByName(cursor.getRangeName()); | ||
1676 | // and write it ! | ||
1677 | te.write(xc); | ||
1678 | topicCellFormats.get(cursorMoves).format(xc); | ||
1679 | } | ||
1680 | } | ||
1681 | } | ||
1682 | |||
1683 | /** | ||
1684 | * writes the given topic. | ||
1685 | * if the first topic was involved, reformat the | ||
1686 | * first row. | ||
1687 | * If any rows were added to the table, reformat | ||
1688 | * the last row. | ||
1689 | * @param topic the index of the topic to write. | ||
1690 | * @param data the topic's data. (see TopicsControl | ||
1691 | * for explanation about the topics data model) | ||
1692 | * @throws Exception if something goes wrong (though nothing should). | ||
1693 | */ | ||
1694 | public void write(int topic, PropertyValue[] data) throws Exception | ||
1695 | { | ||
1696 | int diff = write2(topic, data); | ||
1697 | /* if the first topic has been written, | ||
1698 | * one needs to reformat the first row. | ||
1699 | */ | ||
1700 | if (topic == 0) | ||
1701 | { | ||
1702 | formatFirstRow(); | ||
1703 | } | ||
1704 | /* | ||
1705 | * if any rows were added, one needs to format | ||
1706 | * the whole table again. | ||
1707 | */ | ||
1708 | if (diff > 0) | ||
1709 | { | ||
1710 | formatLastRow(); | ||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | /** | ||
1715 | * Writes all the topics to thetopics table. | ||
1716 | * @param topicsData a List containing all Topic's Data. | ||
1717 | */ | ||
1718 | public void writeAll(List<PropertyValue[]> topicsData) | ||
1719 | { | ||
1720 | try | ||
1721 | { | ||
1722 | for (int i = 0; i < topicsData.size() - 1; i++) | ||
1723 | { | ||
1724 | write2(i, topicsData.get(i)); | ||
1725 | } | ||
1726 | formatLastRow(); | ||
1727 | } | ||
1728 | catch (Exception ex) | ||
1729 | { | ||
1730 | ex.printStackTrace(); | ||
1731 | } | ||
1732 | } | ||
1733 | |||
1734 | /** | ||
1735 | * removes obsolete rows, reducing the | ||
1736 | * topics table to the given number of topics. | ||
1737 | * Note this method does only reducing - if | ||
1738 | * the number of topics given is greater than the | ||
1739 | * number of actuall topics it does *not* add | ||
1740 | * new rows ! | ||
1741 | * Note also that the first topic will never be removed. | ||
1742 | * If the table contains no topics, the whole section will | ||
1743 | * be removed uppon finishing. | ||
1744 | * The reason for that is a "table-design" one: the first topic is | ||
1745 | * maintained in order to be able to add rows with a design of this topic, | ||
1746 | * and not of the header row. | ||
1747 | * @param topics the number of topics the table should contain. | ||
1748 | * @throws Exception | ||
1749 | */ | ||
1750 | public void reduceDocumentTo(int topics) throws Exception | ||
1751 | { | ||
1752 | // we never remove the first topic... | ||
1753 | if (topics <= 0) | ||
1754 | { | ||
1755 | topics = 1; | ||
1756 | } | ||
1757 | XTableRows tableRows = table.getRows(); | ||
1758 | int targetNumOfRows = topics * rowsPerTopic + 1; | ||
1759 | formatLastRow(); | ||
1760 | while (writtenTopics.size() > topics) | ||
1761 | { | ||
1762 | writtenTopics.remove(topics); | ||
1763 | } | ||
1764 | } | ||
1765 | |||
1766 | /** | ||
1767 | * reapply the format of the first (header) row. | ||
1768 | */ | ||
1769 | private void formatFirstRow() | ||
1770 | { | ||
1771 | XTextTableCursor cursor = table.createCursorByCellName("A1"); | ||
1772 | formatTable(cursor, firstRowFormat, false); | ||
1773 | } | ||
1774 | |||
1775 | /** | ||
1776 | * reaply the format of the last row. | ||
1777 | */ | ||
1778 | private void formatLastRow() | ||
1779 | { | ||
1780 | XTextTableCursor cursor = table.createCursorByCellName("A1"); | ||
1781 | cursor.gotoEnd(false); | ||
1782 | formatTable(cursor, lastRowFormat, true); | ||
1783 | } | ||
1784 | |||
1785 | /** | ||
1786 | * returns a text element for the given cell, | ||
1787 | * which will write the given text. | ||
1788 | * @param cell the topics cell number. | ||
1789 | * @param value the value to write. | ||
1790 | * @return a TextElement object which will write the given value | ||
1791 | * to the given cell. | ||
1792 | */ | ||
1793 | private TextElement setItemText(int cell, Object value) | ||
1794 | { | ||
1795 | if (cell >= 0) | ||
1796 | { | ||
1797 | TextElement te = ((TextElement) topicCells.get(cell)); | ||
1798 | if (te != null) | ||
1799 | { | ||
1800 | te.text = value.toString(); | ||
1801 | } | ||
1802 | return te; | ||
1803 | } | ||
1804 | return null; | ||
1805 | } | ||
1806 | |||
1807 | /** | ||
1808 | * formats a series of cells from the given one, | ||
1809 | * using the given List of TableCellFormatter objects, | ||
1810 | * in the given order. | ||
1811 | * This method is used to format the first (header) and the last | ||
1812 | * rows of the table. | ||
1813 | * @param cursor a table cursor, pointing to the start cell to format | ||
1814 | * @param formats a List containing TableCellFormatter objects. Each will format one cell in the direction specified. | ||
1815 | * @param reverse if true the cursor will move left, formatting in reverse order (used for the last row). | ||
1816 | */ | ||
1817 | private void formatTable(XTextTableCursor cursor, List<TableCellFormatter> formats, boolean reverse) | ||
1818 | { | ||
1819 | for (int i = 0; i < formats.size(); i++) | ||
1820 | { | ||
1821 | formats.get(i).format(table.getCellByName(cursor.getRangeName())); | ||
1822 | if (reverse) | ||
1823 | { | ||
1824 | cursor.goLeft((short) 1, false); | ||
1825 | } | ||
1826 | else | ||
1827 | { | ||
1828 | cursor.goRight((short) 1, false); | ||
1829 | } | ||
1830 | } | ||
1831 | } | ||
1832 | } | ||
1833 | |||
1834 | |||
1835 | /* | ||
1836 | * ================================= | ||
1837 | * Here are some static help methods | ||
1838 | * ================================= | ||
1839 | */ | ||
1840 | public static String[] getNamesWhichStartWith(String[] allNames, String prefix) | ||
1841 | { | ||
1842 | ArrayList<String> v = new ArrayList<String>(); | ||
1843 | for (int i = 0; i < allNames.length; i++) | ||
1844 | { | ||
1845 | if (allNames[i].startsWith(prefix)) | ||
1846 | { | ||
1847 | v.add(allNames[i]); | ||
1848 | } | ||
1849 | } | ||
1850 | String[] s = new String[v.size()]; | ||
1851 | return v.toArray(s); | ||
1852 | } | ||
1853 | |||
1854 | /** | ||
1855 | * Convenience method, costs the given object to an XNamed, and returnes its name. | ||
1856 | * @param obj an XNamed object. | ||
1857 | * @return the name of the given object. | ||
1858 | */ | ||
1859 | public static String getName(Object obj) | ||
1860 | { | ||
1861 | return UnoRuntime.queryInterface(XNamed.class, obj).getName(); | ||
1862 | } | ||
1863 | |||
1864 | /** | ||
1865 | * convenience method, for removing a number of cells from a table. | ||
1866 | * @param table | ||
1867 | * @param start | ||
1868 | * @param count | ||
1869 | */ | ||
1870 | public static void removeTableRows(Object table, int start, int count) | ||
1871 | { | ||
1872 | XTableRows rows = UnoRuntime.queryInterface(XTextTable.class, table).getRows(); | ||
1873 | } | ||
1874 | |||
1875 | /** | ||
1876 | * Convenience method for inserting some cells into a table. | ||
1877 | * @param table | ||
1878 | * @param start | ||
1879 | * @param count | ||
1880 | */ | ||
1881 | public static void insertTableRows(Object table, int start, int count) | ||
1882 | { | ||
1883 | XTableRows rows = UnoRuntime.queryInterface(XTextTable.class, table).getRows(); | ||
1884 | rows.insertByIndex(start, count); | ||
1885 | } | ||
1886 | |||
1887 | /** | ||
1888 | * returns the row index for this cursor, assuming | ||
1889 | * the cursor points to a single cell. | ||
1890 | * @param cursor | ||
1891 | * @return the row index in which the cursor is. | ||
1892 | */ | ||
1893 | public static int getRowIndex(XTextTableCursor cursor) | ||
1894 | { | ||
1895 | return getRowIndex(cursor.getRangeName()); | ||
1896 | } | ||
1897 | |||
1898 | /** | ||
1899 | * returns the row index for this cell name. | ||
1900 | * @param cellName | ||
1901 | * @return the row index for this cell name. | ||
1902 | */ | ||
1903 | public static int getRowIndex(String cellName) | ||
1904 | { | ||
1905 | return Integer.parseInt(cellName.substring(1)); | ||
1906 | } | ||
1907 | |||
1908 | /** | ||
1909 | * returns the rows count of this table, assuming | ||
1910 | * there is no vertical merged cells. | ||
1911 | * @param table | ||
1912 | * @return the rows count of the given table. | ||
1913 | */ | ||
1914 | public static int getRowCount(XTextTable table) | ||
1915 | { | ||
1916 | String[] cells = table.getCellNames(); | ||
1917 | return getRowIndex(cells[cells.length - 1]); | ||
1918 | } | ||
1919 | } | ||
1920 | |||
1921 | /* | ||
1922 | * =========================================================================================== | ||
1923 | * | ||
1924 | * End of AgendaTempalte class | ||
1925 | * | ||
1926 | * =========================================================================================== | ||
1927 | * | ||
1928 | */ | ||
1929 | /* | ||
1930 | * ================================= | ||
1931 | * The AgendaElement interface | ||
1932 | * ================================= | ||
1933 | */ | ||
1934 | /** | ||
1935 | * Interface that is used for writing content to a Uno Text / TextRange | ||
1936 | */ | ||
1937 | interface AgendaElement | ||
1938 | { | ||
1939 | |||
1940 | void write(Object any) throws Exception; | ||
1941 | } | ||
1942 | |||
1943 | |||
1944 | /* | ||
1945 | * ================================= | ||
1946 | * The ParaStyled class | ||
1947 | * ================================= | ||
1948 | */ | ||
1949 | /** | ||
1950 | * Basic implementation of the AgendaElement interface - | ||
1951 | * writes nothing, but applies a ParaStyle to the given XText/XTextRange | ||
1952 | * | ||
1953 | * TODO To change the template for this generated type comment go to | ||
1954 | * Window - Preferences - Java - Code Style - Code Templates | ||
1955 | */ | ||
1956 | class ParaStyled implements AgendaElement | ||
1957 | { | ||
1958 | |||
1959 | String paraStyle; | ||
1960 | |||
1961 | ParaStyled(String paraStyle_) | ||
1962 | { | ||
1963 | paraStyle = paraStyle_; | ||
1964 | } | ||
1965 | |||
1966 | void format(Object textRange) | ||
1967 | { | ||
1968 | XText o; | ||
1969 | o = UnoRuntime.queryInterface(XText.class, textRange); | ||
1970 | if (o == null) | ||
1971 | { | ||
1972 | o = UnoRuntime.queryInterface(XTextRange.class, textRange).getText(); | ||
1973 | } | ||
1974 | XTextRange xtr = UnoRuntime.queryInterface(XTextRange.class, textRange); | ||
1975 | XTextCursor cursor = o.createTextCursorByRange(xtr); | ||
1976 | |||
1977 | Helper.setUnoPropertyValue(cursor, "ParaStyleName", paraStyle); | ||
1978 | } | ||
1979 | |||
1980 | public void write(Object textRange) | ||
1981 | { | ||
1982 | format(textRange); | ||
1983 | } | ||
1984 | } | ||
1985 | |||
1986 | /* | ||
1987 | * ================================= | ||
1988 | * The TextElement class | ||
1989 | * ================================= | ||
1990 | */ | ||
1991 | /** | ||
1992 | * A basic implementation of AgendaElement: | ||
1993 | * writes a String to the given XText/XTextRange, and applies | ||
1994 | * a ParaStyle to it (using the parent class). | ||
1995 | */ | ||
1996 | class TextElement extends ParaStyled | ||
1997 | { | ||
1998 | |||
1999 | String text; | ||
2000 | |||
2001 | TextElement(XTextRange range) | ||
2002 | { | ||
2003 | this(range.getString(), (String) Helper.getUnoPropertyValue(range.getStart(), "ParaStyleName")); | ||
2004 | } | ||
2005 | |||
2006 | TextElement(String text_, String paraStyle_) | ||
2007 | { | ||
2008 | super(paraStyle_); | ||
2009 | text = text_; | ||
2010 | } | ||
2011 | |||
2012 | public void write(Object textRange) | ||
2013 | { | ||
2014 | UnoRuntime.queryInterface(XTextRange.class, textRange).setString(text); | ||
2015 | if (!text.equals(PropertyNames.EMPTY_STRING)) | ||
2016 | { | ||
2017 | super.write(textRange); | ||
2018 | } | ||
2019 | } | ||
2020 | } | ||
2021 | |||
2022 | /** | ||
2023 | * A Text element which, if the text to write is empty (null or PropertyNames.EMPTY_STRING) | ||
2024 | * inserts a placeholder instead. | ||
2025 | * | ||
2026 | * TODO To change the template for this generated type comment go to | ||
2027 | * Window - Preferences - Java - Code Style - Code Templates | ||
2028 | */ | ||
2029 | class PlaceholderTextElement extends TextElement | ||
2030 | { | ||
2031 | |||
2032 | String hint; | ||
2033 | String placeHolderText; | ||
2034 | XMultiServiceFactory xmsf; | ||
2035 | |||
2036 | PlaceholderTextElement(XTextRange textRange, String placeHolderText_, String hint_, XMultiServiceFactory xmsf_) | ||
2037 | { | ||
2038 | super(textRange); | ||
2039 | placeHolderText = placeHolderText_; | ||
2040 | hint = hint_; | ||
2041 | xmsf = xmsf_; | ||
2042 | } | ||
2043 | |||
2044 | PlaceholderTextElement(String text, String paraStyle, String placeHolderText_, String hint_, XMultiServiceFactory xmsf_) | ||
2045 | { | ||
2046 | super(text, paraStyle); | ||
2047 | placeHolderText = placeHolderText_; | ||
2048 | hint = hint_; | ||
2049 | xmsf = xmsf_; | ||
2050 | } | ||
2051 | |||
2052 | public void write(Object textRange) | ||
2053 | { | ||
2054 | super.write(textRange); | ||
2055 | if (text == null || text.equals(PropertyNames.EMPTY_STRING)) | ||
2056 | { | ||
2057 | XTextRange xTextRange = UnoRuntime.queryInterface(XTextRange.class, textRange); | ||
2058 | try | ||
2059 | { | ||
2060 | XTextContent xTextContent = AgendaTemplate.createPlaceHolder(xmsf, placeHolderText, hint); | ||
2061 | xTextRange.getText().insertTextContent(xTextRange.getStart(), xTextContent, true); | ||
2062 | } | ||
2063 | catch (Exception ex) | ||
2064 | { | ||
2065 | ex.printStackTrace(); | ||
2066 | } | ||
2067 | } | ||
2068 | } | ||
2069 | } | ||
2070 | |||
2071 | /* | ||
2072 | * ================================= | ||
2073 | * The PlaceHolder class | ||
2074 | * ================================= | ||
2075 | */ | ||
2076 | /** | ||
2077 | * An Agenda element which writes no text, but inserts a placeholder, and formats | ||
2078 | * it using a ParaStyleName. | ||
2079 | * | ||
2080 | */ | ||
2081 | class PlaceholderElement extends ParaStyled | ||
2082 | { | ||
2083 | |||
2084 | String hint; | ||
2085 | String placeHolderText; | ||
2086 | XMultiServiceFactory xmsf; | ||
2087 | |||
2088 | PlaceholderElement(String paraStyle, String placeHolderText_, String hint_, XMultiServiceFactory xmsf_) | ||
2089 | { | ||
2090 | super(paraStyle); | ||
2091 | placeHolderText = placeHolderText_; | ||
2092 | hint = hint_; | ||
2093 | xmsf = xmsf_; | ||
2094 | } | ||
2095 | |||
2096 | public void write(Object textRange) | ||
2097 | { | ||
2098 | XTextRange xTextRange = UnoRuntime.queryInterface(XTextRange.class, textRange); | ||
2099 | try | ||
2100 | { | ||
2101 | XTextContent xTextContent = AgendaTemplate.createPlaceHolder(xmsf, placeHolderText, hint); | ||
2102 | xTextRange.getText().insertTextContent(xTextRange.getStart(), xTextContent, true); | ||
2103 | super.write(textRange); | ||
2104 | } | ||
2105 | catch (Exception ex) | ||
2106 | { | ||
2107 | ex.printStackTrace(); | ||
2108 | } | ||
2109 | } | ||
2110 | } | ||
2111 | |||
2112 | |||
2113 | /* | ||
2114 | * ================================= | ||
2115 | * The AgendaItem class | ||
2116 | * ================================= | ||
2117 | */ | ||
2118 | /** | ||
2119 | * An implementation of AgendaElement which | ||
2120 | * gets as a parameter a table cursor, and writes | ||
2121 | * a text to the cell marked by this table cursor, and | ||
2122 | * a place holder to the next cell. | ||
2123 | * | ||
2124 | * TODO To change the template for this generated type comment go to | ||
2125 | * Window - Preferences - Java - Code Style - Code Templates | ||
2126 | */ | ||
2127 | class AgendaItem implements AgendaElement | ||
2128 | { | ||
2129 | |||
2130 | TextElement textElement; | ||
2131 | AgendaElement field; | ||
2132 | public Object table; | ||
2133 | String name; | ||
2134 | |||
2135 | AgendaItem(String name_, TextElement te, AgendaElement f) | ||
2136 | { | ||
2137 | name = name_; | ||
2138 | field = f; | ||
2139 | textElement = te; | ||
2140 | } | ||
2141 | |||
2142 | public void write(Object tableCursor) throws Exception | ||
2143 | { | ||
2144 | XTextTableCursor xTextTableCursor = UnoRuntime.queryInterface(XTextTableCursor.class, tableCursor); | ||
2145 | XTextTable xTextTable = UnoRuntime.queryInterface(XTextTable.class, table); | ||
2146 | |||
2147 | String cellname = xTextTableCursor.getRangeName(); | ||
2148 | Object cell = xTextTable.getCellByName(cellname); | ||
2149 | |||
2150 | textElement.write(cell); | ||
2151 | |||
2152 | xTextTableCursor.goRight((short) 1, false); | ||
2153 | |||
2154 | //second field is actually always null... | ||
2155 | // this is a preparation for adding placeholders. | ||
2156 | if (field != null) | ||
2157 | { | ||
2158 | field.write(xTextTable.getCellByName(xTextTableCursor.getRangeName())); | ||
2159 | } | ||
2160 | } | ||
2161 | } | ||
2162 | |||
2163 | /* | ||
2164 | * ================================= | ||
2165 | * The TableCellFormatter class | ||
2166 | * ================================= | ||
2167 | */ | ||
2168 | /** | ||
2169 | * reads/write a table cell format from/to a table cell or a group of cells. | ||
2170 | * | ||
2171 | */ | ||
2172 | class TableCellFormatter | ||
2173 | { | ||
2174 | |||
2175 | static String[] properties = new String[] | ||
2176 | { | ||
2177 | "BackColor", | ||
2178 | "BackTransparent", | ||
2179 | "BorderDistance", | ||
2180 | "BottomBorder", | ||
2181 | "BottomBorderDistance", | ||
2182 | "LeftBorder", | ||
2183 | "LeftBorderDistance", | ||
2184 | "RightBorder", | ||
2185 | "RightBorderDistance", | ||
2186 | "TopBorder", | ||
2187 | "TopBorderDistance" | ||
2188 | }; | ||
2189 | private Object[] values = new Object[properties.length]; | ||
2190 | |||
2191 | public TableCellFormatter(Object tableCell) | ||
2192 | { | ||
2193 | for (int i = 0; i < properties.length; i++) | ||
2194 | { | ||
2195 | values[i] = Helper.getUnoPropertyValue(tableCell, properties[i]); | ||
2196 | } | ||
2197 | } | ||
2198 | |||
2199 | public void format(Object tableCell) | ||
2200 | { | ||
2201 | Helper.setUnoPropertyValues(tableCell, properties, values); | ||
2202 | } | ||
2203 | } | ||
2204 | |||
2205 | |||
2206 | |||
2207 | |||
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.java deleted file mode 100644 index 755651fd9e09..000000000000 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.java +++ /dev/null | |||
@@ -1,376 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | import com.sun.star.awt.FontDescriptor; | ||
21 | import com.sun.star.awt.XButton; | ||
22 | import com.sun.star.awt.XCheckBox; | ||
23 | import com.sun.star.awt.XControl; | ||
24 | import com.sun.star.awt.XDateField; | ||
25 | import com.sun.star.awt.XFixedText; | ||
26 | import com.sun.star.awt.XListBox; | ||
27 | import com.sun.star.awt.XRadioButton; | ||
28 | import com.sun.star.awt.XTextComponent; | ||
29 | import com.sun.star.awt.XTimeField; | ||
30 | import com.sun.star.lang.XMultiServiceFactory; | ||
31 | import com.sun.star.wizards.common.Helper; | ||
32 | import com.sun.star.wizards.common.PropertyNames; | ||
33 | import com.sun.star.wizards.ui.UIConsts; | ||
34 | import com.sun.star.wizards.ui.WizardDialog; | ||
35 | |||
36 | /** | ||
37 | * This class is generated Automatically.... | ||
38 | * bla bla bla | ||
39 | */ | ||
40 | public abstract class AgendaWizardDialog extends WizardDialog implements AgendaWizardDialogConst, UIConsts { | ||
41 | //GUI Components as Class members. | ||
42 | XFixedText lblTitle1; | ||
43 | XCheckBox chkMinutes; | ||
44 | XFixedText lblHelp1; | ||
45 | XFixedText lblPageDesign; | ||
46 | XListBox listPageDesign; | ||
47 | //Image Control | ||
48 | XControl imgHelp1; | ||
49 | XControl imgHelp2; | ||
50 | XControl imgHelp3; | ||
51 | XControl imgHelp4; | ||
52 | XControl imgHelp6; | ||
53 | XFixedText lblTitle2; | ||
54 | XFixedText lblTime; | ||
55 | XFixedText lblTitle; | ||
56 | XFixedText lblLocation; | ||
57 | XTextComponent cbLocation; | ||
58 | XTimeField txtTime; | ||
59 | XTextComponent txtTitle; | ||
60 | XFixedText lblHelp2; | ||
61 | XFixedText lblDate; | ||
62 | XDateField txtDate; | ||
63 | XFixedText lblTitle3; | ||
64 | XCheckBox chkMeetingTitle; | ||
65 | XCheckBox chkRead; | ||
66 | XCheckBox chkBring; | ||
67 | XCheckBox chkNotes; | ||
68 | XFixedText lblHelp3; | ||
69 | XFixedText lblTitle5; | ||
70 | XCheckBox chkConvenedBy; | ||
71 | XCheckBox chkPresiding; | ||
72 | XCheckBox chkNoteTaker; | ||
73 | XCheckBox chkTimekeeper; | ||
74 | XCheckBox chkAttendees; | ||
75 | XCheckBox chkObservers; | ||
76 | XCheckBox chkResourcePersons; | ||
77 | XFixedText lblHelp4; | ||
78 | XFixedText lblTitle4; | ||
79 | XFixedText lblTopic; | ||
80 | XFixedText lblResponsible; | ||
81 | XFixedText lblDuration; | ||
82 | //XFixedText lblHelp5; | ||
83 | XTextComponent txtTemplateName; | ||
84 | XRadioButton optCreateAgenda; | ||
85 | XRadioButton optMakeChanges; | ||
86 | XFixedText lblProceed; | ||
87 | XFixedText lblTemplateName; | ||
88 | XFixedText lblTemplatePath; | ||
89 | XFixedText lblTitle6; | ||
90 | XTextComponent txtTemplatePath; | ||
91 | XButton btnTemplatePath; | ||
92 | XFixedText lblHelp6; | ||
93 | XFixedText lblHelpPg6; | ||
94 | XButton btnInsert; | ||
95 | XButton btnRemove; | ||
96 | XButton btnUp; | ||
97 | XButton btnDown; | ||
98 | |||
99 | final private String IMGHELP1_HID = PropertyNames.EMPTY_STRING; | ||
100 | |||
101 | |||
102 | //Font Descriptors as Class members. | ||
103 | FontDescriptor fontDescriptor1 = new FontDescriptor(); | ||
104 | FontDescriptor fontDescriptor2 = new FontDescriptor(); | ||
105 | FontDescriptor fontDescriptor4 = new FontDescriptor(); | ||
106 | |||
107 | //Resources Object | ||
108 | AgendaWizardDialogResources resources; | ||
109 | |||
110 | private String[] PROPS_LIST = new String[] {"Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
111 | private String[] PROPS_LABEL_B = new String[] {PropertyNames.FONT_DESCRIPTOR, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
112 | private String[] PROPS_CHECK = new String[] {PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
113 | private String[] PROPS_BUTTON = new String[] {PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
114 | private String[] PROPS_X = new String[] {PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
115 | private String[] PROPS_TEXTAREA = new String[] {PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
116 | private String[] PROPS_TEXT = new String[] {PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
117 | private String[] PROPS_IMAGE = new String[] {PropertyNames.PROPERTY_BORDER, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_IMAGEURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, "ScaleImage", PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}; | ||
118 | |||
119 | private static final Short NO_BORDER = new Short((short)0); | ||
120 | |||
121 | public AgendaWizardDialog(XMultiServiceFactory xmsf) { | ||
122 | super(xmsf,HID); | ||
123 | //Load Resources | ||
124 | resources = new AgendaWizardDialogResources(xmsf); | ||
125 | |||
126 | //set dialog properties... | ||
127 | Helper.setUnoPropertyValues(xDialogModel, | ||
128 | new String[] { PropertyNames.PROPERTY_CLOSEABLE,PropertyNames.PROPERTY_HEIGHT,PropertyNames.PROPERTY_MOVEABLE,PropertyNames.PROPERTY_POSITION_X,PropertyNames.PROPERTY_POSITION_Y,PropertyNames.PROPERTY_STEP,PropertyNames.PROPERTY_TABINDEX,PropertyNames.PROPERTY_TITLE,PropertyNames.PROPERTY_WIDTH}, | ||
129 | new Object[] { Boolean.TRUE,210,Boolean.TRUE,200,52,INTEGERS[1],new Short((short)1),resources.resAgendaWizardDialog_title,310} | ||
130 | ); | ||
131 | |||
132 | //Set member- FontDescriptors... | ||
133 | fontDescriptor1.Weight = 150; | ||
134 | fontDescriptor1.Underline = com.sun.star.awt.FontUnderline.SINGLE; | ||
135 | fontDescriptor2.Weight = 100; | ||
136 | fontDescriptor4.Weight = 150; | ||
137 | } | ||
138 | |||
139 | //build components | ||
140 | public void buildStep1() { | ||
141 | lblTitle1 = insertLabel("lblTitle1", | ||
142 | PROPS_LABEL_B, | ||
143 | new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle1_value,Boolean.TRUE,91,INTEGERS[8],INTEGERS[1],new Short((short)100),212} | ||
144 | ); | ||
145 | lblPageDesign = insertLabel("lblPageDesign", | ||
146 | PROPS_TEXT, | ||
147 | new Object[] { INTEGERS[8],resources.reslblPageDesign_value,97,32,INTEGERS[1],new Short((short)101),66} | ||
148 | ); | ||
149 | listPageDesign = insertListBox("listPageDesign", null, null, | ||
150 | PROPS_LIST, | ||
151 | new Object[] { Boolean.TRUE,INTEGER_12,LISTPAGEDESIGN_HID,166,30,INTEGERS[1],new Short((short)102),70} | ||
152 | ); | ||
153 | chkMinutes = insertCheckBox("chkMinutes", null, | ||
154 | PROPS_CHECK, | ||
155 | new Object[] { INTEGERS[9],CHKMINUTES_HID,resources.reschkMinutes_value,97,50,new Short((short)0),INTEGERS[1],new Short((short)103),203} | ||
156 | ); | ||
157 | imgHelp1 = insertImage("imgHelp1", | ||
158 | PROPS_IMAGE, | ||
159 | new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID, AgendaWizardDialogConst.INFO_IMAGE_URL, 92,145, Boolean.FALSE, INTEGERS[1], new Short((short)104),INTEGERS[10]} | ||
160 | ); | ||
161 | lblHelp1 = insertLabel("lblHelp1", | ||
162 | PROPS_TEXTAREA, | ||
163 | new Object[] { 39,resources.reslblHelp1_value,Boolean.TRUE,104,145,INTEGERS[1],new Short((short)105),199} | ||
164 | ); | ||
165 | |||
166 | } | ||
167 | |||
168 | public void buildStep2() { | ||
169 | lblTitle2 = insertLabel("lblTitle2", | ||
170 | PROPS_LABEL_B, | ||
171 | new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle2_value,Boolean.TRUE,91,INTEGERS[8],INTEGERS[2],new Short((short)200),212} | ||
172 | ); | ||
173 | lblDate = insertLabel("lblDate", | ||
174 | PROPS_TEXT, | ||
175 | new Object[] { INTEGERS[8],resources.reslblDate_value,97,32,INTEGERS[2],new Short((short)201),66} | ||
176 | ); | ||
177 | txtDate = insertDateField("txtDate", null, | ||
178 | PROPS_LIST, | ||
179 | new Object[] { Boolean.TRUE,INTEGER_12,TXTDATE_HID,166,30,INTEGERS[2],new Short((short)202),70} | ||
180 | ); | ||
181 | lblTime = insertLabel("lblTime", | ||
182 | PROPS_TEXT, | ||
183 | new Object[] { INTEGERS[8],resources.reslblTime_value,97,50,INTEGERS[2],new Short((short)203),66} | ||
184 | ); | ||
185 | txtTime = insertTimeField("txtTime", null, | ||
186 | new String[] {PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, "StrictFormat", PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}, | ||
187 | new Object[] { INTEGER_12,TXTTIME_HID,166,48,INTEGERS[2],Boolean.TRUE,new Short((short)204),70} | ||
188 | ); | ||
189 | |||
190 | lblTitle = insertLabel("lblTitle", | ||
191 | PROPS_TEXT, | ||
192 | new Object[] { INTEGERS[8],resources.reslblTitle_value,97,68,INTEGERS[2],new Short((short)205),66} | ||
193 | ); | ||
194 | txtTitle = insertTextField("txtTitle", null, | ||
195 | new String[] {PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}, | ||
196 | new Object[] { 26,TXTTITLE_HID,Boolean.TRUE,166,66,INTEGERS[2],new Short((short)206),138} | ||
197 | ); | ||
198 | lblLocation = insertLabel("lblLocation", | ||
199 | PROPS_TEXT, | ||
200 | new Object[] { INTEGERS[8],resources.reslblLocation_value,97,100,INTEGERS[2],new Short((short)207),66} | ||
201 | ); | ||
202 | cbLocation = insertTextField("cbLocation", null,null, | ||
203 | new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH}, | ||
204 | new Object[] { 34,CBLOCATION_HID,Boolean.TRUE,166,98,INTEGERS[2],new Short((short)208),138} | ||
205 | ); | ||
206 | |||
207 | imgHelp2 = insertImage("imgHelp2", | ||
208 | PROPS_IMAGE, | ||
209 | new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, 92,145,Boolean.FALSE, INTEGERS[2],new Short((short)209),INTEGERS[10]} | ||
210 | ); | ||
211 | lblHelp2 = insertLabel("lblHelp2", | ||
212 | PROPS_TEXTAREA, | ||
213 | new Object[] { 39,resources.reslblHelp2_value,Boolean.TRUE,104,145,INTEGERS[2],new Short((short)210),199} | ||
214 | ); | ||
215 | |||
216 | } | ||
217 | |||
218 | public void buildStep3() { | ||
219 | lblTitle3 = insertLabel("lblTitle3", | ||
220 | PROPS_LABEL_B, | ||
221 | new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle3_value,Boolean.TRUE,91,INTEGERS[8],INTEGERS[3],new Short((short)300),212} | ||
222 | ); | ||
223 | chkMeetingTitle = insertCheckBox("chkMeetingTitle", null, | ||
224 | PROPS_CHECK, | ||
225 | new Object[] { INTEGERS[8],CHKMEETINGTITLE_HID,resources.reschkMeetingTitle_value,97,32,new Short((short)1),INTEGERS[3],new Short((short)301),69} | ||
226 | ); | ||
227 | chkRead = insertCheckBox("chkRead", null, | ||
228 | PROPS_CHECK, | ||
229 | new Object[] { INTEGERS[8],CHKREAD_HID,resources.reschkRead_value,97,46,new Short((short)0),INTEGERS[3],new Short((short)302),162} | ||
230 | ); | ||
231 | chkBring = insertCheckBox("chkBring", null, | ||
232 | PROPS_CHECK, | ||
233 | new Object[] { INTEGERS[8],CHKBRING_HID,resources.reschkBring_value,97,60,new Short((short)0),INTEGERS[3],new Short((short)303),162} | ||
234 | ); | ||
235 | chkNotes = insertCheckBox("chkNotes", null, | ||
236 | PROPS_CHECK, | ||
237 | new Object[] { INTEGERS[8],CHKNOTES_HID,resources.reschkNotes_value,97,74,new Short((short)1),INTEGERS[3],new Short((short)304),160} | ||
238 | ); | ||
239 | imgHelp3 = insertImage("imgHelp3", | ||
240 | PROPS_IMAGE, | ||
241 | new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, 92,145,Boolean.FALSE, INTEGERS[3],new Short((short)305),INTEGERS[10]} | ||
242 | ); | ||
243 | lblHelp3 = insertLabel("lblHelp3", | ||
244 | PROPS_TEXTAREA, | ||
245 | new Object[] { 39,resources.reslblHelp3_value,Boolean.TRUE,104,145,INTEGERS[3],new Short((short)306),199} | ||
246 | ); | ||
247 | } | ||
248 | |||
249 | public void buildStep4() { | ||
250 | lblTitle5 = insertLabel("lblTitle5", | ||
251 | PROPS_LABEL_B, | ||
252 | new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle5_value,Boolean.TRUE,91,INTEGERS[8],INTEGERS[4],new Short((short)400),212} | ||
253 | ); | ||
254 | chkConvenedBy = insertCheckBox("chkConvenedBy", null, | ||
255 | PROPS_CHECK, | ||
256 | new Object[] { INTEGERS[8],CHKCONVENEDBY_HID,resources.reschkConvenedBy_value,97,32,new Short((short)1),INTEGERS[4],new Short((short)401),150} | ||
257 | ); | ||
258 | chkPresiding = insertCheckBox("chkPresiding", null, | ||
259 | PROPS_CHECK, | ||
260 | new Object[] { INTEGERS[8],CHKPRESIDING_HID,resources.reschkPresiding_value,97,46,new Short((short)0),INTEGERS[4],new Short((short)402),150} | ||
261 | ); | ||
262 | chkNoteTaker = insertCheckBox("chkNoteTaker", null, | ||
263 | PROPS_CHECK, | ||
264 | new Object[] { INTEGERS[8],CHKNOTETAKER_HID,resources.reschkNoteTaker_value,97,60,new Short((short)0),INTEGERS[4],new Short((short)403),150} | ||
265 | ); | ||
266 | chkTimekeeper = insertCheckBox("chkTimekeeper", null, | ||
267 | PROPS_CHECK, | ||
268 | new Object[] { INTEGERS[8],CHKTIMEKEEPER_HID,resources.reschkTimekeeper_value,97,74,new Short((short)0),INTEGERS[4],new Short((short)404),150} | ||
269 | ); | ||
270 | chkAttendees = insertCheckBox("chkAttendees", null, | ||
271 | PROPS_CHECK, | ||
272 | new Object[] { INTEGERS[8],CHKATTENDEES_HID,resources.reschkAttendees_value,97,88,new Short((short)1),INTEGERS[4],new Short((short)405),150} | ||
273 | ); | ||
274 | chkObservers = insertCheckBox("chkObservers", null, | ||
275 | PROPS_CHECK, | ||
276 | new Object[] { INTEGERS[8],CHKOBSERVERS_HID,resources.reschkObservers_value,97,102,new Short((short)0),INTEGERS[4],new Short((short)406),150} | ||
277 | ); | ||
278 | chkResourcePersons = insertCheckBox("chkResourcePersons", null, | ||
279 | PROPS_CHECK, | ||
280 | new Object[] { INTEGERS[8],CHKRESOURCEPERSONS_HID,resources.reschkResourcePersons_value,97,116,new Short((short)0),INTEGERS[4],new Short((short)407),150} | ||
281 | ); | ||
282 | imgHelp4 = insertImage("imgHelp4", | ||
283 | PROPS_IMAGE, | ||
284 | new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, 92,145,Boolean.FALSE, INTEGERS[4],new Short((short)408),INTEGERS[10]} | ||
285 | ); | ||
286 | lblHelp4 = insertLabel("lblHelp4", | ||
287 | PROPS_TEXTAREA, | ||
288 | new Object[] { 39,resources.reslblHelp4_value,Boolean.TRUE,104,145,INTEGERS[4],new Short((short)409),199} | ||
289 | ); | ||
290 | } | ||
291 | |||
292 | public void buildStep5() { | ||
293 | lblTitle4 = insertLabel("lblTitle4", | ||
294 | PROPS_LABEL_B, | ||
295 | new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle4_value,Boolean.TRUE,91,INTEGERS[8],INTEGERS[5],new Short((short)500),212} | ||
296 | ); | ||
297 | lblTopic = insertLabel("lblTopic", | ||
298 | PROPS_TEXT, | ||
299 | new Object[] { INTEGERS[8],resources.reslblTopic_value,107,28,INTEGERS[5],new Short((short)71),501} | ||
300 | ); | ||
301 | lblResponsible = insertLabel("lblResponsible", | ||
302 | PROPS_TEXT, | ||
303 | new Object[] { INTEGERS[8],resources.reslblResponsible_value,195,28,INTEGERS[5],new Short((short)72),502} | ||
304 | ); | ||
305 | lblDuration = insertLabel("lblDuration", | ||
306 | PROPS_TEXT, | ||
307 | new Object[] { INTEGERS[8],resources.reslblDuration_value,267,28,INTEGERS[5],new Short((short)73),503} | ||
308 | ); | ||
309 | |||
310 | |||
311 | |||
312 | |||
313 | |||
314 | btnInsert = insertButton("btnInsert", BTNINSERT_ACTION_PERFORMED, | ||
315 | PROPS_BUTTON, | ||
316 | new Object[] { INTEGER_14,BTNINSERT_HID,resources.resButtonInsert,92,136,INTEGERS[5],new Short((short)580),INTEGER_40} | ||
317 | ); | ||
318 | btnRemove = insertButton("btnRemove", BTNREMOVE_ACTION_PERFORMED, | ||
319 | PROPS_BUTTON, | ||
320 | new Object[] { INTEGER_14,BTNREMOVE_HID,resources.resButtonRemove,134,136,INTEGERS[5],new Short((short)581),INTEGER_40} | ||
321 | ); | ||
322 | btnUp = insertButton("btnUp", BTNUP_ACTION_PERFORMED, | ||
323 | PROPS_BUTTON, | ||
324 | new Object[] { INTEGER_14,BTNUP_HID,resources.resButtonUp,202,136,INTEGERS[5],new Short((short)582),INTEGER_50} | ||
325 | ); | ||
326 | btnDown = insertButton("btnDown", BTNDOWN_ACTION_PERFORMED, | ||
327 | PROPS_BUTTON, | ||
328 | new Object[] { INTEGER_14,BTNDOWN_HID,resources.resButtonDown,254,136,INTEGERS[5],new Short((short)583),INTEGER_50} | ||
329 | ); | ||
330 | |||
331 | |||
332 | } | ||
333 | |||
334 | public void buildStep6() { | ||
335 | |||
336 | lblTitle6 = insertLabel("lblTitle6", | ||
337 | PROPS_LABEL_B, | ||
338 | new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle6_value,Boolean.TRUE,91,INTEGERS[8],INTEGERS[6],new Short((short)600),212} | ||
339 | ); | ||
340 | lblHelpPg6 = insertLabel("lblHelpPg6", | ||
341 | PROPS_TEXTAREA, | ||
342 | new Object[] { 24,resources.reslblHelpPg6_value,Boolean.TRUE,97,32,INTEGERS[6],new Short((short)601),204} | ||
343 | ); | ||
344 | |||
345 | lblTemplateName = insertLabel("lblTemplateName", | ||
346 | PROPS_TEXT, | ||
347 | new Object[] { INTEGERS[8],resources.reslblTemplateName_value,97,62,INTEGERS[6],new Short((short)602),101} | ||
348 | ); | ||
349 | txtTemplateName = insertTextField("txtTemplateName", TXTTEMPLATENAME_TEXT_CHANGED, | ||
350 | PROPS_X, | ||
351 | new Object[] { INTEGER_12,TXTTEMPLATENAME_HID,202,60,INTEGERS[6],new Short((short)603),100} | ||
352 | ); | ||
353 | lblProceed = insertLabel("lblProceed", | ||
354 | PROPS_TEXT, | ||
355 | new Object[] { INTEGERS[8],resources.reslblProceed_value,97,101,INTEGERS[6],new Short((short)607),204} | ||
356 | ); | ||
357 | optCreateAgenda = insertRadioButton("optCreateAgenda", null, | ||
358 | PROPS_CHECK, | ||
359 | new Object[] { INTEGERS[8],OPTCREATEAGENDA_HID,resources.resoptCreateAgenda_value,103,113,new Short((short)1),INTEGERS[6],new Short((short)608),198} | ||
360 | ); | ||
361 | optMakeChanges = insertRadioButton("optMakeChanges", null, | ||
362 | PROPS_BUTTON, | ||
363 | new Object[] { INTEGERS[8],OPTMAKECHANGES_HID,resources.resoptMakeChanges_value,103,125,INTEGERS[6],new Short((short)609),198} | ||
364 | ); | ||
365 | imgHelp6 = insertImage("imgHelp6", | ||
366 | PROPS_IMAGE, | ||
367 | new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, 92,145,Boolean.FALSE, INTEGERS[6],new Short((short)610),INTEGERS[10]} | ||
368 | ); | ||
369 | lblHelp6 = insertLabel("lblHelp6", | ||
370 | PROPS_TEXTAREA, | ||
371 | new Object[] { 39,resources.reslblHelp6_value,Boolean.TRUE,104,145,INTEGERS[6],new Short((short)611),199} | ||
372 | ); | ||
373 | |||
374 | } | ||
375 | |||
376 | } | ||
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.java deleted file mode 100644 index b5bb78b0f43e..000000000000 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.java +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | import com.sun.star.wizards.common.HelpIds; | ||
21 | |||
22 | public interface AgendaWizardDialogConst { | ||
23 | |||
24 | /** | ||
25 | * These are event method names, used with reflection | ||
26 | * to call the methods under these names uppon | ||
27 | * events. | ||
28 | */ | ||
29 | |||
30 | final String LISTPAGEDESIGN_ACTION_PERFORMED = "pageDesignChanged"; | ||
31 | final String TXTTEMPLATENAME_TEXT_CHANGED = "templateTitleChanged"; | ||
32 | final String BTNTEMPLATEPATH_ACTION_PERFORMED = "saveAs"; | ||
33 | final String BTNINSERT_ACTION_PERFORMED = "insertRow"; | ||
34 | final String BTNREMOVE_ACTION_PERFORMED = "removeRow"; | ||
35 | final String BTNUP_ACTION_PERFORMED = "rowUp"; | ||
36 | final String BTNDOWN_ACTION_PERFORMED = "rowDown"; | ||
37 | |||
38 | final String INFO_IMAGE_URL = "private:resource/dbu/image/19205"; | ||
39 | /* ==================================== | ||
40 | * Help IDs | ||
41 | * ==================================== | ||
42 | */ | ||
43 | final int HID = 41051; | ||
44 | |||
45 | /* | ||
46 | * "HID:(hid)" - the dialog | ||
47 | * "HID:(hid+1) - the help button | ||
48 | * "HID:(hid+2)" - the back button | ||
49 | * "HID:(hid+3)" - the next button | ||
50 | * "HID:(hid+4)" - the create button | ||
51 | * "HID:(hid+5)" - the cancel button | ||
52 | */ | ||
53 | |||
54 | final String LISTPAGEDESIGN_HID = HelpIds.getHelpIdString((HID + 6)); | ||
55 | final String CHKMINUTES_HID = HelpIds.getHelpIdString((HID + 7)); | ||
56 | final String TXTTIME_HID = HelpIds.getHelpIdString((HID + 8)); | ||
57 | final String TXTDATE_HID = HelpIds.getHelpIdString((HID + 9)); | ||
58 | final String TXTTITLE_HID = HelpIds.getHelpIdString((HID + 10)); | ||
59 | final String CBLOCATION_HID = HelpIds.getHelpIdString((HID + 11)); | ||
60 | |||
61 | final String CHKMEETINGTITLE_HID = HelpIds.getHelpIdString((HID + 12)); | ||
62 | final String CHKREAD_HID = HelpIds.getHelpIdString((HID + 13)); | ||
63 | final String CHKBRING_HID = HelpIds.getHelpIdString((HID + 14)); | ||
64 | final String CHKNOTES_HID = HelpIds.getHelpIdString((HID + 15)); | ||
65 | |||
66 | final String CHKCONVENEDBY_HID = HelpIds.getHelpIdString((HID + 16)); | ||
67 | final String CHKPRESIDING_HID = HelpIds.getHelpIdString((HID + 17)); | ||
68 | final String CHKNOTETAKER_HID = HelpIds.getHelpIdString((HID + 18)); | ||
69 | final String CHKTIMEKEEPER_HID = HelpIds.getHelpIdString((HID + 19)); | ||
70 | final String CHKATTENDEES_HID = HelpIds.getHelpIdString((HID + 20)); | ||
71 | final String CHKOBSERVERS_HID = HelpIds.getHelpIdString((HID + 21)); | ||
72 | final String CHKRESOURCEPERSONS_HID = HelpIds.getHelpIdString((HID + 22)); | ||
73 | |||
74 | final String TXTTEMPLATENAME_HID = HelpIds.getHelpIdString((HID + 23)); | ||
75 | final String TXTTEMPLATEPATH_HID = HelpIds.getHelpIdString((HID + 24)); | ||
76 | final String BTNTEMPLATEPATH_HID = HelpIds.getHelpIdString((HID + 25)); | ||
77 | |||
78 | final String OPTCREATEAGENDA_HID = HelpIds.getHelpIdString((HID + 26)); | ||
79 | final String OPTMAKECHANGES_HID = HelpIds.getHelpIdString((HID + 27)); | ||
80 | |||
81 | final String BTNINSERT_HID = HelpIds.getHelpIdString((HID + 28)); | ||
82 | final String BTNREMOVE_HID = HelpIds.getHelpIdString((HID + 29)); | ||
83 | final String BTNUP_HID = HelpIds.getHelpIdString((HID + 30)); | ||
84 | final String BTNDOWN_HID = HelpIds.getHelpIdString((HID + 31)); | ||
85 | |||
86 | final int LAST_HID = HID + 32; | ||
87 | |||
88 | /* | ||
89 | * 32 : scroll bar | ||
90 | * 33 - 35 first topics row | ||
91 | * 36 - 38 second | ||
92 | * 39 - 41 | ||
93 | * 42 - 44 | ||
94 | * 45 - 47 | ||
95 | * total 5 rows / 3 controls. | ||
96 | */ | ||
97 | |||
98 | |||
99 | } | ||
100 | |||
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java deleted file mode 100644 index 8d7804610144..000000000000 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java +++ /dev/null | |||
@@ -1,570 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | |||
19 | package com.sun.star.wizards.agenda; | ||
20 | |||
21 | import java.util.ArrayList; | ||
22 | |||
23 | import com.sun.star.awt.ItemEvent; | ||
24 | import com.sun.star.awt.VclWindowPeerAttribute; | ||
25 | import com.sun.star.awt.XItemListener; | ||
26 | import com.sun.star.awt.XWindow; | ||
27 | import com.sun.star.awt.XWindowPeer; | ||
28 | import com.sun.star.beans.PropertyValue; | ||
29 | import com.sun.star.lang.EventObject; | ||
30 | import com.sun.star.lang.XMultiServiceFactory; | ||
31 | import com.sun.star.task.XInteractionHandler; | ||
32 | import com.sun.star.text.XTextDocument; | ||
33 | import com.sun.star.uno.UnoRuntime; | ||
34 | import com.sun.star.util.CloseVetoException; | ||
35 | import com.sun.star.util.XCloseable; | ||
36 | import com.sun.star.wizards.common.Configuration; | ||
37 | import com.sun.star.wizards.common.Desktop; | ||
38 | import com.sun.star.wizards.common.FileAccess; | ||
39 | import com.sun.star.wizards.common.HelpIds; | ||
40 | import com.sun.star.wizards.common.Helper; | ||
41 | import com.sun.star.wizards.common.NoValidPathException; | ||
42 | import com.sun.star.wizards.common.PropertyNames; | ||
43 | import com.sun.star.wizards.common.SystemDialog; | ||
44 | import com.sun.star.wizards.document.OfficeDocument; | ||
45 | import com.sun.star.wizards.text.ViewHandler; | ||
46 | import com.sun.star.wizards.ui.PathSelection; | ||
47 | import com.sun.star.wizards.ui.XPathSelectionListener; | ||
48 | import com.sun.star.wizards.ui.event.DataAware; | ||
49 | import com.sun.star.wizards.ui.event.RadioDataAware; | ||
50 | import com.sun.star.wizards.ui.event.UnoDataAware; | ||
51 | |||
52 | import com.sun.star.beans.XPropertySet; | ||
53 | import com.sun.star.uno.XInterface; | ||
54 | |||
55 | /** | ||
56 | * This class is the dialog implementation class - | ||
57 | * there is not much business logic here - but mostley | ||
58 | * event methods. | ||
59 | * Some event methods are also implemented in TopicsControl and TopicsControl.ControlRow. | ||
60 | */ | ||
61 | public class AgendaWizardDialogImpl extends AgendaWizardDialog | ||
62 | { | ||
63 | /** | ||
64 | * used to prevent a double start of the wizard. | ||
65 | */ | ||
66 | static boolean running; | ||
67 | |||
68 | /** | ||
69 | * the preview document controller. | ||
70 | */ | ||
71 | AgendaTemplate agendaTemplate; | ||
72 | /** | ||
73 | * the data model, read from the OOo configuration. | ||
74 | * (live synchronized: when the user changes the gui, | ||
75 | * the data model changes, except for topics). | ||
76 | */ | ||
77 | private CGAgenda agenda; | ||
78 | |||
79 | /** | ||
80 | * the topics control, a gui element which | ||
81 | * manipulates the topics data according to the | ||
82 | * user's input. | ||
83 | */ | ||
84 | private TopicsControl topicsControl; | ||
85 | |||
86 | /** | ||
87 | * an array with two array memebers: | ||
88 | * agendaTemplates[0] contains an array with | ||
89 | * UI template names. | ||
90 | * agendaTemplates[1] contains an array with | ||
91 | * corresponding URLs. | ||
92 | */ | ||
93 | private String[][] agendaTemplates; | ||
94 | |||
95 | PathSelection myPathSelection; | ||
96 | |||
97 | String sTemplatePath; | ||
98 | String sUserTemplatePath; | ||
99 | String sBitmapPath; | ||
100 | |||
101 | String sPath; | ||
102 | |||
103 | /** constructor */ | ||
104 | public AgendaWizardDialogImpl(XMultiServiceFactory xmsf) | ||
105 | { | ||
106 | super(xmsf); | ||
107 | } | ||
108 | |||
109 | protected void enterStep(int OldStep, int NewStep) {} | ||
110 | protected void leaveStep(int OldStep, int NewStep) {} | ||
111 | |||
112 | /** | ||
113 | * read the configuration data, open the specified template, | ||
114 | * initialize the template controller (AgendaTemplate) and | ||
115 | * set the status of the displayed template to the one | ||
116 | * read from the configuration. | ||
117 | * build the dialog. | ||
118 | * Synchronize the dialog to the same status (read from | ||
119 | * the configuration). | ||
120 | * show the dialog. | ||
121 | */ | ||
122 | public void startWizard() { | ||
123 | running = true; | ||
124 | try { | ||
125 | // read configuration data. | ||
126 | agenda = new CGAgenda(); | ||
127 | |||
128 | Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda", false); | ||
129 | agenda.readConfiguration(root,"cp_"); | ||
130 | |||
131 | // initialize the agenda template | ||
132 | agendaTemplate = new AgendaTemplate(xMSF, agenda, resources, this); | ||
133 | initializeTemplates(); | ||
134 | |||
135 | agendaTemplate.load(agendaTemplates[1][agenda.cp_AgendaType] , new ArrayList<PropertyValue[]>()); | ||
136 | |||
137 | // build the dialog. | ||
138 | buildStep1(); | ||
139 | buildStep2(); | ||
140 | buildStep3(); | ||
141 | buildStep4(); | ||
142 | buildStep5(); | ||
143 | topicsControl = new TopicsControl(this,xMSF, agenda); | ||
144 | buildStep6(); | ||
145 | drawNaviBar(); | ||
146 | |||
147 | initializePaths(); | ||
148 | |||
149 | //special Control for setting the save Path: | ||
150 | insertPathSelectionControl(); | ||
151 | |||
152 | // create the peer | ||
153 | XWindow xw = agendaTemplate.xFrame.getContainerWindow(); | ||
154 | XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xw); | ||
155 | this.createWindowPeer( xWindowPeer ); | ||
156 | |||
157 | // initialize roadmap | ||
158 | this.addRoadmap(); | ||
159 | this.insertRoadMapItems( | ||
160 | new String[] { resources.resStep1, resources.resStep2, resources.resStep3, resources.resStep4, resources.resStep5, resources.resStep6, } , | ||
161 | new int[] { 1,2,3,4,5,6}, | ||
162 | new boolean[] { true,true,true,true,true,true } | ||
163 | ); | ||
164 | this.setMaxStep(6); | ||
165 | |||
166 | // synchronize GUI and CGAgenda object. | ||
167 | makeDA(); | ||
168 | if(myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(PropertyNames.EMPTY_STRING)) {myPathSelection.initializePath();} | ||
169 | |||
170 | executeDialog(agendaTemplate.xFrame); | ||
171 | removeTerminateListener(); | ||
172 | closeDocument(); | ||
173 | running = false; | ||
174 | |||
175 | } | ||
176 | catch (Exception ex) { | ||
177 | removeTerminateListener(); | ||
178 | ex.printStackTrace(); | ||
179 | running=false; | ||
180 | } | ||
181 | |||
182 | |||
183 | } | ||
184 | |||
185 | private class myPathSelectionListener implements XPathSelectionListener { | ||
186 | public void validatePath() { | ||
187 | if (myPathSelection.usedPathPicker) { | ||
188 | filenameChanged = true; | ||
189 | } | ||
190 | myPathSelection.usedPathPicker = false; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | |||
195 | public void insertPathSelectionControl() { | ||
196 | myPathSelection = new PathSelection(xMSF, this, PathSelection.TransferMode.SAVE, PathSelection.DialogTypes.FILE); | ||
197 | myPathSelection.insert(6, 97, 70, 205, (short) 45, resources.reslblTemplatePath_value, true, HelpIds.getHelpIdString( HID + 24 ), HelpIds.getHelpIdString( HID + 25 )); | ||
198 | myPathSelection.sDefaultDirectory = sUserTemplatePath; | ||
199 | myPathSelection.sDefaultName = "myAgendaTemplate.ott"; | ||
200 | myPathSelection.sDefaultFilter = "writer8_template"; | ||
201 | myPathSelection.addSelectionListener(new myPathSelectionListener()); | ||
202 | } | ||
203 | |||
204 | private void initializePaths() { | ||
205 | try { | ||
206 | sUserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", PropertyNames.EMPTY_STRING); | ||
207 | sBitmapPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../wizard/bitmap"); | ||
208 | } catch (NoValidPathException e) { | ||
209 | e.printStackTrace(); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | private void checkSavePath() { | ||
214 | if (agenda.cp_TemplatePath == null || | ||
215 | agenda.cp_TemplatePath.equals(PropertyNames.EMPTY_STRING) || | ||
216 | !getFileAccess().exists(FileAccess.getParentDir(agenda.cp_TemplatePath),false) || | ||
217 | !getFileAccess().isDirectory(FileAccess.getParentDir(agenda.cp_TemplatePath ))) | ||
218 | { | ||
219 | try { | ||
220 | agenda.cp_TemplatePath = | ||
221 | FileAccess.connectURLs( | ||
222 | FileAccess.getOfficePath(xMSF, "Work", PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING) , | ||
223 | resources.resDefaultFilename | ||
224 | ); | ||
225 | } | ||
226 | catch (Exception ex) { | ||
227 | ex.printStackTrace(); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | /** | ||
233 | * bind controls to the agenda member (DataAware model) | ||
234 | */ | ||
235 | private void makeDA() { | ||
236 | |||
237 | setControlProperty("listPageDesign", PropertyNames.STRING_ITEM_LIST, agendaTemplates[0]); | ||
238 | |||
239 | checkSavePath(); | ||
240 | |||
241 | UnoDataAware.attachListBox( agenda, "cp_AgendaType", listPageDesign , null, true ).updateUI(); | ||
242 | UnoDataAware.attachCheckBox( agenda, "cp_IncludeMinutes", chkMinutes, null, true).updateUI(); | ||
243 | |||
244 | UnoDataAware.attachEditControl(agenda, "cp_Title", txtTitle, agendaTemplate , true).updateUI(); | ||
245 | UnoDataAware.attachDateControl(agenda, "cp_Date", txtDate, agendaTemplate , true).updateUI(); | ||
246 | UnoDataAware.attachTimeControl(agenda, "cp_Time", txtTime, agendaTemplate , true).updateUI(); | ||
247 | UnoDataAware.attachEditControl(agenda, "cp_Location", cbLocation, agendaTemplate , true).updateUI(); | ||
248 | |||
249 | UnoDataAware.attachCheckBox(agenda,"cp_ShowMeetingType", chkMeetingTitle , new RedrawListener( TemplateConsts.FILLIN_MEETING_TYPE ) , true); | ||
250 | UnoDataAware.attachCheckBox(agenda,"cp_ShowRead", chkRead , new RedrawListener( TemplateConsts.FILLIN_READ ) , true).updateUI(); | ||
251 | UnoDataAware.attachCheckBox(agenda,"cp_ShowBring", chkBring , new RedrawListener( TemplateConsts.FILLIN_BRING ) , true).updateUI(); | ||
252 | UnoDataAware.attachCheckBox(agenda,"cp_ShowNotes", chkNotes , new RedrawListener( TemplateConsts.FILLIN_NOTES ) , true).updateUI(); | ||
253 | |||
254 | UnoDataAware.attachCheckBox(agenda,"cp_ShowCalledBy", chkConvenedBy , new RedrawListener( TemplateConsts.FILLIN_CALLED_BY ) , true).updateUI(); | ||
255 | UnoDataAware.attachCheckBox(agenda,"cp_ShowFacilitator", chkPresiding , new RedrawListener( TemplateConsts.FILLIN_FACILITATOR ) , true).updateUI(); | ||
256 | UnoDataAware.attachCheckBox(agenda,"cp_ShowNotetaker", chkNoteTaker , new RedrawListener( TemplateConsts.FILLIN_NOTETAKER ) , true).updateUI(); | ||
257 | UnoDataAware.attachCheckBox(agenda,"cp_ShowTimekeeper", chkTimekeeper , new RedrawListener( TemplateConsts.FILLIN_TIMEKEEPER ) , true).updateUI(); | ||
258 | UnoDataAware.attachCheckBox(agenda,"cp_ShowAttendees", chkAttendees , new RedrawListener( TemplateConsts.FILLIN_PARTICIPANTS ) , true).updateUI(); | ||
259 | UnoDataAware.attachCheckBox(agenda,"cp_ShowObservers", chkObservers , new RedrawListener( TemplateConsts.FILLIN_OBSERVERS ) , true).updateUI(); | ||
260 | UnoDataAware.attachCheckBox(agenda,"cp_ShowResourcePersons", chkResourcePersons , new RedrawListener( TemplateConsts.FILLIN_RESOURCE_PERSONS ) , true).updateUI(); | ||
261 | |||
262 | UnoDataAware.attachEditControl(agenda, "cp_TemplateName", txtTemplateName, null, true).updateUI(); | ||
263 | RadioDataAware.attachRadioButtons( agenda, "cp_ProceedMethod", | ||
264 | new Object[] {optCreateAgenda, optMakeChanges} ,null,true).updateUI(); | ||
265 | |||
266 | listPageDesign.addItemListener(new XItemListener() { | ||
267 | public void itemStateChanged(ItemEvent ie) { | ||
268 | pageDesignChanged(ie); | ||
269 | } | ||
270 | public void disposing(EventObject eo) {} | ||
271 | }); | ||
272 | } | ||
273 | |||
274 | /** used in developement to start the wizard */ | ||
275 | public static void main(String args[]) | ||
276 | { | ||
277 | String ConnectStr = "uno:socket,host=127.0.0.1,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager"; | ||
278 | try { | ||
279 | XMultiServiceFactory xLocMSF = Desktop.connect(ConnectStr); | ||
280 | AgendaWizardDialogImpl wizard = new AgendaWizardDialogImpl(xLocMSF); | ||
281 | wizard.startWizard(); | ||
282 | |||
283 | } | ||
284 | catch (Exception exception) { | ||
285 | exception.printStackTrace(); | ||
286 | } | ||
287 | } | ||
288 | |||
289 | |||
290 | |||
291 | /** | ||
292 | * read the available agenda wizard templates. | ||
293 | */ | ||
294 | public boolean initializeTemplates() { | ||
295 | try { | ||
296 | XInterface xPathInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings"); | ||
297 | XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xPathInterface); | ||
298 | sTemplatePath = ((String[]) xPropertySet.getPropertyValue("Template_user"))[0]; | ||
299 | |||
300 | String sAgendaPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../common/wizard/agenda" ); | ||
301 | |||
302 | agendaTemplates = FileAccess.getFolderTitles(xMSF, "aw" , sAgendaPath); | ||
303 | |||
304 | return true; | ||
305 | } catch (NoValidPathException nopathexception) { | ||
306 | nopathexception.printStackTrace(); | ||
307 | return false; | ||
308 | } catch (Exception exception) { | ||
309 | exception.printStackTrace(); | ||
310 | return false; | ||
311 | } | ||
312 | } | ||
313 | |||
314 | /* ****************************** | ||
315 | * Event methods | ||
316 | * ****************************** | ||
317 | */ | ||
318 | |||
319 | /** | ||
320 | * first page, page design listbox changed. | ||
321 | */ | ||
322 | public void pageDesignChanged(ItemEvent ie) { | ||
323 | int selected = ie.Selected; | ||
324 | try { | ||
325 | agendaTemplate.load( agendaTemplates[1][selected] , topicsControl.getTopicsData()); | ||
326 | } | ||
327 | catch (Exception ex) { | ||
328 | SystemDialog.showMessageBox(xMSF, "ErrBox", VclWindowPeerAttribute.OK, resources.resErrOpenTemplate); | ||
329 | ex.printStackTrace(); | ||
330 | } | ||
331 | agendaTemplate.refreshTopicConstants(); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * last page, template title changed... | ||
336 | */ | ||
337 | public void templateTitleChanged() { | ||
338 | String title = (String)Helper.getUnoPropertyValue( getModel(txtTemplateName), "Text" ); | ||
339 | agendaTemplate.setTemplateTitle( title ); | ||
340 | } | ||
341 | |||
342 | |||
343 | private FileAccess fileAccess1; | ||
344 | /** convenience method. | ||
345 | * instead of creating a FileAccess object every time | ||
346 | * it is needed, I have a FileAccess object memeber. | ||
347 | * the first time it is needed it will be created, and | ||
348 | * then be reused... | ||
349 | * @return the FileAccess memeber object. | ||
350 | */ | ||
351 | private FileAccess getFileAccess() { | ||
352 | if (fileAccess1 == null) | ||
353 | try { | ||
354 | fileAccess1 = new FileAccess(xMSF); | ||
355 | } catch (Exception e) { | ||
356 | e.printStackTrace(); | ||
357 | } | ||
358 | return fileAccess1; | ||
359 | |||
360 | } | ||
361 | /** | ||
362 | * indicates if the filename was changed by the user through | ||
363 | * the "save as" dialog. | ||
364 | * If it is so, one needs not warn the user | ||
365 | * upon overwrite, since she was already warned. | ||
366 | */ | ||
367 | private boolean filenameChanged = false; | ||
368 | |||
369 | /** | ||
370 | * last page, "browse" ("...") button was clicked... | ||
371 | */ | ||
372 | public void saveAs() { | ||
373 | try { | ||
374 | |||
375 | checkSavePath(); | ||
376 | |||
377 | SystemDialog saveAs = SystemDialog.createStoreDialog(xMSF); | ||
378 | saveAs.addFilterToDialog("ott","writer8_template",true); | ||
379 | // call the saveAs dialog. | ||
380 | String url = saveAs.callStoreDialog( | ||
381 | FileAccess.getParentDir(agenda.cp_TemplatePath), | ||
382 | FileAccess.getFilename(agenda.cp_TemplatePath)); | ||
383 | |||
384 | if (url != null) { | ||
385 | agenda.cp_TemplatePath = url; | ||
386 | setFilename(url); | ||
387 | filenameChanged = true; | ||
388 | } | ||
389 | } | ||
390 | catch (Exception ex) { | ||
391 | ex.printStackTrace(); | ||
392 | } | ||
393 | |||
394 | |||
395 | } | ||
396 | |||
397 | /** | ||
398 | * is called when the user | ||
399 | * changes the path through the "save as" dialog. | ||
400 | * The path displayed is a translated, user-friendly, platform dependant path. | ||
401 | * @param url the new save url. | ||
402 | */ | ||
403 | private void setFilename(String url) { | ||
404 | try { | ||
405 | String path = getFileAccess().getPath(url,PropertyNames.EMPTY_STRING); | ||
406 | Helper.setUnoPropertyValue( getModel(myPathSelection.xSaveTextBox), "Text", path); | ||
407 | } | ||
408 | catch (Exception ex) { | ||
409 | ex.printStackTrace(); | ||
410 | } | ||
411 | |||
412 | } | ||
413 | |||
414 | public void insertRow() { | ||
415 | topicsControl.insertRow(); | ||
416 | } | ||
417 | |||
418 | public void removeRow() { | ||
419 | topicsControl.removeRow(); | ||
420 | } | ||
421 | |||
422 | public void rowUp() { | ||
423 | topicsControl.rowUp(); | ||
424 | } | ||
425 | |||
426 | public void rowDown() { | ||
427 | topicsControl.rowDown(); | ||
428 | } | ||
429 | |||
430 | |||
431 | /* ************************ | ||
432 | * Navigation bar methods | ||
433 | * ************************ | ||
434 | */ | ||
435 | |||
436 | public void cancelWizard() { | ||
437 | xDialog.endExecute(); | ||
438 | running = false; | ||
439 | } | ||
440 | |||
441 | public boolean finishWizard() { | ||
442 | boolean bSaveSuccess = false; // pesimistic :( | ||
443 | XTextDocument xTextDocument; | ||
444 | |||
445 | try { | ||
446 | FileAccess fileAccess = new FileAccess(xMSF); | ||
447 | sPath = myPathSelection.getSelectedPath(); | ||
448 | if (sPath.equals(PropertyNames.EMPTY_STRING)) { | ||
449 | myPathSelection.triggerPathPicker(); | ||
450 | sPath = myPathSelection.getSelectedPath(); | ||
451 | } | ||
452 | sPath = fileAccess.getURL(sPath); | ||
453 | |||
454 | //first, if the filename was not changed, thus | ||
455 | //it is coming from a saved session, check if the | ||
456 | // file exists and warn the user. | ||
457 | if (!filenameChanged) | ||
458 | if (fileAccess.exists(sPath, true)) { | ||
459 | |||
460 | int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resFileExists); | ||
461 | if (answer == 3) // user said: no, do not overwrite.... | ||
462 | return false; | ||
463 | } | ||
464 | |||
465 | agendaTemplate.xTextDocument.lockControllers(); | ||
466 | |||
467 | xTextDocument = UnoRuntime.queryInterface(XTextDocument.class,agendaTemplate.document); | ||
468 | |||
469 | bSaveSuccess = OfficeDocument.store(xMSF, xTextDocument, sPath , "writer8_template", false ); | ||
470 | } catch (Exception e) { | ||
471 | SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "ErrorBox", VclWindowPeerAttribute.OK, resources.resErrSaveTemplate); | ||
472 | } | ||
473 | |||
474 | if (bSaveSuccess) { | ||
475 | try { | ||
476 | topicsControl.saveTopics(agenda); | ||
477 | Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda", true); | ||
478 | agenda.writeConfiguration(root,"cp_"); | ||
479 | Configuration.commit(root); | ||
480 | } | ||
481 | catch (Exception ex) { | ||
482 | ex.printStackTrace(); | ||
483 | } | ||
484 | |||
485 | agendaTemplate.finish( topicsControl.getTopicsData()); | ||
486 | |||
487 | //I have no exact idea what this is doing, but the error message kept | ||
488 | //popping up, no matter what I tried. Even though I excluded this, it | ||
489 | //kept working perfectly. I suggest that this tries to store the template | ||
490 | //document, but it is already stored, written down by a code above. The | ||
491 | //reason this piece is malfunctioning, because the agendaTemplate.document | ||
492 | //is read-only (At least as my tests indicated.). | ||
493 | |||
494 | agendaTemplate.xTextDocument.unlockControllers(); | ||
495 | |||
496 | PropertyValue loadValues[] = new PropertyValue[2]; | ||
497 | loadValues[0] = new PropertyValue(); | ||
498 | loadValues[0].Name = "AsTemplate"; | ||
499 | if (agenda.cp_ProceedMethod == 1) { | ||
500 | loadValues[0].Value = Boolean.TRUE; | ||
501 | } else { | ||
502 | loadValues[0].Value = Boolean.FALSE; | ||
503 | } | ||
504 | loadValues[1] = new PropertyValue(); | ||
505 | loadValues[1].Name = "InteractionHandler"; | ||
506 | try { | ||
507 | loadValues[1].Value = UnoRuntime.queryInterface(XInteractionHandler.class, xMSF.createInstance("com.sun.star.comp.uui.UUIInteractionHandler")); | ||
508 | } catch (Exception e) { | ||
509 | e.printStackTrace(); | ||
510 | } | ||
511 | Object oDoc = OfficeDocument.load(Desktop.getDesktop(xMSF), sPath, "_default", new PropertyValue[0]); | ||
512 | xTextDocument = (com.sun.star.text.XTextDocument) oDoc; | ||
513 | XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); | ||
514 | ViewHandler myViewHandler = new ViewHandler(xDocMSF, xTextDocument); | ||
515 | try { | ||
516 | myViewHandler.setViewSetting("ZoomType", new Short(com.sun.star.view.DocumentZoomType.OPTIMAL)); | ||
517 | } | ||
518 | catch (Exception ex) { | ||
519 | ex.printStackTrace(); | ||
520 | } | ||
521 | } else { | ||
522 | agendaTemplate.xTextDocument.unlockControllers(); | ||
523 | return false; | ||
524 | } | ||
525 | xDialog.endExecute(); | ||
526 | running = false; | ||
527 | return true; | ||
528 | } | ||
529 | |||
530 | private void closeDocument() { | ||
531 | try { | ||
532 | XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, agendaTemplate.xFrame); | ||
533 | xCloseable.close(false); | ||
534 | } catch (CloseVetoException e) { | ||
535 | e.printStackTrace(); | ||
536 | } | ||
537 | } | ||
538 | |||
539 | /* ******************** | ||
540 | * Sub Classes | ||
541 | * ******************** | ||
542 | */ | ||
543 | |||
544 | |||
545 | /** | ||
546 | * this class is used to redraw an item's table when | ||
547 | * the user clicks one of the checkboxes in step 3 or 4. | ||
548 | */ | ||
549 | private class RedrawListener implements DataAware.Listener { | ||
550 | |||
551 | private String itemName; | ||
552 | |||
553 | public RedrawListener(String itemName_) { | ||
554 | itemName = itemName_; | ||
555 | } | ||
556 | |||
557 | /* (non-Javadoc) | ||
558 | * @see com.sun.star.wizards.ui.event.DataAware.Listener#eventPerformed(java.lang.Object) | ||
559 | */ | ||
560 | public void eventPerformed(Object event) { | ||
561 | agendaTemplate.xTextDocument.lockControllers(); | ||
562 | agendaTemplate.redraw(itemName); | ||
563 | agendaTemplate.refreshConstants(); | ||
564 | agendaTemplate.xTextDocument.unlockControllers(); | ||
565 | } | ||
566 | } | ||
567 | |||
568 | |||
569 | } | ||
570 | |||
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.java deleted file mode 100644 index 46ad1e0ba04a..000000000000 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.java +++ /dev/null | |||
@@ -1,247 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | |||
19 | package com.sun.star.wizards.agenda; | ||
20 | |||
21 | import com.sun.star.lang.XMultiServiceFactory; | ||
22 | import com.sun.star.wizards.common.Resource; | ||
23 | |||
24 | public class AgendaWizardDialogResources extends Resource { | ||
25 | |||
26 | final static String UNIT_NAME = "dbwizres"; | ||
27 | final static String MODULE_NAME = "dbw"; | ||
28 | final static int RID_AGENDAWIZARDDIALOG_START = 5000; | ||
29 | final static int RID_COMMON_START = 500; | ||
30 | |||
31 | |||
32 | String resAgendaWizardDialog_title; | ||
33 | String resoptMakeChanges_value; | ||
34 | String reslblTemplateName_value; | ||
35 | String reslblTemplatePath_value; | ||
36 | String reslblProceed_value; | ||
37 | String reslblTitle1_value; | ||
38 | String reslblTitle3_value; | ||
39 | String reslblTitle2_value; | ||
40 | String reslblTitle4_value; | ||
41 | String reslblTitle5_value; | ||
42 | String reslblTitle6_value; | ||
43 | String reschkMinutes_value; | ||
44 | String reslblHelp1_value; | ||
45 | String reslblTime_value; | ||
46 | String reslblTitle_value; | ||
47 | String reslblLocation_value; | ||
48 | String reslblHelp2_value; | ||
49 | String resbtnTemplatePath_value; | ||
50 | String resoptCreateAgenda_value; | ||
51 | String reslblHelp6_value; | ||
52 | String reslblTopic_value; | ||
53 | String reslblResponsible_value; | ||
54 | String reslblDuration_value; | ||
55 | String reschkConvenedBy_value; | ||
56 | String reschkPresiding_value; | ||
57 | String reschkNoteTaker_value; | ||
58 | String reschkTimekeeper_value; | ||
59 | String reschkAttendees_value; | ||
60 | String reschkObservers_value; | ||
61 | String reschkResourcePersons_value; | ||
62 | String reslblHelp4_value; | ||
63 | String reschkMeetingTitle_value; | ||
64 | String reschkRead_value; | ||
65 | String reschkBring_value; | ||
66 | String reschkNotes_value; | ||
67 | String reslblHelp3_value; | ||
68 | |||
69 | String reslblDate_value; | ||
70 | String reslblHelpPg6_value; | ||
71 | String reslblPageDesign_value; | ||
72 | |||
73 | String resDefaultFilename; | ||
74 | String resDefaultTitle; | ||
75 | |||
76 | String resErrSaveTemplate; | ||
77 | |||
78 | String resPlaceHolderTitle; | ||
79 | String resPlaceHolderDate; | ||
80 | String resPlaceHolderTime; | ||
81 | String resPlaceHolderLocation; | ||
82 | String resPlaceHolderHint; | ||
83 | |||
84 | String resStep1; | ||
85 | String resStep2; | ||
86 | String resStep3; | ||
87 | String resStep4; | ||
88 | String resStep5; | ||
89 | String resStep6; | ||
90 | |||
91 | String resErrOpenTemplate; | ||
92 | |||
93 | String itemMeetingType; | ||
94 | String itemRead; | ||
95 | String itemBring; | ||
96 | String itemNote; | ||
97 | String itemCalledBy; | ||
98 | String itemFacilitator; | ||
99 | String itemNotetaker; | ||
100 | String itemTimekeeper; | ||
101 | String itemAttendees; | ||
102 | String itemObservers; | ||
103 | String itemResource; | ||
104 | |||
105 | String resButtonInsert; | ||
106 | String resButtonRemove; | ||
107 | String resButtonUp; | ||
108 | String resButtonDown; | ||
109 | |||
110 | String resPlaceHolderDateTitle; | ||
111 | String resPlaceHolderTimeTitle; | ||
112 | String resPlaceHolderLocationTitle; | ||
113 | String resPlaceHolderTopics; | ||
114 | String resPlaceHolderNum; | ||
115 | String resPlaceHolderTopic; | ||
116 | String resPlaceHolderResponsible; | ||
117 | String resPlaceHolderTimeHeader; | ||
118 | String resPlaceHolderAdditionalInformation; | ||
119 | String resPlaceHolderMinutesFor; | ||
120 | String resPlaceHolderDiscussion; | ||
121 | String resPlaceHolderConclusion; | ||
122 | String resPlaceHolderToDo; | ||
123 | String resPlaceHolderResponsibleParty; | ||
124 | String resPlaceHolderDeadline; | ||
125 | // | ||
126 | |||
127 | |||
128 | // *** common resources *** | ||
129 | |||
130 | String resFileExists; | ||
131 | |||
132 | public AgendaWizardDialogResources(XMultiServiceFactory xmsf) { | ||
133 | super(xmsf,UNIT_NAME,MODULE_NAME); | ||
134 | |||
135 | /** | ||
136 | * Delete the String, uncomment the getResText method | ||
137 | * | ||
138 | */ | ||
139 | resAgendaWizardDialog_title = getResText(RID_AGENDAWIZARDDIALOG_START + 1); | ||
140 | resoptMakeChanges_value = getResText(RID_AGENDAWIZARDDIALOG_START + 2); | ||
141 | reslblTemplateName_value = getResText(RID_AGENDAWIZARDDIALOG_START + 3); | ||
142 | reslblTemplatePath_value = getResText(RID_AGENDAWIZARDDIALOG_START + 4); | ||
143 | reslblProceed_value = getResText(RID_AGENDAWIZARDDIALOG_START + 5); | ||
144 | reslblTitle1_value = getResText(RID_AGENDAWIZARDDIALOG_START + 6); | ||
145 | reslblTitle3_value = getResText(RID_AGENDAWIZARDDIALOG_START + 7); | ||
146 | reslblTitle2_value = getResText(RID_AGENDAWIZARDDIALOG_START + 8); | ||
147 | reslblTitle4_value = getResText(RID_AGENDAWIZARDDIALOG_START + 9); | ||
148 | reslblTitle5_value = getResText(RID_AGENDAWIZARDDIALOG_START + 10); | ||
149 | reslblTitle6_value = getResText(RID_AGENDAWIZARDDIALOG_START + 11); | ||
150 | reschkMinutes_value = getResText(RID_AGENDAWIZARDDIALOG_START + 12); | ||
151 | reslblHelp1_value = getResText(RID_AGENDAWIZARDDIALOG_START + 13); | ||
152 | reslblTime_value = getResText(RID_AGENDAWIZARDDIALOG_START + 14); | ||
153 | reslblTitle_value = getResText(RID_AGENDAWIZARDDIALOG_START + 15); | ||
154 | reslblLocation_value = getResText(RID_AGENDAWIZARDDIALOG_START + 16); | ||
155 | reslblHelp2_value = getResText(RID_AGENDAWIZARDDIALOG_START + 17); | ||
156 | resbtnTemplatePath_value = getResText(RID_AGENDAWIZARDDIALOG_START + 18); | ||
157 | resoptCreateAgenda_value = getResText(RID_AGENDAWIZARDDIALOG_START + 19); | ||
158 | reslblHelp6_value = getResText(RID_AGENDAWIZARDDIALOG_START + 20); | ||
159 | reslblTopic_value = getResText(RID_AGENDAWIZARDDIALOG_START + 21); | ||
160 | reslblResponsible_value = getResText(RID_AGENDAWIZARDDIALOG_START + 22); | ||
161 | reslblDuration_value = getResText(RID_AGENDAWIZARDDIALOG_START + 23); | ||
162 | reschkConvenedBy_value = getResText(RID_AGENDAWIZARDDIALOG_START + 24); | ||
163 | reschkPresiding_value = getResText(RID_AGENDAWIZARDDIALOG_START + 25); | ||
164 | reschkNoteTaker_value = getResText(RID_AGENDAWIZARDDIALOG_START + 26); | ||
165 | reschkTimekeeper_value = getResText(RID_AGENDAWIZARDDIALOG_START + 27); | ||
166 | reschkAttendees_value = getResText(RID_AGENDAWIZARDDIALOG_START + 28); | ||
167 | reschkObservers_value = getResText(RID_AGENDAWIZARDDIALOG_START + 29); | ||
168 | reschkResourcePersons_value = getResText(RID_AGENDAWIZARDDIALOG_START + 30); | ||
169 | reslblHelp4_value = getResText(RID_AGENDAWIZARDDIALOG_START + 31); | ||
170 | reschkMeetingTitle_value = getResText(RID_AGENDAWIZARDDIALOG_START + 32); | ||
171 | reschkRead_value = getResText(RID_AGENDAWIZARDDIALOG_START + 33); | ||
172 | reschkBring_value = getResText(RID_AGENDAWIZARDDIALOG_START + 34); | ||
173 | reschkNotes_value = getResText(RID_AGENDAWIZARDDIALOG_START + 35); | ||
174 | reslblHelp3_value = getResText(RID_AGENDAWIZARDDIALOG_START + 36); | ||
175 | reslblDate_value = getResText(RID_AGENDAWIZARDDIALOG_START + 38); | ||
176 | reslblHelpPg6_value = getResText(RID_AGENDAWIZARDDIALOG_START + 39); | ||
177 | reslblPageDesign_value = getResText(RID_AGENDAWIZARDDIALOG_START + 40); | ||
178 | |||
179 | resDefaultFilename = getResText(RID_AGENDAWIZARDDIALOG_START + 41); | ||
180 | resDefaultFilename = resDefaultFilename.substring(0,resDefaultFilename.length()-4) + ".ott"; | ||
181 | |||
182 | resDefaultTitle = getResText(RID_AGENDAWIZARDDIALOG_START + 42); | ||
183 | |||
184 | resErrSaveTemplate = getResText(RID_AGENDAWIZARDDIALOG_START + 43); | ||
185 | |||
186 | resPlaceHolderTitle = getResText(RID_AGENDAWIZARDDIALOG_START + 44); | ||
187 | resPlaceHolderDate = getResText(RID_AGENDAWIZARDDIALOG_START + 45); | ||
188 | resPlaceHolderTime = getResText(RID_AGENDAWIZARDDIALOG_START + 46); | ||
189 | resPlaceHolderLocation = getResText(RID_AGENDAWIZARDDIALOG_START + 47); | ||
190 | resPlaceHolderHint = getResText(RID_AGENDAWIZARDDIALOG_START + 48); | ||
191 | |||
192 | |||
193 | resStep1 = getResText(RID_AGENDAWIZARDDIALOG_START + 50); | ||
194 | resStep2 = getResText(RID_AGENDAWIZARDDIALOG_START + 51); | ||
195 | resStep3 = getResText(RID_AGENDAWIZARDDIALOG_START + 52); | ||
196 | resStep4 = getResText(RID_AGENDAWIZARDDIALOG_START + 53); | ||
197 | resStep5 = getResText(RID_AGENDAWIZARDDIALOG_START + 54); | ||
198 | resStep6 = getResText(RID_AGENDAWIZARDDIALOG_START + 55); | ||
199 | |||
200 | resErrOpenTemplate = getResText(RID_AGENDAWIZARDDIALOG_START + 56); | ||
201 | |||
202 | itemMeetingType = getResText(RID_AGENDAWIZARDDIALOG_START + 57); | ||
203 | itemBring = getResText(RID_AGENDAWIZARDDIALOG_START + 58); | ||
204 | itemRead = getResText(RID_AGENDAWIZARDDIALOG_START + 59); | ||
205 | itemNote = getResText(RID_AGENDAWIZARDDIALOG_START + 60); | ||
206 | |||
207 | itemCalledBy = getResText(RID_AGENDAWIZARDDIALOG_START + 61); | ||
208 | itemFacilitator = getResText(RID_AGENDAWIZARDDIALOG_START + 62); | ||
209 | itemAttendees = getResText(RID_AGENDAWIZARDDIALOG_START + 63); | ||
210 | itemNotetaker = getResText(RID_AGENDAWIZARDDIALOG_START + 64); | ||
211 | itemTimekeeper = getResText(RID_AGENDAWIZARDDIALOG_START + 65); | ||
212 | itemObservers = getResText(RID_AGENDAWIZARDDIALOG_START + 66); | ||
213 | itemResource = getResText(RID_AGENDAWIZARDDIALOG_START + 67); | ||
214 | |||
215 | resButtonInsert = getResText(RID_AGENDAWIZARDDIALOG_START + 68); | ||
216 | resButtonRemove = getResText(RID_AGENDAWIZARDDIALOG_START + 69); | ||
217 | resButtonUp = getResText(RID_AGENDAWIZARDDIALOG_START + 70); | ||
218 | resButtonDown = getResText(RID_AGENDAWIZARDDIALOG_START + 71); | ||
219 | |||
220 | // | ||
221 | resPlaceHolderDateTitle = getResText(RID_AGENDAWIZARDDIALOG_START + 72); | ||
222 | resPlaceHolderTimeTitle = getResText(RID_AGENDAWIZARDDIALOG_START + 73); | ||
223 | resPlaceHolderLocationTitle = getResText(RID_AGENDAWIZARDDIALOG_START + 74); | ||
224 | resPlaceHolderTopics = getResText(RID_AGENDAWIZARDDIALOG_START + 75); | ||
225 | resPlaceHolderNum = getResText(RID_AGENDAWIZARDDIALOG_START + 76); | ||
226 | resPlaceHolderTopic = getResText(RID_AGENDAWIZARDDIALOG_START + 77); | ||
227 | resPlaceHolderResponsible = getResText(RID_AGENDAWIZARDDIALOG_START + 78); | ||
228 | resPlaceHolderTimeHeader = getResText(RID_AGENDAWIZARDDIALOG_START + 79); | ||
229 | resPlaceHolderAdditionalInformation = getResText(RID_AGENDAWIZARDDIALOG_START + 80); | ||
230 | resPlaceHolderMinutesFor = getResText(RID_AGENDAWIZARDDIALOG_START + 81); | ||
231 | resPlaceHolderDiscussion = getResText(RID_AGENDAWIZARDDIALOG_START + 82); | ||
232 | resPlaceHolderConclusion = getResText(RID_AGENDAWIZARDDIALOG_START + 83); | ||
233 | resPlaceHolderToDo = getResText(RID_AGENDAWIZARDDIALOG_START + 84); | ||
234 | resPlaceHolderResponsibleParty = getResText(RID_AGENDAWIZARDDIALOG_START + 85); | ||
235 | resPlaceHolderDeadline = getResText(RID_AGENDAWIZARDDIALOG_START + 86); | ||
236 | |||
237 | |||
238 | // | ||
239 | |||
240 | /* | ||
241 | * Common resources | ||
242 | */ | ||
243 | |||
244 | resFileExists = getResText(RID_COMMON_START + 19); | ||
245 | |||
246 | } | ||
247 | } | ||
diff --git a/wizards/com/sun/star/wizards/agenda/CGAgenda.java b/wizards/com/sun/star/wizards/agenda/CGAgenda.java deleted file mode 100644 index 318bfe67d295..000000000000 --- a/wizards/com/sun/star/wizards/agenda/CGAgenda.java +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | import com.sun.star.wizards.common.ConfigGroup; | ||
21 | import com.sun.star.wizards.common.ConfigSet; | ||
22 | import com.sun.star.wizards.common.PropertyNames; | ||
23 | |||
24 | /** | ||
25 | * CGAgenda means Configuration Group Agenda. | ||
26 | * This object encapsulates a OOo configuration group, used | ||
27 | * to save the state of the agenda wizard for reloading uppon | ||
28 | * next start. | ||
29 | */ | ||
30 | public class CGAgenda extends ConfigGroup | ||
31 | { | ||
32 | |||
33 | /** step 1 - design*/ | ||
34 | public int cp_AgendaType; | ||
35 | /** step 1 - include minutes*/ | ||
36 | public boolean cp_IncludeMinutes; | ||
37 | /** step 2 - title */ | ||
38 | public String cp_Title = PropertyNames.EMPTY_STRING; | ||
39 | /** step 2 - date */ | ||
40 | public String cp_Date; | ||
41 | /** step 2 - time */ | ||
42 | public String cp_Time; | ||
43 | /** step 2 - location */ | ||
44 | public String cp_Location = PropertyNames.EMPTY_STRING; | ||
45 | /** step 3 - show meeting type */ | ||
46 | public boolean cp_ShowMeetingType; | ||
47 | /** step 3 - show read */ | ||
48 | public boolean cp_ShowRead; | ||
49 | /** step 3 - show bring */ | ||
50 | public boolean cp_ShowBring; | ||
51 | /** step 3 - show notes */ | ||
52 | public boolean cp_ShowNotes; | ||
53 | /** step 4 - show called by */ | ||
54 | public boolean cp_ShowCalledBy; | ||
55 | /** step 4 - show facilitator */ | ||
56 | public boolean cp_ShowFacilitator; | ||
57 | /** step 4 - show notes taker */ | ||
58 | public boolean cp_ShowNotetaker; | ||
59 | /** step 4 - show time keeper */ | ||
60 | public boolean cp_ShowTimekeeper; | ||
61 | /** step 4 - show attendees */ | ||
62 | public boolean cp_ShowAttendees; | ||
63 | /** step 4 - show observers */ | ||
64 | public boolean cp_ShowObservers; | ||
65 | /** step 4 - show resource persons */ | ||
66 | public boolean cp_ShowResourcePersons; | ||
67 | /** page 6 - template title */ | ||
68 | public String cp_TemplateName; | ||
69 | /** page 6 - template url */ | ||
70 | public String cp_TemplatePath; | ||
71 | /** page 6 - how to proceed */ | ||
72 | public int cp_ProceedMethod; | ||
73 | /** page 5 - topics ( a set )*/ | ||
74 | public ConfigSet cp_Topics = new ConfigSet(CGTopic.class); | ||
75 | } | ||
diff --git a/wizards/com/sun/star/wizards/agenda/CGTopic.java b/wizards/com/sun/star/wizards/agenda/CGTopic.java deleted file mode 100644 index a9f978973605..000000000000 --- a/wizards/com/sun/star/wizards/agenda/CGTopic.java +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | |||
21 | import com.sun.star.beans.PropertyValue; | ||
22 | import com.sun.star.wizards.common.ConfigGroup; | ||
23 | import com.sun.star.wizards.common.Indexable; | ||
24 | import com.sun.star.wizards.common.PropertyNames; | ||
25 | |||
26 | /** | ||
27 | * CGTopic means: Configuration Group Topic. | ||
28 | * This object encapsulates a configuration group with topic information. | ||
29 | * Since the topics gui conftrol uses its own data model, there is | ||
30 | * also code here to convert from the data model to CGTopic object (the constructor) | ||
31 | * and vice versa (setDataToRow method - used when loading the last session...) | ||
32 | */ | ||
33 | public class CGTopic extends ConfigGroup implements Indexable { | ||
34 | |||
35 | /** sort order */ | ||
36 | public int cp_Index; | ||
37 | /** topic name */ | ||
38 | public String cp_Topic; | ||
39 | /** responsible */ | ||
40 | public String cp_Responsible; | ||
41 | /** time */ | ||
42 | public String cp_Time; | ||
43 | |||
44 | public CGTopic() {} | ||
45 | |||
46 | /** | ||
47 | * create a new CGTopic object with data from the given row. | ||
48 | * the row object is a PropertyValue array, as used | ||
49 | * by the TopicsControl's data model. | ||
50 | * @param row PropertyValue array as used by the TopicsControl data model. | ||
51 | */ | ||
52 | public CGTopic( Object row) { | ||
53 | PropertyValue[] pv = (PropertyValue[])row; | ||
54 | String num = (String)pv[0].Value; | ||
55 | cp_Index = Integer.valueOf(num.substring(0,num.length() - 1)).intValue(); | ||
56 | cp_Topic = (String)pv[1].Value; | ||
57 | cp_Responsible = (String)pv[2].Value; | ||
58 | cp_Time = (String)pv[3].Value; | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * copies the data in this CGTopic object | ||
63 | * to the given row. | ||
64 | * @param row the row object (PropertyValue array) to | ||
65 | * copy the data to. | ||
66 | */ | ||
67 | public void setDataToRow(Object row) { | ||
68 | PropertyValue[] pv = (PropertyValue[])row; | ||
69 | pv[0].Value = PropertyNames.EMPTY_STRING + cp_Index + "."; | ||
70 | pv[1].Value = cp_Topic; | ||
71 | pv[2].Value = cp_Responsible; | ||
72 | pv[3].Value = cp_Time; | ||
73 | } | ||
74 | |||
75 | public int getIndex() { | ||
76 | return cp_Index; | ||
77 | } | ||
78 | |||
79 | } | ||
diff --git a/wizards/com/sun/star/wizards/agenda/CallWizard.java b/wizards/com/sun/star/wizards/agenda/CallWizard.java deleted file mode 100644 index 9a16ac330ac6..000000000000 --- a/wizards/com/sun/star/wizards/agenda/CallWizard.java +++ /dev/null | |||
@@ -1,213 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | import com.sun.star.beans.XPropertyAccess; | ||
21 | import com.sun.star.comp.loader.FactoryHelper; | ||
22 | import com.sun.star.lang.XInitialization; | ||
23 | import com.sun.star.lang.XMultiServiceFactory; | ||
24 | import com.sun.star.lang.XServiceInfo; | ||
25 | import com.sun.star.lang.XSingleServiceFactory; | ||
26 | import com.sun.star.lang.XTypeProvider; | ||
27 | import com.sun.star.registry.XRegistryKey; | ||
28 | import com.sun.star.task.XJob; | ||
29 | import com.sun.star.task.XJobExecutor; | ||
30 | import com.sun.star.uno.Type; | ||
31 | import com.sun.star.wizards.common.PropertyNames; | ||
32 | |||
33 | /** | ||
34 | * This class capsulates the class, that implements the minimal component, a factory for | ||
35 | * creating the service (<CODE>__getServiceFactory</CODE>). | ||
36 | */ | ||
37 | public class CallWizard { | ||
38 | |||
39 | /** | ||
40 | * Gives a factory for creating the service. This method is called by the | ||
41 | * <code>JavaLoader</code> | ||
42 | * | ||
43 | * <p></p> | ||
44 | * | ||
45 | * @param stringImplementationName The implementation name of the component. | ||
46 | * @param xMSF The service manager, who gives access to every known service. | ||
47 | * @param xregistrykey Makes structural information (except regarding tree | ||
48 | * structures) of a single registry key accessible. | ||
49 | * | ||
50 | * @return Returns a <code>XSingleServiceFactory</code> for creating the component. | ||
51 | * | ||
52 | * @see com.sun.star.comp.loader.JavaLoader | ||
53 | */ | ||
54 | public static XSingleServiceFactory __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey) { | ||
55 | XSingleServiceFactory xsingleservicefactory = null; | ||
56 | |||
57 | if (stringImplementationName.equals(WizardImplementation.class.getName())) { | ||
58 | xsingleservicefactory = FactoryHelper.getServiceFactory(WizardImplementation.class, WizardImplementation.__serviceName, xMSF, xregistrykey); | ||
59 | } | ||
60 | |||
61 | return xsingleservicefactory; | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * This class implements the component. At least the interfaces XServiceInfo, | ||
66 | * XTypeProvider, and XInitialization should be provided by the service. | ||
67 | */ | ||
68 | public static class WizardImplementation implements XInitialization, XTypeProvider, XServiceInfo, XJobExecutor { | ||
69 | |||
70 | /** | ||
71 | * The constructor of the inner class has a XMultiServiceFactory parameter. | ||
72 | * | ||
73 | * @param xmultiservicefactoryInitialization A special service factory could be | ||
74 | * introduced while initializing. | ||
75 | */ | ||
76 | public WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization) { | ||
77 | xmultiservicefactory = xmultiservicefactoryInitialization; | ||
78 | |||
79 | if (xmultiservicefactory != null) { | ||
80 | |||
81 | } | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * Execute Wizard | ||
86 | * | ||
87 | * @param str only valid parameter is 'start' at the moment. | ||
88 | */ | ||
89 | |||
90 | public void trigger(String str) { | ||
91 | try { | ||
92 | if (str.equalsIgnoreCase(PropertyNames.START)) { | ||
93 | AgendaWizardDialogImpl aw = new AgendaWizardDialogImpl(xmultiservicefactory); | ||
94 | if (!AgendaWizardDialogImpl.running) { | ||
95 | aw.startWizard(); | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | catch (Exception ex) { | ||
100 | ex.printStackTrace(); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | //******************************************* | ||
105 | |||
106 | /** | ||
107 | * The service name, that must be used to get an instance of this service. | ||
108 | */ | ||
109 | private static final String __serviceName = "com.sun.star.wizards.agenda.CallWizard"; | ||
110 | |||
111 | /** | ||
112 | * The service manager, that gives access to all registered services. | ||
113 | */ | ||
114 | private XMultiServiceFactory xmultiservicefactory; | ||
115 | |||
116 | /** | ||
117 | * This method is a member of the interface for initializing an object directly | ||
118 | * after its creation. | ||
119 | * | ||
120 | * @param object This array of arbitrary objects will be passed to the component | ||
121 | * after its creation. | ||
122 | * | ||
123 | * @throws com.sun.star.uno.Exception Every exception will not be handled, but | ||
124 | * will be passed to the caller. | ||
125 | */ | ||
126 | public void initialize(Object[] object) throws com.sun.star.uno.Exception { | ||
127 | |||
128 | } | ||
129 | |||
130 | /** | ||
131 | * This method returns an array of all supported service names. | ||
132 | * | ||
133 | * @return Array of supported service names. | ||
134 | */ | ||
135 | public java.lang.String[] getSupportedServiceNames() { | ||
136 | String[] stringSupportedServiceNames = new String[1]; | ||
137 | stringSupportedServiceNames[0] = __serviceName; | ||
138 | |||
139 | return (stringSupportedServiceNames); | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * This method returns true, if the given service will be supported by the | ||
144 | * component. | ||
145 | * | ||
146 | * @param stringService Service name. | ||
147 | * | ||
148 | * @return True, if the given service name will be supported. | ||
149 | */ | ||
150 | public boolean supportsService(String stringService) { | ||
151 | boolean booleanSupportsService = false; | ||
152 | |||
153 | if (stringService.equals(__serviceName)) { | ||
154 | booleanSupportsService = true; | ||
155 | } | ||
156 | |||
157 | return (booleanSupportsService); | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * This method returns an array of bytes, that can be used to unambiguously | ||
162 | * distinguish between two sets of types, e.g. to realise hashing functionality | ||
163 | * when the object is introspected. Two objects that return the same ID also | ||
164 | * have to return the same set of types in getTypes(). If an unique | ||
165 | * implementation Id cannot be provided this method has to return an empty | ||
166 | * sequence. Important: If the object aggregates other objects the ID has to be | ||
167 | * unique for the whole combination of objects. | ||
168 | * | ||
169 | * @return Array of bytes, in order to distinguish between two sets. | ||
170 | */ | ||
171 | public byte[] getImplementationId() { | ||
172 | byte[] byteReturn = { | ||
173 | }; | ||
174 | |||
175 | try { | ||
176 | byteReturn = (PropertyNames.EMPTY_STRING + this.hashCode()).getBytes(); | ||
177 | } catch (Exception exception) { | ||
178 | System.err.println(exception); | ||
179 | } | ||
180 | |||
181 | return (byteReturn); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Return the class name of the component. | ||
186 | * | ||
187 | * @return Class name of the component. | ||
188 | */ | ||
189 | public java.lang.String getImplementationName() { | ||
190 | return (WizardImplementation.class.getName()); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Provides a sequence of all types (usually interface types) provided by the | ||
195 | * object. | ||
196 | * | ||
197 | * @return Sequence of all types (usually interface types) provided by the | ||
198 | * service. | ||
199 | */ | ||
200 | public com.sun.star.uno.Type[] getTypes() { | ||
201 | Type[] typeReturn = { | ||
202 | }; | ||
203 | |||
204 | try { | ||
205 | typeReturn = new Type[] { new Type(XPropertyAccess.class), new Type(XJob.class), new Type(XJobExecutor.class), new Type(XTypeProvider.class), new Type(XServiceInfo.class), new Type(XInitialization.class)}; | ||
206 | } catch (Exception exception) { | ||
207 | System.err.println(exception); | ||
208 | } | ||
209 | |||
210 | return (typeReturn); | ||
211 | } | ||
212 | } | ||
213 | } | ||
diff --git a/wizards/com/sun/star/wizards/agenda/MANIFEST.MF b/wizards/com/sun/star/wizards/agenda/MANIFEST.MF deleted file mode 100644 index b9a31ef4732c..000000000000 --- a/wizards/com/sun/star/wizards/agenda/MANIFEST.MF +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | RegistrationClassName: com.sun.star.wizards.agenda.CallWizard | ||
2 | UNO-Type-Path: | ||
diff --git a/wizards/com/sun/star/wizards/agenda/TemplateConsts.java b/wizards/com/sun/star/wizards/agenda/TemplateConsts.java deleted file mode 100644 index c2d5b7071f05..000000000000 --- a/wizards/com/sun/star/wizards/agenda/TemplateConsts.java +++ /dev/null | |||
@@ -1,149 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | public interface TemplateConsts | ||
21 | { | ||
22 | |||
23 | public final static String FILLIN_TITLE = "<title>"; | ||
24 | public final static String FILLIN_DATE = "<date>"; | ||
25 | public final static String FILLIN_TIME = "<time>"; | ||
26 | public final static String FILLIN_LOCATION = "<location>"; | ||
27 | /** | ||
28 | * section name <b>prefix</b> for sections that contain items. | ||
29 | * this is also used as table name prefix, since each items section | ||
30 | * must contain a table whos name is identical name to the section's name. | ||
31 | */ | ||
32 | public final static String SECTION_ITEMS = "AGENDA_ITEMS"; | ||
33 | /** | ||
34 | * the name of the section which contains the topics. | ||
35 | */ | ||
36 | public final static String SECTION_TOPICS = "AGENDA_TOPICS"; | ||
37 | /** | ||
38 | * the name of the parent minutes section. | ||
39 | */ | ||
40 | public final static String SECTION_MINUTES_ALL = "MINUTES_ALL"; | ||
41 | /** | ||
42 | * the name of the child nimutes section. | ||
43 | * This section will be duplicated for each topic. | ||
44 | */ | ||
45 | public final static String SECTION_MINUTES = "MINUTES"; //public final static String AGENDA_ITEM = "AGENDA_ITEM"; | ||
46 | /** | ||
47 | * taged headings and names. | ||
48 | * These will be searched in item tables (in the template) and will be | ||
49 | * replaced with resource strings. | ||
50 | * | ||
51 | * headings... | ||
52 | */ | ||
53 | public final static String FILLIN_MEETING_TYPE = "<meeting-type>"; | ||
54 | public final static String FILLIN_BRING = "<bring>"; | ||
55 | public final static String FILLIN_READ = "<read>"; | ||
56 | public final static String FILLIN_NOTES = "<notes>"; | ||
57 | /** | ||
58 | * names... | ||
59 | */ | ||
60 | public final static String FILLIN_CALLED_BY = "<called-by>"; | ||
61 | public final static String FILLIN_FACILITATOR = "<facilitator>"; | ||
62 | public final static String FILLIN_PARTICIPANTS = "<attendees>"; | ||
63 | public final static String FILLIN_NOTETAKER = "<notetaker>"; | ||
64 | public final static String FILLIN_TIMEKEEPER = "<timekeeper>"; | ||
65 | public final static String FILLIN_OBSERVERS = "<observers>"; | ||
66 | public final static String FILLIN_RESOURCE_PERSONS = "<resource-persons>"; | ||
67 | /** | ||
68 | * Styles (paragraph styles) used for agenda items. | ||
69 | * headings styles | ||
70 | * | ||
71 | */ | ||
72 | public final static String STYLE_MEETING_TYPE = "MeetingType"; | ||
73 | public final static String STYLE_BRING = "Bring"; | ||
74 | public final static String STYLE_READ = "Read"; | ||
75 | public final static String STYLE_NOTES = "Notes"; | ||
76 | /** | ||
77 | * names styles | ||
78 | */ | ||
79 | public final static String STYLE_CALLED_BY = "CalledBy"; | ||
80 | public final static String STYLE_FACILITATOR = "Facilitator"; | ||
81 | public final static String STYLE_PARTICIPANTS = "Attendees"; | ||
82 | public final static String STYLE_NOTETAKER = "Notetaker"; | ||
83 | public final static String STYLE_TIMEKEEPER = "Timekeeper"; | ||
84 | public final static String STYLE_OBSERVERS = "Observers"; | ||
85 | public final static String STYLE_RESOURCE_PERSONS = "ResourcePersons"; | ||
86 | /** | ||
87 | * Styles (paragraph styles) used for the <b>text</b> of agenda items | ||
88 | * The agenda wizard creates fill-in fields with the given styles...) | ||
89 | * | ||
90 | * headings fields styles | ||
91 | */ | ||
92 | public final static String STYLE_MEETING_TYPE_TEXT = "MeetingTypeText"; | ||
93 | public final static String STYLE_BRING_TEXT = "BringText"; | ||
94 | public final static String STYLE_READ_TEXT = "ReadText"; | ||
95 | public final static String STYLE_NOTES_TEXT = "NotesText"; | ||
96 | /** | ||
97 | * names field styles | ||
98 | */ | ||
99 | public final static String STYLE_CALLED_BY_TEXT = "CalledByText"; | ||
100 | public final static String STYLE_FACILITATOR_TEXT = "FacilitatorText"; | ||
101 | public final static String STYLE_PARTICIPANTS_TEXT = "AttendeesText"; | ||
102 | public final static String STYLE_NOTETAKER_TEXT = "NotetakerText"; | ||
103 | public final static String STYLE_TIMEKEEPER_TEXT = "TimekeeperText"; | ||
104 | public final static String STYLE_OBSERVERS_TEXT = "ObserversText"; | ||
105 | public final static String STYLE_RESOURCE_PERSONS_TEXT = "ResourcePersonsText"; | ||
106 | /** | ||
107 | * Fillins for the topic table. | ||
108 | * These strings will be searched inside the topic table as | ||
109 | * part of detecting its structure. | ||
110 | */ | ||
111 | public final static String FILLIN_TOPIC_NUMBER = "<num>"; | ||
112 | public final static String FILLIN_TOPIC_TOPIC = "<topic>"; | ||
113 | public final static String FILLIN_TOPIC_RESPONSIBLE = "<responsible>"; | ||
114 | public final static String FILLIN_TOPIC_TIME = "<topic-time>"; | ||
115 | /** | ||
116 | * fillins for minutes. | ||
117 | * These will be searched in the minutes section and will be replaced | ||
118 | * with the appropriate data. | ||
119 | */ | ||
120 | public final static String FILLIN_MINUTES_TITLE = "<minutes-title>"; | ||
121 | public final static String FILLIN_MINUTES_LOCATION = "<minutes-location>"; | ||
122 | public final static String FILLIN_MINUTES_DATE = "<minutes-date>"; | ||
123 | public final static String FILLIN_MINUTES_TIME = "<minutes-time>"; | ||
124 | /** | ||
125 | * Minutes-topic fillins | ||
126 | * These will be searched in the minutes-child-section, and | ||
127 | * will be replaced with topic data. | ||
128 | */ | ||
129 | public final static String FILLIN_MINUTE_NUM = "<mnum>"; | ||
130 | public final static String FILLIN_MINUTE_TOPIC = "<mtopic>"; | ||
131 | public final static String FILLIN_MINUTE_RESPONSIBLE = "<mresponsible>"; | ||
132 | public final static String FILLIN_MINUTE_TIME = "<mtime>"; | ||
133 | |||
134 | public final static String FILLIN_DATETITLE = "#datetitle#"; | ||
135 | public final static String FILLIN_TIMETITLE = "#timetitle#"; | ||
136 | public final static String FILLIN_LOCATIONTITLE = "#locationtitle#"; | ||
137 | public final static String FILLIN_TOPICS = "#topics#"; | ||
138 | public final static String FILLIN_NUM = "#num.#"; | ||
139 | public final static String FILLIN_TOPIC = "#topicheader#"; | ||
140 | public final static String FILLIN_RESPONSIBLE = "#responsibleheader#"; | ||
141 | public final static String FILLIN_TIME_HEADER = "#timeheader#"; | ||
142 | public final static String FILLIN_ADDITIONAL_INFORMATION = "#additional-information#"; | ||
143 | public final static String FILLIN_MINUTES_FOR = "#minutes-for#"; | ||
144 | public final static String FILLIN_DISCUSSION = "#discussion#"; | ||
145 | public final static String FILLIN_CONCLUSION = "#conclusion#"; | ||
146 | public final static String FILLIN_TO_DO = "#to-do#"; | ||
147 | public final static String FILLIN_RESPONSIBLE_PARTY = "#responsible-party#"; | ||
148 | public final static String FILLIN_DEADLINE = "#deadline#"; | ||
149 | } | ||
diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.java b/wizards/com/sun/star/wizards/agenda/TopicsControl.java deleted file mode 100644 index 551c8da86b0d..000000000000 --- a/wizards/com/sun/star/wizards/agenda/TopicsControl.java +++ /dev/null | |||
@@ -1,1327 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of the LibreOffice project. | ||
3 | * | ||
4 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
7 | * | ||
8 | * This file incorporates work covered by the following license notice: | ||
9 | * | ||
10 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
11 | * contributor license agreements. See the NOTICE file distributed | ||
12 | * with this work for additional information regarding copyright | ||
13 | * ownership. The ASF licenses this file to you under the Apache | ||
14 | * License, Version 2.0 (the "License"); you may not use this file | ||
15 | * except in compliance with the License. You may obtain a copy of | ||
16 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||
17 | */ | ||
18 | package com.sun.star.wizards.agenda; | ||
19 | |||
20 | import java.util.List; | ||
21 | import java.util.ArrayList; | ||
22 | import com.sun.star.wizards.common.HelpIds; | ||
23 | |||
24 | import com.sun.star.awt.FocusEvent; | ||
25 | import com.sun.star.awt.Key; | ||
26 | import com.sun.star.awt.KeyEvent; | ||
27 | import com.sun.star.awt.KeyModifier; | ||
28 | import com.sun.star.awt.Selection; | ||
29 | import com.sun.star.awt.XControl; | ||
30 | import com.sun.star.awt.XFocusListener; | ||
31 | import com.sun.star.awt.XKeyListener; | ||
32 | import com.sun.star.awt.XTextComponent; | ||
33 | import com.sun.star.awt.XWindow; | ||
34 | import com.sun.star.beans.PropertyValue; | ||
35 | import com.sun.star.lang.EventObject; | ||
36 | import com.sun.star.lang.XMultiServiceFactory; | ||
37 | import com.sun.star.uno.UnoRuntime; | ||
38 | import com.sun.star.wizards.common.Helper; | ||
39 | import com.sun.star.wizards.common.Properties; | ||
40 | import com.sun.star.wizards.common.PropertyNames; | ||
41 | import com.sun.star.wizards.ui.ControlScroller; | ||
42 | import com.sun.star.wizards.ui.UnoDialog2; | ||
43 | import com.sun.star.wizards.ui.event.EventNames; | ||
44 | import com.sun.star.wizards.ui.event.MethodInvocation; | ||
45 | |||
46 | /** | ||
47 | * This class implements the UI functionality of the topics scroller control. | ||
48 | * <br/> | ||
49 | * During developement, there has been a few changes which were not *fully* done - | ||
50 | * mainly in converting the topics and time boxes from combobox and time box to normal textboxes, | ||
51 | * so in the code they might be referenced as combobox or timebox. This should be | ||
52 | * rather understood as topicstextbox and timetextbox. | ||
53 | * <br/> | ||
54 | * <br/> | ||
55 | * Important behaiviour of this control is that there is always a | ||
56 | * blank row at the end, in which the user can enter data.<br/> | ||
57 | * Once the row is not blank (thus, the user entered data...), | ||
58 | * a new blank row is added.<br/> | ||
59 | * Once the user removes the last *unempty* row, by deleteing its data, it becomes | ||
60 | * the *last empty row* and the one after is being automatically removed.<br/> | ||
61 | * <br/> | ||
62 | * The contorl shows 5 rows at a time.<br/> | ||
63 | * If, for example, only 2 rows exist (from which the 2ed one is empty...) | ||
64 | * then the other three rows, which do not exist in the data model, are disabled. | ||
65 | * <br/> | ||
66 | * The following other functionality is implemented: | ||
67 | * <br/> | ||
68 | * 0. synchroniting data between controls, data model and live preview. | ||
69 | * 1. Tab scrolling.<br/> | ||
70 | * 2. Keyboard scrolling.<br/> | ||
71 | * 3. Removing rows and adding new rows.<br/> | ||
72 | * 4. Moving rows up and down. <br/> | ||
73 | * <br/> | ||
74 | * This control relays on the ControlScroller control which uses the following | ||
75 | * Data model:<br/> | ||
76 | * 1. It uses a vector, whos members are arrays of PropertyValue.<br/> | ||
77 | * 2. Each array represents a row.<br/> | ||
78 | * (Note: the Name and Value memebrs of the PropertyValue object are being used...) | ||
79 | * 3. Each property Value represents a value for a single control with the following rules:<br/> | ||
80 | * 3. a. the Value of the property is used for as value of the controls (usually text).<br/> | ||
81 | * 3. b. the Name of the property is used to map values to UI controls in the following manner:<br/> | ||
82 | * 3. b. 1. only the Name of the first X Rows is regarded, where X is the number of visible rows | ||
83 | * (in the agenda wizard this would be 5, since 5 topic rows are visible on the dialog).<br/> | ||
84 | * 3. b. 2. The Names of the first X (or 5...) rows are the names of the UI Controls to | ||
85 | * hold values. When the control scroller scrolls, it looks at the first 5 rows and uses | ||
86 | * the names specified there to map the current values to the specified controls. | ||
87 | * <br/> | ||
88 | * This data model makes the following limitations on the implementation: | ||
89 | * When moving rows, only the values should be moved. The Rows objects, which contain | ||
90 | * also the Names of the controls should not be switched. <br/> | ||
91 | * also when deleting or inserting rows, attention should be paid that no rows should be removed | ||
92 | * or inserted. Instead, only the Values should rotate. | ||
93 | * <br/> | ||
94 | * <br/> | ||
95 | * To save the topics in the registry a ConfigSet of objects of type CGTopic is | ||
96 | * being used. | ||
97 | * This one is not synchronized "live", since it is unnecessary... instead, it is | ||
98 | * synchronized on call, before the settings should be saved. | ||
99 | */ | ||
100 | public class TopicsControl extends ControlScroller implements XFocusListener | ||
101 | { | ||
102 | |||
103 | /** | ||
104 | * The name prefix of the number (label) controls | ||
105 | */ | ||
106 | public static final String LABEL = "lblTopicCnt_"; | ||
107 | /** | ||
108 | * The name prefix of the topic (text) controls | ||
109 | */ | ||
110 | public static final String TOPIC = "txtTopicTopic_"; | ||
111 | /** | ||
112 | * The name prefix of the responsible (text) controls | ||
113 | */ | ||
114 | public static final String RESP = "cbTopicResp_"; | ||
115 | /** | ||
116 | * The name prefix of the time (text) controls | ||
117 | */ | ||
118 | public static final String TIME = "txtTopicTime_"; | ||
119 | Object lastFocusControl; | ||
120 | int lastFocusRow; | ||
121 | /** | ||
122 | * the last | ||
123 | * topic text box. | ||
124 | * When pressing tab on this one a scroll down *may* be performed. | ||
125 | */ | ||
126 | private Object firstTopic; | ||
127 | /** | ||
128 | * the first time box. | ||
129 | * When pressing shift-tab on this control, a scroll up *may* be performed. | ||
130 | */ | ||
131 | private Object lastTime; | ||
132 | /** | ||
133 | * is used when constructing to track the tab index | ||
134 | * of the created control rows. | ||
135 | */ | ||
136 | private int tabIndex = 520; | ||
137 | |||
138 | //This maintains for each topic, if something has been written in it. | ||
139 | private ArrayList<Boolean> rowUsedArray = new ArrayList<Boolean>(); | ||
140 | |||
141 | /** | ||
142 | * create a new TopicControl. Since this is used specifically for the | ||
143 | * agenda dialog, I use step 5, and constant location - and need no paramter... | ||
144 | * @param dialog the parent dialog | ||
145 | * @param xmsf service factory | ||
146 | * @param agenda the Agenda configuration data (contains the current topics data). | ||
147 | */ | ||
148 | public TopicsControl(AgendaWizardDialog dialog, XMultiServiceFactory xmsf, CGAgenda agenda) | ||
149 | { | ||
150 | super(dialog, xmsf, 5, 92, 38, 212, 5, 18, AgendaWizardDialogConst.LAST_HID); | ||
151 | initializeScrollFields(agenda); | ||
152 | initialize(agenda.cp_Topics.getSize() + 1); | ||
153 | for(int i=0; i < agenda.cp_Topics.getSize(); ++i) rowUsedArray.add(false); | ||
154 | |||
155 | // set some focus listeners for TAB scroll down and up... | ||
156 | try | ||
157 | { | ||
158 | |||
159 | // prepare scroll down on tab press... | ||
160 | Object lastTime = ((ControlRow) ControlGroupVector.get(nblockincrement - 1)).timebox; | ||
161 | |||
162 | MethodInvocation mi = new MethodInvocation("lastControlKeyPressed", this, KeyEvent.class); | ||
163 | dialog.getGuiEventListener().add(TIME + (nblockincrement - 1), EventNames.EVENT_KEY_PRESSED, mi); | ||
164 | |||
165 | addKeyListener(lastTime, (XKeyListener) dialog.getGuiEventListener()); | ||
166 | |||
167 | //prepare scroll up on tab press... | ||
168 | firstTopic = ((ControlRow) ControlGroupVector.get(0)).textbox; | ||
169 | |||
170 | mi = new MethodInvocation("firstControlKeyPressed", this, KeyEvent.class); | ||
171 | dialog.getGuiEventListener().add(TOPIC + 0, EventNames.EVENT_KEY_PRESSED, mi); | ||
172 | |||
173 | addKeyListener(firstTopic, (XKeyListener) dialog.getGuiEventListener()); | ||
174 | |||
175 | } | ||
176 | catch (NoSuchMethodException ex) | ||
177 | { | ||
178 | ex.printStackTrace(); | ||
179 | } | ||
180 | |||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Is used to add a keylistener to different controls... | ||
185 | */ | ||
186 | static void addKeyListener(Object control, XKeyListener listener) | ||
187 | { | ||
188 | XWindow xlastControl = UnoRuntime.queryInterface(XWindow.class, | ||
189 | control); | ||
190 | xlastControl.addKeyListener(listener); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Is used to add a focuslistener to different controls... | ||
195 | */ | ||
196 | static void addFocusListener(Object control, XFocusListener listener) | ||
197 | { | ||
198 | XWindow xlastControl = UnoRuntime.queryInterface(XWindow.class, | ||
199 | control); | ||
200 | xlastControl.addFocusListener(listener); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Implementation of the parent class... | ||
205 | */ | ||
206 | protected void initializeScrollFields() | ||
207 | { | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * initializes the data of the control. | ||
212 | * @param agenda | ||
213 | */ | ||
214 | protected void initializeScrollFields(CGAgenda agenda) | ||
215 | { | ||
216 | // create a row for each topic with the given values.... | ||
217 | for (int i = 0; i < agenda.cp_Topics.getSize(); i++) | ||
218 | { | ||
219 | PropertyValue[] row = newRow(i); | ||
220 | ((CGTopic) agenda.cp_Topics.getElementAt(i)).setDataToRow(row); | ||
221 | // a parent class method | ||
222 | registerControlGroup(row, i); | ||
223 | this.updateDocumentRow(i); | ||
224 | } | ||
225 | // inserts a blank row at the end... | ||
226 | insertRowAtEnd(); | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * Insert a blank (empty) row | ||
231 | * as last row of the control. | ||
232 | * The control has always a blank row at the | ||
233 | * end, which enables the user to enter data... | ||
234 | */ | ||
235 | protected void insertRowAtEnd() | ||
236 | { | ||
237 | int l = scrollfields.size(); | ||
238 | registerControlGroup(newRow(l), l); | ||
239 | setTotalFieldCount(l + 1); | ||
240 | |||
241 | // if the new row is visible, it must have been disabled | ||
242 | // so it should be now enabled... | ||
243 | if (l - nscrollvalue < nblockincrement) | ||
244 | { | ||
245 | ((ControlRow) ControlGroupVector.get(l - nscrollvalue)).setEnabled(true); | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * The Topics Set in the CGAgenda object is synchronized to | ||
251 | * the current content of the topics. | ||
252 | * @param agenda | ||
253 | */ | ||
254 | void saveTopics(CGAgenda agenda) | ||
255 | { | ||
256 | agenda.cp_Topics.clear(); | ||
257 | for (int i = 0; i < scrollfields.size() - 1; i++) | ||
258 | { | ||
259 | agenda.cp_Topics.add(i, | ||
260 | new CGTopic(scrollfields.get(i))); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * overrides the parent class method to also enable the | ||
266 | * row whenever data is written to it. | ||
267 | * @param guiRow | ||
268 | */ | ||
269 | protected void fillupControls(int guiRow) | ||
270 | { | ||
271 | super.fillupControls(guiRow); | ||
272 | ((ControlRow) ControlGroupVector.get(guiRow)).setEnabled(true); | ||
273 | } | ||
274 | |||
275 | /** | ||
276 | * remove the last row | ||
277 | */ | ||
278 | protected void removeLastRow() | ||
279 | { | ||
280 | int l = scrollfields.size(); | ||
281 | |||
282 | // if we should scroll up... | ||
283 | if ((l - nscrollvalue >= 1) && (l - nscrollvalue <= nblockincrement) && nscrollvalue > 0) | ||
284 | { | ||
285 | while ((l - nscrollvalue >= 1) && (l - nscrollvalue <= nblockincrement) && nscrollvalue > 0) | ||
286 | { | ||
287 | setScrollValue(nscrollvalue - 1); | ||
288 | } | ||
289 | } | ||
290 | // if we should disable a row... | ||
291 | else if (nscrollvalue == 0 && l - 1 < nblockincrement) | ||
292 | { | ||
293 | ControlRow cr = (ControlRow) ControlGroupVector.get(l - 1); | ||
294 | cr.setEnabled(false); | ||
295 | } | ||
296 | |||
297 | unregisterControlGroup(l - 1); | ||
298 | setTotalFieldCount(l - 1); | ||
299 | } | ||
300 | |||
301 | /** | ||
302 | * in order to use the "move up", "downPropertyNames.SPACEinsert" and "remove" buttons, | ||
303 | * we track the last control the gained focus, in order to know which | ||
304 | * row should be handled. | ||
305 | * @param fe | ||
306 | */ | ||
307 | public void focusGained(FocusEvent fe) | ||
308 | { | ||
309 | XControl xc = UnoRuntime.queryInterface(XControl.class, fe.Source); | ||
310 | focusGained(xc); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * Sometimes I set the focus programatically to a control | ||
315 | * (for example when moving a row up or down, the focus should move | ||
316 | * with it). | ||
317 | * In such cases, no VCL event is being triggered so it must | ||
318 | * be called programtically. | ||
319 | * This is done by this method. | ||
320 | * @param control | ||
321 | */ | ||
322 | private void focusGained(XControl control) | ||
323 | { | ||
324 | try | ||
325 | { | ||
326 | //calculate in which row we are... | ||
327 | String name = (String) Helper.getUnoPropertyValue(UnoDialog2.getModel(control), PropertyNames.PROPERTY_NAME); | ||
328 | int i = name.indexOf("_"); | ||
329 | String num = name.substring(i + 1); | ||
330 | lastFocusRow = Integer.valueOf(num).intValue() + nscrollvalue; | ||
331 | lastFocusControl = control; | ||
332 | // enable/disable the buttons... | ||
333 | enableButtons(); | ||
334 | } | ||
335 | catch (Exception ex) | ||
336 | { | ||
337 | ex.printStackTrace(); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * enable or disable the buttons according to the | ||
343 | * current row we are in. | ||
344 | */ | ||
345 | private void enableButtons() | ||
346 | { | ||
347 | UnoDialog2.setEnabled(getAD().btnInsert, (lastFocusRow < scrollfields.size() - 1 ? Boolean.TRUE : Boolean.FALSE)); | ||
348 | UnoDialog2.setEnabled(getAD().btnRemove, (lastFocusRow < scrollfields.size() - 1 ? Boolean.TRUE : Boolean.FALSE)); | ||
349 | UnoDialog2.setEnabled(getAD().btnUp, (lastFocusRow > 0 ? Boolean.TRUE : Boolean.FALSE)); | ||
350 | UnoDialog2.setEnabled(getAD().btnDown, (lastFocusRow < scrollfields.size() - 1 ? Boolean.TRUE : Boolean.FALSE)); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * compolsary implementation of FocusListener. | ||
355 | * @param fe | ||
356 | */ | ||
357 | public void focusLost(FocusEvent fe) | ||
358 | { | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * compolsary implementation of FocusListener. | ||
363 | * @param o | ||
364 | */ | ||
365 | public void disposing(EventObject o) | ||
366 | { | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * Convenience method. Is used to get a reference of | ||
371 | * the template controller (live preview in background). | ||
372 | * @return the parent dialog, casted to AgendaWizardDialog. | ||
373 | */ | ||
374 | private AgendaWizardDialog getAD() | ||
375 | { | ||
376 | return (AgendaWizardDialog) this.CurUnoDialog; | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * move the current row up | ||
381 | */ | ||
382 | public void rowUp() | ||
383 | { | ||
384 | rowUp(lastFocusRow - nscrollvalue, lastFocusControl); | ||
385 | |||
386 | //swap the items in rowUsedArray | ||
387 | boolean temp = rowUsedArray.get(lastFocusRow - nscrollvalue); | ||
388 | rowUsedArray.set(lastFocusRow - nscrollvalue, rowUsedArray.get(lastFocusRow)); | ||
389 | rowUsedArray.set(lastFocusRow, temp); | ||
390 | ((AgendaWizardDialogImpl)CurUnoDialog).agendaTemplate.refreshTopicConstants(); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * move the current row down. | ||
395 | */ | ||
396 | public void rowDown() | ||
397 | { | ||
398 | rowDown(lastFocusRow - nscrollvalue, lastFocusControl); | ||
399 | |||
400 | //swap the items in rowUsedArray | ||
401 | boolean temp = rowUsedArray.get(lastFocusRow - nscrollvalue); | ||
402 | rowUsedArray.set(lastFocusRow - nscrollvalue, rowUsedArray.get(lastFocusRow)); | ||
403 | rowUsedArray.set(lastFocusRow, temp); | ||
404 | ((AgendaWizardDialogImpl)CurUnoDialog).agendaTemplate.refreshTopicConstants(); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Removes the current row. | ||
409 | * See general class documentation explanation about the | ||
410 | * data model used and the limitations which explain the implementation here. | ||
411 | */ | ||
412 | public void removeRow() | ||
413 | { | ||
414 | for (int i = lastFocusRow; i < scrollfields.size() - 1; i++) | ||
415 | { | ||
416 | PropertyValue[] pv1 = scrollfields.get(i); | ||
417 | PropertyValue[] pv2 = scrollfields.get(i + 1); | ||
418 | pv1[1].Value = pv2[1].Value; | ||
419 | pv1[2].Value = pv2[2].Value; | ||
420 | pv1[3].Value = pv2[3].Value; | ||
421 | updateDocumentRow(i); | ||
422 | if (i - nscrollvalue < nblockincrement) | ||
423 | { | ||
424 | fillupControls(i - nscrollvalue); | ||
425 | } | ||
426 | } | ||
427 | removeLastRow(); | ||
428 | |||
429 | ((AgendaWizardDialogImpl)CurUnoDialog).agendaTemplate.refreshTopicConstants(); | ||
430 | rowUsedArray.remove(lastFocusRow); | ||
431 | |||
432 | // update the live preview background document | ||
433 | reduceDocumentToTopics(); | ||
434 | |||
435 | // the focus should return to the edit control | ||
436 | focus(lastFocusControl); | ||
437 | } | ||
438 | |||
439 | /** | ||
440 | * Inserts a row before the current row. | ||
441 | * See general class documentation explanation about the | ||
442 | * data model used and the limitations which explain the implementation here. | ||
443 | */ | ||
444 | public void insertRow() | ||
445 | { | ||
446 | insertRowAtEnd(); | ||
447 | for (int i = scrollfields.size() - 2; i > lastFocusRow; i--) | ||
448 | { | ||
449 | PropertyValue[] pv1 = scrollfields.get(i); | ||
450 | PropertyValue[] pv2 = scrollfields.get(i - 1); | ||
451 | pv1[1].Value = pv2[1].Value; | ||
452 | pv1[2].Value = pv2[2].Value; | ||
453 | pv1[3].Value = pv2[3].Value; | ||
454 | updateDocumentRow(i); | ||
455 | if (i - nscrollvalue < nblockincrement) | ||
456 | { | ||
457 | fillupControls(i - nscrollvalue); | ||
458 | } | ||
459 | } | ||
460 | |||
461 | // after rotating all the properties from this row on, | ||
462 | // we clear the row, so it is practically a new one... | ||
463 | PropertyValue[] pv1 = scrollfields.get(lastFocusRow); | ||
464 | pv1[1].Value = PropertyNames.EMPTY_STRING; | ||
465 | pv1[2].Value = PropertyNames.EMPTY_STRING; | ||
466 | pv1[3].Value = PropertyNames.EMPTY_STRING; | ||
467 | |||
468 | // update the preview document. | ||
469 | updateDocumentRow(lastFocusRow); | ||
470 | |||
471 | rowUsedArray.add(lastFocusRow,false); | ||
472 | |||
473 | fillupControls(lastFocusRow - nscrollvalue); | ||
474 | |||
475 | focus(lastFocusControl); | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * create a new row with the given index. | ||
480 | * The index is important because it is used in the | ||
481 | * Name member of the PropertyValue objects. | ||
482 | * To know why see general class documentation above (data model explanation). | ||
483 | * @param i the index of the new row | ||
484 | * @return | ||
485 | */ | ||
486 | private PropertyValue[] newRow(int i) | ||
487 | { | ||
488 | PropertyValue[] pv = new PropertyValue[4]; | ||
489 | pv[0] = Properties.createProperty(LABEL + i, PropertyNames.EMPTY_STRING + (i + 1) + "."); | ||
490 | pv[1] = Properties.createProperty(TOPIC + i, PropertyNames.EMPTY_STRING); | ||
491 | pv[2] = Properties.createProperty(RESP + i, PropertyNames.EMPTY_STRING); | ||
492 | pv[3] = Properties.createProperty(TIME + i, PropertyNames.EMPTY_STRING); | ||
493 | |||
494 | ((AgendaWizardDialogImpl)CurUnoDialog).agendaTemplate.refreshTopicConstants(); | ||
495 | rowUsedArray.add(i,false); | ||
496 | |||
497 | return pv; | ||
498 | } | ||
499 | |||
500 | /** | ||
501 | * Implementation of ControlScroller | ||
502 | * This is a UI method which inserts a new row to the control. | ||
503 | * It uses the child-class ControlRow. (see below). | ||
504 | * @param _index | ||
505 | * @param npos | ||
506 | * @see ControlRow | ||
507 | */ | ||
508 | protected void insertControlGroup(int _index, int npos) | ||
509 | { | ||
510 | ControlRow oControlRow = new ControlRow((AgendaWizardDialog) CurUnoDialog, iCompPosX, npos, _index, tabIndex); | ||
511 | ControlGroupVector.add(oControlRow); | ||
512 | tabIndex += 4; | ||
513 | } | ||
514 | |||
515 | /** | ||
516 | * Implementation of ControlScroller | ||
517 | * This is a UI method which makes a row visibele. | ||
518 | * As far as I know it is never called. | ||
519 | * @param _index | ||
520 | * @param _bIsVisible | ||
521 | * @see ControlRow | ||
522 | */ | ||
523 | protected void setControlGroupVisible(int _index, boolean _bIsVisible) | ||
524 | { | ||
525 | ((ControlRow) ControlGroupVector.get(_index)).setVisible(_bIsVisible); | ||
526 | |||
527 | } | ||
528 | |||
529 | /** | ||
530 | * Checks if a row is empty. | ||
531 | * This is used when the last row is changed. | ||
532 | * If it is empty, the next row (which is always blank) is removed. | ||
533 | * If it is not empty, a next row must exist. | ||
534 | * @param row the index number of the row to check. | ||
535 | * @return true if empty. false if not. | ||
536 | */ | ||
537 | protected boolean isRowEmpty(int row) | ||
538 | { | ||
539 | PropertyValue[] data = getTopicData(row); | ||
540 | |||
541 | // now - is this row empty? | ||
542 | return data[1].Value.equals(PropertyNames.EMPTY_STRING) && | ||
543 | data[2].Value.equals(PropertyNames.EMPTY_STRING) && | ||
544 | data[3].Value.equals(PropertyNames.EMPTY_STRING); | ||
545 | |||
546 | } | ||
547 | /** | ||
548 | * is used for data tracking. | ||
549 | */ | ||
550 | private Object[] oldData; | ||
551 | |||
552 | /** | ||
553 | * update the preview document and | ||
554 | * remove/insert rows if needed. | ||
555 | * @param guiRow | ||
556 | * @param column | ||
557 | */ | ||
558 | synchronized void fieldChanged(int guiRow, int column) | ||
559 | { | ||
560 | synchronized(this) | ||
561 | { | ||
562 | |||
563 | try | ||
564 | { | ||
565 | // First, I update the document | ||
566 | PropertyValue[] data = getTopicData(guiRow + nscrollvalue); | ||
567 | |||
568 | if (data == null) | ||
569 | { | ||
570 | return; | ||
571 | } | ||
572 | boolean equal = true; | ||
573 | |||
574 | if (oldData != null) | ||
575 | { | ||
576 | for (int i = 0; i < data.length && equal; i++) | ||
577 | { | ||
578 | equal = (equal & data[i].Value.equals(oldData[i])); | ||
579 | } | ||
580 | if (equal) | ||
581 | { | ||
582 | return; | ||
583 | } | ||
584 | } | ||
585 | else | ||
586 | { | ||
587 | oldData = new Object[4]; | ||
588 | } | ||
589 | for (int i = 0; i < data.length; i++) | ||
590 | { | ||
591 | oldData[i] = data[i].Value; | ||
592 | } | ||
593 | updateDocumentCell(guiRow + nscrollvalue, column, data); | ||
594 | |||
595 | if (isRowEmpty(guiRow + nscrollvalue)) | ||
596 | { | ||
597 | /* if this is the row before the last one | ||
598 | * (the last row is always empty) | ||
599 | * delete the last row... | ||
600 | */ | ||
601 | if (guiRow + nscrollvalue == scrollfields.size() - 2) | ||
602 | { | ||
603 | removeLastRow(); | ||
604 | |||
605 | /* | ||
606 | * now consequentially check the last two rows, | ||
607 | * and remove the last one if they are both empty. | ||
608 | * (actually I check always the "before last" row, | ||
609 | * because the last one is always empty... | ||
610 | */ | ||
611 | while (scrollfields.size() > 1 && isRowEmpty(scrollfields.size() - 2)) | ||
612 | { | ||
613 | removeLastRow(); | ||
614 | } | ||
615 | ControlRow cr = (ControlRow) ControlGroupVector.get(scrollfields.size() - nscrollvalue - 1); | ||
616 | |||
617 | // if a remove was performed, set focus to the last row with some data in it... | ||
618 | focus(getControl(cr, column)); | ||
619 | |||
620 | // update the preview document. | ||
621 | reduceDocumentToTopics(); | ||
622 | } | ||
623 | |||
624 | } | ||
625 | else | ||
626 | { // row contains data | ||
627 | // is this the last row? | ||
628 | if ((guiRow + nscrollvalue + 1) == scrollfields.size()) | ||
629 | { | ||
630 | insertRowAtEnd(); | ||
631 | } | ||
632 | } | ||
633 | if(rowUsedArray.get(guiRow) == false){ | ||
634 | ((AgendaWizardDialogImpl)CurUnoDialog).agendaTemplate.refreshTopicConstants(); | ||
635 | rowUsedArray.set(guiRow,true); | ||
636 | } | ||
637 | } | ||
638 | catch (Exception e) | ||
639 | { | ||
640 | e.printStackTrace(); | ||
641 | } | ||
642 | |||
643 | } | ||
644 | } | ||
645 | |||
646 | /** | ||
647 | * return the corresponding row data for the given index. | ||
648 | * @param topic index of the topic to get. | ||
649 | * @return a PropertyValue array with the data for the given topic. | ||
650 | */ | ||
651 | public PropertyValue[] getTopicData(int topic) | ||
652 | { | ||
653 | if (topic < scrollfields.size()) | ||
654 | { | ||
655 | return scrollfields.get(topic); | ||
656 | } | ||
657 | else | ||
658 | { | ||
659 | return null; | ||
660 | } | ||
661 | } | ||
662 | |||
663 | /** | ||
664 | * If the user presses tab on the last control, and | ||
665 | * there *are* more rows in the model, scroll down. | ||
666 | * @param event | ||
667 | */ | ||
668 | public void lastControlKeyPressed(KeyEvent event) | ||
669 | { | ||
670 | // if tab without shift was pressed... | ||
671 | if ((event.KeyCode == Key.TAB) && (event.Modifiers == 0)) | ||
672 | // if there is another row... | ||
673 | { | ||
674 | if ((nblockincrement + nscrollvalue) < scrollfields.size()) | ||
675 | { | ||
676 | setScrollValue(nscrollvalue + 1); | ||
677 | //focus(firstTopic); | ||
678 | focus(getControl((ControlRow) ControlGroupVector.get(4), 1)); | ||
679 | |||
680 | } | ||
681 | } | ||
682 | } | ||
683 | |||
684 | /** | ||
685 | * If the user presses shift-tab on the first control, and | ||
686 | * there *are* more rows in the model, scroll up. | ||
687 | * @param event | ||
688 | */ | ||
689 | public void firstControlKeyPressed(KeyEvent event) | ||
690 | { | ||
691 | // if tab with shift was pressed... | ||
692 | if ((event.KeyCode == Key.TAB) && (event.Modifiers == KeyModifier.SHIFT)) | ||
693 | { | ||
694 | if (nscrollvalue > 0) | ||
695 | { | ||
696 | setScrollValue(nscrollvalue - 1); | ||
697 | focus(lastTime); | ||
698 | } | ||
699 | } | ||
700 | } | ||
701 | |||
702 | /** | ||
703 | * sets focus to the given control. | ||
704 | * @param textControl | ||
705 | */ | ||
706 | private void focus(Object textControl) | ||
707 | { | ||
708 | UnoRuntime.queryInterface(XWindow.class, textControl).setFocus(); | ||
709 | XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, textControl); | ||
710 | String text = xTextComponent.getText(); | ||
711 | xTextComponent.setSelection(new Selection(0, text.length())); | ||
712 | XControl xc = UnoRuntime.queryInterface(XControl.class, textControl); | ||
713 | focusGained(xc); | ||
714 | } | ||
715 | |||
716 | /** | ||
717 | * moves the given row one row down. | ||
718 | * @param guiRow the gui index of the row to move. | ||
719 | * @param control the control to gain focus after moving. | ||
720 | */ | ||
721 | synchronized void rowDown(int guiRow, Object control) | ||
722 | { | ||
723 | // only perform if this is not the last row. | ||
724 | int actuallRow = guiRow + nscrollvalue; | ||
725 | if (actuallRow + 1 < scrollfields.size()) | ||
726 | { | ||
727 | // get the current selection | ||
728 | Selection selection = getSelection(control); | ||
729 | |||
730 | // the last row should scroll... | ||
731 | boolean scroll = guiRow == (nblockincrement - 1); | ||
732 | if (scroll) | ||
733 | { | ||
734 | setScrollValue(nscrollvalue + 1); | ||
735 | } | ||
736 | int scroll1 = nscrollvalue; | ||
737 | |||
738 | switchRows(guiRow, guiRow + (scroll ? -1 : 1)); | ||
739 | |||
740 | if (nscrollvalue != scroll1) | ||
741 | { | ||
742 | guiRow += (nscrollvalue - scroll1); | ||
743 | } | ||
744 | setSelection(guiRow + (scroll ? 0 : 1), control, selection); | ||
745 | } | ||
746 | } | ||
747 | |||
748 | synchronized void rowUp(int guiRow, Object control) | ||
749 | { | ||
750 | // only perform if this is not the first row | ||
751 | int actuallRow = guiRow + nscrollvalue; | ||
752 | if (actuallRow > 0) | ||
753 | { | ||
754 | // get the current selection | ||
755 | Selection selection = getSelection(control); | ||
756 | |||
757 | // the last row should scroll... | ||
758 | boolean scroll = (guiRow == 0); | ||
759 | if (scroll) | ||
760 | { | ||
761 | setScrollValue(nscrollvalue - 1); | ||
762 | } | ||
763 | switchRows(guiRow, guiRow + (scroll ? 1 : -1)); | ||
764 | |||
765 | setSelection(guiRow - (scroll ? 0 : 1), control, selection); | ||
766 | } | ||
767 | } | ||
768 | |||
769 | /** | ||
770 | * moves the cursor up. | ||
771 | * @param guiRow | ||
772 | * @param control | ||
773 | */ | ||
774 | synchronized void cursorUp(int guiRow, Object control) | ||
775 | { | ||
776 | // is this the last full row ? | ||
777 | int actuallRow = guiRow + nscrollvalue; | ||
778 | //if this is the first row | ||
779 | if (actuallRow == 0) | ||
780 | { | ||
781 | return; | ||
782 | // the first row should scroll... | ||
783 | } | ||
784 | boolean scroll = (guiRow == 0); | ||
785 | ControlRow upperRow; | ||
786 | if (scroll) | ||
787 | { | ||
788 | setScrollValue(nscrollvalue - 1); | ||
789 | upperRow = (ControlRow) ControlGroupVector.get(guiRow); | ||
790 | } | ||
791 | else | ||
792 | { | ||
793 | upperRow = (ControlRow) ControlGroupVector.get(guiRow - 1); | ||
794 | } | ||
795 | focus(getControl(upperRow, control)); | ||
796 | |||
797 | } | ||
798 | |||
799 | /** | ||
800 | * moves the cursor down | ||
801 | * @param guiRow | ||
802 | * @param control | ||
803 | */ | ||
804 | synchronized void cursorDown(int guiRow, Object control) | ||
805 | { | ||
806 | // is this the last full row ? | ||
807 | int actuallRow = guiRow + nscrollvalue; | ||
808 | //if this is the last row, exit | ||
809 | if (actuallRow == scrollfields.size() - 1) | ||
810 | { | ||
811 | return; | ||
812 | // the first row should scroll... | ||
813 | } | ||
814 | boolean scroll = (guiRow == nblockincrement - 1); | ||
815 | ControlRow lowerRow; | ||
816 | if (scroll) | ||
817 | { | ||
818 | setScrollValue(nscrollvalue + 1); | ||
819 | lowerRow = (ControlRow) ControlGroupVector.get(guiRow); | ||
820 | } | ||
821 | // if we scrolled we are done... | ||
822 | //otherwise... | ||
823 | else | ||
824 | { | ||
825 | lowerRow = (ControlRow) ControlGroupVector.get(guiRow + 1); | ||
826 | } | ||
827 | focus(getControl(lowerRow, control)); | ||
828 | } | ||
829 | |||
830 | /** | ||
831 | * changes the values of the given rows with eachother | ||
832 | * @param row1 one can figure out what this parameter is... | ||
833 | * @param row2 one can figure out what this parameter is... | ||
834 | */ | ||
835 | private void switchRows(int row1, int row2) | ||
836 | { | ||
837 | PropertyValue[] o1 = scrollfields.get(row1 + nscrollvalue); | ||
838 | PropertyValue[] o2 = scrollfields.get(row2 + nscrollvalue); | ||
839 | |||
840 | Object temp = null; | ||
841 | for (int i = 1; i < o1.length; i++) | ||
842 | { | ||
843 | temp = o1[i].Value; | ||
844 | o1[i].Value = o2[i].Value; | ||
845 | o2[i].Value = temp; | ||
846 | } | ||
847 | |||
848 | fillupControls(row1); | ||
849 | fillupControls(row2); | ||
850 | |||
851 | updateDocumentRow(row1 + nscrollvalue, o1); | ||
852 | updateDocumentRow(row2 + nscrollvalue, o2); | ||
853 | |||
854 | /* | ||
855 | * if we changed the last row, add another one... | ||
856 | */ | ||
857 | if ((row1 + nscrollvalue + 1 == scrollfields.size()) || | ||
858 | (row2 + nscrollvalue + 1 == scrollfields.size())) | ||
859 | { | ||
860 | insertRowAtEnd(); | ||
861 | /* | ||
862 | * if we did not change the last row but | ||
863 | * we did change the one before - check if we | ||
864 | * have two empty rows at the end. | ||
865 | * If so, delete the last one... | ||
866 | */ | ||
867 | } | ||
868 | else if ((row1 + nscrollvalue) + (row2 + nscrollvalue) == (scrollfields.size() * 2 - 5)) | ||
869 | { | ||
870 | if (isRowEmpty(scrollfields.size() - 2) && isRowEmpty(scrollfields.size() - 1)) | ||
871 | { | ||
872 | removeLastRow(); | ||
873 | reduceDocumentToTopics(); | ||
874 | } | ||
875 | } | ||
876 | } | ||
877 | |||
878 | /** | ||
879 | * returns the current Selection of a text field | ||
880 | * @param control a text field from which the Selection object | ||
881 | * should be gotten. | ||
882 | * @return the selection object. | ||
883 | */ | ||
884 | private Selection getSelection(Object control) | ||
885 | { | ||
886 | return UnoRuntime.queryInterface(XTextComponent.class, control).getSelection(); | ||
887 | } | ||
888 | |||
889 | /** | ||
890 | * sets a text selection to a given control. | ||
891 | * This is used when one moves a row up or down. | ||
892 | * After moving row X to X+/-1, the selection (or cursor position) of the | ||
893 | * last focused control should be restored. | ||
894 | * The control's row is the given guiRow. | ||
895 | * The control's column is detecte4d according to the given event. | ||
896 | * This method is called as subsequent to different events, | ||
897 | * thus it is comfortable to use the event here to detect the column, | ||
898 | * rather than in the different event methods. | ||
899 | * @param guiRow the row of the control to set the selection to. | ||
900 | * @param eventSource helps to detect the control's column to set the selection to. | ||
901 | * @param s the selection object to set. | ||
902 | */ | ||
903 | private void setSelection(int guiRow, Object eventSource, Selection s) | ||
904 | { | ||
905 | ControlRow cr = (ControlRow) ControlGroupVector.get(guiRow); | ||
906 | Object control = getControl(cr, eventSource); | ||
907 | UnoRuntime.queryInterface(XWindow.class, control).setFocus(); | ||
908 | UnoRuntime.queryInterface(XTextComponent.class, control).setSelection(s); | ||
909 | } | ||
910 | |||
911 | /** | ||
912 | * returns a control out of the given row, according to a column number. | ||
913 | * @param cr control row object. | ||
914 | * @param column the column number. | ||
915 | * @return the control... | ||
916 | */ | ||
917 | private Object getControl(ControlRow cr, int column) | ||
918 | { | ||
919 | switch (column) | ||
920 | { | ||
921 | case 0: | ||
922 | return cr.label; | ||
923 | case 1: | ||
924 | return cr.textbox; | ||
925 | case 2: | ||
926 | return cr.combobox; | ||
927 | case 3: | ||
928 | return cr.timebox; | ||
929 | default: | ||
930 | throw new IllegalArgumentException("No such column"); | ||
931 | } | ||
932 | } | ||
933 | |||
934 | /** | ||
935 | * returns a control out of the given row, which is | ||
936 | * in the same column as the given control. | ||
937 | * @param cr control row object | ||
938 | * @param control a control indicating a column. | ||
939 | * @return | ||
940 | */ | ||
941 | private Object getControl(ControlRow cr, Object control) | ||
942 | { | ||
943 | int column = getColumn(control); | ||
944 | return getControl(cr, column); | ||
945 | } | ||
946 | |||
947 | /** | ||
948 | * returns the column number of the given control. | ||
949 | * @param control | ||
950 | * @return | ||
951 | */ | ||
952 | private int getColumn(Object control) | ||
953 | { | ||
954 | String name = (String) Helper.getUnoPropertyValue(UnoDialog2.getModel(control), PropertyNames.PROPERTY_NAME); | ||
955 | if (name.startsWith(TOPIC)) | ||
956 | { | ||
957 | return 1; | ||
958 | } | ||
959 | if (name.startsWith(RESP)) | ||
960 | { | ||
961 | return 2; | ||
962 | } | ||
963 | if (name.startsWith(TIME)) | ||
964 | { | ||
965 | return 3; | ||
966 | } | ||
967 | if (name.startsWith(LABEL)) | ||
968 | { | ||
969 | return 0; | ||
970 | } | ||
971 | return -1; | ||
972 | } | ||
973 | |||
974 | /** | ||
975 | * updates the given row in the preview document. | ||
976 | * @param row | ||
977 | */ | ||
978 | private void updateDocumentRow(int row) | ||
979 | { | ||
980 | updateDocumentRow(row, scrollfields.get(row)); | ||
981 | } | ||
982 | |||
983 | /** | ||
984 | * update the given row in the preview document with the given data. | ||
985 | * @param row | ||
986 | * @param data | ||
987 | */ | ||
988 | private void updateDocumentRow(int row, PropertyValue[] data) | ||
989 | { | ||
990 | try | ||
991 | { | ||
992 | ((AgendaWizardDialogImpl) CurUnoDialog).agendaTemplate.topics.write(row, data); | ||
993 | } | ||
994 | catch (Exception ex) | ||
995 | { | ||
996 | ex.printStackTrace(); | ||
997 | } | ||
998 | } | ||
999 | |||
1000 | /** | ||
1001 | * updates a single cell in the preview document. | ||
1002 | * Is called when a single value is changed, since we really | ||
1003 | * don't have to update the whole row for one small changhe... | ||
1004 | * @param row the data row to update (topic number). | ||
1005 | * @param column the column to update (a gui column, not a document column). | ||
1006 | * @param data the data of the entire row. | ||
1007 | */ | ||
1008 | private void updateDocumentCell(int row, int column, PropertyValue[] data) | ||
1009 | { | ||
1010 | try | ||
1011 | { | ||
1012 | ((AgendaWizardDialogImpl) CurUnoDialog).agendaTemplate.topics.writeCell(row, column, data); | ||
1013 | } | ||
1014 | catch (Exception ex) | ||
1015 | { | ||
1016 | ex.printStackTrace(); | ||
1017 | } | ||
1018 | } | ||
1019 | |||
1020 | /** | ||
1021 | * when removeing rows, this method updates | ||
1022 | * the preview document to show the number of rows | ||
1023 | * according to the data model. | ||
1024 | */ | ||
1025 | private void reduceDocumentToTopics() | ||
1026 | { | ||
1027 | try | ||
1028 | { | ||
1029 | ((AgendaWizardDialogImpl) CurUnoDialog).agendaTemplate.topics.reduceDocumentTo(scrollfields.size() - 1); | ||
1030 | } | ||
1031 | catch (Exception ex) | ||
1032 | { | ||
1033 | ex.printStackTrace(); | ||
1034 | } | ||
1035 | } | ||
1036 | |||
1037 | /** | ||
1038 | * needed to make this data poblic. | ||
1039 | * @return the List containing the topics data. | ||
1040 | */ | ||
1041 | public List<PropertyValue[]> getTopicsData() | ||
1042 | { | ||
1043 | return scrollfields; | ||
1044 | } | ||
1045 | /** | ||
1046 | * A static member used for the child-class ControlRow (GUI Constant) | ||
1047 | */ | ||
1048 | private static Integer I_12 = 12; | ||
1049 | /** | ||
1050 | * A static member used for the child-class ControlRow (GUI Constant) | ||
1051 | */ | ||
1052 | private static Integer I_8 = 8; | ||
1053 | /** | ||
1054 | * A static member used for the child-class ControlRow (GUI Constant) | ||
1055 | */ | ||
1056 | private static final String[] LABEL_PROPS = new String[] | ||
1057 | { | ||
1058 | PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH | ||
1059 | }; | ||
1060 | /** | ||
1061 | * A static member used for the child-class ControlRow (GUI Constant) | ||
1062 | */ | ||
1063 | private static final String[] TEXT_PROPS = new String[] | ||
1064 | { | ||
1065 | PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH | ||
1066 | }; | ||
1067 | |||
1068 | /** | ||
1069 | * A class represting a single GUI row. | ||
1070 | * Note that the instance methods of this class | ||
1071 | * are being called and handle controls of | ||
1072 | * a single row. | ||
1073 | */ | ||
1074 | public class ControlRow implements XKeyListener | ||
1075 | { | ||
1076 | |||
1077 | /** | ||
1078 | * the number (label) control | ||
1079 | */ | ||
1080 | Object label; | ||
1081 | /** | ||
1082 | * the topic (text) control | ||
1083 | */ | ||
1084 | Object textbox; | ||
1085 | /** | ||
1086 | * the responsible (text, yes, text) control | ||
1087 | */ | ||
1088 | Object combobox; | ||
1089 | /** | ||
1090 | * the time (text, yes, text) control | ||
1091 | */ | ||
1092 | Object timebox; | ||
1093 | /** | ||
1094 | * the row offset of this instance (0 = first gui row) | ||
1095 | */ | ||
1096 | int offset; | ||
1097 | |||
1098 | /** | ||
1099 | * called through an event listener when the | ||
1100 | * topic text is changed by the user. | ||
1101 | * updates the data model and the preview document. | ||
1102 | */ | ||
1103 | public void topicTextChanged() | ||
1104 | { | ||
1105 | try | ||
1106 | { | ||
1107 | // update the data model | ||
1108 | fieldInfo(offset, 1); | ||
1109 | // update the preview document | ||
1110 | fieldChanged(offset, 1); | ||
1111 | } | ||
1112 | catch (Exception ex) | ||
1113 | { | ||
1114 | ex.printStackTrace(); | ||
1115 | } | ||
1116 | } | ||
1117 | |||
1118 | /** | ||
1119 | * called through an event listener when the | ||
1120 | * responsible text is changed by the user. | ||
1121 | * updates the data model and the preview document. | ||
1122 | */ | ||
1123 | public void responsibleTextChanged() | ||
1124 | { | ||
1125 | try | ||
1126 | { | ||
1127 | // update the data model | ||
1128 | fieldInfo(offset, 2); | ||
1129 | // update the preview document | ||
1130 | fieldChanged(offset, 2); | ||
1131 | } | ||
1132 | catch (Exception ex) | ||
1133 | { | ||
1134 | ex.printStackTrace(); | ||
1135 | } | ||
1136 | } | ||
1137 | |||
1138 | /** | ||
1139 | * called through an event listener when the | ||
1140 | * time text is changed by the user. | ||
1141 | * updates the data model and the preview document. | ||
1142 | */ | ||
1143 | public void timeTextChanged() | ||
1144 | { | ||
1145 | try | ||
1146 | { | ||
1147 | // update the data model | ||
1148 | fieldInfo(offset, 3); | ||
1149 | // update the preview document | ||
1150 | fieldChanged(offset, 3); | ||
1151 | } | ||
1152 | catch (Exception ex) | ||
1153 | { | ||
1154 | ex.printStackTrace(); | ||
1155 | } | ||
1156 | } | ||
1157 | |||
1158 | /** | ||
1159 | * constructor. Create the row in the given dialog given cordinates, | ||
1160 | * with the given offset (row number) and tabindex. | ||
1161 | * Note that since I use this specifically for the agenda wizard, | ||
1162 | * the step and all control coordinates inside the | ||
1163 | * row are constant (5). | ||
1164 | * @param dialog the agenda dialog | ||
1165 | * @param x x coordinates | ||
1166 | * @param y y coordinates | ||
1167 | * @param i the gui row index | ||
1168 | * @param tabindex first tab index for this row. | ||
1169 | */ | ||
1170 | public ControlRow(AgendaWizardDialog dialog, int x, int y, int i, int tabindex) | ||
1171 | { | ||
1172 | |||
1173 | offset = i; | ||
1174 | |||
1175 | Integer y_ = new Integer(y); | ||
1176 | |||
1177 | label = dialog.insertLabel(LABEL + i, | ||
1178 | LABEL_PROPS, | ||
1179 | new Object[] | ||
1180 | { | ||
1181 | I_8, PropertyNames.EMPTY_STRING + (i + 1) + ".", new Integer(x + 4), new Integer(y + 2), IStep, new Short((short) tabindex), 10 | ||
1182 | }); | ||
1183 | |||
1184 | textbox = dialog.insertTextField(TOPIC + i, "topicTextChanged", this, | ||
1185 | TEXT_PROPS, | ||
1186 | new Object[] | ||
1187 | { | ||
1188 | I_12, HelpIds.getHelpIdString(curHelpIndex + i * 3 + 1), new Integer(x + 15), y_, IStep, new Short((short) (tabindex + 1)), 84 | ||
1189 | }); | ||
1190 | |||
1191 | combobox = dialog.insertTextField(RESP + i, "responsibleTextChanged", this, | ||
1192 | TEXT_PROPS, | ||
1193 | new Object[] | ||
1194 | { | ||
1195 | I_12, HelpIds.getHelpIdString(curHelpIndex + i * 3 + 2), new Integer(x + 103), y_, IStep, new Short((short) (tabindex + 2)), 68 | ||
1196 | }); | ||
1197 | |||
1198 | timebox = dialog.insertTextField(TIME + i, "timeTextChanged", this, | ||
1199 | TEXT_PROPS, | ||
1200 | new Object[] | ||
1201 | { | ||
1202 | I_12, HelpIds.getHelpIdString(curHelpIndex + i * 3 + 3), new Integer(x + 175), y_, IStep, new Short((short) (tabindex + 3)), 20 | ||
1203 | }); | ||
1204 | |||
1205 | setEnabled(false); | ||
1206 | addKeyListener(textbox, this); | ||
1207 | addKeyListener(combobox, this); | ||
1208 | addKeyListener(timebox, this); | ||
1209 | |||
1210 | addFocusListener(textbox, TopicsControl.this); | ||
1211 | addFocusListener(combobox, TopicsControl.this); | ||
1212 | addFocusListener(timebox, TopicsControl.this); | ||
1213 | |||
1214 | } | ||
1215 | |||
1216 | /** | ||
1217 | * not implemented. | ||
1218 | * @param visible | ||
1219 | */ | ||
1220 | public void setVisible(boolean visible) | ||
1221 | { | ||
1222 | // Helper.setUnoPropertyValue(UnoDialog2.getModel(button),"Visible", visible ? Boolean.TRUE : Boolean.FASLE); | ||
1223 | } | ||
1224 | |||
1225 | /** | ||
1226 | * enables/disables the row. | ||
1227 | * @param enabled true for enable, false for disable. | ||
1228 | */ | ||
1229 | public void setEnabled(boolean enabled) | ||
1230 | { | ||
1231 | Boolean b = enabled ? Boolean.TRUE : Boolean.FALSE; | ||
1232 | UnoDialog2.setEnabled(label, b); | ||
1233 | UnoDialog2.setEnabled(textbox, b); | ||
1234 | UnoDialog2.setEnabled(combobox, b); | ||
1235 | UnoDialog2.setEnabled(timebox, b); | ||
1236 | } | ||
1237 | |||
1238 | /** | ||
1239 | * Impelementation of XKeyListener. | ||
1240 | * Optionally performs the one of the following: | ||
1241 | * cursor up, or down, row up or down | ||
1242 | */ | ||
1243 | public void keyPressed(KeyEvent event) | ||
1244 | { | ||
1245 | if (isMoveDown(event)) | ||
1246 | { | ||
1247 | rowDown(offset, event.Source); | ||
1248 | } | ||
1249 | else if (isMoveUp(event)) | ||
1250 | { | ||
1251 | rowUp(offset, event.Source); | ||
1252 | } | ||
1253 | else if (isDown(event)) | ||
1254 | { | ||
1255 | cursorDown(offset, event.Source); | ||
1256 | } | ||
1257 | else if (isUp(event)) | ||
1258 | { | ||
1259 | cursorUp(offset, event.Source); | ||
1260 | } | ||
1261 | enableButtons(); | ||
1262 | } | ||
1263 | |||
1264 | /** | ||
1265 | * returns the column number of the given control. | ||
1266 | * The given control must belong to this row or | ||
1267 | * an IllegalArgumentException will accure. | ||
1268 | * @param control | ||
1269 | * @return an int columnd number of the given control (0 to 3). | ||
1270 | */ | ||
1271 | private int getColumn(Object control) | ||
1272 | { | ||
1273 | if (control == textbox) | ||
1274 | { | ||
1275 | return 1; | ||
1276 | } | ||
1277 | else if (control == combobox) | ||
1278 | { | ||
1279 | return 2; | ||
1280 | } | ||
1281 | else if (control == timebox) | ||
1282 | { | ||
1283 | return 3; | ||
1284 | } | ||
1285 | else if (control == label) | ||
1286 | { | ||
1287 | return 0; | ||
1288 | } | ||
1289 | else | ||
1290 | { | ||
1291 | throw new IllegalArgumentException("Control is not part of this ControlRow"); | ||
1292 | } | ||
1293 | } | ||
1294 | |||
1295 | private boolean isMoveDown(KeyEvent e) | ||
1296 | { | ||
1297 | return (e.KeyCode == Key.DOWN) && (e.Modifiers == KeyModifier.MOD1); | ||
1298 | } | ||
1299 | |||
1300 | private boolean isMoveUp(KeyEvent e) | ||
1301 | { | ||
1302 | return (e.KeyCode == Key.UP) && (e.Modifiers == KeyModifier.MOD1); | ||
1303 | } | ||
1304 | |||
1305 | private boolean isDown(KeyEvent e) | ||
1306 | { | ||
1307 | return (e.KeyCode == Key.DOWN) && (e.Modifiers == 0); | ||
1308 | } | ||
1309 | |||
1310 | private boolean isUp(KeyEvent e) | ||
1311 | { | ||
1312 | return (e.KeyCode == Key.UP) && (e.Modifiers == 0); | ||
1313 | } | ||
1314 | |||
1315 | public void keyReleased(KeyEvent arg0) | ||
1316 | { | ||
1317 | } | ||
1318 | |||
1319 | |||
1320 | /* (non-Javadoc) | ||
1321 | * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject) | ||
1322 | */ | ||
1323 | public void disposing(EventObject arg0) | ||
1324 | { | ||
1325 | } | ||
1326 | } | ||
1327 | } | ||