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


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 2007 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.ide.undo;
011:
012:        import java.net.URI;
013:
014:        import org.eclipse.core.filesystem.URIUtil;
015:        import org.eclipse.core.resources.IProject;
016:        import org.eclipse.core.resources.IProjectDescription;
017:        import org.eclipse.core.resources.IResource;
018:        import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory;
019:        import org.eclipse.core.runtime.Assert;
020:        import org.eclipse.core.runtime.CoreException;
021:        import org.eclipse.core.runtime.IAdaptable;
022:        import org.eclipse.core.runtime.IProgressMonitor;
023:        import org.eclipse.core.runtime.IStatus;
024:        import org.eclipse.core.runtime.Platform;
025:        import org.eclipse.core.runtime.Status;
026:        import org.eclipse.ui.internal.ide.undo.UndoMessages;
027:
028:        /**
029:         * A MoveProjectOperation represents an undoable operation for moving a
030:         * project's content to a different location. Clients may call the public API
031:         * from a background thread.
032:         * 
033:         * This class is intended to be instantiated and used by clients. It is not
034:         * intended to be subclassed by clients.
035:         * 
036:         * @since 3.3
037:         * 
038:         */
039:        public class MoveProjectOperation extends
040:                AbstractCopyOrMoveResourcesOperation {
041:
042:            private URI projectLocation;
043:
044:            /**
045:             * Create a MoveProjectOperation that moves the specified project contents
046:             * to a new location.
047:             * 
048:             * @param project
049:             *            the project to be moved
050:             * @param location
051:             *            the location for the project
052:             * @param label
053:             *            the label of the operation
054:             */
055:            public MoveProjectOperation(IProject project, URI location,
056:                    String label) {
057:                super (new IResource[] { project }, label);
058:                Assert.isLegal(project != null);
059:                if (URIUtil.toPath(location).equals(Platform.getLocation())) {
060:                    projectLocation = null;
061:                } else {
062:                    projectLocation = location;
063:                }
064:            }
065:
066:            /*
067:             * (non-Javadoc)
068:             * 
069:             * @see org.eclipse.ui.ide.undo.AbstractWorkspaceOperation#updateResourceChangeDescriptionFactory(org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory,
070:             *      int)
071:             */
072:            protected boolean updateResourceChangeDescriptionFactory(
073:                    IResourceChangeDescriptionFactory factory, int operation) {
074:                // A change of project location only is not of interest to
075:                // model providers, so treat it as if nothing is happening.
076:                return false;
077:            }
078:
079:            /*
080:             * Get the project that this operation is moving.
081:             */
082:            private IProject getProject() {
083:                return (IProject) resources[0];
084:            }
085:
086:            /*
087:             * (non-Javadoc)
088:             * @see org.eclipse.ui.ide.undo.AbstractCopyOrMoveResourcesOperation#isDestinationPathValid(org.eclipse.core.resources.IResource, int)
089:             */
090:            protected boolean isDestinationPathValid(IResource resource,
091:                    int index) {
092:                // path has already been validated in #computeMoveOrCopyStatus()
093:                return true;
094:            }
095:
096:            /*
097:             * (non-Javadoc)
098:             * @see org.eclipse.ui.ide.undo.AbstractCopyOrMoveResourcesOperation#getProposedName(org.eclipse.core.resources.IResource, int)
099:             */
100:            protected String getProposedName(IResource resource, int index) {
101:                return getProject().getName();
102:            }
103:
104:            /*
105:             * (non-Javadoc)
106:             * 
107:             * Checks that the specified project location is valid in addition to
108:             * superclass checks.
109:             * 
110:             * @see org.eclipse.ui.ide.undo.AbstractCopyOrMoveResourcesOperation#computeMoveOrCopyStatus()
111:             */
112:            protected IStatus computeMoveOrCopyStatus() {
113:                IStatus status = Status.OK_STATUS;
114:                if (projectLocation != null) {
115:                    status = getWorkspace().validateProjectLocationURI(
116:                            getProject(), projectLocation);
117:                }
118:                if (status.isOK()) {
119:                    return super .computeMoveOrCopyStatus();
120:                }
121:                return status;
122:            }
123:
124:            /*
125:             * (non-Javadoc)
126:             * 
127:             * Map execute to moving the project
128:             * 
129:             * @see org.eclipse.ui.ide.undo.AbstractWorkspaceOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor,
130:             *      org.eclipse.core.runtime.IAdaptable)
131:             */
132:            protected void doExecute(IProgressMonitor monitor, IAdaptable uiInfo)
133:                    throws CoreException {
134:                projectLocation = moveProject(getProject(), projectLocation,
135:                        monitor);
136:                // nothing was overwritten
137:                setResourceDescriptions(new ResourceDescription[0]);
138:            }
139:
140:            /*
141:             * (non-Javadoc)
142:             * 
143:             * Map undo to moving the project.
144:             * 
145:             * @see org.eclipse.ui.ide.undo.AbstractWorkspaceOperation#doUndo(org.eclipse.core.runtime.IProgressMonitor,
146:             *      org.eclipse.core.runtime.IAdaptable)
147:             */
148:            protected void doUndo(IProgressMonitor monitor, IAdaptable uiInfo)
149:                    throws CoreException {
150:                doExecute(monitor, uiInfo);
151:            }
152:
153:            /*
154:             * Move the project to its new location, returning its previous location.
155:             */
156:            URI moveProject(IProject project, URI locationURI,
157:                    IProgressMonitor monitor) throws CoreException {
158:                monitor
159:                        .setTaskName(UndoMessages.AbstractCopyOrMoveResourcesOperation_moveProjectProgress);
160:
161:                IProjectDescription description = project.getDescription();
162:                // Record the original path so this can be undone
163:                URI newDestinationURI = description.getLocationURI();
164:                // Set the new location into the project's description
165:                description.setLocationURI(locationURI);
166:
167:                project.move(description, IResource.FORCE | IResource.SHALLOW,
168:                        monitor);
169:
170:                // Now adjust the projectLocation so this can be undone/redone.
171:                return newDestinationURI;
172:            }
173:
174:            /*
175:             * (non-Javadoc)
176:             * 
177:             * Map undo to move status.
178:             * 
179:             * @see org.eclipse.ui.ide.undo.AbstractWorkspaceOperation#computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor)
180:             */
181:            public IStatus computeUndoableStatus(IProgressMonitor monitor) {
182:                IStatus status = super.computeUndoableStatus(monitor);
183:                if (status.isOK()) {
184:                    status = computeMoveOrCopyStatus();
185:                }
186:                return status;
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.