Source Code Cross Referenced for QuickLaunch.java in  » Groupware » lucane » org » lucane » applications » quicklaunch » 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 » Groupware » lucane » org.lucane.applications.quicklaunch 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Lucane - a collaborative platform
003:         * Copyright (C) 2004  Vincent Fiack <vfiack@mail15.com>
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:        package org.lucane.applications.quicklaunch;
020:
021:        import org.lucane.client.*;
022:        import org.lucane.client.widgets.*;
023:        import org.lucane.common.*;
024:
025:        import java.awt.*;
026:        import java.awt.event.*;
027:        import java.util.*;
028:
029:        import javax.swing.*;
030:
031:        public class QuickLaunch extends StandalonePlugin implements 
032:                ActionListener, MouseListener {
033:            private static final String MAIN_INTERFACE = "org.lucane.applications.maininterface";
034:
035:            private TrayIcon trayIcon;
036:
037:            /**
038:             * Void contructor. Used by PluginManager
039:             */
040:            public QuickLaunch() {
041:            }
042:
043:            /**
044:             * @param friends the Client the Plugin belongs to
045:             * @param starter is true if the Clients started the plugin (start() will be
046:             *        called instead of follow()
047:             * @return a new instance of the Plugin.
048:             */
049:            public Plugin newInstance(ConnectInfo[] friends) {
050:                QuickLaunch self = new QuickLaunch();
051:
052:                try {
053:                    self.trayIcon = new TrayIcon(
054:                            this .getImageIcon(getIcon16()), Client
055:                                    .getInstance().getMyInfos().getName()
056:                                    + " - Lucane Groupware");
057:                } catch (Throwable t) {
058:                    self.trayIcon = null;
059:                }
060:
061:                return self;
062:            }
063:
064:            /**
065:             * Show a dialog asking for the friend name
066:             */
067:            public void start() {
068:                if (this .trayIcon == null) {
069:                    //no user message if we aren't on windows
070:                    if (System.getProperty("os.name").startsWith("Win"))
071:                        DialogBox.error(tr("err.noTray"));
072:                    else
073:                        Logging
074:                                .getLogger()
075:                                .info(
076:                                        "Not on windows, running MainInterface instead of QuickLaunch");
077:
078:                    PluginManager.getInstance().run(MAIN_INTERFACE,
079:                            new ConnectInfo[0]);
080:                    Client.getInstance().setStartupPlugin(MAIN_INTERFACE);
081:                    return;
082:                }
083:
084:                addMenuToTray();
085:
086:                this .trayIcon.addMouseListener(this );
087:                this .trayIcon.setVisible(true);
088:
089:                //show the message only once
090:                if (getLocalConfig().getInt("show-popup", 1) != 0) {
091:                    this .trayIcon.showInfo(tr("lucane.is.ready"),
092:                            "Lucane Groupware");
093:                    getLocalConfig().set("show-popup", 0);
094:                }
095:            }
096:
097:            public void actionPerformed(ActionEvent ae) {
098:                if (ae.getSource() instanceof  JMenuItem) {
099:                    JMenuItem src = (JMenuItem) ae.getSource();
100:
101:                    if (src.getName().equals("exit")) {
102:                        cleanExit();
103:                        return;
104:                    }
105:
106:                    if (src.getName().equals(MAIN_INTERFACE))
107:                        showMainInterface();
108:                    else
109:                        runPlugin(src.getName());
110:                } else
111:                    showMainInterface();
112:            }
113:
114:            public void mouseClicked(MouseEvent e) {
115:            }
116:
117:            public void mouseEntered(MouseEvent e) {
118:            }
119:
120:            public void mouseExited(MouseEvent e) {
121:            }
122:
123:            public void mouseReleased(MouseEvent e) {
124:            }
125:
126:            public void mousePressed(MouseEvent e) {
127:                if (e.getClickCount() == 2)
128:                    showMainInterface();
129:            }
130:
131:            private void addMenuToTray() {
132:                HashMap categories = new HashMap();
133:
134:                //create menu list	
135:                Iterator plugins = PluginManager.getInstance()
136:                        .getAvailablePlugins();
137:                plugins = PluginComparator.sortPlugins(plugins);
138:
139:                while (plugins.hasNext()) {
140:                    Plugin p = (Plugin) plugins.next();
141:
142:                    JMenu category = (JMenu) categories.get(p.getCategory());
143:                    if (category == null) {
144:                        category = new JMenu(p.getCategory());
145:                        categories.put(p.getCategory(), category);
146:
147:                        //copy menu to real one
148:                        if (!p.getCategory().equals("Invisible"))
149:                            this .trayIcon.add(category);
150:                    }
151:
152:                    ImageIcon icon = new ImageIcon();
153:                    try {
154:                        icon = p.getImageIcon(p.getIcon());
155:                        icon = new ImageIcon(icon.getImage().getScaledInstance(
156:                                16, 16, Image.SCALE_SMOOTH));
157:                    } catch (Exception e) {
158:                        //error at icon loading
159:                    }
160:
161:                    JMenuItem menu = new JMenuItem(p.getTitle(), icon);
162:                    menu.setName(p.getName());
163:                    menu.setToolTipText(p.getToolTip());
164:                    menu.addActionListener(this );
165:                    category.add(menu);
166:                }
167:
168:                this .trayIcon.addSeparator();
169:
170:                //windows
171:                this .trayIcon.add(new WindowMenu(this ));
172:
173:                //open main interface
174:                JMenuItem menu = new JMenuItem(tr("open"));
175:                menu.setName("org.lucane.applications.maininterface");
176:                menu.addActionListener(this );
177:                this .trayIcon.add(menu);
178:
179:                //exit
180:                menu = new JMenuItem(tr("exit"));
181:                menu.setName("exit");
182:                menu.addActionListener(this );
183:                this .trayIcon.add(menu);
184:            }
185:
186:            private void runPlugin(String pluginName) {
187:                ConnectInfo[] friends = null;
188:                Plugin plugin = PluginManager.getInstance().getPlugin(
189:                        pluginName);
190:
191:                // get users
192:                if (plugin.isStandalone())
193:                    friends = new ConnectInfo[0];
194:                else {
195:                    ListBox userList = new ListBox(null, plugin.getTitle(),
196:                            tr("msg.selectUsers"), Client.getInstance()
197:                                    .getUserList());
198:                    Object[] users = userList.selectItems();
199:                    if (users != null) {
200:                        friends = new ConnectInfo[users.length];
201:                        for (int i = 0; i < friends.length; i++)
202:                            friends[i] = Communicator.getInstance()
203:                                    .getConnectInfo((String) users[i]);
204:                    }
205:                }
206:
207:                // run the plugin if the user didn't click on cancel
208:                if (friends != null)
209:                    PluginManager.getInstance().run(pluginName, friends);
210:            }
211:
212:            private boolean activatePlugin(String pluginName) {
213:                boolean activated = false;
214:
215:                Iterator plugins = PluginManager.getInstance()
216:                        .getRunningPlugins();
217:                while (plugins.hasNext()) {
218:                    Plugin plugin = (Plugin) plugins.next();
219:                    if (!plugin.getName().equals(pluginName))
220:                        continue;
221:
222:                    Iterator windows = Client.getInstance().getWindowManager()
223:                            .getWindowsFor(plugin);
224:                    if (!windows.hasNext())
225:                        continue;
226:
227:                    while (windows.hasNext()) {
228:                        ManagedWindow window = (ManagedWindow) windows.next();
229:                        window.show();
230:                    }
231:                    activated = true;
232:                }
233:
234:                return activated;
235:            }
236:
237:            private void showMainInterface() {
238:                if (!activatePlugin(MAIN_INTERFACE))
239:                    runPlugin(MAIN_INTERFACE);
240:            }
241:
242:            private void cleanExit() {
243:                Logging.getLogger().finer("QuickLaunch::cleanExit()");
244:                this .trayIcon.setVisible(false);
245:                exit();
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.