Source Code Cross Referenced for IDataWizard.java in  » GIS » udig-1.1 » net » refractions » udig » catalog » ui » 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 » GIS » udig 1.1 » net.refractions.udig.catalog.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.refractions.udig.catalog.ui;
002:
003:        import org.eclipse.jface.dialogs.IDialogSettings;
004:        import org.eclipse.jface.viewers.IStructuredSelection;
005:        import org.eclipse.jface.viewers.StructuredSelection;
006:        import org.eclipse.jface.wizard.IWizardPage;
007:        import org.eclipse.jface.wizard.Wizard;
008:        import org.eclipse.jface.wizard.WizardPage;
009:        import org.eclipse.ui.IWorkbench;
010:        import org.eclipse.ui.IWorkbenchWizard;
011:
012:        /**
013:         * A wizard which is used to import data into udig.
014:         * <p>
015:         * This is wizard is made up of <b>primary</b> pages, and <b>secondary</b> pages. A primary page
016:         * is an
017:         * 
018:         * @see org.eclipse.jface.wizard.IWizardPage that the wizard declares it will contain. A secondary
019:         *      page is a page which is dynamically contributed to the wizard via a primary page, or another
020:         *      secondary page.
021:         *      </p>
022:         *      <p>
023:         *      Sublcasses declare the ordered set of primary pages with the getPrimaryPages() method.
024:         *      Secondary pages are contributed dynamically by returning them from a call to
025:         * @see org.eclipse.jface.wizard.IWizardPage#getNextPage().
026:         *      </p>
027:         *      <p>
028:         *      Secondary page processing will continue, until a page returns null from getNextPage().
029:         *      Processing then continues at the next primary page. If no more primary pages exist, the
030:         *      wizard finishes.
031:         *      </p>
032:         *      <p>
033:         *      If using an IDataWizard outside of the workbench wizard framework, it is up to client code
034:         *      to call
035:         * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
036:         *      org.eclipse.jface.viewers.IStructuredSelection) immediatly after instantiating the wizard.
037:         *      </p>
038:         *      <p>
039:         *      The following are requirements on the pages of the wizard.
040:         *      <ul>
041:         *      <li>They must extend from
042:         * @see org.eclipse.jface.wizard.WizardPage
043:         *      <li>getNextPage must either return a new wizard page, or super.getNextPage()
044:         *      <li>init(WizardPage) must be called before returning a page from
045:         *      </ul>
046:         *      <p>
047:         *      Example: <code>
048:         * 	public IWizardPage getNextPage() {
049:         * 		if (returnNewPage) {
050:         * 			WizardPage newPage = new WizardPage(....);
051:         * 			IDataWizard wizard = (IDataWizard)getWizard();
052:         * 			wizard.init(page);
053:         * 			return page;
054:         * 		}
055:         * 
056:         * 		return super.getNextPage();
057:         * 	}
058:         * </code>
059:         *      </p>
060:         *      It is important to note that pages inside this wizard must return a page or
061:         *      super.getNextPage() from getNextPage().
062:         *      </p>
063:         *      <p>
064:         *      This wizard creates dialog settings for pages upon creation.
065:         *      </p>
066:         * @author Justin Deoliveira,Refractions Research Inc.,jdeolive@refractions.net
067:         */
068:        public abstract class IDataWizard extends Wizard implements 
069:                IWorkbenchWizard {
070:
071:            static final String SETTINGS = "IDataWizard"; //$NON-NLS-1$
072:
073:            /** the primary wizard pages * */
074:            WizardPage[] pages;
075:
076:            /** the selection * */
077:            IStructuredSelection selection = new StructuredSelection();
078:
079:            /** the workbench * */
080:            IWorkbench workbench;
081:
082:            public IDataWizard() {
083:                // set up dialog settings
084:                IDialogSettings settings = CatalogUIPlugin.getDefault()
085:                        .getDialogSettings().getSection(SETTINGS);
086:                if (settings == null) {
087:                    settings = CatalogUIPlugin.getDefault().getDialogSettings()
088:                            .addNewSection(SETTINGS);
089:                }
090:                setDialogSettings(settings);
091:            }
092:
093:            /**
094:             * @see IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
095:             *      org.eclipse.jface.viewers.IStructuredSelection)
096:             */
097:            public void init(IWorkbench workbench,
098:                    IStructuredSelection selection) {
099:                this .workbench = workbench;
100:                this .selection = selection;
101:
102:                setNeedsProgressMonitor(true);
103:            }
104:
105:            /**
106:             * @return the selection the wizard was initialized with.
107:             */
108:            public IStructuredSelection getSelection() {
109:                return selection;
110:            }
111:
112:            /**
113:             * @return the workbench the wizard was initialized with.
114:             */
115:            public IWorkbench getWorkbench() {
116:                return workbench;
117:            }
118:
119:            /**
120:             * Adds the primary pages to the wizard.
121:             * 
122:             * @see org.eclipse.jface.wizard.IWizard#addPages()
123:             */
124:            public void addPages() {
125:                this .pages = getPrimaryPages();
126:                for (int i = 0; i < pages.length; i++) {
127:                    init(pages[i]);
128:                    addPage(pages[i]);
129:                }
130:            }
131:
132:            /**
133:             * Returns the next primary page in the page sequence. This method is called by the
134:             * 
135:             * @see org.eclipse.jface.wizard.IWizardContainer when a page does not contribute a secondary
136:             *      page.
137:             * @see org.eclipse.jface.wizard.IWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
138:             */
139:            public IWizardPage getNextPage(IWizardPage page) {
140:                // a string of pages is done, find next primary
141:                return getNextPrimaryPage(page);
142:            }
143:
144:            /**
145:             * Determines if the wizard has any more primary pages.
146:             * 
147:             * @return True if so, otherwise false.
148:             */
149:            public boolean hasMorePrimaryPages() {
150:                return getNextPrimaryPage(getContainer().getCurrentPage()) != null;
151:            }
152:
153:            /**
154:             * Returns the next primary page, based on the current page.
155:             * 
156:             * @param page A primary page, or secondary page.
157:             * @return The next primary page, or null if no more in sequence.
158:             */
159:            private IWizardPage getNextPrimaryPage(IWizardPage page) {
160:                // back up until we reach a primary page
161:                IWizardPage[] primary = getPages();
162:
163:                while (page != null) {
164:                    // do an index of in primary list
165:                    for (int i = 0; i < primary.length; i++) {
166:                        if (page == primary[i]) {
167:                            // found it, make sure not last page
168:                            if (i == primary.length - 1) {
169:                                return null;
170:                            }
171:                            return primary[i + 1];
172:                        }
173:                    }
174:                    page = page.getPreviousPage();
175:                }
176:
177:                return null;
178:            }
179:
180:            /**
181:             * @see org.eclipse.jface.wizard.IWizard#needsPreviousAndNextButtons()
182:             */
183:            public boolean needsPreviousAndNextButtons() {
184:                return true;
185:            }
186:
187:            @Override
188:            /**
189:             * Determines if there are any more pages in the sequence.
190:             * <p>
191:             * The wizard can finish if the following 3 properies hold.
192:             * <ol>
193:             * <li>The current page is complete (@see IWizardPage#isPageComplete())
194:             * <li>The current page can not flip to the next page (@see IWizardPage#canFlipToNextPage())
195:             * <li>There are no more primary pages.
196:             * </ol>
197:             * </p>
198:             * 
199:             * @see org.eclipse.jface.wizard.IWizard#canFinish()
200:             */
201:            public boolean canFinish() {
202:                // check if current page is complete
203:                IWizardPage page = getContainer().getCurrentPage();
204:                if (!page.isPageComplete())
205:                    return false;
206:
207:                // first as the page if it has more pages
208:                if (page.canFlipToNextPage()) {
209:                    return false;
210:                }
211:
212:                // find out if there is another primary page
213:                return getNextPrimaryPage(page) == null;
214:            }
215:
216:            /**
217:             * Initializes a wizard page for use in the data wizard. This method should be called by pages
218:             * returning a new page from getNextPage().
219:             * 
220:             * @param page The page to be initialized.
221:             */
222:            public void init(WizardPage page) {
223:                page.setWizard(this );
224:            }
225:
226:            /**
227:             * Returns the set of primary pages. This method is called while the wizard is being
228:             * instantiated.
229:             */
230:            protected abstract WizardPage[] getPrimaryPages();
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.