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


001:        package net.refractions.udig.project.ui.internal.wizard.url;
002:
003:        import java.io.Serializable;
004:        import java.net.MalformedURLException;
005:        import java.net.URL;
006:        import java.util.ArrayList;
007:        import java.util.Arrays;
008:        import java.util.List;
009:        import java.util.Map;
010:
011:        import net.refractions.udig.catalog.CatalogPlugin;
012:        import net.refractions.udig.catalog.IService;
013:        import net.refractions.udig.catalog.internal.ServiceFactoryImpl;
014:        import net.refractions.udig.catalog.ui.UDIGConnectionPage;
015:        import net.refractions.udig.project.ui.internal.Messages;
016:        import net.refractions.udig.project.ui.internal.ProjectUIPlugin;
017:
018:        import org.eclipse.core.runtime.IProgressMonitor;
019:        import org.eclipse.jface.dialogs.IDialogSettings;
020:        import org.eclipse.jface.wizard.IWizardPage;
021:        import org.eclipse.jface.wizard.WizardPage;
022:        import org.eclipse.swt.SWT;
023:        import org.eclipse.swt.events.ModifyEvent;
024:        import org.eclipse.swt.events.ModifyListener;
025:        import org.eclipse.swt.events.SelectionEvent;
026:        import org.eclipse.swt.layout.GridData;
027:        import org.eclipse.swt.layout.GridLayout;
028:        import org.eclipse.swt.widgets.Combo;
029:        import org.eclipse.swt.widgets.Composite;
030:        import org.eclipse.swt.widgets.Label;
031:
032:        /**
033:         * @author Amr Alam TODO To change the template for this generated type comment go to Window -
034:         *         Preferences - Java - Code Style - Code Templates
035:         */
036:        public class URLWizardPage extends WizardPage implements 
037:                ModifyListener, UDIGConnectionPage {
038:
039:            final static String[] types = {};
040:            /** <code>url</code> field */
041:            protected Combo url;
042:            private static final String URL_WIZARD = "URL_WIZARD"; //$NON-NLS-1$
043:            private static final String URL_RECENT = "URL_RECENT"; //$NON-NLS-1$
044:            private IDialogSettings settings;
045:            private static final int COMBO_HISTORY_LENGTH = 15;
046:
047:            /**
048:             * Construct <code>URLWizardPage</code>.
049:             */
050:            public URLWizardPage() {
051:                super (Messages.URLWizardPage_title);
052:
053:                settings = ProjectUIPlugin.getDefault().getDialogSettings()
054:                        .getSection(URL_WIZARD);
055:                if (settings == null) {
056:                    settings = ProjectUIPlugin.getDefault().getDialogSettings()
057:                            .addNewSection(URL_WIZARD);
058:                }
059:            }
060:
061:            public String getId() {
062:                // TODO Auto-generated method stub
063:                return null;
064:            }
065:
066:            public boolean canProcess(Object object) {
067:                URL url = CatalogPlugin.locateURL(object);
068:                if (url == null) {
069:                    return false;
070:                }
071:                return true;
072:            }
073:
074:            public Map<String, Serializable> toParams(Object object) {
075:                return null;
076:            }
077:
078:            public void createControl(Composite parent) {
079:                String[] recentURLs = settings.getArray(URL_RECENT);
080:                if (recentURLs == null) {
081:                    recentURLs = new String[0];
082:                }
083:
084:                GridData gridData;
085:                Composite composite = new Composite(parent, SWT.NULL);
086:
087:                GridLayout gridLayout = new GridLayout();
088:                int columns = 1;
089:                gridLayout.numColumns = columns;
090:                composite.setLayout(gridLayout);
091:
092:                gridData = new GridData();
093:
094:                Label urlLabel = new Label(composite, SWT.NONE);
095:                urlLabel.setText(Messages.URLWizardPage_label_url_text);
096:                urlLabel.setLayoutData(gridData);
097:
098:                gridData = new GridData(GridData.FILL_HORIZONTAL);
099:                gridData.widthHint = 400;
100:
101:                url = new Combo(composite, SWT.BORDER);
102:                url.setItems(recentURLs);
103:                url.setVisibleItemCount(15);
104:                url.setLayoutData(gridData);
105:                url.setText("http://"); //$NON-NLS-1$
106:                url.addModifyListener(this );
107:
108:                setControl(composite);
109:                setPageComplete(true);
110:            }
111:
112:            public boolean isPageComplete() {
113:                try {
114:                    new URL(url.getText());
115:                } catch (MalformedURLException e) {
116:                    return false;
117:                }
118:                return true;
119:            }
120:
121:            public boolean canFlipToNextPage() {
122:                // return canFlip;
123:                IWizardPage[] pages = getWizard().getPages();
124:                return isPageComplete()
125:                        && !pages[pages.length - 1].equals(this );
126:            }
127:
128:            /**
129:             * Double click in list, or return from url control.
130:             * 
131:             * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
132:             * @param e
133:             */
134:            public void widgetDefaultSelected(SelectionEvent e) {
135:                e.getClass();// kill warning
136:                if (getWizard().canFinish()) {
137:                    getWizard().performFinish();
138:                }
139:            }
140:
141:            /**
142:             * This should be called using the Wizard .. job when next/finish is pressed.
143:             */
144:            public List<IService> getResources(IProgressMonitor monitor)
145:                    throws Exception {
146:                URL location = new URL(url.getText());
147:                ServiceFactoryImpl serviceFactory = new ServiceFactoryImpl();
148:                List<IService> services = serviceFactory.acquire(location);
149:                /*
150:                 * Success! Store the URL in history.
151:                 */
152:                saveWidgetValues();
153:                return services;
154:            }
155:
156:            public void modifyText(ModifyEvent e) {
157:                try {
158:                    new URL(url.getText());
159:                    setErrorMessage(null);
160:                } catch (MalformedURLException exception) {
161:                    setErrorMessage(Messages.URLWizardPage_error_invalidURL);
162:                }
163:                getWizard().getContainer().updateButtons();
164:            }
165:
166:            /**
167:             * Saves the widget values
168:             */
169:            private void saveWidgetValues() {
170:                // Update history
171:                if (settings != null) {
172:                    String[] recentURLs = settings.getArray(URL_RECENT);
173:                    if (recentURLs == null) {
174:                        recentURLs = new String[0];
175:                    }
176:                    recentURLs = addToHistory(recentURLs, url.getText());
177:                    settings.put(URL_RECENT, recentURLs);
178:                }
179:            }
180:
181:            /**
182:             * Adds an entry to a history, while taking care of duplicate history items and excessively long
183:             * histories. The assumption is made that all histories should be of length
184:             * <code>COMBO_HISTORY_LENGTH</code>.
185:             * 
186:             * @param history the current history
187:             * @param newEntry the entry to add to the history
188:             * @return the history with the new entry appended Stolen from
189:             *         org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage
190:             */
191:            private String[] addToHistory(String[] history, String newEntry) {
192:                ArrayList<String> l = new ArrayList<String>(Arrays
193:                        .asList(history));
194:                addToHistory(l, newEntry);
195:                String[] r = new String[l.size()];
196:                l.toArray(r);
197:                return r;
198:            }
199:
200:            /**
201:             * Adds an entry to a history, while taking care of duplicate history items and excessively long
202:             * histories. The assumption is made that all histories should be of length
203:             * <code>COMBO_HISTORY_LENGTH</code>.
204:             * 
205:             * @param history the current history
206:             * @param newEntry the entry to add to the history Stolen from
207:             *        org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage
208:             */
209:            private void addToHistory(List<String> history, String newEntry) {
210:                history.remove(newEntry);
211:                history.add(0, newEntry);
212:
213:                // since only one new item was added, we can be over the limit
214:                // by at most one item
215:                if (history.size() > COMBO_HISTORY_LENGTH)
216:                    history.remove(COMBO_HISTORY_LENGTH);
217:            }
218:
219:            public Map<String, Serializable> getParams() {
220:                // TODO Auto-generated method stub
221:                return null;
222:            }
223:
224:            public List<URL> getURLs() {
225:                // TODO Auto-generated method stub
226:                return null;
227:            }
228:        }
w___w_w.j_a___v___a___2_s_.c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.