Source Code Cross Referenced for ExportDDLWizardFileSelectionPage.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.InputStream;
006:
007:        import org.eclipse.jface.viewers.StructuredSelection;
008:        import org.eclipse.swt.SWT;
009:        import org.eclipse.swt.events.SelectionAdapter;
010:        import org.eclipse.swt.events.SelectionEvent;
011:        import org.eclipse.swt.layout.GridData;
012:        import org.eclipse.swt.layout.GridLayout;
013:        import org.eclipse.swt.widgets.Button;
014:        import org.eclipse.swt.widgets.Composite;
015:        import org.eclipse.swt.widgets.Control;
016:        import org.eclipse.swt.widgets.Label;
017:        import org.eclipse.swt.widgets.Text;
018:        import org.eclipse.swt.widgets.Tree;
019:        import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
020:
021:        import com.quantum.flatfiles.MessageUtil;
022:        import com.quantum.view.widget.ErrorMessageDisplayer;
023:        import com.quantum.view.widget.FileSelectionWidget;
024:
025:        /**
026:         * @author BC Holmes
027:         */
028:        public class ExportDDLWizardFileSelectionPage extends
029:                WizardNewFileCreationPage implements  ErrorMessageDisplayer,
030:                PropertyChangeListener {
031:
032:            private Tree resourceTree;
033:            private Text resourceName;
034:            private Text workspaceFileName;
035:
036:            private final InputStreamProvider inputStreamProvider;
037:            private FileSelectionWidget fileSelection;
038:            private boolean saveInFileSystem = true;
039:
040:            /**
041:             * Creates a new wizard page. 
042:             *
043:             * @param pageName the name of the page
044:             */
045:            public ExportDDLWizardFileSelectionPage(String pageName,
046:                    InputStreamProvider inputStreamProvider) {
047:                super (pageName, new StructuredSelection());
048:                this .inputStreamProvider = inputStreamProvider;
049:                setFileName("create.sql");
050:                setTitle(MessageUtil.getString(getClass(), "title"));
051:                setDescription(MessageUtil.getString(getClass(), "description"));
052:            }
053:
054:            public void createControl(Composite parent) {
055:                Composite topLevel1 = new Composite(parent, SWT.NONE);
056:                topLevel1.setLayout(new GridLayout(2, false));
057:                topLevel1.setLayoutData(new GridData(
058:                        GridData.VERTICAL_ALIGN_FILL
059:                                | GridData.HORIZONTAL_ALIGN_FILL));
060:                Button fileSystemRadioButton = new Button(topLevel1, SWT.RADIO);
061:                GridData gridData = new GridData();
062:                gridData.horizontalSpan = 2;
063:                fileSystemRadioButton.setLayoutData(gridData);
064:                fileSystemRadioButton.setText(MessageUtil.getString(getClass(),
065:                        "saveInFileSystem"));
066:                fileSystemRadioButton
067:                        .addSelectionListener(new SelectionAdapter() {
068:                            public void widgetSelected(SelectionEvent event) {
069:                                Button button = (Button) event.getSource();
070:                                changeOptions(button.getSelection());
071:                            }
072:                        });
073:                Label label = new Label(topLevel1, SWT.NONE);
074:                label.setText("");
075:
076:                this .fileSelection = new FileSelectionWidget(topLevel1,
077:                        SWT.NONE, this );
078:
079:                Button workspaceRadioButton = new Button(topLevel1, SWT.RADIO);
080:                gridData = new GridData();
081:                gridData.horizontalSpan = 2;
082:                workspaceRadioButton.setLayoutData(gridData);
083:                workspaceRadioButton.setText(MessageUtil.getString(getClass(),
084:                        "saveInWorkspace"));
085:                workspaceRadioButton
086:                        .addSelectionListener(new SelectionAdapter() {
087:                            public void widgetSelected(SelectionEvent event) {
088:                                Button button = (Button) event.getSource();
089:                                changeOptions(!button.getSelection());
090:                            }
091:                        });
092:
093:                label = new Label(topLevel1, SWT.NONE);
094:                label.setText("");
095:                Composite composite = new Composite(topLevel1, SWT.NONE);
096:                composite.setLayout(new GridLayout());
097:                composite.setLayoutData(new GridData(GridData.FILL_BOTH));
098:                super .createControl(composite);
099:
100:                Composite control = (Composite) getControl();
101:                findParts(control);
102:
103:                setControl(topLevel1);
104:
105:                fileSystemRadioButton.setSelection(true);
106:                changeOptions(true);
107:                this .fileSelection.addPropertyChangeListener(this );
108:            }
109:
110:            /**
111:             * I worry that this approach to finding the sub-components is fragile, but the 
112:             * Eclipse API doesn't really give me a better alternative.
113:             * @param composite
114:             */
115:            private void findParts(Composite composite) {
116:                Control[] controls = composite.getChildren();
117:                for (int i = 0, length = (controls == null ? 0
118:                        : controls.length); i < length; i++) {
119:                    if (controls[i] instanceof  Tree) {
120:                        this .resourceTree = (Tree) controls[i];
121:                    } else if (controls[i] instanceof  Composite) {
122:                        findParts((Composite) controls[i]);
123:                    } else if (controls[i] instanceof  Text
124:                            && this .resourceName != null) {
125:                        this .workspaceFileName = (Text) controls[i];
126:                    } else if (controls[i] instanceof  Text
127:                            && this .resourceName == null) {
128:                        this .resourceName = (Text) controls[i];
129:                    } else if (controls[i] instanceof  Button) {
130:                        Button button = (Button) controls[i];
131:                        button.setVisible(false);
132:                        button.setEnabled(false);
133:                    }
134:                }
135:            }
136:
137:            private void changeOptions(boolean fileSystem) {
138:                if (this .resourceName != null) {
139:                    this .resourceName.setEnabled(!fileSystem);
140:                }
141:                if (this .resourceTree != null) {
142:                    this .resourceTree.setEnabled(!fileSystem);
143:                }
144:                if (this .workspaceFileName != null) {
145:                    this .workspaceFileName.setEnabled(!fileSystem);
146:                }
147:
148:                this .fileSelection.setEnabled(fileSystem);
149:                if (fileSystem) {
150:                    setPageComplete(this .fileSelection.getFile() != null);
151:                } else {
152:                    setPageComplete(super .validatePage());
153:                }
154:                this .saveInFileSystem = fileSystem;
155:            }
156:
157:            public void dispose() {
158:                super .dispose();
159:                this .fileSelection.removePropertyChangeListener(this );
160:            }
161:
162:            /**
163:             * Returns a stream containing the initial contents to be given to new file resource
164:             * instances.  <b>Subclasses</b> may wish to override.  This default implementation
165:             * provides no initial contents.
166:             *
167:             * @return initial contents to be given to new file resource instances
168:             */
169:            protected InputStream getInitialContents() {
170:                return this .inputStreamProvider.getInputStream();
171:            }
172:
173:            public void propertyChange(PropertyChangeEvent event) {
174:                if ("file".equals(event.getPropertyName())) {
175:                    setPageComplete(event.getNewValue() != null);
176:                }
177:            }
178:
179:            public Object createOutputFile() {
180:                if (this.saveInFileSystem) {
181:                    return this.fileSelection.createFile(getInitialContents());
182:                } else {
183:                    return createNewFile();
184:                }
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.