Source Code Cross Referenced for RowSetSelectionQuery.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » dataconnectivity » customizers » 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 » org.netbeans.modules.visualweb.dataconnectivity.customizers 
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:        /*
042:         * RowSetSelectionQuery.java
043:         *
044:         * Created on June 9, 2005, 9:40 AM
045:         */
046:
047:        package org.netbeans.modules.visualweb.dataconnectivity.customizers;
048:
049:        import java.awt.Color;
050:        import java.awt.Dimension;
051:        import java.awt.Graphics;
052:        import java.awt.Graphics2D;
053:        import java.awt.GridBagConstraints;
054:        import java.awt.Insets;
055:        import javax.swing.ImageIcon;
056:        import javax.swing.JButton;
057:        import javax.swing.JPanel;
058:        import org.openide.util.NbBundle;
059:        import org.openide.util.Utilities;
060:
061:        /**
062:         * This presents either a short form of the sql text or the full sql text.
063:         *
064:         * @author  jfbrown
065:         */
066:        public class RowSetSelectionQuery extends javax.swing.JPanel {
067:
068:            private static final ImageIcon closedIcon = new ImageIcon(
069:                    Utilities
070:                            .loadImage("org/netbeans/modules/visualweb/dataconnectivity/resources/sqlClosed.gif"));
071:            private static final ImageIcon openIcon = new ImageIcon(
072:                    Utilities
073:                            .loadImage("org/netbeans/modules/visualweb/dataconnectivity/resources/sqlOpened.gif"));
074:            private static final ImageIcon emptyIcon = new ImageIcon(Utilities
075:                    .loadImage("org/openide/resources/actions/empty.gif"));
076:            boolean expanded = false;
077:            private static final Color bgColor = (new javax.swing.JLabel())
078:                    .getBackground();
079:
080:            SpecialButton expandButton = new SpecialButton();
081:            boolean noExpand = false; // is expandable (e.g., is only one line)
082:
083:            /** Creates new form RowSetSelectionQuery */
084:            public RowSetSelectionQuery(String sql) {
085:                initComponents();
086:
087:                String bStuff = " SQL"; //NOI18N
088:                this .getAccessibleContext().setAccessibleName(bStuff);
089:                this .getAccessibleContext().setAccessibleDescription(bStuff);
090:                shortSql.getAccessibleContext().setAccessibleName(bStuff);
091:                shortSql.getAccessibleContext()
092:                        .setAccessibleDescription(bStuff);
093:                longSql.getAccessibleContext().setAccessibleName(bStuff);
094:                longSql.getAccessibleContext().setAccessibleDescription(bStuff);
095:
096:                this .setBackground(bgColor);
097:
098:                /*
099:                JPanel lac = new JPanel() ;
100:                lac.addMouseListener( new java.awt.event.MouseAdapter() {
101:                    public void mouseClicked(java.awt.event.MouseEvent me) {
102:                        if ( noExpand ) return ;
103:                        setExpanded( ! expanded ) ;
104:                    }
105:
106:                }) ;
107:                lac.add( expandButton ) ;
108:                 */
109:
110:                expandButton.setToolTipText(NbBundle.getMessage(
111:                        RowSetSelectionQuery.class, "ExpandSql_tooltip"));
112:
113:                expandButton
114:                        .addActionListener(new java.awt.event.ActionListener() {
115:                            public void actionPerformed(
116:                                    java.awt.event.ActionEvent evt) {
117:                                if (noExpand)
118:                                    return;
119:                                setExpanded(!expanded);
120:                            }
121:                        });
122:
123:                longSql.setText(sql);
124:                String[] lines = sql.split("\n");
125:                int maxWidth = 25;
126:                for (int i = 0; i < lines.length; i++) {
127:                    if (maxWidth < lines[i].length())
128:                        maxWidth = lines[i].length();
129:                }
130:                int width = maxWidth;
131:                if (lines.length <= 2) {
132:                    shortSql.setText(sql);
133:                    expandButton.setIcon(emptyIcon);
134:                    noExpand = true;
135:                    // setExpanded( true ) ;
136:
137:                } else {
138:                    // long query
139:                    String lowerSql = sql.toLowerCase();
140:                    StringBuffer dsql = new StringBuffer(100);
141:                    int pos = -1;
142:                    dsql.append(lines[0]).append(" ...\n"); // NOI18N
143:                    width = lines[0].length();
144:                    for (int i = 1; i < lines.length; i++) {
145:                        String nn = lines[i].toLowerCase();
146:                        pos = nn.indexOf("from"); // NOI18N
147:                        if (pos >= 0) {
148:                            if (pos < 5) {
149:                                dsql.append(lines[i]);
150:                                dsql.append(" ..."); // NOI18N
151:                                int line2 = lines[i].length() + 4;
152:                                if (line2 > width) {
153:                                    width = line2;
154:                                }
155:                                break;
156:                            }
157:                        }
158:                    }
159:                    if (pos < 0)
160:                        dsql.append(lines[1]);
161:                    shortSql.setText(dsql.toString());
162:                    setExpanded(false);
163:                }
164:                if (width > 60)
165:                    width = 60;
166:                this .width_short = width;
167:                shortSql.setColumns(width);
168:                if (maxWidth > 70)
169:                    maxWidth = 70;
170:                this .width_long = maxWidth;
171:                longSql.setColumns(maxWidth);
172:
173:                // add the expand button (or a blank filler of the same size).
174:                GridBagConstraints gbc = new java.awt.GridBagConstraints();
175:                gbc.gridheight = 2;
176:                gbc.gridx = 0;
177:                gbc.gridy = 0;
178:                gbc.anchor = GridBagConstraints.NORTHWEST;
179:                if (!noExpand) {
180:                    add(expandButton, gbc);
181:                } else {
182:                    add(new EmptyPanel(), gbc);
183:                }
184:            }
185:
186:            private int width_short = 30;
187:            private int width_long = 30;
188:
189:            /** This method is called from within the constructor to
190:             * initialize the form.
191:             * WARNING: Do NOT modify this code. The content of this method is
192:             * always regenerated by the Form Editor.
193:             */
194:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
195:            private void initComponents() {
196:                java.awt.GridBagConstraints gridBagConstraints;
197:
198:                shortSql = new javax.swing.JTextArea();
199:                longSql = new javax.swing.JTextArea();
200:
201:                setLayout(new java.awt.GridBagLayout());
202:
203:                shortSql.setBackground(bgColor);
204:                shortSql.setColumns(25);
205:                shortSql.setEditable(false);
206:                shortSql.setTabSize(4);
207:                gridBagConstraints = new java.awt.GridBagConstraints();
208:                gridBagConstraints.gridx = 1;
209:                gridBagConstraints.gridy = 0;
210:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
211:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
212:                gridBagConstraints.weightx = 1.0;
213:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
214:                add(shortSql, gridBagConstraints);
215:
216:                longSql.setBackground(bgColor);
217:                longSql.setColumns(25);
218:                longSql.setEditable(false);
219:                longSql.setTabSize(4);
220:                longSql.setEnabled(false);
221:                gridBagConstraints = new java.awt.GridBagConstraints();
222:                gridBagConstraints.gridx = 1;
223:                gridBagConstraints.gridy = 0;
224:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
225:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
226:                gridBagConstraints.weightx = 1.0;
227:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
228:                add(longSql, gridBagConstraints);
229:
230:            }
231:
232:            // </editor-fold>//GEN-END:initComponents
233:
234:            public synchronized void setExpanded(boolean newExpanded) {
235:                expandButton.setText(null);
236:                if (newExpanded) {
237:                    shortSql.setVisible(false);
238:                    longSql.setColumns(this .width_long);
239:                    longSql.setVisible(true);
240:                    expandButton.setIcon(openIcon);
241:                    expanded = true;
242:                } else {
243:                    shortSql.setVisible(true);
244:                    longSql.setColumns(this .width_short);
245:                    longSql.setVisible(false);
246:                    expandButton.setIcon(closedIcon);
247:                    expanded = false;
248:                }
249:            }
250:
251:            // Variables declaration - do not modify//GEN-BEGIN:variables
252:            private javax.swing.JTextArea longSql;
253:            private javax.swing.JTextArea shortSql;
254:
255:            // End of variables declaration//GEN-END:variables
256:
257:            public class SpecialButton extends JButton {
258:
259:                private final int gSize = 16;
260:                private final Dimension dim = new Dimension(gSize, gSize);
261:
262:                public boolean isOpaque() {
263:                    return false;
264:                }
265:
266:                public void paintComponent(Graphics g) {
267:                    Graphics2D g2 = (Graphics2D) g;
268:                    ImageIcon im = (ImageIcon) this .getIcon();
269:                    g2.drawImage(im.getImage(), 0, 0, this .getWidth(), this 
270:                            .getHeight(), bgColor, null);
271:                }
272:
273:                public Dimension getPreferredSize() {
274:                    return dim;
275:                }
276:
277:                public Dimension getMinimumSize() {
278:                    return dim;
279:                }
280:
281:                public Dimension getMaximumSize() {
282:                    return dim;
283:                }
284:
285:                public Insets getInsets() {
286:                    return new Insets(0, 0, 0, 0);
287:                }
288:            }
289:
290:            public class EmptyPanel extends JPanel {
291:                private final int gSize = 16;
292:                private final Dimension dim = new Dimension(gSize, gSize);
293:
294:                public EmptyPanel() {
295:                    super ();
296:                    String bStuff = " "; //NOI18N
297:                    this .getAccessibleContext().setAccessibleName(bStuff);
298:                    this .getAccessibleContext()
299:                            .setAccessibleDescription(bStuff);
300:                }
301:
302:                public boolean isOpaque() {
303:                    return false;
304:                }
305:
306:                public void paintComponent(Graphics g) {
307:                    Graphics2D g2 = (Graphics2D) g;
308:                    ImageIcon im = emptyIcon;
309:                    g2.drawImage(im.getImage(), 0, 0, this .getWidth(), this 
310:                            .getHeight(), bgColor, null);
311:                }
312:
313:                public Dimension getPreferredSize() {
314:                    return dim;
315:                }
316:
317:                public Dimension getMinimumSize() {
318:                    return dim;
319:                }
320:
321:                public Dimension getMaximumSize() {
322:                    return dim;
323:                }
324:
325:                public Insets getInsets() {
326:                    return new Insets(0, 0, 0, 0);
327:                }
328:            }
329:
330:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.