Source Code Cross Referenced for ExportResultSetDataWizardPage.java in  » Database-Client » QuantumDB » com » quantum » flatfiles » wizard » 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 » QuantumDB » com.quantum.flatfiles.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.quantum.flatfiles.wizard;
002:
003:        import java.io.File;
004:
005:        import com.quantum.QuantumPlugin;
006:        import com.quantum.flatfiles.MessageUtil;
007:        import com.quantum.flatfiles.QuantumFlatFilesPlugin;
008:        import com.quantum.flatfiles.converter.ConverterFactory;
009:        import com.quantum.flatfiles.preferences.CSVPreferences;
010:        import com.quantum.sql.SQLResultSetResults;
011:        import com.quantum.sql.Scrollable;
012:        import com.quantum.view.widget.ComboViewer;
013:        import com.quantum.wizards.PropertyChangeWizardPage;
014:
015:        import org.eclipse.jface.preference.IPreferenceStore;
016:        import org.eclipse.jface.viewers.ISelectionChangedListener;
017:        import org.eclipse.jface.viewers.IStructuredContentProvider;
018:        import org.eclipse.jface.viewers.IStructuredSelection;
019:        import org.eclipse.jface.viewers.LabelProvider;
020:        import org.eclipse.jface.viewers.SelectionChangedEvent;
021:        import org.eclipse.jface.viewers.StructuredSelection;
022:        import org.eclipse.jface.viewers.Viewer;
023:        import org.eclipse.swt.SWT;
024:        import org.eclipse.swt.events.ModifyEvent;
025:        import org.eclipse.swt.events.ModifyListener;
026:        import org.eclipse.swt.events.SelectionAdapter;
027:        import org.eclipse.swt.events.SelectionEvent;
028:        import org.eclipse.swt.layout.GridData;
029:        import org.eclipse.swt.layout.GridLayout;
030:        import org.eclipse.swt.widgets.Button;
031:        import org.eclipse.swt.widgets.Composite;
032:        import org.eclipse.swt.widgets.FileDialog;
033:        import org.eclipse.swt.widgets.Group;
034:        import org.eclipse.swt.widgets.Label;
035:        import org.eclipse.swt.widgets.Text;
036:
037:        /**
038:         * @author BC Holmes
039:         */
040:        class ExportResultSetDataWizardPage extends PropertyChangeWizardPage {
041:
042:            private final SQLResultSetResults results;
043:
044:            private Text fileName;
045:            private Button overwrite;
046:            private String exportType = ConverterFactory.EXCEL_SPREADSHEET;
047:
048:            /**
049:             * @param pageName
050:             */
051:            protected ExportResultSetDataWizardPage(String pageName,
052:                    SQLResultSetResults results) {
053:                super (pageName);
054:                setTitle(MessageUtil.getString(getClass(), "title"));
055:                setDescription(MessageUtil.getString(getClass(), "description"));
056:                this .results = results;
057:            }
058:
059:            public void createControl(Composite parent) {
060:                setPageComplete(false);
061:
062:                Composite composite = new Composite(parent, SWT.NULL);
063:                composite.setLayout(new GridLayout(3, false));
064:                composite.setLayoutData(new GridData(GridData.FILL_BOTH));
065:
066:                createRowsPart(composite);
067:
068:                Label label = new Label(composite, SWT.NULL);
069:                label.setText(MessageUtil.getString(getClass(), "fileName"));
070:                this .fileName = new Text(composite, SWT.BORDER | SWT.SINGLE);
071:                this .fileName.setLayoutData(new GridData(
072:                        GridData.FILL_HORIZONTAL));
073:
074:                Button browse = new Button(composite, SWT.PUSH);
075:                browse.setText(MessageUtil.getString(getClass(), "browse"));
076:                browse.setLayoutData(new GridData(
077:                        GridData.HORIZONTAL_ALIGN_FILL));
078:                browse.addSelectionListener(new SelectionAdapter() {
079:                    public void widgetSelected(SelectionEvent event) {
080:                        FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
081:                        String filename = dialog.open();
082:                        if (filename != null) {
083:                            ExportResultSetDataWizardPage.this .fileName
084:                                    .setText(filename);
085:                            validate(filename);
086:                        }
087:                    }
088:                });
089:
090:                this .fileName.addModifyListener(new ModifyListener() {
091:                    public void modifyText(ModifyEvent event) {
092:                        validate(((Text) event.getSource()).getText());
093:                    }
094:                });
095:
096:                label = new Label(composite, SWT.NULL);
097:                label
098:                        .setText(MessageUtil.getString(getClass(),
099:                                "exportFormat"));
100:
101:                ComboViewer viewer = new ComboViewer(composite);
102:                viewer.getControl().setLayoutData(
103:                        new GridData(GridData.FILL_HORIZONTAL));
104:                viewer.setContentProvider(new IStructuredContentProvider() {
105:                    public void dispose() {
106:                    }
107:
108:                    public void inputChanged(Viewer viewer, Object oldInput,
109:                            Object newInput) {
110:                    }
111:
112:                    public Object[] getElements(Object inputElement) {
113:                        if (inputElement instanceof  String[]) {
114:                            return (String[]) inputElement;
115:                        } else {
116:                            return null;
117:                        }
118:                    }
119:                });
120:                viewer.setLabelProvider(new LabelProvider() {
121:                    public String getText(Object element) {
122:                        return element == null ? "" : MessageUtil.getString(
123:                                ConverterFactory.class, (String) element);
124:                    }
125:                });
126:                viewer.setInput(ConverterFactory.getConverterTypes());
127:                viewer.setSelection(new StructuredSelection(
128:                        ConverterFactory.EXCEL_SPREADSHEET));
129:                viewer
130:                        .addSelectionChangedListener(new ISelectionChangedListener() {
131:                            public void selectionChanged(
132:                                    SelectionChangedEvent event) {
133:                                IStructuredSelection selection = (IStructuredSelection) event
134:                                        .getSelection();
135:                                setExportType(selection.isEmpty() ? null
136:                                        : (String) selection.getFirstElement());
137:                            }
138:                        });
139:
140:                Label filler = new Label(composite, SWT.NULL);
141:                filler.setText("");
142:                filler.setLayoutData(new GridData(
143:                        GridData.HORIZONTAL_ALIGN_BEGINNING));
144:
145:                IPreferenceStore store = QuantumPlugin.getDefault()
146:                        .getPreferenceStore();
147:                boolean confirmOverwrite = store
148:                        .getBoolean(com.quantum.PluginPreferences.EXPORT_CONFIRM_OVERWRITE);
149:
150:                this .overwrite = new Button(composite, SWT.CHECK);
151:                overwrite.setSelection(confirmOverwrite);
152:                this .overwrite.setText(MessageUtil.getString(getClass(),
153:                        "overwrite"));
154:                GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
155:                gridData.horizontalSpan = 3;
156:                this .overwrite.setLayoutData(gridData);
157:
158:                setControl(composite);
159:            }
160:
161:            protected void setExportType(String exportType) {
162:                this .exportType = exportType;
163:                IPreferenceStore store = QuantumFlatFilesPlugin.getDefault()
164:                        .getPreferenceStore();
165:                // Set the default filename for CSV from the preferences
166:                String defaultCSVFileName = store
167:                        .getString(CSVPreferences.DEFAULT_PATH)
168:                        + store.getString(CSVPreferences.DEFAULT_FILE_NAME);
169:                if (exportType.equals(ConverterFactory.COMMA_SEPARATED_VALUES)) {
170:                    if (this .fileName.getText().equals("")) {
171:                        this .fileName.setText(defaultCSVFileName);
172:                    }
173:                } else {
174:                    // If the text equals the default for CSV, and CSV is not selected, it's
175:                    // likely that's a left-over. We blank the text.
176:                    if (this .fileName.getText().equals(defaultCSVFileName)) {
177:                        this .fileName.setText("");
178:                    }
179:                }
180:            }
181:
182:            private void validate(String fileName) {
183:                File file = new File(fileName);
184:                if (file.exists() && file.isFile()) {
185:                    setErrorMessage(null);
186:                    setPageComplete(true);
187:                } else if (!file.exists() && !fileName.endsWith(File.separator)) {
188:                    setErrorMessage(null);
189:                    setPageComplete(true);
190:                } else {
191:                    setErrorMessage(MessageUtil.getString(getClass(),
192:                            "invalidFileName"));
193:                    setPageComplete(false);
194:                }
195:            }
196:
197:            /**
198:             * @param composite
199:             */
200:            private void createRowsPart(Composite composite) {
201:                Group group = new Group(composite, SWT.NULL);
202:                group.setText(MessageUtil.getString(getClass(), "rows"));
203:                GridData data = new GridData(GridData.FILL_HORIZONTAL);
204:                data.horizontalSpan = 3;
205:                group.setLayout(new GridLayout());
206:                group.setLayoutData(data);
207:
208:                Button allRowsButton = new Button(group, SWT.RADIO);
209:                allRowsButton.setText(MessageUtil.getString(getClass(),
210:                        "allRows"));
211:
212:                Button currentRowsButton = new Button(group, SWT.RADIO);
213:                if (this .results instanceof  Scrollable) {
214:                    Scrollable scrollable = (Scrollable) this .results;
215:                    currentRowsButton.setText(MessageUtil.getString(getClass(),
216:                            "currentRowsWithRange", new Object[] {
217:                                    new Integer(scrollable.getStart()),
218:                                    new Integer(scrollable.getEnd()) }));
219:                    if (scrollable.hasNextPage()
220:                            || scrollable.hasPreviousPage()) {
221:                        currentRowsButton.setSelection(true);
222:                    } else {
223:                        currentRowsButton.setEnabled(false);
224:                    }
225:                } else {
226:                    currentRowsButton.setText(MessageUtil.getString(getClass(),
227:                            "currentRows"));
228:                    currentRowsButton.setEnabled(false);
229:                }
230:            }
231:
232:            public String getFileName() {
233:                return this .fileName == null ? null : this .fileName.getText();
234:            }
235:
236:            public boolean overwriteFile() {
237:                return this .overwrite == null ? false : this .overwrite
238:                        .getSelection();
239:            }
240:
241:            public String getExportType() {
242:                return exportType;
243:            }
244:
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.