Source Code Cross Referenced for ExportDetailsPage.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.beans.PropertyChangeEvent;
004:        import java.beans.PropertyChangeListener;
005:        import java.io.File;
006:        import java.sql.SQLException;
007:        import java.util.Arrays;
008:
009:        import com.quantum.ImageStore;
010:        import com.quantum.QuantumPlugin;
011:        import com.quantum.flatfiles.MessageUtil;
012:        import com.quantum.model.Bookmark;
013:        import com.quantum.model.Schema;
014:        import com.quantum.ui.dialog.ExceptionDisplayDialog;
015:        import com.quantum.ui.dialog.SQLExceptionDialog;
016:        import com.quantum.util.DisplayableComparator;
017:        import com.quantum.util.connection.NotConnectedException;
018:        import com.quantum.view.widget.SimpleLabelProvider;
019:
020:        import org.eclipse.jface.viewers.ISelectionChangedListener;
021:        import org.eclipse.jface.viewers.IStructuredContentProvider;
022:        import org.eclipse.jface.viewers.IStructuredSelection;
023:        import org.eclipse.jface.viewers.SelectionChangedEvent;
024:        import org.eclipse.jface.viewers.TableViewer;
025:        import org.eclipse.jface.viewers.Viewer;
026:        import org.eclipse.jface.wizard.WizardPage;
027:        import org.eclipse.swt.SWT;
028:        import org.eclipse.swt.events.ModifyEvent;
029:        import org.eclipse.swt.events.ModifyListener;
030:        import org.eclipse.swt.events.SelectionAdapter;
031:        import org.eclipse.swt.events.SelectionEvent;
032:        import org.eclipse.swt.layout.GridData;
033:        import org.eclipse.swt.layout.GridLayout;
034:        import org.eclipse.swt.widgets.Button;
035:        import org.eclipse.swt.widgets.Combo;
036:        import org.eclipse.swt.widgets.Composite;
037:        import org.eclipse.swt.widgets.FileDialog;
038:        import org.eclipse.swt.widgets.Group;
039:        import org.eclipse.swt.widgets.Label;
040:        import org.eclipse.swt.widgets.Text;
041:
042:        /**
043:         * @author BC Holmes
044:         */
045:        public class ExportDetailsPage extends WizardPage {
046:
047:            public class ContentProviderImpl implements 
048:                    IStructuredContentProvider, PropertyChangeListener {
049:
050:                public Object[] getElements(Object inputElement) {
051:                    if (inputElement == null) {
052:                        return null;
053:                    } else if (inputElement instanceof  Bookmark
054:                            && ((Bookmark) inputElement).isConnected()) {
055:                        Schema[] schemas = new Schema[0];
056:                        try {
057:                            schemas = ((Bookmark) inputElement).getSchemas();
058:                            Arrays.sort(schemas, new DisplayableComparator());
059:                        } catch (NotConnectedException e) {
060:                            ExceptionDisplayDialog.openError(getShell(), null,
061:                                    null, e);
062:                        } catch (SQLException e) {
063:                            SQLExceptionDialog.openException(getShell(),
064:                                    (Bookmark) inputElement, e);
065:                        }
066:                        return schemas;
067:                    } else if (inputElement instanceof  Bookmark) {
068:                        return new Schema[0];
069:                    } else {
070:                        return null;
071:                    }
072:                }
073:
074:                public void dispose() {
075:                }
076:
077:                public void propertyChange(PropertyChangeEvent event) {
078:                    if ("connected".equals(event.getPropertyName())) {
079:                        refreshTable();
080:                    }
081:                }
082:
083:                public void inputChanged(Viewer viewer, Object oldInput,
084:                        Object newInput) {
085:                    if (newInput != null && newInput instanceof  Bookmark) {
086:                        if (oldInput != null && oldInput instanceof  Bookmark) {
087:                            ((Bookmark) oldInput)
088:                                    .removePropertyChangeListener(this );
089:                        }
090:
091:                        ((Bookmark) newInput).addPropertyChangeListener(this );
092:                    }
093:                }
094:            }
095:
096:            private Bookmark bookmark;
097:            private Schema schema;
098:            private String idMethod;
099:            private String fileName;
100:            private String databaseName;
101:            private TableViewer tableViewer;
102:            private ContentProviderImpl contentProvider;
103:
104:            protected void refreshTable() {
105:                if (this .bookmark.isConnected()) {
106:                    this .tableViewer.refresh();
107:                }
108:            }
109:
110:            public void dispose() {
111:                if (this .bookmark != null) {
112:                    this .bookmark
113:                            .removePropertyChangeListener(this .contentProvider);
114:                }
115:                super .dispose();
116:            }
117:
118:            /**
119:             * @param pageName
120:             */
121:            protected ExportDetailsPage(String pageName) {
122:                super (pageName);
123:
124:                setTitle(MessageUtil
125:                        .getString(ExportDetailsPage.class, "title"));
126:                setDescription(MessageUtil.getString(ExportDetailsPage.class,
127:                        "description"));
128:            }
129:
130:            public void createControl(Composite parent) {
131:
132:                Composite composite = new Composite(parent, SWT.NONE);
133:                composite.setLayout(new GridLayout(1, false));
134:
135:                composite.setLayoutData(new GridData(GridData.FILL_BOTH));
136:
137:                Label label = new Label(composite, SWT.NONE);
138:                label.setText(MessageUtil.getString(ExportDetailsPage.class,
139:                        "schema"));
140:                label.setLayoutData(new GridData(
141:                        GridData.VERTICAL_ALIGN_BEGINNING));
142:
143:                this .tableViewer = new TableViewer(composite);
144:                this .tableViewer.setLabelProvider(new SimpleLabelProvider(
145:                        ImageStore.getImage(ImageStore.SCHEMA, QuantumPlugin
146:                                .getDefault())));
147:                this .tableViewer
148:                        .setContentProvider(this .contentProvider = new ContentProviderImpl());
149:                if (this .bookmark != null) {
150:                    this .tableViewer.setInput(this .bookmark);
151:                }
152:                this .tableViewer.getControl().setLayoutData(
153:                        new GridData(GridData.FILL_BOTH));
154:
155:                this .tableViewer
156:                        .addSelectionChangedListener(new ISelectionChangedListener() {
157:                            public void selectionChanged(
158:                                    SelectionChangedEvent event) {
159:                                IStructuredSelection selection = (IStructuredSelection) event
160:                                        .getSelection();
161:                                setSchema(selection.isEmpty() ? null
162:                                        : (Schema) selection.getFirstElement());
163:                                updateState();
164:                            }
165:                        });
166:
167:                Group group = new Group(composite, SWT.NONE);
168:                group.setText(MessageUtil.getString(ExportDetailsPage.class,
169:                        "torque"));
170:                group.setLayout(new GridLayout(2, false));
171:                group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
172:
173:                label = new Label(group, SWT.NONE);
174:                label.setText(MessageUtil.getString(ExportDetailsPage.class,
175:                        "databaseName"));
176:
177:                Text databaseName = new Text(group, SWT.BORDER);
178:                databaseName.setLayoutData(new GridData(
179:                        GridData.FILL_HORIZONTAL));
180:                databaseName.addModifyListener(new ModifyListener() {
181:                    public void modifyText(ModifyEvent event) {
182:                        setDatabaseName(((Text) event.getSource()).getText());
183:                        updateState();
184:                    }
185:                });
186:
187:                label = new Label(group, SWT.NONE);
188:                label.setText(MessageUtil.getString(ExportDetailsPage.class,
189:                        "idMethod"));
190:
191:                Combo idMethodCombo = new Combo(group, SWT.READ_ONLY);
192:                idMethodCombo.setLayoutData(new GridData(
193:                        GridData.FILL_HORIZONTAL));
194:                idMethodCombo.setItems(new String[] { "none", "native",
195:                        "idbroker" });
196:
197:                idMethodCombo.addSelectionListener(new SelectionAdapter() {
198:                    public void widgetSelected(SelectionEvent event) {
199:                        setIdMethod(((Combo) event.getSource()).getText());
200:                        updateState();
201:                    }
202:                });
203:
204:                Label blankArea = new Label(composite, SWT.NONE);
205:                blankArea.setText("");
206:
207:                createDestinationArea(composite);
208:
209:                setControl(composite);
210:                updateState();
211:            }
212:
213:            private void createDestinationArea(Composite composite) {
214:                Composite fileArea = new Composite(composite, SWT.NULL);
215:                fileArea.setLayout(new GridLayout(3, false));
216:                fileArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
217:                        | GridData.VERTICAL_ALIGN_BEGINNING));
218:                Label label = new Label(fileArea, SWT.NONE);
219:                label.setText(MessageUtil.getString(ExportDetailsPage.class,
220:                        "fileName"));
221:
222:                final Text fileNameText = new Text(fileArea, SWT.BORDER);
223:                fileNameText.setLayoutData(new GridData(
224:                        GridData.FILL_HORIZONTAL));
225:                fileNameText.addModifyListener(new ModifyListener() {
226:                    public void modifyText(ModifyEvent event) {
227:                        String text = ((Text) event.getSource()).getText();
228:                        setFileName(text);
229:                        updateState();
230:                    }
231:                });
232:
233:                Button button = new Button(fileArea, SWT.NONE);
234:                button.setText(MessageUtil.getString(ExportDetailsPage.class,
235:                        "browse"));
236:                button.addSelectionListener(new SelectionAdapter() {
237:                    public void widgetSelected(SelectionEvent event) {
238:                        FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
239:                        dialog.setFilterExtensions(new String[] { "xml" });
240:                        dialog
241:                                .setFilterNames(new String[] { MessageUtil
242:                                        .getString(ExportDetailsPage.class,
243:                                                "xmlFiles") });
244:                        String filename = dialog.open();
245:                        if (filename != null) {
246:                            fileNameText.setText(filename);
247:                            setFileName(filename);
248:                            updateState();
249:                        }
250:                    }
251:                });
252:            }
253:
254:            protected void updateState() {
255:                boolean pageComplete = (this .bookmark != null && this .bookmark
256:                        .isConnected());
257:                pageComplete &= (this .databaseName != null && this .databaseName
258:                        .trim().length() > 0);
259:                pageComplete &= (this .fileName != null && !(new File(
260:                        this .fileName)).isDirectory());
261:                pageComplete &= (this .idMethod != null);
262:                pageComplete &= (this .schema != null);
263:
264:                setPageComplete(pageComplete);
265:            }
266:
267:            public Bookmark getBookmark() {
268:                return this .bookmark;
269:            }
270:
271:            public String getFileName() {
272:                return this .fileName;
273:            }
274:
275:            protected void setFileName(String fileName) {
276:                this .fileName = fileName;
277:            }
278:
279:            public String getDatabaseName() {
280:                return this .databaseName;
281:            }
282:
283:            public void setBookmark(Bookmark bookmark) {
284:                this .bookmark = bookmark;
285:                this .tableViewer.setInput(this .bookmark);
286:            }
287:
288:            public Schema getSchema() {
289:                return this .schema;
290:            }
291:
292:            public void setSchema(Schema schema) {
293:                this .schema = schema;
294:            }
295:
296:            public void setDatabaseName(String databaseName) {
297:                this .databaseName = databaseName;
298:            }
299:
300:            public String getIdMethod() {
301:                return this .idMethod;
302:            }
303:
304:            public void setIdMethod(String idMethod) {
305:                this.idMethod = idMethod;
306:            }
307:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.