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


001:        package org.columba.mail.gui.composer;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Color;
005:        import java.awt.Font;
006:        import java.awt.event.ActionEvent;
007:        import java.awt.event.ActionListener;
008:        import java.awt.event.ItemEvent;
009:        import java.awt.event.ItemListener;
010:        import java.awt.event.MouseEvent;
011:        import java.awt.event.MouseListener;
012:        import java.io.BufferedReader;
013:        import java.io.File;
014:        import java.io.FileReader;
015:        import java.io.IOException;
016:        import java.util.Observable;
017:        import java.util.Observer;
018:
019:        import javax.swing.BorderFactory;
020:        import javax.swing.JButton;
021:        import javax.swing.JPanel;
022:        import javax.swing.JTextArea;
023:        import javax.swing.UIManager;
024:        import javax.swing.text.JTextComponent;
025:
026:        import org.columba.core.config.Config;
027:        import org.columba.core.gui.base.RoundedBorder;
028:        import org.columba.core.gui.util.FontProperties;
029:        import org.columba.core.xml.XmlElement;
030:        import org.columba.mail.config.AccountItem;
031:        import org.columba.mail.gui.config.account.EditSignatureAction;
032:
033:        public class SignatureView extends JPanel implements  MouseListener,
034:                ItemListener, Observer {
035:
036:            private ComposerController controller;
037:
038:            private AccountItem item;
039:
040:            private JTextComponent textPane;
041:
042:            private JButton button;
043:
044:            public SignatureView(ComposerController controller) {
045:                super ();
046:
047:                this .controller = controller;
048:
049:                setLayout(new BorderLayout());
050:
051:                setBackground(UIManager.getColor("TextArea.background"));
052:
053:                setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
054:
055:                JPanel centerPanel = new JPanel();
056:                centerPanel.setBackground(UIManager
057:                        .getColor("TextArea.background"));
058:
059:                centerPanel.setBorder(BorderFactory.createCompoundBorder(
060:                        new RoundedBorder(new Color(220, 220, 220)),
061:                        BorderFactory.createEmptyBorder(8, 8, 8, 8)));
062:                centerPanel.setLayout(new BorderLayout());
063:
064:                add(centerPanel, BorderLayout.CENTER);
065:
066:                // setBorder(BorderFactory.createCompoundBorder(BorderFactory
067:                // .createEmptyBorder(5, 5, 5, 5), BorderFactory
068:                // .createCompoundBorder(new RoundedBorder(
069:                // new Color(220, 220, 220)), BorderFactory
070:                // .createEmptyBorder(5, 5, 5, 5))));
071:
072:                button = new JButton("Edit Signature...");
073:                button.addActionListener(new ActionListener() {
074:                    public void actionPerformed(ActionEvent event) {
075:                        new EditSignatureAction(SignatureView.this .controller,
076:                                item).actionPerformed(null);
077:                    }
078:                });
079:
080:                JPanel topPanel = new JPanel();
081:
082:                topPanel.setBackground(UIManager
083:                        .getColor("TextArea.background"));
084:                topPanel.setLayout(new BorderLayout());
085:                topPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
086:
087:                topPanel.add(button, BorderLayout.WEST);
088:
089:                centerPanel.add(topPanel, BorderLayout.NORTH);
090:
091:                textPane = new JTextArea();
092:
093:                centerPanel.add(textPane, BorderLayout.CENTER);
094:
095:                textPane.setEditable(false);
096:                textPane.setBackground(UIManager
097:                        .getColor("TextArea.background"));
098:                // textPane.setEnabled(false);
099:                textPane.addMouseListener(this );
100:
101:                Font font = FontProperties.getTextFont();
102:                setFont(font);
103:
104:                XmlElement options = Config.getInstance().get("options")
105:                        .getElement("/options");
106:                XmlElement gui = options.getElement("gui");
107:                XmlElement fonts = gui.getElement("fonts");
108:
109:                if (fonts == null) {
110:                    fonts = gui.addSubElement("fonts");
111:                }
112:
113:                // register interest on configuration changes
114:                fonts.addObserver(this );
115:
116:                item = (AccountItem) controller.getAccountController()
117:                        .getView().getSelectedItem();
118:
119:                if (item.getIdentity().getSignature() != null)
120:                    readSignature(item.getIdentity().getSignature());
121:
122:                // if account selection changes, reload signature file
123:                controller.getAccountController().getView().addItemListener(
124:                        this );
125:
126:                // add listener to changes
127:                item.getIdentity().addObserver(this );
128:
129:            }
130:
131:            public void itemStateChanged(ItemEvent e) {
132:                if (e.getStateChange() == ItemEvent.SELECTED) {
133:
134:                    // remove listener from old account selection
135:                    item.getIdentity().removeObserver(this );
136:
137:                    item = (AccountItem) controller.getAccountController()
138:                            .getView().getSelectedItem();
139:                    if (item.getIdentity().getSignature() != null) {
140:                        readSignature(item.getIdentity().getSignature());
141:                    } else {
142:                        textPane.setText("");
143:                    }
144:
145:                    // add listener to changes
146:                    item.getIdentity().addObserver(this );
147:
148:                }
149:
150:            }
151:
152:            /**
153:             * Read signature from file.
154:             * 
155:             * @param signatureFile
156:             *            signature file
157:             */
158:            private void readSignature(File signatureFile) {
159:                StringBuffer strbuf = new StringBuffer();
160:
161:                try {
162:                    BufferedReader in = new BufferedReader(new FileReader(
163:                            signatureFile));
164:                    String str;
165:
166:                    while ((str = in.readLine()) != null) {
167:                        strbuf.append(str + "\n");
168:                    }
169:
170:                    in.close();
171:
172:                    textPane.setText(strbuf.toString());
173:
174:                } catch (IOException ex) {
175:                    textPane.setText("");
176:                }
177:            }
178:
179:            public void mouseClicked(MouseEvent event) {
180:                if ((event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0
181:                        && item != null) {
182:                    if (event.getClickCount() >= 2) {
183:                        new EditSignatureAction(controller, item)
184:                                .actionPerformed(null);
185:                    }
186:                }
187:            }
188:
189:            public void mouseEntered(MouseEvent e) {
190:                // TODO Auto-generated method stub
191:
192:            }
193:
194:            public void mouseExited(MouseEvent e) {
195:                // TODO Auto-generated method stub
196:
197:            }
198:
199:            public void mousePressed(MouseEvent e) {
200:                // TODO Auto-generated method stub
201:
202:            }
203:
204:            public void mouseReleased(MouseEvent e) {
205:                // TODO Auto-generated method stub
206:
207:            }
208:
209:            /**
210:             * 
211:             * @see org.columba.mail.gui.config.general.MailOptionsDialog
212:             * 
213:             * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
214:             */
215:            public void update(Observable arg0, Object arg1) {
216:                Font font = FontProperties.getTextFont();
217:                setFont(font);
218:
219:                readSignature(item.getIdentity().getSignature());
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.