Source Code Cross Referenced for CalendarList.java in  » Mail-Clients » columba-1.4 » org » columba » calendar » ui » box » 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.box 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.columba.calendar.ui.box;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Color;
005:        import java.awt.Component;
006:        import java.awt.Font;
007:        import java.awt.Graphics;
008:        import java.awt.Insets;
009:        import java.text.DateFormat;
010:        import java.util.Iterator;
011:        import java.util.List;
012:
013:        import javax.swing.BorderFactory;
014:        import javax.swing.DefaultListModel;
015:        import javax.swing.JLabel;
016:        import javax.swing.JList;
017:        import javax.swing.JPanel;
018:        import javax.swing.JTextField;
019:        import javax.swing.ListCellRenderer;
020:        import javax.swing.ListModel;
021:        import javax.swing.border.AbstractBorder;
022:        import javax.swing.border.Border;
023:
024:        import org.columba.calendar.model.api.IEventInfo;
025:        import org.columba.calendar.resourceloader.IconKeys;
026:        import org.columba.calendar.resourceloader.ResourceLoader;
027:        import org.jdesktop.swingx.JXList;
028:        import org.jdesktop.swingx.decorator.Highlighter;
029:        import org.jdesktop.swingx.decorator.HighlighterPipeline;
030:        import org.jdesktop.swingx.decorator.RolloverHighlighter;
031:
032:        public class CalendarList extends JXList {
033:
034:            private DefaultListModel listModel;
035:
036:            public CalendarList() {
037:                super ();
038:
039:                setCellRenderer(new MyListCellRenderer());
040:
041:                setBorder(null);
042:                setHighlighters(new HighlighterPipeline(
043:                        new Highlighter[] { new RolloverHighlighter(new Color(
044:                                248, 248, 248), Color.white) }));
045:                setRolloverEnabled(true);
046:
047:            }
048:
049:            public void addAll(List<IEventInfo> list) {
050:                Iterator<IEventInfo> it = list.iterator();
051:                while (it.hasNext()) {
052:                    addElement(it.next());
053:                }
054:            }
055:
056:            public void add(IEventInfo result) {
057:                addElement(result);
058:            }
059:
060:            /**
061:             * ********************** filtering
062:             * *********************************************
063:             */
064:
065:            /**
066:             * Associates filtering document listener to text component.
067:             */
068:
069:            public void installJTextField(JTextField input) {
070:                if (input != null) {
071:                    FilteringModel model = (FilteringModel) getModel();
072:                    input.getDocument().addDocumentListener(model);
073:                }
074:            }
075:
076:            /**
077:             * Disassociates filtering document listener from text component.
078:             */
079:
080:            public void uninstallJTextField(JTextField input) {
081:                if (input != null) {
082:                    FilteringModel model = (FilteringModel) getModel();
083:                    input.getDocument().removeDocumentListener(model);
084:                }
085:            }
086:
087:            /**
088:             * Doesn't let model change to non-filtering variety
089:             */
090:
091:            public void setModel(ListModel model) {
092:                if (!(model instanceof  FilteringModel)) {
093:                    throw new IllegalArgumentException();
094:                } else {
095:                    super .setModel(model);
096:                }
097:            }
098:
099:            /**
100:             * Adds item to model of list
101:             */
102:            public void addElement(IEventInfo element) {
103:                ((FilteringModel) getModel()).addElement(element);
104:            }
105:
106:            class MyListCellRenderer extends JPanel implements  ListCellRenderer {
107:
108:                private JLabel iconLabel = new JLabel();
109:
110:                private JLabel titleLabel = new JLabel();
111:
112:                private JLabel descriptionLabel = new JLabel();
113:
114:                private JPanel centerPanel;
115:
116:                private JLabel startDateLabel = new JLabel();
117:
118:                private Border lineBorder = new HeaderSeparatorBorder(
119:                        new Color(230, 230, 230));
120:
121:                private DateFormat df = DateFormat.getDateTimeInstance();
122:
123:                MyListCellRenderer() {
124:                    setLayout(new BorderLayout());
125:
126:                    centerPanel = new JPanel();
127:                    centerPanel.setLayout(new BorderLayout());
128:
129:                    JPanel titlePanel = new JPanel();
130:                    titlePanel.setLayout(new BorderLayout());
131:                    titlePanel.add(titleLabel, BorderLayout.WEST);
132:                    titlePanel.add(startDateLabel, BorderLayout.EAST);
133:
134:                    centerPanel.add(titlePanel, BorderLayout.NORTH);
135:                    centerPanel.add(descriptionLabel, BorderLayout.CENTER);
136:                    centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0,
137:                            0, 2));
138:                    add(iconLabel, BorderLayout.WEST);
139:                    add(centerPanel, BorderLayout.CENTER);
140:
141:                    descriptionLabel.setFont(descriptionLabel.getFont()
142:                            .deriveFont(Font.ITALIC));
143:
144:                    setBorder(BorderFactory.createCompoundBorder(lineBorder,
145:                            BorderFactory.createEmptyBorder(2, 2, 2, 2)));
146:                    iconLabel.setBorder(BorderFactory.createEmptyBorder(2, 4,
147:                            2, 8));
148:
149:                    centerPanel.setOpaque(false);
150:                    titlePanel.setOpaque(false);
151:                    setOpaque(true);
152:
153:                }
154:
155:                public Component getListCellRendererComponent(JList list,
156:                        Object value, int index, boolean isSelected,
157:                        boolean cellHasFocus) {
158:
159:                    if (isSelected) {
160:                        setBackground(list.getSelectionBackground());
161:                        setForeground(list.getSelectionForeground());
162:                    } else {
163:                        setBackground(list.getBackground());
164:                        setForeground(list.getForeground());
165:                    }
166:
167:                    IEventInfo result = (IEventInfo) value;
168:
169:                    titleLabel.setText(result.getEvent().getSummary());
170:                    iconLabel.setIcon(ResourceLoader
171:                            .getSmallIcon(IconKeys.NEW_APPOINTMENT));
172:                    if (result.getEvent().getLocation() != null
173:                            && result.getEvent().getLocation().length() > 0)
174:                        descriptionLabel.setText(result.getEvent()
175:                                .getLocation());
176:                    else
177:                        descriptionLabel.setText("no Location specified");
178:
179:                    startDateLabel.setText(df.format(result.getEvent()
180:                            .getDtStart().getTime()));
181:                    return this ;
182:                }
183:
184:            }
185:
186:            class HeaderSeparatorBorder extends AbstractBorder {
187:
188:                protected Color color;
189:
190:                public HeaderSeparatorBorder(Color color) {
191:                    super ();
192:
193:                    this .color = color;
194:                }
195:
196:                /**
197:                 * Paints the border for the specified component with the specified
198:                 * position and size.
199:                 * 
200:                 * @param c
201:                 *            the component for which this border is being painted
202:                 * @param g
203:                 *            the paint graphics
204:                 * @param x
205:                 *            the x position of the painted border
206:                 * @param y
207:                 *            the y position of the painted border
208:                 * @param width
209:                 *            the width of the painted border
210:                 * @param height
211:                 *            the height of the painted border
212:                 */
213:                public void paintBorder(Component c, Graphics g, int x, int y,
214:                        int width, int height) {
215:                    Color oldColor = g.getColor();
216:                    g.setColor(color);
217:                    g
218:                            .drawLine(x, y + height - 1, x + width - 1, y
219:                                    + height - 1);
220:
221:                    g.setColor(oldColor);
222:                }
223:
224:                /**
225:                 * Returns the insets of the border.
226:                 * 
227:                 * @param c
228:                 *            the component for which this border insets value applies
229:                 */
230:                public Insets getBorderInsets(Component c) {
231:                    return new Insets(0, 0, 1, 0);
232:                }
233:
234:                /**
235:                 * Reinitialize the insets parameter with this Border's current Insets.
236:                 * 
237:                 * @param c
238:                 *            the component for which this border insets value applies
239:                 * @param insets
240:                 *            the object to be reinitialized
241:                 */
242:                public Insets getBorderInsets(Component c, Insets insets) {
243:                    insets.left = insets.top = insets.right = insets.bottom = 1;
244:                    return insets;
245:                }
246:
247:            }
248:
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.