Source Code Cross Referenced for CalendarListController.java in  » Mail-Clients » columba-1.4 » org » columba » calendar » ui » list » 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.list 
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.list;
019:
020:        import java.awt.Color;
021:        import java.awt.event.MouseAdapter;
022:        import java.awt.event.MouseEvent;
023:        import java.io.InputStream;
024:        import java.util.Enumeration;
025:
026:        import javax.swing.DefaultListSelectionModel;
027:        import javax.swing.JComponent;
028:        import javax.swing.JPopupMenu;
029:        import javax.swing.event.EventListenerList;
030:        import javax.swing.event.ListSelectionEvent;
031:        import javax.swing.event.ListSelectionListener;
032:
033:        import org.columba.calendar.base.api.ICalendarItem;
034:        import org.columba.calendar.config.Config;
035:        import org.columba.calendar.config.api.ICalendarList;
036:        import org.columba.calendar.ui.frame.api.ICalendarMediator;
037:        import org.columba.calendar.ui.list.api.CalendarSelectionChangedEvent;
038:        import org.columba.calendar.ui.list.api.ICalendarListView;
039:        import org.columba.calendar.ui.list.api.ICalendarSelectionChangedListener;
040:        import org.columba.core.gui.menu.ExtendablePopupMenu;
041:        import org.columba.core.gui.menu.MenuXMLDecoder;
042:
043:        import com.miginfocom.ashape.AShapeUtil;
044:        import com.miginfocom.ashape.shapes.AShape;
045:        import com.miginfocom.calendar.category.Category;
046:        import com.miginfocom.calendar.category.CategoryDepository;
047:        import com.miginfocom.util.gfx.GfxUtil;
048:
049:        /**
050:         * CalendarListController class
051:         * @author fdietz
052:         * 
053:         */
054:        public class CalendarListController implements  ICalendarListView,
055:                ListSelectionListener {
056:
057:            private CheckableList list;
058:
059:            public static final String PROP_FILTERED = "filterRow";
060:
061:            private ICalendarMediator frameMediator;
062:
063:            private CheckableItemListTableModel model;
064:
065:            private ICalendarItem selection;
066:
067:            private Category localCategory;
068:
069:            private Category webCategory;
070:
071:            private EventListenerList listenerList = new EventListenerList();
072:
073:            private ExtendablePopupMenu menu;
074:
075:            public CalendarListController(ICalendarMediator frameMediator) {
076:                super ();
077:
078:                this .frameMediator = frameMediator;
079:
080:                model = new CheckableItemListTableModel();
081:                list = new CheckableList();
082:                list.setModel(model);
083:                list.getSelectionModel().addListSelectionListener(this );
084:
085:                // create default root nodes <Local> and <Web>
086:                Category rootCategory = CategoryDepository.getRoot();
087:
088:                localCategory = rootCategory.addSubCategory("local", "Local");
089:                webCategory = rootCategory.addSubCategory("web", "Web");
090:
091:                loadCalendarPreferences();
092:
093:                list.addMouseListener(new MyMouseListener());
094:            }
095:
096:            /**
097:             * Get popup menu
098:             * 
099:             * @return popup menu
100:             */
101:            public JPopupMenu getPopupMenu() {
102:                return menu;
103:            }
104:
105:            /**
106:             * create the PopupMenu
107:             */
108:            public void createPopupMenu(ICalendarMediator mediator) {
109:
110:                InputStream is = this .getClass().getResourceAsStream(
111:                        "/org/columba/calendar/action/contextmenu_list.xml");
112:
113:                menu = new MenuXMLDecoder(mediator).createPopupMenu(is);
114:
115:            }
116:
117:            /* (non-Javadoc)
118:             * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
119:             */
120:            public void valueChanged(ListSelectionEvent e) {
121:                if (e.getValueIsAdjusting()) {
122:                    return;
123:                }
124:
125:                DefaultListSelectionModel theList = (DefaultListSelectionModel) e
126:                        .getSource();
127:                if (!theList.isSelectionEmpty()) {
128:                    int index = theList.getAnchorSelectionIndex();
129:
130:                    selection = (ICalendarItem) ((CheckableItemListTableModel) list
131:                            .getModel()).getElement(index);
132:
133:                    fireSelectionChanged(selection);
134:
135:                } else {
136:                    fireSelectionChanged(null);
137:                }
138:            }
139:
140:            /**
141:             * 
142:             */
143:            private void loadCalendarPreferences() {
144:                ICalendarList list = Config.getInstance().getCalendarList();
145:                Enumeration<ICalendarItem> e = list.getElements();
146:                while (e.hasMoreElements()) {
147:                    ICalendarItem item = e.nextElement();
148:
149:                    Category category = createCalendar(item.getId(), item
150:                            .getName(), item.getColor().getRGB(), item
151:                            .getType());
152:
153:                    // if (calendarId.equals("work"))
154:                    // category.setPropertyDeep(Category.PROP_IS_HIDDEN, Boolean
155:                    // .valueOf(false), Boolean.TRUE);
156:                    // else
157:                    // category.setPropertyDeep(Category.PROP_IS_HIDDEN, Boolean
158:                    // .valueOf(true), Boolean.TRUE);
159:
160:                    // category filtering is disabled as default
161:                    category.setPropertyDeep(Category.PROP_IS_HIDDEN, Boolean
162:                            .valueOf(true), Boolean.TRUE);
163:
164:                    // calendar is selected as default
165:                    item.setSelected(true);
166:
167:                    model.addElement(item);
168:
169:                }
170:
171:            }
172:
173:            /**
174:             * @param calendarId
175:             * @param name
176:             * @param colorInt
177:             * @param type
178:             */
179:            public Category createCalendar(String calendarId, String name,
180:                    int colorInt, ICalendarItem.TYPE type) {
181:
182:                Category calendar = null;
183:                if (type == ICalendarItem.TYPE.LOCAL)
184:                    calendar = localCategory.addSubCategory(calendarId, name);
185:                else if (type == ICalendarItem.TYPE.WEB)
186:                    calendar = webCategory.addSubCategory(calendarId, name);
187:
188:                String bgName = AShapeUtil.DEFAULT_BACKGROUND_SHAPE_NAME;
189:                String outlineName = AShapeUtil.DEFAULT_OUTLINE_SHAPE_NAME;
190:                String titleName = AShapeUtil.DEFAULT_TITLE_TEXT_SHAPE_NAME;
191:                String textName = AShapeUtil.DEFAULT_MAIN_TEXT_SHAPE_NAME;
192:
193:                Color color = new Color(colorInt);
194:                Color outlineColor = GfxUtil.tintColor(color, -0.4f);
195:
196:                CategoryDepository.setOverride(calendarId, bgName,
197:                        AShape.A_PAINT, GfxUtil.alphaColor(color, 145));
198:                CategoryDepository.setOverride(calendarId, outlineName,
199:                        AShape.A_PAINT, outlineColor);
200:                CategoryDepository.setOverride(calendarId, titleName,
201:                        AShape.A_PAINT, outlineColor);
202:                CategoryDepository.setOverride(calendarId, textName,
203:                        AShape.A_PAINT, outlineColor);
204:
205:                return calendar;
206:            }
207:
208:            /* (non-Javadoc)
209:             * @see org.columba.calendar.ui.list.api.ICalendarListView#getView()
210:             */
211:            public JComponent getView() {
212:                return list;
213:            }
214:
215:            class MyMouseListener extends MouseAdapter {
216:
217:                MyMouseListener() {
218:
219:                }
220:
221:                /**
222:                 * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
223:                 */
224:                @Override
225:                public void mouseClicked(MouseEvent e) {
226:                    handleEvent(e);
227:                }
228:
229:                /**
230:                 * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent)
231:                 */
232:                @Override
233:                public void mousePressed(MouseEvent e) {
234:                    handleEvent(e);
235:                }
236:
237:                /**
238:                 * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
239:                 */
240:                @Override
241:                public void mouseReleased(MouseEvent e) {
242:                    handleEvent(e);
243:                }
244:
245:                /**
246:                 * @param e
247:                 */
248:                private void handleEvent(MouseEvent e) {
249:                    CheckableItemListTableModel model = (CheckableItemListTableModel) list
250:                            .getModel();
251:
252:                    int count = model.getRowCount();
253:                    for (int i = 0; i < count; i++) {
254:                        ICalendarItem item = (ICalendarItem) model
255:                                .getElement(i);
256:                        String calendarId = item.getId();
257:                        boolean selected = item.isSelected();
258:
259:                        Category category = CategoryDepository
260:                                .getCategory(calendarId);
261:                        if (category == null)
262:                            continue;
263:
264:                        category.setPropertyDeep(Category.PROP_IS_HIDDEN,
265:                                Boolean.valueOf(!selected), Boolean.TRUE);
266:
267:                    }
268:
269:                    frameMediator.fireFilterUpdated();
270:
271:                }
272:            }
273:
274:            /* (non-Javadoc)
275:             * @see org.columba.calendar.ui.list.api.ICalendarListView#getSelected()
276:             */
277:            public ICalendarItem getSelected() {
278:                if (selection == null)
279:                    return null;
280:
281:                return selection;
282:            }
283:
284:            /**
285:             * Adds a listener.
286:             */
287:            public void addSelectionChangedListener(
288:                    ICalendarSelectionChangedListener listener) {
289:                listenerList.add(ICalendarSelectionChangedListener.class,
290:                        listener);
291:            }
292:
293:            /**
294:             * Removes a previously registered listener.
295:             */
296:            public void removeSelectionChangedListener(
297:                    ICalendarSelectionChangedListener listener) {
298:                listenerList.remove(ICalendarSelectionChangedListener.class,
299:                        listener);
300:            }
301:
302:            /**
303:             * Propagates an event to all registered listeners notifying them that this
304:             * folder has been renamed.
305:             */
306:            public void fireSelectionChanged(ICalendarItem selection) {
307:                CalendarSelectionChangedEvent e = new CalendarSelectionChangedEvent(
308:                        this , selection);
309:                // Guaranteed to return a non-null array
310:                Object[] listeners = listenerList.getListenerList();
311:
312:                // Process the listeners last to first, notifying
313:                // those that are interested in this event
314:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
315:                    if (listeners[i] == ICalendarSelectionChangedListener.class) {
316:                        ((ICalendarSelectionChangedListener) listeners[i + 1])
317:                                .selectionChanged(e);
318:                    }
319:                }
320:            }
321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.