Source Code Cross Referenced for DataFilter.java in  » Database-Client » VelaSource » vela » view » 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 » Database Client » VelaSource » vela.view 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package vela.view;
002:
003:        /*
004:         * Copyright 2007 Madhav Pulipaka
005:         * 
006:         * This file is part of Vela.
007:
008:         * Vela is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License as published by
010:         * the Free Software Foundation; either version 2 of the License, or
011:         * (at your option) any later version.
012:         *
013:         * Vela is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with Vela; if not, write to the Free Software
020:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
021:         */
022:        import java.awt.Color;
023:        import java.awt.Component;
024:        import java.awt.Container;
025:        import java.awt.Cursor;
026:        import java.awt.Dimension;
027:        import java.awt.FlowLayout;
028:        import java.awt.BorderLayout;
029:        import java.awt.Font;
030:        import java.awt.Frame;
031:        import java.awt.Toolkit;
032:        import java.awt.event.ActionEvent;
033:        import java.awt.event.ActionListener;
034:        import java.awt.event.ItemEvent;
035:        import java.awt.event.ItemListener;
036:        import java.awt.event.KeyEvent;
037:        import java.awt.event.KeyListener;
038:
039:        import javax.swing.BorderFactory;
040:        import javax.swing.JButton;
041:        import javax.swing.JComboBox;
042:        import javax.swing.JDialog;
043:        import javax.swing.JEditorPane;
044:        import javax.swing.JLabel;
045:        import javax.swing.JPanel;
046:        import javax.swing.JScrollPane;
047:        import javax.swing.JTextArea;
048:        import javax.swing.JTextPane;
049:        import javax.swing.JToolTip;
050:        import javax.swing.border.Border;
051:        import javax.swing.event.DocumentEvent;
052:        import javax.swing.event.DocumentListener;
053:        import javax.swing.text.Position;
054:        import vela.model.*;
055:        import vela.common.Constants;
056:
057:        public class DataFilter extends JDialog implements  ActionListener,
058:                KeyListener, ItemListener, Constants {
059:
060:            private static final int WIDTH = 400;
061:            private static final int HEIGHT = 200;
062:            JComboBox colNames;
063:            JEditorPane tpFilterString;
064:            DBObject tableObj;
065:            Frame parentFrame;
066:            String title;
067:
068:            public DataFilter(Frame frame, DBObject tableObj, String title) {
069:                super (frame, title, true);
070:                this .tableObj = tableObj;
071:                this .title = title;
072:                parentFrame = frame;
073:                Container container = getContentPane();
074:                JButton btnApply = new JButton("Apply");
075:                JButton btnCancel = new JButton("Cancel");
076:                JButton btnClear = new JButton("Clear");
077:                btnApply.setActionCommand("Apply");
078:                btnCancel.setActionCommand("Cancel");
079:                btnClear.setActionCommand("Clear");
080:                Dimension screenSize = Toolkit.getDefaultToolkit()
081:                        .getScreenSize();
082:                setBounds((int) (screenSize.getWidth() / 2) - (WIDTH / 2),
083:                        (int) (screenSize.getHeight() / 2) - (HEIGHT / 2),
084:                        WIDTH, HEIGHT);
085:                btnApply.addActionListener(this );
086:                btnClear.addActionListener(this );
087:                btnCancel.addActionListener(this );
088:                JPanel southPanel = new JPanel(
089:                        new FlowLayout(FlowLayout.CENTER));
090:                southPanel.add(btnApply);
091:                southPanel.add(btnClear);
092:                southPanel.add(btnCancel);
093:
094:                JLabel help = new JLabel(" ? ");
095:                help.setBorder(BorderFactory.createEtchedBorder());
096:                help.setFont(new Font("Lucida Console", Font.BOLD, fontBig));
097:                JLabel label = null;
098:                if (title.startsWith("Filter")) {
099:                    label = new JLabel("Please enter the filter criteria.");
100:                    help
101:                            .setToolTipText("<HTML><FONT FACE=\"Verdana, sans-serif\" size=\"3\">Enter SQL \"WHERE\" clause as Filter Criteria.<BR>Please do not include \"WHERE\" in the filter criteria.<BR>Filter criteria is not case sensitive.</Font></HTML>");
102:                } else {
103:                    label = new JLabel("Please enter the sorting criteria.");
104:                    label.setToolTipText("");
105:                    help
106:                            .setToolTipText("<HTML><FONT FACE=\"Verdana, sans-serif\" size=\"3\">Enter list of columns separated by \",\" as sort criteria.<BR>To sort in descending order of a column include \"DESC\" after the column name.<BR>For example sort criteria \"COLUMN1, COLUMN2 DESC\" will sort the table data<BR>in ascending order for COLUMN1 and in descending order for COLUMN2.<BR>Sort criteria is not case sensitive.</Font></HTML>");
107:                }
108:                label.setFont(new Font(fontFamily, Font.BOLD, fontBig));
109:                container.add(southPanel, BorderLayout.SOUTH);
110:                JPanel northPanel = new JPanel(new BorderLayout());
111:                northPanel.add(label);
112:                northPanel.add(help, BorderLayout.EAST);
113:                container.add(northPanel, BorderLayout.NORTH);
114:
115:                btnApply.setFont(new Font("Verdana", Font.BOLD, 12));
116:                //btnApply.setBackground(new Color(0,0,100));
117:                //btnApply.setForeground(new Color(0,0,128));
118:
119:                btnCancel.setFont(new Font("Verdana", Font.BOLD, 12));
120:                //btnCancel.setBackground(new Color(0,0,100));
121:                //btnCancel.setForeground(new Color(0,0,128));
122:
123:                btnClear.setFont(new Font("Verdana", Font.BOLD, 12));
124:                //btnClear.setBackground(new Color(0,0,100));
125:                //btnClear.setForeground(new Color(0,0,128));
126:
127:                //JPanel centerPanel = new JPanel();
128:                //centerPanel.setBorder(BorderFactory.createEtchedBorder(1));
129:                //add(centerPanel);
130:                tpFilterString = new JEditorPane();
131:                tpFilterString.setFont(new Font(fontFamily, Font.BOLD,
132:                        fontSmall));
133:                tpFilterString.setLayout(null);
134:                tpFilterString.addKeyListener(this );
135:                container.add(new JScrollPane(tpFilterString));
136:                colNames = new JComboBox();
137:                tpFilterString.add(colNames);
138:                colNames.setVisible(false);
139:                colNames.addItemListener(this );
140:                colNames.setSize(new Dimension(100, 0));
141:                colNames.setBorder(null);
142:                colNames.setOpaque(false);
143:                tpFilterString.setText("");
144:                if (tableObj.getTableFilter() != null
145:                        && tableObj.getTableFilter().trim().length() > 0
146:                        && title.startsWith("Filter"))
147:                    tpFilterString.setText(tableObj.getTableFilter());
148:                else if (tableObj.getTableSort() != null
149:                        && tableObj.getTableSort().trim().length() > 0
150:                        && title.startsWith("Sort"))
151:                    tpFilterString.setText(tableObj.getTableSort());
152:            }
153:
154:            public void actionPerformed(ActionEvent ae) {
155:                setCursor(new Cursor(Cursor.WAIT_CURSOR));
156:                try {
157:                    if (ae.getActionCommand().equalsIgnoreCase("Apply")) {
158:                        if (title.startsWith("Filter"))
159:                            tableObj.setTableFilter(tpFilterString.getText()
160:                                    .trim());
161:                        else
162:                            tableObj.setTableSort(tpFilterString.getText()
163:                                    .trim());
164:                        setVisible(false);
165:                        dispose();
166:                    } else if (ae.getActionCommand().equalsIgnoreCase("Cancel")) {
167:                        setVisible(false);
168:                        dispose();
169:                    } else if (ae.getActionCommand().equalsIgnoreCase("Clear")) {
170:                        tpFilterString.setText("");
171:                    }
172:                } finally {
173:                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
174:                }
175:            }
176:
177:            public void keyPressed(KeyEvent e) {
178:
179:            }
180:
181:            public void keyReleased(KeyEvent e) {
182:                if (e.getKeyCode() == KeyEvent.VK_SPACE && e.isControlDown()) {
183:                    /*System.out.println("Key Released.");
184:                    colNames.setVisible(true);
185:                    colNames.setLocation(tpFilterString.getCaret().getMagicCaretPosition());*/
186:                }
187:            }
188:
189:            public void keyTyped(KeyEvent e) {
190:
191:            }
192:
193:            public void itemStateChanged(ItemEvent e) {
194:                setCursor(new Cursor(Cursor.WAIT_CURSOR));
195:                try {
196:                    if (e.getStateChange() == ItemEvent.SELECTED) {
197:                        int caretPos = tpFilterString.getCaretPosition();
198:                        String currentText = tpFilterString.getText();
199:                        String textBefore = currentText.substring(0, caretPos);
200:                        String textAfter = currentText.substring(caretPos);
201:                        tpFilterString.setText(textBefore
202:                                + colNames.getSelectedItem() + textAfter);
203:                        colNames.setVisible(false);
204:                    }
205:                } finally {
206:                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
207:                }
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.