Source Code Cross Referenced for RaveStringCustomEditor.java in  » IDE-Netbeans » visualweb.api.designer » com » sun » jsfcl » std » 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 » IDE Netbeans » visualweb.api.designer » com.sun.jsfcl.std 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package com.sun.jsfcl.std;
042:
043:        import java.awt.BorderLayout;
044:        import java.awt.event.KeyAdapter;
045:        import java.awt.event.KeyEvent;
046:        import javax.swing.BorderFactory;
047:        import javax.swing.JTextArea;
048:        import javax.swing.JTextField;
049:        import javax.swing.UIManager;
050:        import javax.swing.text.JTextComponent;
051:
052:        import org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor;
053:
054:        import com.sun.jsfcl.util.ComponentBundle;
055:
056:        /**
057:         *This is a clone of the code from org.netbeans.beaninfo.editors.StringCustomEditor.  Its the cheezy
058:         *way to do it, but since the class was not built to be subclasseable, I cloned it to get same behavior
059:         *and hope it reduces risk of regressions.
060:         *
061:         * @author eric
062:         */
063:
064:        /** A custom editor for Strings.
065:         *
066:         * @author  Ian Formanek
067:         * @version 1.00, Sep 21, 1998
068:         * @deprecated
069:         */
070:        public class RaveStringCustomEditor extends javax.swing.JPanel
071:                implements  EnhancedCustomPropertyEditor {
072:
073:            protected static final ComponentBundle bundle = ComponentBundle
074:                    .getBundle(RaveStringCustomEditor.class);
075:
076:            boolean oneline = false;
077:            String instructions = null;
078:
079:            //enh 29294, provide one line editor on request
080:            /** Create a StringCustomEditor.
081:             * @param value the initial value for the string
082:             * @param editable whether to show the editor in read only or read-write mode
083:             * @param oneline whether the text component should be a single-line or multi-line component
084:             * @param instructions any instructions that should be displayed
085:             */
086:            RaveStringCustomEditor(String value, boolean editable,
087:                    boolean oneline, String instructions, boolean ignoreCrs,
088:                    RaveStringEditor propertyEditor) {
089:                // EAT: modified - added ignoreCrs, propertyEditor
090:
091:                this .oneline = oneline;
092:                this .instructions = instructions;
093:                this .ignoreCrs = ignoreCrs;
094:                this .propertyEditor = propertyEditor;
095:                init(value, editable);
096:            }
097:
098:            /** Initializes the Form
099:             * @deprecated Nothing should be using this constructor */
100:            public RaveStringCustomEditor(String s, boolean editable,
101:                    RaveStringEditor propertyEditor) {
102:                this .propertyEditor = propertyEditor;
103:                init(s, editable);
104:            }
105:
106:            private void init(String s, boolean editable) {
107:                setLayout(new java.awt.BorderLayout());
108:                if (oneline) {
109:                    textArea = new javax.swing.JTextField();
110:                    add(textArea, BorderLayout.CENTER);
111:                } else {
112:                    textAreaScroll = new javax.swing.JScrollPane();
113:                    textArea = new javax.swing.JTextArea();
114:                    textAreaScroll.setViewportView(textArea);
115:                    add(textAreaScroll, BorderLayout.CENTER);
116:                    // EAT: added start
117:                    if (ignoreCrs) {
118:                        textArea.addKeyListener(new KeyAdapter() {
119:                            public void keyReleased(KeyEvent event) {
120:                                if (event.getKeyCode() == KeyEvent.VK_ENTER) {
121:                                    event.consume();
122:                                }
123:                            }
124:
125:                            public void keyPressed(KeyEvent event) {
126:                                if (event.getKeyCode() == KeyEvent.VK_ENTER) {
127:                                    event.consume();
128:                                }
129:                            }
130:
131:                            public void keyTyped(KeyEvent event) {
132:                                if (event.getKeyCode() == KeyEvent.VK_ENTER) {
133:                                    event.consume();
134:                                }
135:                            }
136:                        });
137:                    }
138:                    // EAT: added end
139:                }
140:                //original constructor code
141:                textArea.setEditable(editable);
142:                textArea.setText(s);
143:                if (textArea instanceof  JTextArea) {
144:                    ((JTextArea) textArea).setWrapStyleWord(true);
145:                    ((JTextArea) textArea).setLineWrap(true);
146:                    setPreferredSize(new java.awt.Dimension(500, 300));
147:                    if (!editable) {
148:                        // hack to fix #9219
149:                        //TODO Fix this to use UIManager values, this is silly
150:                        JTextField hack = new JTextField();
151:                        hack.setEditable(false);
152:                        textArea.setBackground(hack.getBackground());
153:                        textArea.setForeground(hack.getForeground());
154:                    }
155:                } else {
156:                    textArea.setMinimumSize(new java.awt.Dimension(100, 20));
157:                }
158:                setBorder(BorderFactory.createEmptyBorder(12, 12, 0, 11));
159:
160:                textArea.getAccessibleContext().setAccessibleName(
161:                        bundle.getMessage("ACS_TextArea")); //NOI18N
162:                if (instructions == null) {
163:                    textArea.getAccessibleContext().setAccessibleDescription(
164:                            bundle.getMessage("ACSD_TextArea")); //NOI18N
165:                } else {
166:                    textArea.getAccessibleContext().setAccessibleDescription(
167:                            instructions);
168:                }
169:                getAccessibleContext().setAccessibleDescription(
170:                        "ACSD_CustomStringEditor"); //NOI18N
171:                //Layout is not quite smart enough about text field along with variable
172:                //size text area
173:                int prefHeight = textArea.getPreferredSize().height + 8;
174:
175:                if (instructions != null) {
176:                    final JTextArea jta = new JTextArea(instructions);
177:                    jta.setEditable(false);
178:                    java.awt.Color c = UIManager.getColor("control"); //NOI18N
179:                    if (c != null) {
180:                        jta.setBackground(c);
181:                    } else {
182:                        jta.setBackground(getBackground());
183:                    }
184:                    jta.setLineWrap(true);
185:                    jta.setWrapStyleWord(true);
186:                    jta.setFont(getFont());
187:                    add(jta, BorderLayout.NORTH, 0);
188:                    jta.getAccessibleContext().setAccessibleName(
189:                            bundle.getMessage("ACS_Instructions")); //NOI18N
190:                    jta.getAccessibleContext().setAccessibleDescription(
191:                            bundle.getMessage("ACSD_Instructions")); //NOI18N
192:                    prefHeight += jta.getPreferredSize().height;
193:                    //jlf guidelines - auto select text when clicked
194:                    jta.addFocusListener(new java.awt.event.FocusListener() {
195:                        public void focusGained(java.awt.event.FocusEvent e) {
196:                            jta.setSelectionStart(0);
197:                            jta.setSelectionEnd(jta.getText().length());
198:                        }
199:
200:                        public void focusLost(java.awt.event.FocusEvent e) {
201:                            jta.setSelectionStart(0);
202:                            jta.setSelectionEnd(0);
203:                        }
204:                    });
205:                }
206:                if (textArea instanceof  JTextField) {
207:                    setPreferredSize(new java.awt.Dimension(300, prefHeight));
208:                }
209:            }
210:
211:            public void addNotify() {
212:                super .addNotify();
213:                //force focus to the editable area
214:                if (isEnabled() && isFocusable()) {
215:                    textArea.requestFocus();
216:                }
217:            }
218:
219:            /**
220:             * @return Returns the property value that is result of the CustomPropertyEditor.
221:             * @exception InvalidStateException when the custom property editor does not represent valid property value
222:             *            (and thus it should not be set)
223:             */
224:            public Object getPropertyValue() throws IllegalStateException {
225:                return propertyEditor.getCustomEditorValue(textArea.getText());
226:            }
227:
228:            private javax.swing.JScrollPane textAreaScroll;
229:            private JTextComponent textArea;
230:            // EAT: added start
231:            protected boolean ignoreCrs;
232:            protected RaveStringEditor propertyEditor;
233:            // EAT: added end
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.