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


001:        package org.columba.core.gui.context;
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.awt.event.ActionEvent;
010:        import java.awt.event.ActionListener;
011:
012:        import javax.swing.Action;
013:        import javax.swing.BorderFactory;
014:        import javax.swing.JLabel;
015:        import javax.swing.JPanel;
016:        import javax.swing.UIManager;
017:        import javax.swing.border.Border;
018:        import javax.swing.border.CompoundBorder;
019:
020:        import org.columba.api.gui.frame.IFrameMediator;
021:        import org.columba.core.context.ContextResultListenerAdapter;
022:        import org.columba.core.context.api.IContextProvider;
023:        import org.columba.core.context.api.IContextResultEvent;
024:        import org.columba.core.context.api.IContextSearchManager;
025:        import org.jdesktop.swingx.JXCollapsiblePane;
026:        import org.jdesktop.swingx.JXHyperlink;
027:
028:        public class ContextResultBox extends JPanel {
029:
030:            private final static Color borderColor2 = UIManager
031:                    .getColor("controlShadow");
032:
033:            private final static Color borderColor1 = UIManager
034:                    .getColor("controlHighlight");
035:
036:            private JXHyperlink link;
037:
038:            private JXHyperlink moreLink;
039:
040:            private JXCollapsiblePane collapsible;
041:
042:            private IContextProvider provider;
043:
044:            private IContextSearchManager contextSearchManager;
045:
046:            public ContextResultBox(final IFrameMediator frameMediator,
047:                    final IContextProvider provider,
048:                    final IContextSearchManager contextSearchManager) {
049:                super ();
050:
051:                this .provider = provider;
052:                this .contextSearchManager = contextSearchManager;
053:
054:                // get notified if search result arrived, to update view
055:                this .contextSearchManager
056:                        .addResultListener(new MyContextResultListener());
057:
058:                collapsible = new JXCollapsiblePane();
059:                // collapsible.getContentPane().setBackground(Color.WHITE);
060:                collapsible.add(provider.getView());
061:                collapsible.setCollapsed(true);
062:
063:                Action toggleAction = collapsible.getActionMap().get(
064:                        JXCollapsiblePane.TOGGLE_ACTION);
065:                // use the collapse/expand icons from the JTree UI
066:                toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON,
067:                        UIManager.getIcon("Tree.expandedIcon"));
068:                toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager
069:                        .getIcon("Tree.collapsedIcon"));
070:                link = new JXHyperlink(toggleAction);
071:                link.setText(provider.getName());
072:                link.setToolTipText(provider.getDescription());
073:
074:                // link.setFont(link.getFont().deriveFont(Font.BOLD));
075:                link.setOpaque(true);
076:                // link.setBackground(titleBackground);
077:                link.setFocusPainted(false);
078:
079:                link.setUnclickedColor(UIManager.getColor("Label.foreground"));
080:                link.setClickedColor(UIManager.getColor("Label.foreground"));
081:
082:                moreLink = new JXHyperlink();
083:                moreLink.setEnabled(false);
084:                moreLink.setText("Show More ..");
085:                Font font = UIManager.getFont("Label.font");
086:                Font smallFont = new Font(font.getName(), font.getStyle(), font
087:                        .getSize() - 2);
088:                moreLink.setFont(smallFont);
089:                moreLink.addActionListener(new ActionListener() {
090:                    public void actionPerformed(ActionEvent e) {
091:                        provider.showMoreResults(frameMediator);
092:                    }
093:                });
094:
095:                setLayout(new BorderLayout());
096:                JPanel top = new JPanel();
097:
098:                top.setBorder(new CompoundBorder(new SeparatorBorder(),
099:                        BorderFactory.createEmptyBorder(2, 4, 2, 4)));
100:
101:                top.setLayout(new BorderLayout());
102:                JLabel iconLabel = new JLabel();
103:
104:                iconLabel.setIcon(provider.getIcon());
105:
106:                iconLabel
107:                        .setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 6));
108:                top.add(iconLabel, BorderLayout.WEST);
109:                top.add(link, BorderLayout.CENTER);
110:                top.add(moreLink, BorderLayout.EAST);
111:                add(top, BorderLayout.NORTH);
112:                add(collapsible, BorderLayout.CENTER);
113:            }
114:
115:            public void showResults() {
116:
117:                if (provider.isEnabledShowMoreLink()) {
118:                    int count = provider.getTotalResultCount();
119:                    moreLink.setEnabled(count > 0);
120:
121:                    if (count > 0) {
122:                        moreLink.setText("Show More (" + count + ") ..");
123:                    }
124:                }
125:            }
126:
127:            class MyContextResultListener extends ContextResultListenerAdapter {
128:
129:                @Override
130:                public void resultArrived(final IContextResultEvent event) {
131:                    if (!event.getProviderName().equals(
132:                            provider.getTechnicalName()))
133:                        return;
134:
135:                    provider.showResult();
136:                    showResults();
137:
138:                }
139:
140:            }
141:
142:            /**
143:             * The border between the stack components. It separates each component with
144:             * a fine line border.
145:             */
146:            class SeparatorBorder implements  Border {
147:
148:                boolean isFirst(Component c) {
149:                    return c.getParent() == null
150:                            || c.getParent().getComponent(0) == c;
151:                }
152:
153:                public Insets getBorderInsets(Component c) {
154:                    // if the collapsible is collapsed, we do not want its border to be
155:                    // painted.
156:                    if (c instanceof  JXCollapsiblePane) {
157:                        if (((JXCollapsiblePane) c).isCollapsed()) {
158:                            return new Insets(0, 0, 0, 0);
159:                        }
160:                    }
161:                    return new Insets(isFirst(c) ? 4 : 1, 0, 1, 0);
162:                }
163:
164:                public boolean isBorderOpaque() {
165:                    return true;
166:                }
167:
168:                public void paintBorder(Component c, Graphics g, int x, int y,
169:                        int width, int height) {
170:                    g.setColor(borderColor1);
171:                    if (isFirst(c)) {
172:                        g.drawLine(x, y + 2, x + width, y + 2);
173:                    }
174:                    //			g.setColor(borderColor2);
175:                    //			g.drawLine(x, y + height - 1, x + width, y + height - 1);
176:                }
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.