Source Code Cross Referenced for QueryController.java in  » Database-Client » ViennaSQL » uk » co » whisperingwind » vienna » 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 » ViennaSQL » uk.co.whisperingwind.vienna 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         ** $Id: QueryController.java,v 1.12 2000/11/01 08:43:37 mrw Exp $
003:         **
004:         ** Controller for the query view. The view contains two main
005:         ** components: a JTable to view the query results and a JTextArea to
006:         ** edit the SQL query.
007:         **
008:         ** Mike Wilson, July 2000, mrw@whisperingwind.co.uk
009:         **
010:         ** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
011:         **
012:         ** This program is free software; you can redistribute it and/or modify
013:         ** it under the terms of the GNU General Public License as published by
014:         ** the Free Software Foundation; either version 2 of the License, or
015:         ** (at your option) any later version.
016:         ** 
017:         ** This program is distributed in the hope that it will be useful,
018:         ** but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
020:         ** GNU General Public License for more details.
021:         ** 
022:         ** You should have received a copy of the GNU Library General
023:         ** Public License along with this library; if not, write to the
024:         ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
025:         ** Boston, MA  02111-1307  USA.
026:         */
027:
028:        package uk.co.whisperingwind.vienna;
029:
030:        import java.awt.Component;
031:        import java.io.File;
032:        import java.sql.Connection;
033:        import javax.swing.JFileChooser;
034:        import uk.co.whisperingwind.framework.Controller;
035:        import uk.co.whisperingwind.framework.Dialogs;
036:        import uk.co.whisperingwind.framework.ModelEvent;
037:        import uk.co.whisperingwind.framework.ViewEvent;
038:
039:        class QueryController extends Controller {
040:            private QueryView queryView = null;
041:            private QueryModel queryModel = null;
042:            private ExportView exportView = null;
043:            private JFileChooser fileChooser = null;
044:
045:            public QueryController(ConfigModel configModel) {
046:                queryModel = new QueryModel(configModel);
047:                queryModel.addObserver(this );
048:                queryView = new QueryView(configModel, queryModel);
049:                queryView.addObserver(this );
050:            }
051:
052:            public Component getWidget() {
053:                return queryView.getContent();
054:            }
055:
056:            public void openFile(String fileName) {
057:                queryModel.openFile(fileName);
058:            }
059:
060:            public boolean saveFile() {
061:                return queryModel.saveFile();
062:            }
063:
064:            public boolean saveFileAs(String fileName) {
065:                return queryModel.saveFileAs(fileName);
066:            }
067:
068:            public void execute(Connection connection) {
069:                queryModel.execute(connection);
070:            }
071:
072:            public void cancelExecute() {
073:                queryModel.cancelExecute();
074:            }
075:
076:            public void editAction(String action) {
077:                queryView.editAction(action);
078:            }
079:
080:            public void focusText() {
081:                queryView.focusText();
082:            }
083:
084:            public boolean hasFileName() {
085:                return getFileName().length() > 0;
086:            }
087:
088:            public String getFileName() {
089:                return queryModel.getFileName();
090:            }
091:
092:            /*
093:             ** Returns true if the query model needs saving.
094:             */
095:
096:            public boolean isDirty() {
097:                return queryModel.isDirty();
098:            }
099:
100:            /*
101:             ** Set the view's status bar text.
102:             */
103:
104:            public void setStatus(String status) {
105:                queryView.setStatus(status);
106:            }
107:
108:            public boolean isExecuting() {
109:                return queryModel.isExecuting();
110:            }
111:
112:            public boolean hasSelection() {
113:                return queryView.hasSelection();
114:            }
115:
116:            public boolean canExport() {
117:                return queryModel.canExport();
118:            }
119:
120:            public void exportResult() {
121:                if (exportView == null) {
122:                    exportView = new ExportView(null, false);
123:                    exportView.addObserver(this );
124:                }
125:
126:                exportView.setVisible(true);
127:            }
128:
129:            public void viewEvent(ViewEvent event) {
130:                if (event.getInitiator() instanceof  QueryView)
131:                    fireEvent(event.getArg1(), (String) event.getArg2());
132:                else if (event.getInitiator() instanceof  ExportView)
133:                    handleExportEvent(event);
134:            }
135:
136:            public void undoEdit() {
137:                queryView.undoEdit();
138:            }
139:
140:            public void redoEdit() {
141:                queryView.redoEdit();
142:            }
143:
144:            public boolean canUndo() {
145:                return queryView.canUndo();
146:            }
147:
148:            public boolean canRedo() {
149:                return queryView.canRedo();
150:            }
151:
152:            private void handleExportEvent(ViewEvent event) {
153:                String action = event.getArg1();
154:
155:                if (action.equals("ok")) {
156:                    String fileName = exportView.getFileName();
157:                    String delimiter = exportView.getDelimiter();
158:                    String quoteString = exportView.getQuote();
159:                    boolean wantQuotes = exportView.getWantQuotes();
160:                    boolean wantTitles = exportView.getWantTitles();
161:
162:                    int rows = queryModel.exportResult(fileName, delimiter,
163:                            quoteString, wantQuotes, wantTitles);
164:
165:                    if (rows > 0) {
166:                        exportView.closeDialog();
167:                        exportView = null;
168:                        Dialogs.showInformation("Exported", "Exported " + rows
169:                                + " rows");
170:                    }
171:
172:                } else if (action.equals("cancel")) {
173:                    exportView.closeDialog();
174:                    exportView = null;
175:                } else if (action.equals("lookup")) {
176:                    if (fileChooser == null)
177:                        fileChooser = new JFileChooser();
178:                    else
179:                        fileChooser.rescanCurrentDirectory();
180:
181:                    fileChooser.setSelectedFile(new File(exportView
182:                            .getFileName()));
183:                    int result = fileChooser.showSaveDialog(exportView
184:                            .getContent());
185:
186:                    if (result == JFileChooser.APPROVE_OPTION) {
187:                        File theFile = fileChooser.getSelectedFile();
188:
189:                        if (theFile != null)
190:                            exportView.setFileName(theFile.getPath());
191:                    }
192:                }
193:            }
194:
195:            public void modelEvent(ModelEvent event) {
196:                String field = event.getField();
197:
198:                if (field.equals("updated")) {
199:                    fireEvent("updated", "");
200:                } else if (field.equals("execute")) {
201:                    String value = (String) event.getValue();
202:
203:                    if (value.equals("end"))
204:                        queryView.setTableModel(queryModel);
205:                }
206:            }
207:
208:            public void cleanUp() {
209:                queryView.cleanUp();
210:                queryModel.deleteObserver(this);
211:                queryView.deleteObserver(this);
212:                queryView = null;
213:                fileChooser = null;
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.