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


001:        package net.refractions.udig.catalog.internal.ui;
002:
003:        import java.io.Serializable;
004:        import java.net.UnknownHostException;
005:        import java.util.Iterator;
006:        import java.util.Map;
007:        import java.util.Map.Entry;
008:
009:        import net.refractions.udig.catalog.IService;
010:        import net.refractions.udig.catalog.ui.UDIGConnectionPage;
011:        import net.refractions.udig.catalog.ui.internal.Messages;
012:        import net.refractions.udig.catalog.ui.workflow.ConnectionState;
013:        import net.refractions.udig.catalog.ui.workflow.WorkflowWizardDialog;
014:        import net.refractions.udig.catalog.ui.workflow.WorkflowWizardPage;
015:        import net.refractions.udig.catalog.ui.workflow.Workflow.Listener;
016:        import net.refractions.udig.catalog.ui.workflow.Workflow.State;
017:        import net.refractions.udig.ui.PlatformGIS;
018:
019:        import org.eclipse.jface.wizard.IWizard;
020:        import org.eclipse.jface.wizard.IWizardPage;
021:        import org.eclipse.swt.graphics.Image;
022:        import org.eclipse.swt.widgets.Composite;
023:        import org.eclipse.swt.widgets.Display;
024:        import org.geotools.data.DataSourceException;
025:
026:        public class ConnectionPage extends WorkflowWizardPage implements 
027:                UDIGConnectionPage, Listener {
028:
029:            /** underlying import page **/
030:            UDIGConnectionPage page;
031:
032:            public ConnectionPage() {
033:                super ("connection"); //set name later //$NON-NLS-1$
034:            }
035:
036:            /**
037:             * @return The decorated page.
038:             * 
039:             */
040:            public UDIGConnectionPage getDecoratedPage() {
041:                return page;
042:            }
043:
044:            public Map<String, Serializable> getParams() {
045:                return page.getParams();
046:            }
047:
048:            @Override
049:            public void setState(State state) {
050:                super .setState(state);
051:
052:                //create the specific connection page
053:                page = ((ConnectionState) state).getConnectionFactory()
054:                        .createConnectionPage();
055:
056:                //do some setup
057:                page.setWizard(getWizard());
058:
059:                //we do the instance check to allow the connection page to 
060:                // optionally extend DataPipelinePage.
061:                if (page instanceof  WorkflowWizardPage) {
062:                    ((WorkflowWizardPage) page).setState(state);
063:                }
064:
065:                //add a listener to the workflow to determine when the workflow 
066:                // moves back, when this happens, we need to forget about the 
067:                // decorated page
068:                state.getWorkflow().addListener(this );
069:
070:            }
071:
072:            @Override
073:            public void shown() {
074:                super .shown();
075:
076:                if (page != null && page instanceof  WorkflowWizardPage) {
077:                    ((WorkflowWizardPage) page).shown();
078:                }
079:            }
080:
081:            public void createControl(Composite parent) {
082:                page.createControl(parent);
083:
084:                setControl(page.getControl());
085:
086:            }
087:
088:            @Override
089:            public boolean isPageComplete() {
090:                boolean complete = page.isPageComplete();
091:                if (complete) {
092:                    //set some context for the connection state
093:                    ConnectionState state = (ConnectionState) getState();
094:                    state.setParams(page.getParams());
095:                }
096:
097:                return complete;
098:            }
099:
100:            @Override
101:            public String getName() {
102:                return page.getName();
103:            }
104:
105:            @Override
106:            public Image getImage() {
107:                return page.getImage();
108:            }
109:
110:            @Override
111:            public String getDescription() {
112:                return page.getDescription();
113:            }
114:
115:            @Override
116:            public String getTitle() {
117:                return page.getTitle();
118:            }
119:
120:            @Override
121:            public String getMessage() {
122:                return page.getMessage();
123:            }
124:
125:            @Override
126:            public IWizardPage getNextPage() {
127:                IWizardPage newPage = this .page.getNextPage();
128:                return newPage;
129:            }
130:
131:            @Override
132:            public void setWizard(IWizard newWizard) {
133:                super .setWizard(newWizard);
134:                if (page != null)
135:                    page.setWizard(newWizard);
136:            }
137:
138:            @Override
139:            public void setVisible(boolean visible) {
140:                if (getControl() != null)
141:                    super .setVisible(visible);
142:            }
143:
144:            public void forward(State current, State prev) {
145:                // TODO Auto-generated method stub
146:
147:            }
148:
149:            public void backward(State current, State next) {
150:                if (next != null && next instanceof  ConnectionState) {
151:                    //reset decorated page
152:                    page = null;
153:
154:                    getControl().getDisplay().syncExec(new Runnable() {
155:                        public void run() {
156:                            getControl().dispose();
157:                        }
158:                    });
159:
160:                    setControl(null);
161:                }
162:            }
163:
164:            public void statePassed(State state) {
165:                PlatformGIS.syncInDisplayThread(new Runnable() {
166:                    public void run() {
167:                        setErrorMessage(null);
168:                    }
169:                });
170:            }
171:
172:            public void stateFailed(State state) {
173:                if (state instanceof  ConnectionState) {
174:                    ConnectionState connectionState = (ConnectionState) state;
175:                    Map<IService, Throwable> errors = connectionState
176:                            .getErrors();
177:                    Iterator<Entry<IService, Throwable>> iterator = errors
178:                            .entrySet().iterator();
179:                    if (iterator.hasNext()) {
180:                        Entry<IService, Throwable> entry = iterator.next();
181:                        Throwable t = entry.getValue();
182:                        final String message = formatException(entry.getKey(),
183:                                t);
184:                        if (Display.getCurrent() == null) {
185:                            Display.getDefault().asyncExec(new Runnable() {
186:                                public void run() {
187:                                    page.setErrorMessage(message);
188:                                }
189:                            });
190:                        } else
191:                            page.setErrorMessage(message);
192:                    }
193:                }
194:            }
195:
196:            private String formatException(IService key, Throwable t) {
197:                if (t instanceof  UnknownHostException) {
198:                    return key.getIdentifier().getHost()
199:                            + Messages.ConnectionPage_illegalHost;
200:                }
201:                if (t instanceof  DataSourceException) {
202:                    String message = t.getMessage();
203:                    if (message.contains("user") && message.contains("does not exist")) //$NON-NLS-1$ //$NON-NLS-2$
204:                        return Messages.ConnectionPage_badUsername;
205:                    if (message.contains("password")) //$NON-NLS-1$
206:                        return Messages.ConnectionPage_badPassword;
207:                }
208:                return Messages.ConnectionPage_genericError;
209:            }
210:
211:            public void started(State first) {
212:
213:            }
214:
215:            public void finished(State last) {
216:                if (!(getContainer() instanceof  WorkflowWizardDialog)
217:                        && getContainer() != null) {
218:                    getWizard().performFinish();
219:                }
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.