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


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the 
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003. 
014:        //
015:        //All Rights Reserved.
016:
017:        package org.columba.core.gui.trayicon;
018:
019:        import java.io.IOException;
020:        import java.io.InputStream;
021:
022:        import javax.swing.Icon;
023:        import javax.swing.JPopupMenu;
024:
025:        import org.columba.api.gui.frame.IFrameMediator;
026:        import org.columba.core.base.OSInfo;
027:        import org.columba.core.gui.base.SelfClosingPopupMenu;
028:        import org.columba.core.gui.menu.MenuXMLDecoder;
029:        import org.columba.core.io.DiskIO;
030:        import org.columba.core.logging.Logging;
031:        import org.columba.core.resourceloader.ImageLoader;
032:        import org.columba.core.shutdown.ShutdownManager;
033:
034:        /**
035:         * Uses the JDIC api to add a tray icon to the system default tray.
036:         * 
037:         * @author Timo Stich <tstich@users.sourceforge.net>
038:         */
039:        public class ColumbaTrayIcon {
040:
041:            private IFrameMediator frameMediator;
042:
043:            /**
044:             * Default icon for the TrayIcon.
045:             */
046:            public static final Icon DEFAULT_ICON = ImageLoader
047:                    .getMiscIcon("trayicon.png");
048:
049:            private static ColumbaTrayIcon instance = new ColumbaTrayIcon();
050:
051:            private JPopupMenu menu;
052:
053:            private TrayIconInterface activeIcon;
054:
055:            protected ColumbaTrayIcon() {
056:                activeIcon = new DefaultTrayIcon();
057:
058:            }
059:
060:            /**
061:             * Gets the instance of the ColumbaTrayIcon.
062:             * 
063:             * @return singleton instance
064:             */
065:            public static ColumbaTrayIcon getInstance() {
066:                return instance;
067:            }
068:
069:            /**
070:             * Add the tray icon to the default system tray.
071:             * 
072:             */
073:            public void addToSystemTray(IFrameMediator frameMediator) {
074:
075:                initPopupMenu();
076:
077:                this .frameMediator = frameMediator;
078:                activeIcon.addToTray(DEFAULT_ICON, "Columba");
079:                activeIcon.setPopupMenu(menu);
080:
081:                ShutdownManager.getInstance().register(new Runnable() {
082:                    public void run() {
083:                        ColumbaTrayIcon.getInstance().removeFromSystemTray();
084:                    }
085:
086:                });
087:            }
088:
089:            /**
090:             * Sets the tooltip of the tray icon.
091:             * 
092:             * @param tooltip
093:             */
094:            public void setTooltip(String tooltip) {
095:                activeIcon.setTooltip(tooltip);
096:            }
097:
098:            /**
099:             * Sets the icon of the tray icon.
100:             * 
101:             * @param icon
102:             */
103:            public void setIcon(Icon icon) {
104:                activeIcon.setIcon(icon);
105:            }
106:
107:            /**
108:             * Removes the tray icon from the system tray.s
109:             */
110:            public void removeFromSystemTray() {
111:                activeIcon.removeFromTray();
112:            }
113:
114:            private void initPopupMenu() {
115:                if (menu == null) {
116:                    menu = new JPopupMenu();
117:
118:                    try {
119:                        InputStream is = DiskIO
120:                                .getResourceStream("org/columba/core/action/trayiconmenu.xml");
121:
122:                        menu = new MenuXMLDecoder(frameMediator)
123:                                .createPopupMenu(is);
124:                    } catch (IOException e) {
125:                        e.printStackTrace();
126:                    }
127:
128:                    // menu.add(new CMenuItem(new OpenNewMailWindowAction(null)));
129:                    // menu.add(new CMenuItem(new
130:                    // OpenNewAddressbookWindowAction(null)));
131:                    // menu.addSeparator();
132:                    // menu.add(new CMenuItem(new AboutDialogAction(null)));
133:                    // menu.add(new CMenuItem(new ShowHelpAction(null)));
134:                    // menu.addSeparator();
135:                    // menu.add(new CMenuItem(new ExitAction(null)));
136:
137:                    new SelfClosingPopupMenu(menu);
138:                }
139:            }
140:
141:            /**
142:             * @return Returns the activeIcon.
143:             */
144:            public TrayIconInterface getActiveIcon() {
145:                return activeIcon;
146:            }
147:
148:            /**
149:             * @param activeIcon
150:             *            The activeIcon to set.
151:             */
152:            public void initActiveIcon() {
153:                try {
154:                    if (OSInfo.isLinux()) {
155:                        activeIcon = new JDICTrayIcon();
156:                    } else if (OSInfo.isWin32Platform()) {
157:                        activeIcon = new JDICTrayIcon();
158:                    } else if (OSInfo.isMac()) {
159:                        // tray icon not supported on Mac
160:                    }
161:                } catch (Exception e) {
162:                    if (Logging.DEBUG)
163:                        e.printStackTrace();
164:
165:                    activeIcon = new DefaultTrayIcon();
166:                } catch (Error e) {
167:                    if (Logging.DEBUG)
168:                        e.printStackTrace();
169:
170:                    activeIcon = new DefaultTrayIcon();
171:                }
172:            }
173:
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.