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


001:        // The contents of this file are subject to the Mozilla Public License Version
002:        // 1.1
003:        //(the "License"); you may not use this file except in compliance with the
004:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005:        //
006:        //Software distributed under the License is distributed on an "AS IS" basis,
007:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008:        //for the specific language governing rights and
009:        //limitations under the License.
010:        //
011:        //The Original Code is "The Columba Project"
012:        //
013:        //The Initial Developers of the Original Code are Frederik Dietz and Timo
014:        // Stich.
015:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016:        //
017:        //All Rights Reserved.
018:        package org.columba.chat.ui.presence;
019:
020:        import java.awt.BorderLayout;
021:        import java.awt.Component;
022:        import java.awt.event.ItemEvent;
023:        import java.awt.event.ItemListener;
024:
025:        import javax.swing.BorderFactory;
026:        import javax.swing.ImageIcon;
027:        import javax.swing.JComboBox;
028:        import javax.swing.JComponent;
029:        import javax.swing.JLabel;
030:        import javax.swing.JList;
031:        import javax.swing.JPanel;
032:        import javax.swing.ListCellRenderer;
033:        import javax.swing.UIManager;
034:
035:        import org.columba.api.statusbar.IStatusBarExtension;
036:        import org.columba.chat.MainInterface;
037:        import org.columba.chat.command.ChangePresenceCommand;
038:        import org.columba.chat.command.ChatCommandReference;
039:        import org.columba.chat.conn.api.ConnectionChangedEvent;
040:        import org.columba.chat.conn.api.IConnectionChangedListener;
041:        import org.columba.chat.conn.api.IConnection.STATUS;
042:        import org.columba.chat.resourceloader.ResourceLoader;
043:        import org.columba.chat.ui.frame.api.IChatFrameMediator;
044:        import org.columba.chat.ui.presence.api.IPresenceController;
045:        import org.columba.core.command.CommandProcessor;
046:        import org.jivesoftware.smack.packet.Presence;
047:
048:        /**
049:         * @author fdietz
050:         * 
051:         */
052:        public class PresenceComboBox extends JPanel implements  ItemListener,
053:                IPresenceController, IStatusBarExtension,
054:                IConnectionChangedListener {
055:
056:            private JLabel label;
057:
058:            private JComboBox comboBox;
059:
060:            private ImageIcon available = ResourceLoader
061:                    .getMiscIcon("online.png");
062:
063:            private ImageIcon extendedaway = ResourceLoader
064:                    .getMiscIcon("extended_away.png");
065:
066:            private ImageIcon away = ResourceLoader.getMiscIcon("away.png");
067:
068:            private ImageIcon busy = ResourceLoader
069:                    .getMiscIcon("unavailable.png");
070:
071:            private ImageIcon offline = ResourceLoader
072:                    .getMiscIcon("offline.png");
073:
074:            private IChatFrameMediator mediator;
075:
076:            public PresenceComboBox(IChatFrameMediator mediator) {
077:                super ();
078:
079:                this .mediator = mediator;
080:
081:                setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
082:
083:                setBackground(UIManager.getColor("Tree.background"));
084:
085:                comboBox = new JComboBox();
086:                // comboBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
087:                comboBox.addItem("Available");
088:                comboBox.addItem("Busy");
089:                comboBox.addItem("Away");
090:                comboBox.addItem("Extended  Aways");
091:                // checkBox.addItem("Custom Message...", null);
092:                // checkBox.addItem("Leave...");
093:
094:                comboBox.setRenderer(new ItemRenderer());
095:
096:                label = new JLabel();
097:                label.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
098:                label.setIcon(offline);
099:
100:                setLayout(new BorderLayout());
101:
102:                add(label, BorderLayout.WEST);
103:
104:                add(comboBox, BorderLayout.CENTER);
105:
106:                comboBox.addItemListener(this );
107:
108:                setEnabled(false);
109:                comboBox.setEnabled(false);
110:                label.setEnabled(false);
111:
112:                MainInterface.connection.addConnectionChangedListener(this );
113:            }
114:
115:            // private void addStatus(String tooltip, ImageIcon icon) {
116:            // JLabel label = new JLabel(icon);
117:            // label.setToolTipText(tooltip);
118:            //
119:            // comboBox.addItem(tooltip);
120:            // }
121:
122:            public void addItemListener(ItemListener l) {
123:                comboBox.addItemListener(l);
124:            }
125:
126:            /**
127:             * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
128:             */
129:            public void itemStateChanged(ItemEvent e) {
130:                Object source = e.getItemSelectable();
131:
132:                int index = ((JComboBox) source).getSelectedIndex();
133:
134:                Presence p = null;
135:                switch (index) {
136:                case 0: {
137:                    label.setIcon(available);
138:                    p = new Presence(Presence.Type.AVAILABLE);
139:                    p.setStatus("Available");
140:                    CommandProcessor.getInstance().addOp(
141:                            new ChangePresenceCommand(mediator,
142:                                    new ChatCommandReference(p)));
143:                    break;
144:                }
145:                case 1: {
146:                    label.setIcon(busy);
147:                    p = new Presence(Presence.Type.UNAVAILABLE);
148:                    p.setStatus("Busy");
149:                    CommandProcessor.getInstance().addOp(
150:                            new ChangePresenceCommand(mediator,
151:                                    new ChatCommandReference(p)));
152:
153:                    break;
154:                }
155:                case 2: {
156:                    label.setIcon(away);
157:                    p = new Presence(Presence.Type.UNAVAILABLE);
158:                    p.setStatus("Away");
159:                    CommandProcessor.getInstance().addOp(
160:                            new ChangePresenceCommand(mediator,
161:                                    new ChatCommandReference(p)));
162:
163:                    break;
164:                }
165:                case 3: {
166:                    label.setIcon(extendedaway);
167:                    p = new Presence(Presence.Type.UNAVAILABLE);
168:                    p.setStatus("Extended Away");
169:                    CommandProcessor.getInstance().addOp(
170:                            new ChangePresenceCommand(mediator,
171:                                    new ChatCommandReference(p)));
172:
173:                    break;
174:                }
175:                }
176:
177:            }
178:
179:            public JComponent getView() {
180:                return this ;
181:            }
182:
183:            public class ItemRenderer extends JLabel implements 
184:                    ListCellRenderer {
185:
186:                public ItemRenderer() {
187:                    /*
188:                     * setIconTextGap(5); setVerticalAlignment(JLabel.CENTER);
189:                     */
190:                }
191:
192:                /** {@inheritDoc} */
193:                public Component getListCellRendererComponent(JList list,
194:                        Object value, int index, boolean isSelected,
195:                        boolean cellHasFocus) {
196:
197:                    setText((String) value);
198:
199:                    return this ;
200:                }
201:            }
202:
203:            /**
204:             * @see org.columba.chat.conn.api.IConnectionChangedListener#connectionChanged(org.columba.chat.conn.api.ConnectionChangedEvent)
205:             */
206:            public void connectionChanged(ConnectionChangedEvent object) {
207:                // IAccount account = object.getAccount();
208:                STATUS status = object.getStatus();
209:
210:                if (status == STATUS.ONLINE) {
211:                    setEnabled(true);
212:                    comboBox.setEnabled(true);
213:                    label.setEnabled(true);
214:                } else if (status == STATUS.OFFLINE) {
215:                    setEnabled(false);
216:                    comboBox.setEnabled(false);
217:                    label.setEnabled(false);
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.