Source Code Cross Referenced for ConnectionErrorPage.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 java.io.ByteArrayOutputStream;
004:        import java.io.PrintStream;
005:        import java.util.Map;
006:
007:        import net.refractions.udig.catalog.IService;
008:        import net.refractions.udig.catalog.internal.ui.ConnectionPage;
009:        import net.refractions.udig.catalog.ui.internal.Messages;
010:        import net.refractions.udig.catalog.ui.workflow.ConnectionErrorState;
011:        import net.refractions.udig.catalog.ui.workflow.WorkflowWizardPage;
012:
013:        import org.eclipse.jface.viewers.ArrayContentProvider;
014:        import org.eclipse.jface.viewers.ISelectionChangedListener;
015:        import org.eclipse.jface.viewers.IStructuredSelection;
016:        import org.eclipse.jface.viewers.LabelProvider;
017:        import org.eclipse.jface.viewers.ListViewer;
018:        import org.eclipse.jface.viewers.SelectionChangedEvent;
019:        import org.eclipse.jface.wizard.IWizardPage;
020:        import org.eclipse.swt.SWT;
021:        import org.eclipse.swt.layout.FormAttachment;
022:        import org.eclipse.swt.layout.FormData;
023:        import org.eclipse.swt.layout.FormLayout;
024:        import org.eclipse.swt.widgets.Composite;
025:        import org.eclipse.swt.widgets.Control;
026:        import org.eclipse.swt.widgets.Label;
027:        import org.eclipse.swt.widgets.Text;
028:
029:        /**
030:         * A wizard page which displays a set of IConnectionErrorHandler objects.
031:         * <p>
032:         * This page is intended for use in a wizard extending
033:         * 
034:         * @see net.refractions.udig.catalog.ui.UDIGImportPage to connect to a service.
035:         *      </p>
036:         * @author Justin Deoliveira
037:         */
038:        public class ConnectionErrorPage extends WorkflowWizardPage {
039:
040:            /** the current handler * */
041:            IConnectionErrorHandler handler;
042:
043:            public ConnectionErrorPage() {
044:                super (Messages.ConnectionErrorPage_pageName);
045:
046:                setDescription(Messages.ConnectionErrorPage_pageDescription);
047:                setTitle(Messages.ConnectionErrorPage_pageTitle);
048:            }
049:
050:            @Override
051:            public boolean isPageComplete() {
052:                return handler.isComplete();
053:            }
054:
055:            @Override
056:            public boolean canFlipToNextPage() {
057:                if (handler != null)
058:                    return handler.canRecover();
059:
060:                return false;
061:            }
062:
063:            public void createControl(Composite parent) {
064:
065:                ConnectionErrorState state = (ConnectionErrorState) getState();
066:
067:                handler = new SimpleConnectionErrorHandler(state.getErrors());
068:                handler.createControl(parent);
069:
070:                setControl(handler.getControl());
071:            }
072:
073:            @Override
074:            public IWizardPage getNextPage() {
075:                if (handler.canRecover() && handler.isComplete()) {
076:                    ConnectionPage page = (ConnectionPage) getPreviousPage();
077:                    return page.getNextPage();
078:                }
079:
080:                return super .getNextPage();
081:            }
082:
083:            static class SimpleConnectionErrorHandler extends
084:                    IConnectionErrorHandler {
085:
086:                Map<IService, Throwable> errors;
087:
088:                SimpleConnectionErrorHandler(Map<IService, Throwable> errors) {
089:                    this .errors = errors;
090:
091:                    setName("Simple"); //$NON-NLS-1$
092:                }
093:
094:                @Override
095:                public boolean canHandle(IService service, Throwable t) {
096:                    return true;
097:                }
098:
099:                @Override
100:                public boolean canRecover() {
101:                    return false;
102:                }
103:
104:                @Override
105:                protected Control create(Composite parent) {
106:                    Composite root = new Composite(parent, SWT.NONE);
107:                    root.setLayout(new FormLayout());
108:
109:                    Label label = new Label(root, SWT.LEFT);
110:                    label.setText(Messages.ConnectionErrorPage_message);
111:
112:                    ListViewer listViewer = new ListViewer(root);
113:                    listViewer.setLabelProvider(new LabelProvider() {
114:                        @Override
115:                        public String getText(Object element) {
116:                            IService service = (IService) element;
117:                            return service.getIdentifier().toString();
118:                        }
119:                    });
120:                    listViewer.setContentProvider(new ArrayContentProvider());
121:                    listViewer.setInput(errors.keySet().toArray());
122:
123:                    final Text text = new Text(root, SWT.BORDER | SWT.MULTI
124:                            | SWT.V_SCROLL | SWT.SCROLL_LINE);
125:
126:                    FormData layoutData = new FormData();
127:                    layoutData.top = new FormAttachment(0);
128:                    layoutData.left = new FormAttachment(0);
129:                    label.setLayoutData(layoutData);
130:
131:                    layoutData = new FormData();
132:                    layoutData.top = new FormAttachment(label, 2, SWT.BOTTOM);
133:                    layoutData.left = new FormAttachment(0);
134:                    layoutData.right = new FormAttachment(100);
135:                    layoutData.bottom = new FormAttachment(50);
136:                    listViewer.getList().setLayoutData(layoutData);
137:
138:                    layoutData = new FormData();
139:                    layoutData.top = new FormAttachment(listViewer.getList(),
140:                            2, SWT.BOTTOM);
141:                    layoutData.left = new FormAttachment(0);
142:                    layoutData.right = new FormAttachment(100);
143:                    layoutData.bottom = new FormAttachment(100);
144:                    text.setLayoutData(layoutData);
145:
146:                    listViewer
147:                            .addSelectionChangedListener(new ISelectionChangedListener() {
148:
149:                                public void selectionChanged(
150:                                        SelectionChangedEvent event) {
151:                                    IStructuredSelection selection = (IStructuredSelection) event
152:                                            .getSelection();
153:                                    if (selection == null
154:                                            || selection.isEmpty())
155:                                        return;
156:
157:                                    IService service = (IService) selection
158:                                            .getFirstElement();
159:                                    Throwable t = errors.get(service);
160:
161:                                    ByteArrayOutputStream out = new ByteArrayOutputStream();
162:                                    t.printStackTrace(new PrintStream(out));
163:                                    text.setText(new String(out.toByteArray()));
164:                                }
165:                            });
166:
167:                    return root;
168:                }
169:
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.