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


001:        /*
002:         *    uDig - User Friendly Desktop Internet GIS client
003:         *    http://udig.refractions.net
004:         *    (C) 2004, Refractions Research Inc.
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package net.refractions.udig.catalog.internal.arcsde.ui;
018:
019:        import java.io.Serializable;
020:        import java.net.URL;
021:        import java.sql.Connection;
022:        import java.util.ArrayList;
023:        import java.util.Arrays;
024:        import java.util.HashMap;
025:        import java.util.List;
026:        import java.util.Map;
027:
028:        import net.refractions.udig.catalog.IService;
029:        import net.refractions.udig.catalog.arcsde.internal.Messages;
030:        import net.refractions.udig.catalog.internal.arcsde.ArcServiceExtension;
031:        import net.refractions.udig.catalog.internal.arcsde.ArcsdePlugin;
032:        import net.refractions.udig.catalog.ui.UDIGConnectionPage;
033:        import net.refractions.udig.catalog.ui.preferences.AbstractProprietaryDatastoreWizardPage;
034:        import net.refractions.udig.catalog.ui.preferences.AbstractProprietaryJarPreferencePage;
035:
036:        import org.eclipse.core.runtime.IProgressMonitor;
037:        import org.eclipse.jface.dialogs.IDialogSettings;
038:        import org.eclipse.swt.custom.CCombo;
039:        import org.eclipse.swt.events.ModifyEvent;
040:        import org.eclipse.swt.events.ModifyListener;
041:        import org.eclipse.swt.widgets.Composite;
042:        import org.eclipse.swt.widgets.Group;
043:        import org.eclipse.swt.widgets.Text;
044:        import org.geotools.data.DataStoreFactorySpi;
045:        import org.geotools.data.DataStoreFactorySpi.Param;
046:        import org.geotools.data.arcsde.ArcSDEDataStoreFactory;
047:
048:        /**
049:         * Provides ...TODO summary sentence
050:         * <p>
051:         * TODO Description
052:         * </p>
053:         * @author dzwiers
054:         * @since 0.6
055:         */
056:        public class ArcSDEWizardPage extends
057:                AbstractProprietaryDatastoreWizardPage implements 
058:                UDIGConnectionPage {
059:            private static final String ARCSDE_WIZARD = "ARCSDE_WIZARD"; //$NON-NLS-1$
060:            private static final String ARCSDE_RECENT = "ARCSDE_RECENT"; //$NON-NLS-1$
061:            private IDialogSettings settings;
062:            private static final int COMBO_HISTORY_LENGTH = 15;
063:            ArrayList<DataBaseConnInfo> dbData;
064:
065:            public ArcSDEWizardPage() {
066:                super (Messages.ArcSDEWizardPage_title);
067:                settings = ArcsdePlugin.getDefault().getDialogSettings()
068:                        .getSection(ARCSDE_WIZARD);
069:                if (settings == null) {
070:                    settings = ArcsdePlugin.getDefault().getDialogSettings()
071:                            .addNewSection(ARCSDE_WIZARD);
072:                }
073:            }
074:
075:            /**
076:             * TODO summary sentence for getDataStoreFactorySpi ...
077:             * 
078:             * @return x
079:             */
080:            protected DataStoreFactorySpi getDataStoreFactorySpi() {
081:                return factory;
082:            }
083:
084:            private static ArcSDEDataStoreFactory factory = new ArcSDEDataStoreFactory();
085:
086:            public String getId() {
087:                return "net.refractions.udig.catalog.ui.arcsde"; //$NON-NLS-1$
088:            }
089:
090:            /**
091:             * TODO summary sentence for getParams ...
092:             * 
093:             * @return x
094:             */
095:            public Map<String, Serializable> getParams() {
096:                Map<String, Serializable> params = new HashMap<String, Serializable>();
097:                Param[] dbParams = factory.getParametersInfo();
098:                params.put(dbParams[1].key, "arcsde"); //$NON-NLS-1$
099:                params.put(dbParams[2].key, getHostText());
100:                String port1 = getPortText();
101:                try {
102:                    params.put(dbParams[3].key, Integer.valueOf(port1));
103:                } catch (NumberFormatException e) {
104:                    params.put(dbParams[3].key, Integer.valueOf(5432));
105:                }
106:
107:                String db = getDBText();
108:                params.put(dbParams[4].key, db);
109:
110:                String user1 = getUserText();
111:                params.put(dbParams[5].key, user1);
112:                String pass1 = getPassText();
113:                params.put(dbParams[6].key, pass1);
114:
115:                return params;
116:            }
117:
118:            /**
119:             *
120:             * @return
121:             */
122:            protected String getPortText() {
123:                return this .port.getText();
124:            }
125:
126:            /**
127:             *
128:             * @return
129:             */
130:            protected String getPassText() {
131:                return this .pass.getText();
132:            }
133:
134:            /**
135:             *
136:             * @return
137:             */
138:            protected String getUserText() {
139:                return this .user.getText();
140:            }
141:
142:            /**
143:             *
144:             * @return
145:             */
146:            protected String getDBText() {
147:                return ((Text) database).getText();
148:            }
149:
150:            /**
151:             *
152:             * @return
153:             */
154:            protected String getHostText() {
155:                return ((CCombo) host).getText();
156:            }
157:
158:            public List<URL> getURLs() {
159:                return null;
160:            }
161:
162:            /**
163:             * TODO summary sentence for isDBCombo ...
164:             * 
165:             * @return x
166:             */
167:            protected boolean isDBCombo() {
168:                // instance?
169:                return false;
170:            }
171:
172:            protected boolean isHostCombo() {
173:                return true;
174:            }
175:
176:            /**
177:             * TODO summary sentence for hasSchema ...
178:             * 
179:             * @return x
180:             */
181:            protected boolean hasSchema() {
182:                return false;
183:            }
184:
185:            /**
186:             * TODO summary sentence for createAdvancedControl ...
187:             * 
188:             * @return x
189:             */
190:            protected Group createAdvancedControl(Composite arg0) {
191:                return null;
192:            }
193:
194:            /**
195:             * TODO summary sentence for getConnection ...
196:             * 
197:             * @return null
198:             */
199:            protected Connection getConnection() {
200:                return null;
201:            }
202:
203:            /**
204:             * TODO summary sentence for populateDB ...
205:             * 
206:             * 
207:             */
208:            protected void populateDB() {
209:                // do nothing
210:            }
211:
212:            /**
213:             * TODO summary sentence for populateSchema ...
214:             * 
215:             * 
216:             */
217:            protected void populateSchema() {
218:                // do nothing
219:            }
220:
221:            @Override
222:            protected boolean doIsPageComplete() {
223:                Map<String, Serializable> p = getParams();
224:                if (p == null)
225:                    return false;
226:                boolean r = factory.canProcess(p);
227:                return r;
228:            }
229:
230:            /*
231:             * @see net.refractions.udig.catalog.ui.UDIGImportPage#getResources(org.eclipse.core.runtime.IProgressMonitor)
232:             */
233:            public List<IService> getResources(IProgressMonitor monitor)
234:                    throws Exception {
235:                if (!isPageComplete())
236:                    return null;
237:
238:                ArcServiceExtension creator = new ArcServiceExtension();
239:
240:                IService service = creator.createService(null, getParams());
241:                service.getInfo(monitor); // load
242:
243:                List<IService> servers = new ArrayList<IService>();
244:                servers.add(service);
245:
246:                /*
247:                 * Success! Store the URL in history.
248:                 */
249:                saveWidgetValues();
250:
251:                return servers;
252:            }
253:
254:            /**
255:             * Saves the widget values
256:             */
257:            private void saveWidgetValues() {
258:                // Update history
259:                if (settings != null) {
260:                    String[] recentARCSDEs = settings.getArray(ARCSDE_RECENT);
261:                    if (recentARCSDEs == null) {
262:                        recentARCSDEs = new String[0];
263:                    }
264:                    String dbs = new DataBaseConnInfo(getHostText(), port
265:                            .getText(), user.getText(), pass.getText(),
266:                            getDBText(), schema.getText()).toString();
267:                    recentARCSDEs = addToHistory(recentARCSDEs, dbs);
268:                    settings.put(ARCSDE_RECENT, recentARCSDEs);
269:                }
270:            }
271:
272:            /**
273:             * Adds an entry to a history, while taking care of duplicate history items
274:             * and excessively long histories.  The assumption is made that all histories
275:             * should be of length <code>COMBO_HISTORY_LENGTH</code>.
276:             *
277:             * @param history the current history
278:             * @param newEntry the entry to add to the history
279:             * @return the history with the new entry appended
280:             * Stolen from org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage
281:             */
282:            private String[] addToHistory(String[] history, String newEntry) {
283:                ArrayList<String> l = new ArrayList<String>(Arrays
284:                        .asList(history));
285:                addToHistory(l, newEntry);
286:                String[] r = new String[l.size()];
287:                l.toArray(r);
288:                return r;
289:            }
290:
291:            /**
292:             * Adds an entry to a history, while taking care of duplicate history items
293:             * and excessively long histories.  The assumption is made that all histories
294:             * should be of length <code>COMBO_HISTORY_LENGTH</code>.
295:             *
296:             * @param history the current history
297:             * @param newEntry the entry to add to the history
298:             * Stolen from org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage
299:             */
300:            private void addToHistory(List<String> history, String newEntry) {
301:                history.remove(newEntry);
302:                history.add(0, newEntry);
303:
304:                // since only one new item was added, we can be over the limit
305:                // by at most one item
306:                if (history.size() > COMBO_HISTORY_LENGTH)
307:                    history.remove(COMBO_HISTORY_LENGTH);
308:            }
309:
310:            @Override
311:            protected void doCreateWizardPage(Composite parent) {
312:                String[] recentARCSDEs = settings.getArray(ARCSDE_RECENT);
313:                ArrayList<String> hosts = new ArrayList<String>();
314:                dbData = new ArrayList<DataBaseConnInfo>();
315:                if (recentARCSDEs != null) {
316:                    for (String recent : recentARCSDEs) {
317:                        DataBaseConnInfo dbs = new DataBaseConnInfo(recent);
318:                        dbData.add(dbs);
319:                        hosts.add(dbs.getHost());
320:                    }
321:                }
322:                if (hosts.size() > 0) {
323:                    ((CCombo) host).setItems(hosts.toArray(new String[0]));
324:                    ((CCombo) host).addModifyListener(new ModifyListener() {
325:                        public void modifyText(ModifyEvent e) {
326:                            if (e.widget != null) {
327:                                for (DataBaseConnInfo db : dbData) {
328:                                    if (db.getHost().equalsIgnoreCase(
329:                                            getHostText())) {
330:                                        port.setText(db.getPort());
331:                                        user.setText(db.getUser());
332:                                        pass.setText(db.getPass());
333:                                        ((Text) database).setText(db.getDb());
334:                                        schema.setText(db.getSchema());
335:                                        break;
336:                                    }
337:                                }
338:                            }
339:                        }
340:                    });
341:                }
342:            }
343:
344:            @Override
345:            protected String getDriversMessage() {
346:                return Messages.ArcSDEWizardPage_MissingDrivers;
347:            }
348:
349:            @Override
350:            protected AbstractProprietaryJarPreferencePage getPreferencePage() {
351:                return new ArcSDEPreferences();
352:            }
353:
354:            @Override
355:            protected String getRestartMessage() {
356:                return Messages.ArcSDEWizardPage_restartApp;
357:            }
358:        }
w__ww__._j__a__v_a___2__s__.__c_o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.