Source Code Cross Referenced for WizardImportPage.java in  » IDE-Eclipse » ui-ide » org » eclipse » ui » dialogs » 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 » IDE Eclipse » ui ide » org.eclipse.ui.dialogs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.dialogs;
011:
012:        import org.eclipse.core.resources.IContainer;
013:        import org.eclipse.core.resources.IResource;
014:        import org.eclipse.core.resources.IWorkspace;
015:        import org.eclipse.core.runtime.IPath;
016:        import org.eclipse.core.runtime.IStatus;
017:        import org.eclipse.jface.dialogs.MessageDialog;
018:        import org.eclipse.jface.viewers.IStructuredSelection;
019:        import org.eclipse.swt.SWT;
020:        import org.eclipse.swt.layout.GridData;
021:        import org.eclipse.swt.layout.GridLayout;
022:        import org.eclipse.swt.widgets.Button;
023:        import org.eclipse.swt.widgets.Composite;
024:        import org.eclipse.swt.widgets.Event;
025:        import org.eclipse.swt.widgets.Label;
026:        import org.eclipse.swt.widgets.Text;
027:        import org.eclipse.swt.widgets.Widget;
028:        import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
029:        import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
030:
031:        /**
032:         * The abstract superclass for a typical import wizard's main page.
033:         * <p>
034:         * Clients may subclass this page to inherit its common destination resource
035:         * selection facilities.
036:         * </p>
037:         * <p>
038:         * Subclasses must implement 
039:         * <ul>
040:         *   <li><code>createSourceGroup</code></li>
041:         * </ul>
042:         * </p>
043:         * <p>
044:         * Subclasses may override
045:         * <ul>
046:         *   <li><code>allowNewContainerName</code></li>
047:         * </ul>
048:         * </p>
049:         * <p>
050:         * Subclasses may extend
051:         * <ul>
052:         *   <li><code>handleEvent</code></li>
053:         * </ul>
054:         * </p>
055:         * @deprecated use WizardResourceImportPage
056:         */
057:        public abstract class WizardImportPage extends WizardDataTransferPage {
058:            private IResource currentResourceSelection;
059:
060:            // initial value stores
061:            private String initialContainerFieldValue;
062:
063:            // widgets
064:            private Text containerNameField;
065:
066:            private Button containerBrowseButton;
067:
068:            /**
069:             * Creates an import wizard page. If the initial resource selection 
070:             * contains exactly one container resource then it will be used as the default
071:             * import destination.
072:             *
073:             * @param name the name of the page
074:             * @param selection the current resource selection
075:             */
076:            protected WizardImportPage(String name,
077:                    IStructuredSelection selection) {
078:                super (name);
079:
080:                if (selection.size() == 1) {
081:                    currentResourceSelection = (IResource) selection
082:                            .getFirstElement();
083:                } else {
084:                    currentResourceSelection = null;
085:                }
086:
087:                if (currentResourceSelection != null) {
088:                    if (currentResourceSelection.getType() == IResource.FILE) {
089:                        currentResourceSelection = currentResourceSelection
090:                                .getParent();
091:                    }
092:
093:                    if (!currentResourceSelection.isAccessible()) {
094:                        currentResourceSelection = null;
095:                    }
096:                }
097:
098:            }
099:
100:            /**
101:             * The <code>WizardImportPage</code> implementation of this 
102:             * <code>WizardDataTransferPage</code> method returns <code>true</code>. 
103:             * Subclasses may override this method.
104:             */
105:            protected boolean allowNewContainerName() {
106:                return true;
107:            }
108:
109:            /** (non-Javadoc)
110:             * Method declared on IDialogPage.
111:             */
112:            public void createControl(Composite parent) {
113:                Composite composite = new Composite(parent, SWT.NULL);
114:                composite.setLayout(new GridLayout());
115:                composite.setLayoutData(new GridData(
116:                        GridData.VERTICAL_ALIGN_FILL
117:                                | GridData.HORIZONTAL_ALIGN_FILL));
118:                composite.setSize(composite.computeSize(SWT.DEFAULT,
119:                        SWT.DEFAULT));
120:
121:                createSourceGroup(composite);
122:
123:                createSpacer(composite);
124:
125:                createBoldLabel(composite,
126:                        IDEWorkbenchMessages.WizardImportPage_destinationLabel);
127:                createDestinationGroup(composite);
128:
129:                createSpacer(composite);
130:
131:                createBoldLabel(composite,
132:                        IDEWorkbenchMessages.WizardImportPage_options);
133:                createOptionsGroup(composite);
134:
135:                restoreWidgetValues();
136:                updateWidgetEnablements();
137:                setPageComplete(determinePageCompletion());
138:
139:                setControl(composite);
140:            }
141:
142:            /**
143:             * Creates the import destination specification controls.
144:             *
145:             * @param parent the parent control
146:             */
147:            protected final void createDestinationGroup(Composite parent) {
148:                // container specification group
149:                Composite containerGroup = new Composite(parent, SWT.NONE);
150:                GridLayout layout = new GridLayout();
151:                layout.numColumns = 3;
152:                containerGroup.setLayout(layout);
153:                containerGroup.setLayoutData(new GridData(
154:                        GridData.HORIZONTAL_ALIGN_FILL
155:                                | GridData.GRAB_HORIZONTAL));
156:
157:                // container label
158:                Label resourcesLabel = new Label(containerGroup, SWT.NONE);
159:                resourcesLabel
160:                        .setText(IDEWorkbenchMessages.WizardImportPage_folder);
161:
162:                // container name entry field
163:                containerNameField = new Text(containerGroup, SWT.SINGLE
164:                        | SWT.BORDER);
165:                containerNameField.addListener(SWT.Modify, this );
166:                GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
167:                        | GridData.GRAB_HORIZONTAL);
168:                data.widthHint = SIZING_TEXT_FIELD_WIDTH;
169:                containerNameField.setLayoutData(data);
170:
171:                // container browse button
172:                containerBrowseButton = new Button(containerGroup, SWT.PUSH);
173:                containerBrowseButton
174:                        .setText(IDEWorkbenchMessages.WizardImportPage_browseLabel);
175:                containerBrowseButton.setLayoutData(new GridData(
176:                        GridData.HORIZONTAL_ALIGN_FILL));
177:                containerBrowseButton.addListener(SWT.Selection, this );
178:
179:                initialPopulateContainerField();
180:            }
181:
182:            /**
183:             * Creates the import source specification controls.
184:             * <p>
185:             * Subclasses must implement this method.
186:             * </p>
187:             *
188:             * @param parent the parent control
189:             */
190:            protected abstract void createSourceGroup(Composite parent);
191:
192:            /**
193:             * Display an error dialog with the specified message.
194:             *
195:             * @param message the error message
196:             */
197:            protected void displayErrorDialog(String message) {
198:                MessageDialog.openError(getContainer().getShell(),
199:                        IDEWorkbenchMessages.WizardImportPage_errorDialogTitle,
200:                        message);
201:            }
202:
203:            /**
204:             * Returns the path of the container resource specified in the container
205:             * name entry field, or <code>null</code> if no name has been typed in.
206:             * <p>
207:             * The container specified by the full path might not exist and would need to
208:             * be created.
209:             * </p>
210:             *
211:             * @return the full path of the container resource specified in
212:             *   the container name entry field, or <code>null</code>
213:             */
214:            protected IPath getContainerFullPath() {
215:                IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
216:
217:                //make the path absolute to allow for optional leading slash
218:                IPath testPath = getResourcePath();
219:
220:                IStatus result = workspace.validatePath(testPath.toString(),
221:                        IResource.PROJECT | IResource.FOLDER);
222:                if (result.isOK()) {
223:                    return testPath;
224:                }
225:
226:                return null;
227:            }
228:
229:            /**
230:             * Return the path for the resource field.
231:             * @return org.eclipse.core.runtime.IPath
232:             */
233:            protected IPath getResourcePath() {
234:                return getPathFromText(this .containerNameField);
235:            }
236:
237:            /**
238:             * Returns the container resource specified in the container name entry field,
239:             * or <code>null</code> if such a container does not exist in the workbench.
240:             *
241:             * @return the container resource specified in the container name entry field,
242:             *   or <code>null</code>
243:             */
244:            protected IContainer getSpecifiedContainer() {
245:                IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
246:                IPath path = getContainerFullPath();
247:                if (workspace.getRoot().exists(path)) {
248:                    return (IContainer) workspace.getRoot().findMember(path);
249:                }
250:
251:                return null;
252:            }
253:
254:            /**
255:             * Opens a container selection dialog and displays the user's subsequent
256:             * container resource selection in this page's container name field.
257:             */
258:            protected void handleContainerBrowseButtonPressed() {
259:                // see if the user wishes to modify this container selection
260:                IPath containerPath = queryForContainer(
261:                        getSpecifiedContainer(),
262:                        IDEWorkbenchMessages.WizardImportPage_selectFolderLabel);
263:
264:                // if a container was selected then put its name in the container name field
265:                if (containerPath != null) {
266:                    containerNameField.setText(containerPath.makeRelative()
267:                            .toString());
268:                }
269:            }
270:
271:            /**
272:             * The <code>WizardImportPage</code> implementation of this 
273:             * <code>Listener</code> method handles all events and enablements for controls
274:             * on this page. Subclasses may extend.
275:             */
276:            public void handleEvent(Event event) {
277:                Widget source = event.widget;
278:
279:                if (source == containerBrowseButton) {
280:                    handleContainerBrowseButtonPressed();
281:                }
282:
283:                setPageComplete(determinePageCompletion());
284:                updateWidgetEnablements();
285:            }
286:
287:            /**
288:             * Sets the initial contents of the container name field.
289:             */
290:            protected final void initialPopulateContainerField() {
291:                if (initialContainerFieldValue != null) {
292:                    containerNameField.setText(initialContainerFieldValue);
293:                } else if (currentResourceSelection != null) {
294:                    containerNameField.setText(currentResourceSelection
295:                            .getFullPath().toString());
296:                }
297:            }
298:
299:            /**
300:             * Sets the value of this page's container resource field, or stores
301:             * it for future use if this page's controls do not exist yet.
302:             *
303:             * @param value new value
304:             */
305:            public void setContainerFieldValue(String value) {
306:                if (containerNameField == null) {
307:                    initialContainerFieldValue = value;
308:                } else {
309:                    containerNameField.setText(value);
310:                }
311:            }
312:
313:            /* (non-Javadoc)
314:             * Method declared on WizardDataTransferPage.
315:             */
316:            protected final boolean validateDestinationGroup() {
317:                if (getContainerFullPath() == null) {
318:                    return false;
319:                }
320:
321:                // If the container exist, validate it
322:                IContainer container = getSpecifiedContainer();
323:                if (container != null) {
324:                    if (!container.isAccessible()) {
325:                        setErrorMessage(IDEWorkbenchMessages.WizardImportPage_folderMustExist);
326:                        return false;
327:                    }
328:                }
329:
330:                return true;
331:
332:            }
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.