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


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