Source Code Cross Referenced for TextComponentHelper.java in  » Net » Terracotta » com » tc » admin » common » 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 » Net » Terracotta » com.tc.admin.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.admin.common;
005:
006:        import java.awt.event.ActionEvent;
007:
008:        import javax.swing.Action;
009:        import javax.swing.ImageIcon;
010:        import javax.swing.JPopupMenu;
011:        import javax.swing.event.CaretEvent;
012:        import javax.swing.event.CaretListener;
013:        import javax.swing.text.BadLocationException;
014:        import javax.swing.text.Document;
015:        import javax.swing.text.JTextComponent;
016:
017:        // XXX: DEPRECATED
018:        public class TextComponentHelper extends XPopupListener implements 
019:                CaretListener {
020:            protected JTextComponent m_component;
021:            protected CutAction m_cutAction;
022:            protected CopyAction m_copyAction;
023:            protected PasteAction m_pasteAction;
024:            protected ClearAction m_clearAction;
025:
026:            public TextComponentHelper() {
027:                super ();
028:            }
029:
030:            public TextComponentHelper(JTextComponent component) {
031:                this ();
032:                setTarget(component);
033:            }
034:
035:            protected void setTarget(JTextComponent component) {
036:                if (m_component != null) {
037:                    m_component.removeCaretListener(this );
038:                }
039:
040:                super .setTarget(m_component = component);
041:
042:                if (component != null) {
043:                    component.addCaretListener(this );
044:                }
045:            }
046:
047:            public JPopupMenu createPopup() {
048:                JPopupMenu popup = new JPopupMenu("TextComponent Actions");
049:
050:                addCutAction(popup);
051:                addCopyAction(popup);
052:                addPasteAction(popup);
053:                addClearAction(popup);
054:
055:                return popup;
056:            }
057:
058:            protected void addCutAction(JPopupMenu popup) {
059:                popup.add(m_cutAction = new CutAction());
060:            }
061:
062:            public Action getCutAction() {
063:                return m_cutAction;
064:            }
065:
066:            protected void addCopyAction(JPopupMenu popup) {
067:                popup.add(m_copyAction = new CopyAction());
068:            }
069:
070:            public Action getCopyAction() {
071:                return m_copyAction;
072:            }
073:
074:            protected void addPasteAction(JPopupMenu popup) {
075:                popup.add(m_pasteAction = new PasteAction());
076:            }
077:
078:            public Action getPasteAction() {
079:                return m_pasteAction;
080:            }
081:
082:            protected void addClearAction(JPopupMenu popup) {
083:                popup.add(m_clearAction = new ClearAction());
084:            }
085:
086:            public Action getClearAction() {
087:                return m_clearAction;
088:            }
089:
090:            protected class CutAction extends XAbstractAction {
091:                protected CutAction() {
092:                    super ("Cut");
093:                    String uri = "/com/tc/admin/icons/cut_edit.gif";
094:                    setSmallIcon(new ImageIcon(getClass().getResource(uri)));
095:                }
096:
097:                public void actionPerformed(ActionEvent ae) {
098:                    m_component.cut();
099:                }
100:            }
101:
102:            protected class CopyAction extends XAbstractAction {
103:                protected CopyAction() {
104:                    super ("Copy");
105:                    String uri = "/com/tc/admin/icons/copy_edit.gif";
106:                    setSmallIcon(new ImageIcon(getClass().getResource(uri)));
107:                }
108:
109:                public void actionPerformed(ActionEvent ae) {
110:                    m_component.copy();
111:                }
112:            }
113:
114:            protected class PasteAction extends XAbstractAction {
115:                protected PasteAction() {
116:                    super ("Paste");
117:                    String uri = "/com/tc/admin/icons/paste_edit.gif";
118:                    setSmallIcon(new ImageIcon(getClass().getResource(uri)));
119:                }
120:
121:                public void actionPerformed(ActionEvent ae) {
122:                    m_component.paste();
123:                }
124:            }
125:
126:            protected class ClearAction extends XAbstractAction {
127:                protected ClearAction() {
128:                    super ("Clear");
129:                    String uri = "/com/tc/admin/icons/clear_co.gif";
130:                    setSmallIcon(new ImageIcon(getClass().getResource(uri)));
131:                }
132:
133:                public void actionPerformed(ActionEvent ae) {
134:                    Document doc = m_component.getDocument();
135:
136:                    try {
137:                        doc.remove(0, doc.getLength());
138:                    } catch (BadLocationException ble) {/**/
139:                    }
140:                }
141:            }
142:
143:            public boolean hasSelectionRange() {
144:                return (m_component.getSelectionStart() - m_component
145:                        .getSelectionEnd()) != 0;
146:            }
147:
148:            private void testEnableMenuItems() {
149:                boolean hasSelectionRange = hasSelectionRange();
150:                boolean editable = m_component.isEditable();
151:
152:                if (m_cutAction != null) {
153:                    m_cutAction.setEnabled(editable && hasSelectionRange);
154:                }
155:
156:                if (m_copyAction != null) {
157:                    m_copyAction.setEnabled(hasSelectionRange);
158:                }
159:
160:                if (m_pasteAction != null) {
161:                    m_pasteAction.setEnabled(editable);
162:                }
163:
164:                if (m_clearAction != null) {
165:                    m_clearAction.setEnabled(m_component.getDocument()
166:                            .getLength() > 0);
167:                }
168:            }
169:
170:            public void caretUpdate(CaretEvent e) {
171:                testEnableMenuItems();
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.