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


001:        /* uDig - User Friendly Desktop Internet GIS client
002:         * http://udig.refractions.net
003:         * (C) 2004, Refractions Research Inc.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation;
008:         * version 2.1 of the License.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         */
015:        package net.refractions.udig.catalog.ui.workflow;
016:
017:        import java.util.ArrayList;
018:        import java.util.Arrays;
019:        import java.util.Collection;
020:        import java.util.Comparator;
021:        import java.util.List;
022:        import java.util.Map;
023:        import java.util.Set;
024:        import java.util.Map.Entry;
025:
026:        import net.refractions.udig.catalog.ui.internal.Messages;
027:        import net.refractions.udig.catalog.ui.workflow.ConnectionFailureState.Data;
028:
029:        import org.eclipse.jface.viewers.ColumnWeightData;
030:        import org.eclipse.jface.viewers.ILabelProvider;
031:        import org.eclipse.jface.viewers.ILabelProviderListener;
032:        import org.eclipse.jface.viewers.ISelectionChangedListener;
033:        import org.eclipse.jface.viewers.IStructuredSelection;
034:        import org.eclipse.jface.viewers.ITreeContentProvider;
035:        import org.eclipse.jface.viewers.SelectionChangedEvent;
036:        import org.eclipse.jface.viewers.TableLayout;
037:        import org.eclipse.jface.viewers.TreeViewer;
038:        import org.eclipse.jface.viewers.Viewer;
039:        import org.eclipse.jface.viewers.ViewerSorter;
040:        import org.eclipse.swt.SWT;
041:        import org.eclipse.swt.custom.SashForm;
042:        import org.eclipse.swt.graphics.Image;
043:        import org.eclipse.swt.layout.FillLayout;
044:        import org.eclipse.swt.widgets.Composite;
045:        import org.eclipse.swt.widgets.Text;
046:        import org.eclipse.swt.widgets.Tree;
047:        import org.eclipse.swt.widgets.TreeItem;
048:
049:        /**
050:         * Wizard Page associated with ConnectionFailurePage
051:         * 
052:         * @author Jesse
053:         * @since 1.1.0
054:         */
055:        public class ConnectionFailurePage extends WorkflowWizardPage implements 
056:                ILabelProvider, ITreeContentProvider {
057:
058:            private TreeViewer viewer;
059:            private Text details;
060:            private static String canProcess = Messages.ConnectionFailurePage_canProcess;
061:
062:            public ConnectionFailurePage() {
063:                super (Messages.ConnectionFailurePage_title);
064:                setTitle(Messages.ConnectionFailurePage_displayedTitle);
065:                setMessage(Messages.ConnectionFailurePage_message);
066:            }
067:
068:            public void createControl(Composite parent) {
069:                SashForm form = new SashForm(parent, SWT.VERTICAL);
070:                Tree tree = new Tree(form, SWT.V_SCROLL | SWT.SINGLE);
071:                TableLayout layout = new TableLayout();
072:                layout.addColumnData(new ColumnWeightData(100, false));
073:                tree.setLayout(layout);
074:                tree.setLinesVisible(true);
075:                viewer = new TreeViewer(tree);
076:
077:                viewer.setContentProvider(this );
078:                viewer.setLabelProvider(this );
079:
080:                viewer
081:                        .addPostSelectionChangedListener(new ISelectionChangedListener() {
082:
083:                            public void selectionChanged(
084:                                    SelectionChangedEvent event) {
085:                                setDetails();
086:                            }
087:                        });
088:
089:                viewer.setSorter(new ViewerSorter() {
090:                    @Override
091:                    public void sort(Viewer viewer, Object[] elements) {
092:                        Arrays.sort(elements, new Comparator<Object>() {
093:
094:                            public int compare(Object o1, Object o2) {
095:                                return 0;
096:                            }
097:
098:                        });
099:                    }
100:
101:                });
102:
103:                Composite composite = new Composite(form, SWT.BORDER);
104:                composite.setLayout(new FillLayout());
105:                details = new Text(composite, SWT.BORDER | SWT.WRAP
106:                        | SWT.READ_ONLY | SWT.V_SCROLL);
107:
108:                form.setWeights(new int[] { 75, 25 });
109:
110:                setControl(form);
111:            }
112:
113:            private void setDetails() {
114:                Object firstElement = ((IStructuredSelection) viewer
115:                        .getSelection()).getFirstElement();
116:                if (firstElement instanceof  Data) {
117:                    Data data = (Data) firstElement;
118:                    String string = data.message;
119:                    if (string == null)
120:                        string = canProcess;
121:                    details.setText(string);
122:                } else {
123:                    details.setText(Messages.ConnectionFailurePage_selectChild);
124:                }
125:            }
126:
127:            @Override
128:            public void shown() {
129:                viewer.setInput(getState().getReports());
130:                if (viewer.getTree().getItemCount() > 0) {
131:                    TreeItem item = viewer.getTree().getItem(0);
132:                    viewer.getTree().setSelection(item);
133:
134:                    setDetails();
135:                }
136:            }
137:
138:            public ConnectionFailureState getState() {
139:                return (ConnectionFailureState) super .getState();
140:            }
141:
142:            @Override
143:            public boolean canFlipToNextPage() {
144:                return false;
145:            }
146:
147:            public void addListener(ILabelProviderListener listener) {
148:            }
149:
150:            public boolean isLabelProperty(Object element, String property) {
151:                return false;
152:            }
153:
154:            public void removeListener(ILabelProviderListener listener) {
155:            }
156:
157:            public Image getImage(Object element) {
158:                return null;
159:            }
160:
161:            @SuppressWarnings("unchecked")
162:            public String getText(Object element) {
163:                if (element instanceof  Entry) {
164:                    Entry<String, List<Data>> entry = (Entry<String, List<Data>>) element;
165:                    return entry.getValue().get(0).name;
166:                }
167:                if (element instanceof  Data) {
168:                    Data data = (Data) element;
169:                    if (getParent(element) == getState().getReports())
170:                        return data.name;
171:                    return data.url.toString();
172:                }
173:                return null;
174:            }
175:
176:            @SuppressWarnings("unchecked")
177:            public Object[] getChildren(Object parentElement) {
178:                if (parentElement instanceof  Map) {
179:                    Map<String, List<Data>> map = (Map<String, List<Data>>) parentElement;
180:                    if (map.values().iterator().next().size() == 1) {
181:
182:                        // no need for hierarchy since each element only has a single data.
183:                        Collection<List<Data>> values = map.values();
184:                        List<Data> all = new ArrayList<Data>();
185:                        for (List<Data> list : values) {
186:                            all.addAll(list);
187:                        }
188:                        return all.toArray();
189:                    } else {
190:                        return map.entrySet().toArray();
191:                    }
192:                }
193:                if (parentElement instanceof  Entry) {
194:                    Entry<String, List<Data>> entry = (Entry<String, List<Data>>) parentElement;
195:                    return entry.getValue().toArray();
196:                }
197:                if (parentElement instanceof  Data) {
198:                    return null;
199:                }
200:                return null;
201:            }
202:
203:            public Object getParent(Object parentElement) {
204:                if (parentElement instanceof  Map) {
205:                    return null;
206:                }
207:                if (parentElement instanceof  Entry) {
208:                    return getState().getReports();
209:                }
210:                if (parentElement instanceof  Data) {
211:                    Set<Entry<String, List<Data>>> set = getState()
212:                            .getReports().entrySet();
213:                    Data data = (Data) parentElement;
214:                    for (Entry<String, List<Data>> entry : set) {
215:                        if (entry.getKey().equals(data.id)) {
216:                            if (entry.getValue().size() == 1)
217:                                return getState().getReports();
218:                            return entry;
219:                        }
220:                    }
221:                }
222:                return null;
223:            }
224:
225:            public boolean hasChildren(Object parentElement) {
226:                if (parentElement instanceof  Map) {
227:                    return true;
228:                }
229:                if (parentElement instanceof  Entry) {
230:                    return true;
231:                }
232:                if (parentElement instanceof  Data) {
233:                    return false;
234:                }
235:                return false;
236:            }
237:
238:            public Object[] getElements(Object elements) {
239:                return getChildren(elements);
240:            }
241:
242:            public void inputChanged(Viewer viewer, Object oldInput,
243:                    Object newInput) {
244:            }
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.