Source Code Cross Referenced for Gui4jCellEditor.java in  » XML-UI » gui4j » org » gui4j » core » swing » 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 » XML UI » gui4j » org.gui4j.core.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.gui4j.core.swing;
002:
003:        import java.awt.Color;
004:        import java.awt.Component;
005:        import java.awt.Font;
006:        import java.awt.event.FocusEvent;
007:        import java.util.Map;
008:
009:        import javax.swing.DefaultCellEditor;
010:        import javax.swing.JTable;
011:        import javax.swing.JTextField;
012:        import javax.swing.JWindow;
013:        import javax.swing.border.Border;
014:        import javax.swing.border.LineBorder;
015:        import javax.swing.text.AttributeSet;
016:        import javax.swing.text.BadLocationException;
017:        import javax.swing.text.PlainDocument;
018:
019:        import org.gui4j.Gui4jCallBase;
020:        import org.gui4j.core.Gui4jCall;
021:
022:        public class Gui4jCellEditor extends DefaultCellEditor {
023:
024:            // infos for notification callback of temporary edit value
025:            private Gui4jCallBase mNotifyCallBase;
026:            private Gui4jCall mNotifyCall;
027:            private Map mNotifyParams;
028:            private Object mNotifyParamsValueKey;
029:
030:            public static Gui4jCellEditor createTextEditor(Font font,
031:                    boolean withBorder) {
032:                NotificationDocument document = new NotificationDocument();
033:                CellEditorTextField textField = new CellEditorTextField(
034:                        document, withBorder);
035:                textField.setBorder(new LineBorder(Color.black));
036:                textField.setFont(font);
037:                Gui4jCellEditor editor = new Gui4jCellEditor(textField);
038:                textField.cellEditor = editor;
039:                document.setCellEditor(editor);
040:                return editor;
041:            }
042:
043:            public Component getTableCellEditorComponent(JTable table,
044:                    Object value, boolean isSelected, int row, int column) {
045:                Component c = super .getTableCellEditorComponent(table, value,
046:                        isSelected, row, column);
047:                JTextField textField = (JTextField) c;
048:                textField.selectAll();
049:                return c;
050:            }
051:
052:            public void setNotificationCallback(Gui4jCallBase gui4jController,
053:                    Gui4jCall notifyTempValue, Map params, Object paramsValueKey) {
054:                this .mNotifyCallBase = gui4jController;
055:                this .mNotifyCall = notifyTempValue;
056:                this .mNotifyParams = params;
057:                this .mNotifyParamsValueKey = paramsValueKey;
058:            }
059:
060:            /**
061:             * Method called by an edit component to notify the cell editor about the
062:             * current temporary (non-committed) value of the editing component.
063:             * 
064:             * @param value
065:             */
066:            public void notifyTempValue(String value) {
067:                // use call back method to pass value on to client controller
068:                if (mNotifyCall != null) {
069:                    mNotifyParams.put(mNotifyParamsValueKey, value);
070:                    mNotifyCall.getValue(mNotifyCallBase, mNotifyParams, null);
071:                }
072:            }
073:
074:            /**
075:             * Constructor for CellEditor.
076:             * 
077:             * @param textField
078:             */
079:            private Gui4jCellEditor(JTextField textField) {
080:                super (textField);
081:            }
082:
083:            public static final class CellEditorTextField extends JTextField {
084:                protected javax.swing.CellEditor cellEditor;
085:                private final boolean withBorder;
086:
087:                public CellEditorTextField(boolean withBorder) {
088:                    this (null, withBorder);
089:                }
090:
091:                public CellEditorTextField(NotificationDocument document,
092:                        boolean withBorder) {
093:                    super (document, null, 0);
094:                    this .withBorder = withBorder;
095:                }
096:
097:                public void setBorder(Border border) {
098:                    if (withBorder) {
099:                        super .setBorder(border);
100:                    }
101:                }
102:
103:                public javax.swing.CellEditor getCellEditor() {
104:                    return cellEditor;
105:                }
106:
107:                public void setCellEditor(javax.swing.CellEditor cellEditor) {
108:                    this .cellEditor = cellEditor;
109:                }
110:
111:                protected void processFocusEvent(FocusEvent e) {
112:                    super .processFocusEvent(e);
113:                    if (e.getID() == FocusEvent.FOCUS_LOST
114:                            && !(e.getOppositeComponent() instanceof  JWindow)) {
115:                        if (cellEditor != null) {
116:                            cellEditor.stopCellEditing();
117:                        }
118:                    }
119:                }
120:            }
121:
122:            private static final class NotificationDocument extends
123:                    PlainDocument {
124:
125:                private Gui4jCellEditor cellEditor;
126:
127:                public NotificationDocument() {
128:                    super ();
129:                }
130:
131:                public void setCellEditor(Gui4jCellEditor cellEditor) {
132:                    this .cellEditor = cellEditor;
133:                }
134:
135:                public void insertString(int offs, String str, AttributeSet a)
136:                        throws BadLocationException {
137:                    super .insertString(offs, str, a);
138:                    notifyCellEditor();
139:                }
140:
141:                public void remove(int offs, int len)
142:                        throws BadLocationException {
143:                    super .remove(offs, len);
144:                    notifyCellEditor();
145:                }
146:
147:                private void notifyCellEditor() throws BadLocationException {
148:                    // notify cell editor of current temporary (non-committed) value
149:                    if (cellEditor != null) {
150:                        String value = getText(0, getLength());
151:                        cellEditor.notifyTempValue(value);
152:                    }
153:                }
154:
155:            }
156:
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.