001: /*--------------------------------------------------------------------------*
002: | Copyright (C) 2006 Christopher Kohlhaas |
003: | |
004: | This program is free software; you can redistribute it and/or modify |
005: | it under the terms of the GNU General Public License as published by the |
006: | Free Software Foundation. A copy of the license has been included with |
007: | these distribution in the COPYING file, if not go to www.fsf.org |
008: | |
009: | As a special exception, you are granted the permissions to link this |
010: | program with every library, which license fulfills the Open Source |
011: | Definition as published by the Open Source Initiative (OSI). |
012: *--------------------------------------------------------------------------*/
013: package org.rapla.client.internal;
014:
015: import java.awt.Component;
016: import java.awt.event.ActionEvent;
017: import java.awt.event.WindowAdapter;
018: import java.awt.event.WindowEvent;
019: import java.util.Collection;
020: import java.util.Collections;
021: import java.util.HashMap;
022: import java.util.Iterator;
023: import java.util.List;
024: import java.util.Vector;
025:
026: import javax.swing.AbstractAction;
027: import javax.swing.Action;
028: import javax.swing.JMenuItem;
029: import javax.swing.JSeparator;
030:
031: import org.apache.avalon.framework.configuration.Configuration;
032: import org.apache.avalon.framework.configuration.DefaultConfiguration;
033: import org.rapla.client.ClientService;
034: import org.rapla.client.RaplaClientListener;
035: import org.rapla.components.calendar.DateRenderer;
036: import org.rapla.components.iolayer.DefaultIO;
037: import org.rapla.components.iolayer.IOInterface;
038: import org.rapla.components.iolayer.WebstartIO;
039: import org.rapla.components.util.Mutex;
040: import org.rapla.components.xmlbundle.I18nBundle;
041: import org.rapla.components.xmlbundle.LocaleSelector;
042: import org.rapla.entities.User;
043: import org.rapla.entities.configuration.CalendarModelConfiguration;
044: import org.rapla.entities.configuration.Preferences;
045: import org.rapla.entities.configuration.RaplaConfiguration;
046: import org.rapla.entities.dynamictype.DynamicType;
047: import org.rapla.entities.dynamictype.DynamicTypeAnnotations;
048: import org.rapla.facade.ClientFacade;
049: import org.rapla.facade.UpdateErrorListener;
050: import org.rapla.framework.PluginDescriptor;
051: import org.rapla.framework.RaplaContext;
052: import org.rapla.framework.RaplaContextException;
053: import org.rapla.framework.RaplaException;
054: import org.rapla.framework.RaplaLocale;
055: import org.rapla.framework.StartupEnvironment;
056: import org.rapla.framework.internal.ContainerImpl;
057: import org.rapla.gui.CalendarModel;
058: import org.rapla.gui.EditController;
059: import org.rapla.gui.InfoFactory;
060: import org.rapla.gui.MenuExtensionPoint;
061: import org.rapla.gui.MenuFactory;
062: import org.rapla.gui.ReservationController;
063: import org.rapla.gui.TreeFactory;
064: import org.rapla.gui.internal.CalendarOption;
065: import org.rapla.gui.internal.ConnectionOption;
066: import org.rapla.gui.internal.LocaleOption;
067: import org.rapla.gui.internal.MainFrame;
068: import org.rapla.gui.internal.MenuFactoryImpl;
069: import org.rapla.gui.internal.RaplaDateRenderer;
070: import org.rapla.gui.internal.StoreCalendarSelectionAction;
071: import org.rapla.gui.internal.UserOption;
072: import org.rapla.gui.internal.common.CalendarModelImpl;
073: import org.rapla.gui.internal.common.CalendarSelectionModel;
074: import org.rapla.gui.internal.common.InternMenus;
075: import org.rapla.gui.internal.common.RaplaClipboard;
076: import org.rapla.gui.internal.edit.EditControllerImpl;
077: import org.rapla.gui.internal.edit.reservation.NoWizard;
078: import org.rapla.gui.internal.edit.reservation.ReservationControllerImpl;
079: import org.rapla.gui.internal.view.InfoFactoryImpl;
080: import org.rapla.gui.internal.view.LicenseInfoUI;
081: import org.rapla.gui.internal.view.TreeFactoryImpl;
082: import org.rapla.gui.toolkit.ErrorDialog;
083: import org.rapla.gui.toolkit.FrameControllerList;
084: import org.rapla.gui.toolkit.MenuInterface;
085: import org.rapla.gui.toolkit.RaplaFrame;
086: import org.rapla.gui.toolkit.RaplaMenu;
087: import org.rapla.gui.toolkit.RaplaMenubar;
088: import org.rapla.gui.toolkit.RaplaSeparator;
089: import org.rapla.gui.toolkit.RaplaWidget;
090: import org.rapla.plugin.RaplaExtensionPoints;
091: import org.rapla.plugin.weekview.WeekViewFactory;
092:
093: /** Implemention of the ClientService.
094: */
095: public class RaplaClientServiceImpl extends ContainerImpl implements
096: ClientService, UpdateErrorListener {
097:
098: Vector listenerList = new Vector();
099: LoadingProgress progress;
100: I18nBundle i18n;
101: ClientFacade facade;
102: boolean started;
103: boolean restartingGUI;
104: String facadeName;
105: boolean defaultLanguageChoosen;
106: FrameControllerList frameControllerList;
107:
108: public RaplaClientServiceImpl(RaplaContext parentContext,
109: Configuration config) throws RaplaException {
110: super (parentContext, config);
111:
112: }
113:
114: class DefaultMenuInsertPoint implements MenuExtensionPoint {
115: MenuInterface menu;
116: String insertId;
117:
118: public DefaultMenuInsertPoint(MenuInterface menu,
119: String insertId) {
120: this .menu = menu;
121: this .insertId = insertId;
122: }
123:
124: public void insert(JMenuItem item) {
125: menu.insertAfterId(item, insertId);
126: }
127:
128: public void insert(JSeparator seperator) {
129: menu.insertAfterId(seperator, insertId);
130: }
131:
132: }
133:
134: protected void init() throws RaplaException {
135: defaultLanguageChoosen = true;
136:
137: // !!Warning: Theres a trivial patent for the use of Progress Bars see http://swpat.ffii.org/patents/txt/ep/0394/160/
138: // You can uncomment the following two lines to disable the progressBar
139: progress = new LoadingProgress();
140: progress.start(1, 5);
141:
142: super .init();
143:
144: facadeName = m_config.getChild("facade").getValue("*");
145: frameControllerList = new FrameControllerList();
146: frameControllerList.enableLogging(getLogger().getChildLogger(
147: "framelist"));
148: addContainerProvidedComponentInstance(FrameControllerList.ROLE,
149: frameControllerList);
150:
151: addContainerProvidedComponent("org.rapla.gui.WelcomeField",
152: LicenseInfoUI.class.getName());
153: addContainerProvidedComponent(MAIN_COMPONENT, RaplaFrame.class
154: .getName());
155:
156: RaplaMenubar menuBar = new RaplaMenubar();
157:
158: RaplaMenu systemMenu = new RaplaMenu(InternMenus.FILE_MENU_ROLE);
159: RaplaMenu editMenu = new RaplaMenu(InternMenus.EDIT_MENU_ROLE);
160: RaplaMenu viewMenu = new RaplaMenu(InternMenus.VIEW_MENU_ROLE);
161: RaplaMenu helpMenu = new RaplaMenu(InternMenus.EXTRA_MENU_ROLE);
162:
163: RaplaMenu newMenu = new RaplaMenu(InternMenus.NEW_MENU_ROLE);
164: RaplaMenu adminMenu = new RaplaMenu(InternMenus.ADMIN_MENU_ROLE);
165: RaplaMenu importMenu = new RaplaMenu(
166: InternMenus.IMPORT_MENU_ROLE);
167: RaplaMenu exportMenu = new RaplaMenu(
168: InternMenus.EXPORT_MENU_ROLE);
169:
170: menuBar.add(systemMenu);
171: menuBar.add(editMenu);
172: menuBar.add(viewMenu);
173: menuBar.add(helpMenu);
174:
175: addContainerProvidedComponentInstance(
176: RaplaExtensionPoints.ADMIN_MENU_EXTENSION_POINT,
177: new DefaultMenuInsertPoint(adminMenu, null));
178: addContainerProvidedComponentInstance(
179: RaplaExtensionPoints.IMPORT_MENU_EXTENSION_POINT,
180: new DefaultMenuInsertPoint(importMenu, null));
181: addContainerProvidedComponentInstance(
182: RaplaExtensionPoints.EXPORT_MENU_EXTENSION_POINT,
183: new DefaultMenuInsertPoint(exportMenu, null));
184: addContainerProvidedComponentInstance(
185: RaplaExtensionPoints.HELP_MENU_EXTENSION_POINT,
186: new DefaultMenuInsertPoint(helpMenu, null));
187: addContainerProvidedComponentInstance(
188: RaplaExtensionPoints.VIEW_MENU_EXTENSION_POINT,
189: new DefaultMenuInsertPoint(viewMenu, null));
190: addContainerProvidedComponentInstance(
191: RaplaExtensionPoints.EDIT_MENU_EXTENSION_POINT,
192: new DefaultMenuInsertPoint(editMenu, "EDIT_END"));
193:
194: addContainerProvidedComponentInstance(InternMenus.MENU_BAR,
195: menuBar);
196: addContainerProvidedComponentInstance(
197: InternMenus.FILE_MENU_ROLE, systemMenu);
198: addContainerProvidedComponentInstance(
199: InternMenus.EDIT_MENU_ROLE, editMenu);
200: addContainerProvidedComponentInstance(
201: InternMenus.VIEW_MENU_ROLE, viewMenu);
202: addContainerProvidedComponentInstance(
203: InternMenus.ADMIN_MENU_ROLE, adminMenu);
204: addContainerProvidedComponentInstance(
205: InternMenus.IMPORT_MENU_ROLE, importMenu);
206: addContainerProvidedComponentInstance(
207: InternMenus.EXPORT_MENU_ROLE, exportMenu);
208: addContainerProvidedComponentInstance(
209: InternMenus.NEW_MENU_ROLE, newMenu);
210: addContainerProvidedComponentInstance(
211: InternMenus.EXTRA_MENU_ROLE, helpMenu);
212:
213: editMenu.add(new RaplaSeparator("EDIT_BEGIN"));
214: editMenu.add(new RaplaSeparator("EDIT_END"));
215:
216: addContainerProvidedComponent(RaplaClipboard.ROLE,
217: RaplaClipboard.class.getName());
218: addContainerProvidedComponent(TreeFactory.ROLE,
219: TreeFactoryImpl.class.getName());
220: addContainerProvidedComponent(MenuFactory.ROLE,
221: MenuFactoryImpl.class.getName());
222: addContainerProvidedComponent(InfoFactory.ROLE,
223: InfoFactoryImpl.class.getName());
224: addContainerProvidedComponent(EditController.ROLE,
225: EditControllerImpl.class.getName());
226: addContainerProvidedComponent(ReservationController.ROLE,
227: ReservationControllerImpl.class.getName());
228: addContainerProvidedComponent(DateRenderer.class.getName(),
229: RaplaDateRenderer.class.getName());
230: addContainerProvidedComponent(
231: RaplaExtensionPoints.RESERVATION_WIZARD_EXTENSION,
232: NoWizard.class.getName());
233:
234: addContainerProvidedComponentInstance(SESSION_MAP,
235: new HashMap());
236:
237: addContainerProvidedComponent(
238: RaplaExtensionPoints.USER_OPTION_PANEL_EXTENSION,
239: UserOption.class.getName());
240: addContainerProvidedComponent(
241: RaplaExtensionPoints.USER_OPTION_PANEL_EXTENSION,
242: CalendarOption.class.getName());
243: addContainerProvidedComponent(
244: RaplaExtensionPoints.USER_OPTION_PANEL_EXTENSION,
245: LocaleOption.class.getName());
246: addContainerProvidedComponent(
247: RaplaExtensionPoints.SYSTEM_OPTION_PANEL_EXTENSION,
248: CalendarOption.class.getName());
249:
250: boolean webstartEnabled = ((StartupEnvironment) getContext()
251: .lookup(StartupEnvironment.ROLE)).getStartupMode() == StartupEnvironment.WEBSTART;
252:
253: if (webstartEnabled) {
254: addContainerProvidedComponent(IOInterface.ROLE,
255: WebstartIO.class.getName());
256: } else {
257: addContainerProvidedComponent(IOInterface.ROLE,
258: DefaultIO.class.getName());
259: }
260:
261: if (progress != null) {
262: progress.advance();
263: }
264: }
265:
266: public ClientFacade getFacade() {
267: return facade;
268: }
269:
270: public void start() throws Exception {
271: if (started)
272: return;
273:
274: try {
275: if (progress != null)
276: progress.advance();
277:
278: getLogger().debug("RaplaClient started");
279: i18n = (I18nBundle) getContext().lookup(I18nBundle.ROLE);
280: facade = (ClientFacade) getContext().lookup(
281: ClientFacade.ROLE + "/" + facadeName);
282: facade.addUpdateErrorListener(this );
283:
284: if (progress != null)
285: progress.advance();
286:
287: if (!facade.isSessionActive()) {
288: startLogin();
289: } else {
290: beginRaplaSession();
291: }
292: } catch (Exception ex) {
293: throw ex;
294: } finally {
295: if (progress != null)
296: progress.close();
297: }
298: }
299:
300: /**
301: * @throws RaplaException
302: *
303: */
304: private void beginRaplaSession() throws RaplaException {
305: initLanguage();
306:
307: CalendarModel model = createCalendarModel();
308: addContainerProvidedComponentInstance(CalendarModel.ROLE, model);
309: addContainerProvidedComponentInstance(
310: CalendarSelectionModel.ROLE, model);
311: if (getFacade().isClientForServer()) {
312: addContainerProvidedComponent(
313: RaplaExtensionPoints.SYSTEM_OPTION_PANEL_EXTENSION,
314: ConnectionOption.class.getName());
315: }
316:
317: List pluginList;
318: try {
319: pluginList = (List) getContext().lookup(
320: PluginDescriptor.PLUGIN_LIST);
321: } catch (RaplaContextException ex) {
322: throw new RaplaException(ex);
323: }
324: initializePlugins(pluginList, getFacade().getPreferences(null));
325:
326: started = true;
327: javax.swing.ToolTipManager.sharedInstance().setDismissDelay(
328: 10000);
329:
330: RaplaFrame mainComponent = (RaplaFrame) getContext().lookup(
331: MAIN_COMPONENT);
332: mainComponent.addWindowListener(new WindowAdapter() {
333: public void windowClosed(WindowEvent e) {
334: try {
335: if (!isRestartingGUI()) {
336: stop();
337: } else {
338: restartingGUI = false;
339: }
340: } catch (Exception ex) {
341: getLogger().error(ex.getMessage(), ex);
342: }
343: }
344:
345: });
346: MainFrame mainFrame = new MainFrame(getContext());
347:
348: fireClientStarted();
349: mainFrame.show();
350: }
351:
352: private void initLanguage() throws RaplaException,
353: RaplaContextException {
354: if (!defaultLanguageChoosen) {
355: Preferences prefs = (Preferences) facade.edit(facade
356: .getPreferences());
357: RaplaLocale raplaLocale = (RaplaLocale) getContext()
358: .lookup(RaplaLocale.ROLE);
359: String currentLanguage = raplaLocale.getLocale()
360: .getLanguage();
361: prefs.putEntry(RaplaLocale.LANGUAGE_ENTRY, currentLanguage);
362: try {
363: facade.store(prefs);
364: } catch (Exception e) {
365: getLogger().error("Can't store language change", e);
366: }
367: } else {
368: String language = facade.getPreferences().getEntryAsString(
369: RaplaLocale.LANGUAGE_ENTRY, null);
370: if (language != null) {
371: LocaleSelector localeSelector = (LocaleSelector) getContext()
372: .lookup(LocaleSelector.ROLE);
373: localeSelector.setLanguage(language);
374: }
375: }
376: }
377:
378: protected void initializePlugins(List pluginList,
379: Preferences preferences) throws RaplaException {
380: RaplaConfiguration raplaConfig = (RaplaConfiguration) preferences
381: .getEntry("org.rapla.plugin");
382: // Add plugin configs
383: for (Iterator it = pluginList.iterator(); it.hasNext();) {
384: PluginDescriptor pluginDescriptor = (PluginDescriptor) it
385: .next();
386: String pluginClassname = pluginDescriptor.getClass()
387: .getName();
388: Configuration pluginConfig = null;
389: if (raplaConfig != null) {
390: pluginConfig = raplaConfig.find("class",
391: pluginClassname);
392: }
393: if (pluginConfig == null) {
394: pluginConfig = new DefaultConfiguration("plugin");
395: }
396: pluginDescriptor.provideServices(this , pluginConfig);
397: }
398:
399: Collection clientPlugins = getAllServicesFor(RaplaExtensionPoints.CLIENT_EXTENSION);
400: // start plugins
401: for (Iterator it = clientPlugins.iterator(); it.hasNext();) {
402: String hint = (String) it.next();
403: try {
404: getContext().lookup(
405: RaplaExtensionPoints.CLIENT_EXTENSION + "/"
406: + hint);
407: getLogger().info("Initialize " + hint);
408: } catch (RaplaContextException ex) {
409: getLogger().error("Can't initialize " + hint, ex);
410: }
411: }
412: }
413:
414: public boolean isRestartingGUI() {
415: return restartingGUI;
416: }
417:
418: public void addRaplaClientListener(RaplaClientListener listener) {
419: listenerList.add(listener);
420: }
421:
422: public void removeRaplaClientListener(RaplaClientListener listener) {
423: listenerList.remove(listener);
424: }
425:
426: public RaplaClientListener[] getRaplaClientListeners() {
427: return (RaplaClientListener[]) listenerList
428: .toArray(new RaplaClientListener[] {});
429: }
430:
431: protected void fireClientClosed(boolean restart) {
432: RaplaClientListener[] listeners = getRaplaClientListeners();
433: for (int i = 0; i < listeners.length; i++)
434: listeners[i].clientClosed(restart);
435: }
436:
437: protected void fireClientStarted() {
438: RaplaClientListener[] listeners = getRaplaClientListeners();
439: for (int i = 0; i < listeners.length; i++)
440: listeners[i].clientStarted();
441: }
442:
443: protected void fireClientAborted() {
444: RaplaClientListener[] listeners = getRaplaClientListeners();
445: for (int i = 0; i < listeners.length; i++)
446: listeners[i].clientAborted();
447: }
448:
449: public boolean isRunning() {
450: return started;
451: }
452:
453: public void restartGUI() {
454: started = false;
455: try {
456: restartingGUI = true;
457: frameControllerList.closeAll();
458: removeAllComponents();
459: init();
460: start();
461: } catch (Exception ex) {
462: getLogger().error(ex.getMessage(), ex);
463: stop();
464: }
465: }
466:
467: public void stop() {
468: stop(false);
469: }
470:
471: public void stop(boolean restart) {
472: if (!started)
473: return;
474:
475: try {
476: facade.logout();
477: } catch (RaplaException ex) {
478: getLogger().error("Clean logout failed", ex);
479: }
480: getLogger().info("Bye");
481: started = false;
482: fireClientClosed(restart);
483: }
484:
485: public void dispose() {
486: if (frameControllerList != null)
487: frameControllerList.closeAll();
488: super .dispose();
489: getLogger().debug("RaplaClient disposed");
490: }
491:
492: private void startLogin() throws Exception {
493: Thread loginThread = new Thread() {
494: public void run() {
495: startLoginInThread();
496: }
497: };
498: loginThread.setDaemon(false);
499: loginThread.start();
500: }
501:
502: /*
503: selectionChanged();
504: }
505:
506: */
507:
508: private void startLoginInThread() {
509: final Mutex loginMutex = new Mutex();
510: try {
511: RaplaWidget welcomeField = (RaplaWidget) getContext()
512: .lookup("org.rapla.gui.WelcomeField");
513: final LanguageChooser languageChooser = new LanguageChooser(
514: getLogger(), getContext());
515:
516: final LoginDialog dlg = LoginDialog.create(getContext(),
517: welcomeField.getComponent(), languageChooser
518: .getComponent());
519:
520: Action languageChanged = new AbstractAction() {
521: private static final long serialVersionUID = 1L;
522:
523: public void actionPerformed(ActionEvent evt) {
524: try {
525: String lang = languageChooser
526: .getSelectedLanguage();
527: if (lang == null) {
528: defaultLanguageChoosen = true;
529: } else {
530: defaultLanguageChoosen = false;
531: getLogger().debug(
532: "Language changing to " + lang);
533: LocaleSelector localeSelector = (LocaleSelector) getContext()
534: .lookup(LocaleSelector.ROLE);
535: localeSelector.setLanguage(lang);
536: getLogger().info(
537: "Language changed "
538: + localeSelector
539: .getLanguage());
540: }
541: } catch (Exception ex) {
542: getLogger().error("Can't change language", ex);
543: }
544: }
545:
546: };
547: languageChooser.setChangeAction(languageChanged);
548:
549: //dlg.setIcon( i18n.getIcon("icon.rapla-small"));
550: if (progress != null)
551: progress.close();
552: Action loginAction = new AbstractAction() {
553: private static final long serialVersionUID = 1L;
554:
555: public void actionPerformed(ActionEvent evt) {
556: String username = dlg.getUsername();
557: char[] password = dlg.getPassword();
558: boolean success = false;
559: try {
560: success = login(username, password);
561: if (!success) {
562: showWarning(i18n.getString("error.login"),
563: dlg);
564: }
565: } catch (RaplaException ex) {
566: showException(ex, dlg);
567: }
568: if (success) {
569: dlg.close();
570: loginMutex.release();
571: try {
572: beginRaplaSession();
573: } catch (RaplaException ex) {
574: showException(ex, null);
575: stop();
576: fireClientAborted();
577: }
578: } // end of else
579: }
580:
581: };
582: Action exitAction = new AbstractAction() {
583: private static final long serialVersionUID = 1L;
584:
585: public void actionPerformed(ActionEvent evt) {
586: dlg.close();
587: loginMutex.release();
588: stop();
589: fireClientAborted();
590: }
591: };
592: loginAction.putValue(Action.NAME, i18n.getString("login"));
593: exitAction.putValue(Action.NAME, i18n.getString("exit"));
594: dlg.setIconImage(i18n.getIcon("icon.rapla_small")
595: .getImage());
596: dlg.setLoginAction(loginAction);
597: dlg.setExitAction(exitAction);
598: dlg.setSize(480, 270);
599: FrameControllerList.centerWindowOnScreen(dlg);
600: dlg.setVisible(true);
601: loginMutex.aquire();
602: loginMutex.aquire();
603: } catch (Exception ex) {
604: getLogger().error("Error during Login ", ex);
605: stop();
606: fireClientAborted();
607: } finally {
608: loginMutex.release();
609: }
610: }
611:
612: public void updateError(RaplaException ex) {
613: getLogger().error("Error updating data", ex);
614: }
615:
616: /**
617: * @see org.rapla.facade.UpdateErrorListener#disconnected()
618: */
619: public void disconnected() {
620: if (started)
621: stop(true);
622: }
623:
624: public void restart() {
625: stop(true);
626: }
627:
628: public void showException(Exception ex, Component component) {
629: try {
630: ErrorDialog dialog = new ErrorDialog(getContext());
631: dialog.showExceptionDialog(ex, component);
632: } catch (RaplaException ex2) {
633: getLogger().error(ex2.getMessage(), ex2);
634: }
635: }
636:
637: private boolean login(String username, char[] password)
638: throws RaplaException {
639: if (facade.login(username, password)) {
640: return true;
641: } else {
642: return false;
643: }
644: }
645:
646: public void showWarning(String warning, Component owner) {
647: try {
648: ErrorDialog dialog = new ErrorDialog(getContext());
649: dialog.showWarningDialog(warning, owner);
650: } catch (RaplaException ex2) {
651: getLogger().error(ex2.getMessage(), ex2);
652: }
653: }
654:
655: private CalendarModel createCalendarModel() throws RaplaException {
656: CalendarModelImpl model = new CalendarModelImpl(getContext());
657: CalendarModelConfiguration conf = (CalendarModelConfiguration) getFacade()
658: .getPreferences().getEntry(
659: StoreCalendarSelectionAction.CONFIG_ENTRY);
660: if (conf != null) {
661: model.setConfiguration(conf);
662: } else {
663: DynamicType[] types = getFacade()
664: .getDynamicTypes(
665: DynamicTypeAnnotations.VALUE_RESOURCE_CLASSIFICATION);
666: if (types.length == 0) {
667: types = getFacade()
668: .getDynamicTypes(
669: DynamicTypeAnnotations.VALUE_PERSON_CLASSIFICATION);
670: }
671: model.setSelectedObjects(Collections
672: .singletonList(types[0]));
673: model.setViewId(WeekViewFactory.WEEK_VIEW);
674: User user = getFacade().getUser();
675: if (!user.isAdmin()) {
676: model.selectUser(user);
677: }
678: model.setUser(user);
679: /*
680: model.setStartDate( null);
681: model.setEndDate( null);*/
682: }
683: model.setSelectedDate(getFacade().today());
684: return model;
685: }
686:
687: }
|