Source Code Cross Referenced for CalendarFrameMediator.java in  » Mail-Clients » columba-1.4 » org » columba » calendar » ui » frame » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.calendar.ui.frame 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // The contents of this file are subject to the Mozilla Public License Version
002:        // 1.1
003:        //(the "License"); you may not use this file except in compliance with the
004:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005:        //
006:        //Software distributed under the License is distributed on an "AS IS" basis,
007:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008:        //for the specific language governing rights and
009:        //limitations under the License.
010:        //
011:        //The Original Code is "The Columba Project"
012:        //
013:        //The Initial Developers of the Original Code are Frederik Dietz and Timo
014:        // Stich.
015:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016:        //
017:        //All Rights Reserved.
018:        package org.columba.calendar.ui.frame;
019:
020:        import java.awt.event.MouseAdapter;
021:        import java.awt.event.MouseEvent;
022:        import java.io.InputStream;
023:        import java.util.Calendar;
024:
025:        import javax.swing.BorderFactory;
026:        import javax.swing.JScrollPane;
027:        import javax.swing.UIManager;
028:
029:        import org.columba.api.gui.frame.IContainer;
030:        import org.columba.api.gui.frame.IDock;
031:        import org.columba.api.gui.frame.IDockable;
032:        import org.columba.calendar.base.api.IActivity;
033:        import org.columba.calendar.model.api.IComponent;
034:        import org.columba.calendar.model.api.IComponentInfo;
035:        import org.columba.calendar.model.api.IDateRange;
036:        import org.columba.calendar.model.api.IEventInfo;
037:        import org.columba.calendar.resourceloader.ResourceLoader;
038:        import org.columba.calendar.store.CalendarStoreFactory;
039:        import org.columba.calendar.store.api.ICalendarStore;
040:        import org.columba.calendar.ui.action.ActivityMovedAction;
041:        import org.columba.calendar.ui.action.EditActivityAction;
042:        import org.columba.calendar.ui.action.NewAppointmentAction;
043:        import org.columba.calendar.ui.calendar.MainCalendarController;
044:        import org.columba.calendar.ui.calendar.api.ActivitySelectionChangedEvent;
045:        import org.columba.calendar.ui.calendar.api.IActivitySelectionChangedListener;
046:        import org.columba.calendar.ui.calendar.api.ICalendarView;
047:        import org.columba.calendar.ui.frame.api.ICalendarMediator;
048:        import org.columba.calendar.ui.list.CalendarListController;
049:        import org.columba.calendar.ui.list.api.ICalendarListView;
050:        import org.columba.calendar.ui.navigation.NavigationController;
051:        import org.columba.calendar.ui.navigation.api.DateRangeChangedEvent;
052:        import org.columba.calendar.ui.navigation.api.ICalendarNavigationView;
053:        import org.columba.calendar.ui.navigation.api.IDateRangeChangedListener;
054:        import org.columba.calendar.ui.tagging.CalendarTagList;
055:        import org.columba.core.config.ViewItem;
056:        import org.columba.core.context.base.api.IStructureValue;
057:        import org.columba.core.context.semantic.api.ISemanticContext;
058:        import org.columba.core.gui.frame.DockFrameController;
059:        import org.columba.core.gui.tagging.TagList;
060:        import org.columba.core.gui.tagging.TagPopupMenu;
061:
062:        /**
063:         * @author fdietz
064:         * 
065:         */
066:        public class CalendarFrameMediator extends DockFrameController
067:                implements  ICalendarMediator {
068:
069:            public static final String PROP_FILTERED = "filterRow";
070:
071:            private CalendarListController listController;
072:
073:            public MainCalendarController calendarController;
074:
075:            private ICalendarNavigationView navigationController;
076:
077:            private IDockable listPanel;
078:
079:            private IDockable calendarPanel;
080:
081:            private IDockable navigationPanel;
082:
083:            private IDockable tagListDockable;
084:
085:            /**
086:             * @param viewItem
087:             */
088:            public CalendarFrameMediator(ViewItem viewItem) {
089:                super (viewItem);
090:
091:                // TestDataGenerator.generateTestData();
092:
093:                calendarController = new MainCalendarController(this );
094:
095:                calendarController
096:                        .addSelectionChangedListener(new MyActivitySelectionChangedListener());
097:
098:                navigationController = new NavigationController();
099:
100:                navigationController
101:                        .addSelectionChangedListener(new IDateRangeChangedListener() {
102:                            public void selectionChanged(
103:                                    DateRangeChangedEvent object) {
104:                                calendarController.setVisibleDateRange(object
105:                                        .getDateRange());
106:
107:                            }
108:                        });
109:
110:                listController = new CalendarListController(this );
111:                listController.getView().addMouseListener(
112:                        new ListMouseListener());
113:
114:                registerDockables();
115:
116:                initContextMenu();
117:
118:            }
119:
120:            private void initContextMenu() {
121:                listController.createPopupMenu(this );
122:                calendarController.createPopupMenu(this );
123:            }
124:
125:            private void registerDockables() {
126:
127:                // calendar list
128:                JScrollPane treeScrollPane = new JScrollPane(listController
129:                        .getView());
130:                // set background of scrollpane, in case the list is smaller than the
131:                // dockable
132:                treeScrollPane.getViewport().setBackground(
133:                        UIManager.getColor("List.background"));
134:                treeScrollPane.setBackground(UIManager
135:                        .getColor("List.background"));
136:                treeScrollPane.setBorder(BorderFactory.createEmptyBorder(2, 2,
137:                        2, 2));
138:                listPanel = registerDockable("calendar_tree", ResourceLoader
139:                        .getString("global", "dockable_calendarlist"),
140:                        treeScrollPane, null);
141:
142:                // JScrollPane tableScrollPane = new JScrollPane(navigationController
143:                // .getView());
144:                // tableScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0,
145:                // 0));
146:
147:                navigationPanel = registerDockable("navigation", ResourceLoader
148:                        .getString("global", "dockable_navigation"),
149:                        navigationController.getView(), null);
150:
151:                calendarPanel = registerDockable("main_calendar",
152:                        ResourceLoader.getString("global",
153:                                "dockable_maincalendar"), calendarController
154:                                .getView(), null);
155:
156:                //		TagList tagList = new CalendarTagList(this);
157:                //		JScrollPane tagListScrollPane = new JScrollPane(tagList);
158:                //		tagListScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
159:                //		tagListScrollPane
160:                //				.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
161:
162:                //		tagListDockable = registerDockable("calendar_taglist", ResourceLoader
163:                //				.getString("global", "dockable_taglist"), tagListScrollPane,
164:                //				new TagPopupMenu(this, tagList));
165:                //		tagList.setPopupMenu(new TagPopupMenu(this, tagList));
166:
167:            }
168:
169:            /**
170:             * @see org.columba.core.gui.frame.DockFrameController#loadDefaultPosition()
171:             */
172:            public void loadDefaultPosition() {
173:
174:                super .dock(calendarPanel, IDock.REGION.CENTER);
175:                super .dock(listPanel, calendarPanel, IDock.REGION.WEST, 0.2f);
176:                super 
177:                        .dock(navigationPanel, listPanel, IDock.REGION.SOUTH,
178:                                0.2f);
179:
180:                super .setSplitProportion(listPanel, 0.2f);
181:                super .setSplitProportion(calendarPanel, 0.2f);
182:            }
183:
184:            /** *********************** container callbacks ************* */
185:
186:            /**
187:             * @see org.columba.api.gui.frame.IFrameMediator#extendMenu(org.columba.api.gui.frame.IContainer)
188:             */
189:            public void extendMenu(IContainer container) {
190:                InputStream is = this .getClass().getResourceAsStream(
191:                        "/org/columba/calendar/action/menu.xml");
192:                getContainer().extendMenu(this , is);
193:            }
194:
195:            /**
196:             * @see org.columba.api.gui.frame.IFrameMediator#extendToolBar(org.columba.api.gui.frame.IContainer)
197:             */
198:            public void extendToolBar(IContainer container) {
199:
200:                InputStream is2 = this .getClass().getResourceAsStream(
201:                        "/org/columba/calendar/action/toolbar.xml");
202:                getContainer().extendToolbar(this , is2);
203:            }
204:
205:            /**
206:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#showDayView()
207:             */
208:            public void showDayView() {
209:
210:                calendarController.setViewMode(ICalendarView.VIEW_MODE_DAY);
211:
212:                navigationController
213:                        .setSelectionMode(NavigationController.SELECTION_MODE_DAY);
214:
215:            }
216:
217:            /**
218:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#showWeekView()
219:             */
220:            public void showWeekView() {
221:                calendarController.setViewMode(ICalendarView.VIEW_MODE_WEEK);
222:
223:                navigationController
224:                        .setSelectionMode(NavigationController.SELECTION_MODE_WEEK);
225:
226:            }
227:
228:            /**
229:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#showWorkWeekView()
230:             */
231:            public void showWorkWeekView() {
232:                calendarController
233:                        .setViewMode(ICalendarView.VIEW_MODE_WORK_WEEK);
234:
235:                navigationController
236:                        .setSelectionMode(NavigationController.SELECTION_MODE_WORK_WEEK);
237:
238:            }
239:
240:            /**
241:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#showMonthView()
242:             */
243:            public void showMonthView() {
244:                calendarController.setViewMode(ICalendarView.VIEW_MODE_MONTH);
245:
246:                navigationController
247:                        .setSelectionMode(NavigationController.SELECTION_MODE_MONTH);
248:
249:            }
250:
251:            /**
252:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#getCalendarView()
253:             */
254:            public ICalendarView getCalendarView() {
255:                return calendarController;
256:            }
257:
258:            /**
259:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#getListView()
260:             */
261:            public ICalendarListView getListView() {
262:                return listController;
263:            }
264:
265:            /**
266:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#getNavigationView()
267:             */
268:            public ICalendarNavigationView getNavigationView() {
269:                return navigationController;
270:            }
271:
272:            /**
273:             * Double-click mouse listener for calendar list component.
274:             */
275:            class ListMouseListener extends MouseAdapter {
276:
277:                /**
278:                 * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent)
279:                 */
280:                public void mousePressed(MouseEvent event) {
281:                    if (event.isPopupTrigger()) {
282:                        processPopup(event);
283:                    }
284:                }
285:
286:                /**
287:                 * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
288:                 */
289:                public void mouseReleased(MouseEvent event) {
290:                    if (event.isPopupTrigger()) {
291:                        processPopup(event);
292:                    }
293:                }
294:
295:                /**
296:                 * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
297:                 */
298:                public void mouseClicked(MouseEvent event) {
299:                    // if mouse button was pressed twice times
300:                    if (event.getClickCount() == 2) {
301:
302:                    }
303:                }
304:
305:                protected void processPopup(final MouseEvent event) {
306:
307:                    listController.getPopupMenu().show(event.getComponent(),
308:                            event.getX(), event.getY());
309:
310:                }
311:            }
312:
313:            /**
314:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#fireFilterUpdated()
315:             */
316:            public void fireFilterUpdated() {
317:                calendarController.recreateFilterRows();
318:
319:            }
320:
321:            /**
322:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#fireActivityMoved(org.columba.calendar.base.api.IActivity)
323:             */
324:            public void fireActivityMoved(IActivity activity) {
325:                new ActivityMovedAction(this ).actionPerformed(null);
326:            }
327:
328:            /**
329:             * @see org.columba.calendar.ui.frame.api.ICalendarMediator#fireStartActivityEditing(org.columba.calendar.base.api.IActivity)
330:             */
331:            public void fireStartActivityEditing(IActivity activity) {
332:                new EditActivityAction(this ).actionPerformed(null);
333:            }
334:
335:            public void fireCreateActivity(IDateRange range) {
336:                new NewAppointmentAction(this , range).actionPerformed(null);
337:            }
338:
339:            /**
340:             * @see org.columba.core.gui.frame.DefaultFrameController#getString(java.lang.String,
341:             *      java.lang.String, java.lang.String)
342:             */
343:            @Override
344:            public String getString(String sPath, String sName, String sID) {
345:                return ResourceLoader.getString(sPath, sID);
346:            }
347:
348:            class MyActivitySelectionChangedListener implements 
349:                    IActivitySelectionChangedListener {
350:
351:                MyActivitySelectionChangedListener() {
352:                }
353:
354:                public void selectionChanged(
355:                        ActivitySelectionChangedEvent object) {
356:                    IActivity[] selection = object.getSelection();
357:                    if (selection == null)
358:                        return;
359:
360:                    if (selection.length == 1) {
361:
362:                        ICalendarStore store = CalendarStoreFactory
363:                                .getInstance().getLocaleStore();
364:                        IComponentInfo c = store.get(selection[0].getId());
365:
366:                        if (c.getType().equals(IComponent.TYPE.EVENT)) {
367:                            IEventInfo event = (IEventInfo) c;
368:
369:                            String summary = event.getEvent().getSummary();
370:                            String description = event.getEvent()
371:                                    .getDescription();
372:                            String location = event.getEvent().getLocation();
373:                            Calendar dtStart = event.getEvent().getDtStart();
374:                            Calendar dtEnd = event.getEvent().getDtEnd();
375:
376:                            // create empty value
377:                            IStructureValue value = getSemanticContext()
378:                                    .createValue();
379:
380:                            // create identity value
381:                            IStructureValue eventValue = value.addChild(
382:                                    ISemanticContext.CONTEXT_NODE_EVENT,
383:                                    ISemanticContext.CONTEXT_NAMESPACE_CORE);
384:
385:                            // summary
386:                            eventValue.setString(
387:                                    ISemanticContext.CONTEXT_ATTR_SUMMARY,
388:                                    ISemanticContext.CONTEXT_NAMESPACE_CORE,
389:                                    summary);
390:                            // description
391:                            eventValue.setString(
392:                                    ISemanticContext.CONTEXT_ATTR_DESCRIPTION,
393:                                    ISemanticContext.CONTEXT_NAMESPACE_CORE,
394:                                    description);
395:                            // location
396:                            eventValue.setString(
397:                                    ISemanticContext.CONTEXT_ATTR_LOCATION,
398:                                    ISemanticContext.CONTEXT_NAMESPACE_CORE,
399:                                    location);
400:
401:                            // date range
402:                            IStructureValue dateRangeValue = eventValue
403:                                    .addChild(
404:                                            ISemanticContext.CONTEXT_NODE_DATERANGE,
405:                                            ISemanticContext.CONTEXT_NAMESPACE_CORE);
406:                            dateRangeValue.setDate(
407:                                    ISemanticContext.CONTEXT_ATTR_STARTDATE,
408:                                    ISemanticContext.CONTEXT_NAMESPACE_CORE,
409:                                    dtStart.getTime());
410:                            dateRangeValue.setDate(
411:                                    ISemanticContext.CONTEXT_ATTR_ENDDATE,
412:                                    ISemanticContext.CONTEXT_NAMESPACE_CORE,
413:                                    dtEnd.getTime());
414:                        }
415:                    }
416:                }
417:
418:            }
419:
420:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.