Index: projects/projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java =================================================================== RCS file: /cvs/projects/projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java,v retrieving revision 1.12 diff -u -r1.12 CommonProjectActions.java --- projects/projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java 14 Jul 2005 20:32:53 -0000 1.12 +++ projects/projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java 29 Jul 2005 14:57:31 -0000 @@ -113,6 +113,48 @@ } /** + * Create an action "Copy Project". + * It should be invoked with an action context containing + * one or more {@link org.netbeans.api.project.Project}s. + *
+ * You might include this in the context menu of a logical view. + *
+ * @since 1.10 + * @return an action + */ + public static Action copyProjectAction() { + return Utilities.getActionsFactory().copyProjectAction(); + } + + /** + * Create an action "Move Project". + * It should be invoked with an action context containing + * one or more {@link org.netbeans.api.project.Project}s. + *+ * You might include this in the context menu of a logical view. + *
+ * @since 1.10 + * @return an action + */ + public static Action moveProjectAction() { + return Utilities.getActionsFactory().moveProjectAction(); + } + + /** + * Create an action "Rename Project". + * It should be invoked with an action context containing + * one or more {@link org.netbeans.api.project.Project}s. + *+ * You might include this in the context menu of a logical view. + *
+ * @since 1.10 + * @return an action + */ + public static Action renameProjectAction() { + return Utilities.getActionsFactory().renameProjectAction(); + } + + /** * Creates action that invokes New Project wizard. * *{@link #EXISTING_SOURCES_FOLDER} keyed action
Index: projects/projectuiapi/src/org/netbeans/spi/project/ui/support/DefaultProjectOperations.java
===================================================================
RCS file: projects/projectuiapi/src/org/netbeans/spi/project/ui/support/DefaultProjectOperations.java
diff -N projects/projectuiapi/src/org/netbeans/spi/project/ui/support/DefaultProjectOperations.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ projects/projectuiapi/src/org/netbeans/spi/project/ui/support/DefaultProjectOperations.java 29 Jul 2005 14:57:31 -0000
@@ -0,0 +1,130 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+package org.netbeans.spi.project.ui.support;
+
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.support.ProjectOperations;
+import org.netbeans.modules.project.uiapi.DefaultProjectOperationsImplementation;
+
+/**Support class to allow the project type implementors to perform {@link ProjectOperations}
+ * by simply calling a method in this class. Each method in this class provides a default
+ * confirmation dialog and default behavior.
+ *
+ * If the project type requires a different behavior of an operation, it is required to provide its
+ * own implementation of the operation.
+ *
+ * @since 1.10
+ * @author Jan Lahoda
+ */
+public final class DefaultProjectOperations {
+
+ /**
+ * Creates a new instance of DefaultProjectOperations
+ */
+ private DefaultProjectOperations() {
+ }
+
+ /**Perform default delete operation. Gathers all necessary data, shows a confirmation
+ * dialog and deletes the project (if confirmed by the user).
+ *
+ * @since 1.10
+ *
+ * @param p project to delete
+ * @throws IllegalArgumentException if
+ *
- As only the ProjectManager is allowed to implement ProjectState interface,
- this change should not directly affect any clients.
-
- The
- p == null
or
+ * if {@link org.netbeans.api.projects.ProjectOperations.isDeleteOperationSupported}
+ * returns false for this project.
+ */
+ public static void performDefaultDeleteOperation(Project p) throws IllegalArgumentException {
+ if (p == null) {
+ throw new IllegalArgumentException("Project is null");
+ }
+
+ if (!ProjectOperations.isDeleteOperationSupported(p)) {
+ throw new IllegalStateException("Attempt to delete project that does not support deletion.");
+ }
+
+ DefaultProjectOperationsImplementation.deleteProject(p);
+ }
+
+ /**Perform default copy operation. Gathers all necessary data, shows a confirmation
+ * dialog and copies the project (if confirmed by the user).
+ *
+ * @since 1.10
+ *
+ * @param p project to copy
+ * @throws IllegalArgumentException if
+ * p == null
or
+ * {@link org.netbeans.api.projects.ProjectOperations.isCopyOperationSupported}
+ * returns false for this project.
+ */
+ public static void performDefaultCopyOperation(Project p) throws IllegalArgumentException {
+ if (p == null) {
+ throw new IllegalArgumentException("Project is null");
+ }
+
+ if (!ProjectOperations.isCopyOperationSupported(p)) {
+ throw new IllegalStateException("Attempt to delete project that does not support copy.");
+ }
+
+ DefaultProjectOperationsImplementation.copyProject(p);
+ }
+
+ /**Perform default move operation. Gathers all necessary data, shows a confirmation
+ * dialog and moves the project (if confirmed by the user).
+ *
+ * @since 1.10
+ *
+ * @param p project to move
+ * @throws IllegalArgumentException if
+ * p == null
or
+ * {@link org.netbeans.api.projects.ProjectOperations.ismoveOperationSupported}
+ * returns false for this project.
+ */
+ public static void performDefaultMoveOperation(Project p) throws IllegalArgumentException {
+ if (p == null) {
+ throw new IllegalArgumentException("Project is null");
+ }
+
+ if (!ProjectOperations.isMoveOperationSupported(p)) {
+ throw new IllegalStateException("Attempt to delete project that does not support move.");
+ }
+
+ DefaultProjectOperationsImplementation.moveProject(p);
+ }
+
+ /**Perform default rename operation. Gathers all necessary data, shows a confirmation
+ * dialog and renames the project (if confirmed by the user).
+ *
+ * @since 1.10
+ *
+ * @param p project to move
+ * @param newName new project's name or null
+ * @throws IllegalArgumentException if
+ * p == null
or
+ * {@link org.netbeans.api.projects.ProjectOperations.ismoveOperationSupported}
+ * returns false for this project.
+ */
+ public static void performDefaultRenameOperation(Project p, String newName) throws IllegalStateException {
+ if (p == null) {
+ throw new IllegalArgumentException("Project is null");
+ }
+
+ if (!ProjectOperations.isMoveOperationSupported(p)) {
+ throw new IllegalStateException("Attempt to delete project that does not support move.");
+ }
+
+ DefaultProjectOperationsImplementation.renameProject(p, newName);
+ }
+
+}
Index: ant/project/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java
===================================================================
RCS file: /cvs/ant/project/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java,v
retrieving revision 1.31
diff -u -r1.31 AntProjectHelper.java
--- ant/project/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java 11 Jul 2005 12:18:05 -0000 1.31
+++ ant/project/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java 29 Jul 2005 14:57:31 -0000
@@ -29,7 +29,6 @@
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.ant.AntArtifact;
import org.netbeans.modules.project.ant.AntBasedProjectFactorySingleton;
-import org.netbeans.modules.project.ant.DefaultAntProjectOperations;
import org.netbeans.modules.project.ant.FileChangeSupport;
import org.netbeans.modules.project.ant.FileChangeSupportEvent;
import org.netbeans.modules.project.ant.FileChangeSupportListener;
@@ -38,7 +37,7 @@
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.CacheDirectoryProvider;
import org.netbeans.spi.project.ProjectState;
-import org.netbeans.api.project.ProjectOperations;
+import org.netbeans.spi.project.support.ProjectOperations;
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
import org.netbeans.spi.queries.SharabilityQueryImplementation;
import org.openide.ErrorManager;
@@ -482,26 +481,6 @@
state.notifyDeleted();
}
- /**Perform default delete operation. Gathers all necessary data, shows a confirmation
- * dialog and deletes the project (if confirmed by the user).
- *
- * @since 1.8
- *
- * @throws IllegalStateException if
- * {@link org.netbeans.api.projects.ProjectOperations.getDefault().isDeleteOperationSupported}
- * returns false for this project.
- */
- public void performDefaultDeleteOperation() throws IllegalStateException {
- Project p = AntBasedProjectFactorySingleton.getProjectFor(this);
-
- assert p != null;
-
- if (!ProjectOperations.getDefault().isDeleteOperationSupported(p)) {
- throw new IllegalStateException("Attempt to delete project that does not support deletion.");
- }
-
- DefaultAntProjectOperations.deleteProject(p);
- }
/**
* Mark this project as being modified without actually changing anything in it.
Index: ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java
===================================================================
RCS file: /cvs/ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java,v
retrieving revision 1.26
diff -u -r1.26 ReferenceHelper.java
--- ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java 3 Apr 2005 01:29:16 -0000 1.26
+++ ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java 29 Jul 2005 14:57:32 -0000
@@ -19,7 +19,9 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -1229,6 +1231,91 @@
*/
AntProjectHelper getAntProjectHelper() {
return h;
+ }
+
+ /**Tries to fix references after copy/rename/move operation on the project.
+ * Handles relative/absolute paths.
+ *
+ * @param originalPath the project folder of the original project
+ * @see org.netbeans.spi.project.CopyOperationImplementation
+ * @see org.netbeans.spi.project.MoveOperationImplementation
+ * @since 1.9
+ */
+ public void fixReferences(File originalPath) {
+ String[] prefixesToFix = new String[] {"file.reference.", "project."};
+ EditableProperties pub = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
+ EditableProperties priv = h.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
+
+ File projectDir = FileUtil.toFile(h.getProjectDirectory());
+
+ List pubRemove = new ArrayList();
+ List privRemove = new ArrayList();
+ Map pubAdd = new HashMap();
+ Map privAdd = new HashMap();
+
+ for (Iterator i = pub.entrySet().iterator(); i.hasNext(); ) {
+ Map.Entry e = (Map.Entry) i.next();
+ String key = (String) e.getKey();
+ boolean cont = false;
+
+ for (int cntr = 0; cntr < prefixesToFix.length; cntr++) {
+ if (key.startsWith(prefixesToFix[cntr])) {
+ cont = true;
+ break;
+ }
+ }
+ if (!cont)
+ continue;
+
+ String value = (String) e.getValue();
+
+ File absolutePath = FileUtil.normalizeFile(PropertyUtils.resolveFile(originalPath, value));
+
+ //TODO: extra base dir relativization:
+ if (!CollocationQuery.areCollocated(absolutePath, projectDir)) {
+ pubRemove.add(key);
+ privAdd.put(key, absolutePath.getAbsolutePath());
+ }
+ }
+
+ for (Iterator i = priv.entrySet().iterator(); i.hasNext(); ) {
+ Map.Entry e = (Map.Entry) i.next();
+ String key = (String) e.getKey();
+ boolean cont = false;
+
+ for (int cntr = 0; cntr < prefixesToFix.length; cntr++) {
+ if (key.startsWith(prefixesToFix[cntr])) {
+ cont = true;
+ break;
+ }
+ }
+ if (!cont)
+ continue;
+
+ String value = (String) e.getValue();
+
+ File absolutePath = FileUtil.normalizeFile(PropertyUtils.resolveFile(originalPath, value));
+
+ //TODO: extra base dir relativization:
+ if (CollocationQuery.areCollocated(absolutePath, projectDir)) {
+ privRemove.add(key);
+ pubAdd.put(key, PropertyUtils.relativizeFile(projectDir, absolutePath));
+ }
+ }
+
+ for (Iterator i = pubRemove.iterator(); i.hasNext(); ) {
+ pub.remove(i.next());
+ }
+
+ for (Iterator i = privRemove.iterator(); i.hasNext(); ) {
+ priv.remove(i.next());
+ }
+
+ pub.putAll(pubAdd);
+ priv.putAll(privAdd);
+
+ h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, pub);
+ h.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, priv);
}
/**
Index: ant/project/apichanges.xml
===================================================================
RCS file: /cvs/ant/project/apichanges.xml,v
retrieving revision 1.7
diff -u -r1.7 apichanges.xml
--- ant/project/apichanges.xml 11 Jul 2005 12:18:02 -0000 1.7
+++ ant/project/apichanges.xml 29 Jul 2005 14:57:33 -0000
@@ -78,14 +78,13 @@
AntProjectHelper.notifyDeleted()
and AntProjectHelper.performDefaultDeleteOperation()
- added.
+ Added AntProjectHelper.notifyDeleted()
. Added ReferenceHelper.fixReferences
.
notifyDeleted
action is added to the ProjectState
,
- allowing the project implmentation to let the ProjectManager
- know that the project has been deleted. ProjectManager.isValid(Project)
added
- to detect deleted projects.
- ProjectOperations
and ProjectOperationsImplementation
added to support
- project delete operation.
+ Introduced:
+
+
notifyDeleted
added to ProjectState
.
+
Project Delete Operation
- *
- * Consists of {@link #getMetadataFiles(Project) getMetadataFiles},
- * {@link #getDataFiles(Project) getDataFiles}, {@link #performClean(Project) performClean}
- * and {@link #notifyDeleted(Project) notifyDeleted}.
- *
- * The delete operation should run in two phases: preparation, when
- * {@link #getMetadataFiles(Project) getMetadataFiles} and {@link #getDataFiles(Project) getDataFiles}
- * (any number of times,
- * in any order) are called and performing, when {@link #performClean(Project) performClean} should be called,
- * then the files previously returned should be deleted (as required by the user)
- * and finally {@link #notifyDeleted(Project) notifyDeleted} should be called.
- *
- * @since 1.6
- * @author Jan Lahoda
- */
-public final class ProjectOperations {
-
- private static ProjectOperations INSTANCE = null;
-
- public static synchronized ProjectOperations getDefault() {
- if (INSTANCE == null) {
- INSTANCE = new ProjectOperations();
- }
-
- return INSTANCE;
- }
-
- private ProjectOperations() {
- }
-
- /**Return list of files that are considered metadata files and folders for the given project.
- * Returns meaningfull values only if some of the is*Supported
methods
- * return true
.
- *
- * @param prj project to test
- * @return list of metadata files/folders
- */
- public List/*is*Supported
methods
- * return true
.
- *
- * @param prj project to test
- * @return list of data files/folders
- */
- public List/*true
if the project supports delete operation,
- * false
otherwise
- */
- public boolean isDeleteOperationSupported(Project prj) {
- return !getDeleteOperationImplementation(prj).isEmpty();
- }
-
- /**Performs pre-delete clean of the project. Should be called immediatelly before
- * the project is deleted.
- *
- * @param prj project to clean
- */
- public void performClean(Project prj) throws IOException {
- for (Iterator i = getDeleteOperationImplementation(prj).iterator(); i.hasNext(); ) {
- ((DeleteOperationImplementation) i.next()).performClean();
- }
- }
-
- /**Post-delete notification that the project has been deleted.. Should be called immediatelly after
- * the project is deleted.
- *
- * @param prj deleted project
- */
- public void notifyDeleted(Project prj) throws IOException {
- for (Iterator i = getDeleteOperationImplementation(prj).iterator(); i.hasNext(); ) {
- ((DeleteOperationImplementation) i.next()).notifyDeleted();
- }
- }
-
- private Collection/*
+ *
+ *
+ * The project type is not required to put an implementation of this interface into the project's
+ * lookup if the above two cases should not be supported.
+ *
+ * @author Jan Lahoda
+ * @since 1.7
+ */
+public interface CopyOperationImplementation extends DataFilesProviderImplementation {
+
+ /**Pre-copy notification. The exact meaning is left on the project implementors, but
+ * typically this means to undeloy the application and remove all artifacts
+ * created by the build project.
+ *
+ * @throws IOException if an I/O operation fails.
+ */
+ public void notifyCopying() throws IOException;
+
+ /**Notification that the copy operation has finished. Is supposed to fix the
+ * newly created (copied) project into the correct state (including changing its display name
+ * to nueName). Should be called on both original and newly created project (in this order).
+ *
+ * @param original the original project
+ * @param originalPath the project folder of the original project (for consistency
+ * with MoveOperationImplementation.notifyMoved)
+ * @param nueName new name for the newly created project.
+ *
+ * @throws IOException if an I/O operation fails.
+ */
+ public void notifyCopied(Project original, File originalPath, String nueName) throws IOException;
+
+}
Index: projects/projectapi/src/org/netbeans/spi/project/DataFilesProviderImplementation.java
===================================================================
RCS file: projects/projectapi/src/org/netbeans/spi/project/DataFilesProviderImplementation.java
diff -N projects/projectapi/src/org/netbeans/spi/project/DataFilesProviderImplementation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ projects/projectapi/src/org/netbeans/spi/project/DataFilesProviderImplementation.java 29 Jul 2005 14:57:33 -0000
@@ -0,0 +1,45 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+package org.netbeans.spi.project;
+
+import java.util.List;
+import org.openide.filesystems.FileObject;
+
+/**
+ * Base for various Project Operations, allows to gather metadata and data files
+ * for a project.
+ *
+ * @author Jan Lahoda
+ * @since 1.7
+ */
+public interface DataFilesProviderImplementation {
+
+ /**
+ * Returns list of {@link FileObject}s the are considered to be metadata files
+ * and folders belonging into this project.
+ * See {@link ProjectOperations#getMetadataFiles()} for more information.
+ *
+ * @return list of {@link FileObject}s that are considered metadata files and folders.
+ */
+ public List/*
+ *
+ *
+ * The project type is not required to put an implementation of this interface into the project's
+ * lookup if the above two cases should not be supported.
+ *
+ * @author Jan Lahoda
+ * @since 1.7
+ */
+public interface DeleteOperationImplementation extends DataFilesProviderImplementation {
+
+ /**Pre-delete notification. The exact meaning is left on the project implementors, but
+ * typically this means to undeloy the application and remove all artifacts
+ * created by the build project.
+ *
+ * @throws IOException if an I/O operation fails.
+ */
+ public void notifyDeleting() throws IOException;
+
+ /**Notification that the delete operation has finished. Is supposed to perform
+ * final cleanup and to call {@link ProjectState#notifyDeleted}.
+ *
+ * @throws IOException if an I/O operation fails.
+ */
+ public void notifyDeleted() throws IOException;
+
+}
Index: projects/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java
===================================================================
RCS file: projects/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java
diff -N projects/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ projects/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java 29 Jul 2005 14:57:33 -0000
@@ -0,0 +1,64 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+package org.netbeans.spi.project;
+
+import java.io.File;
+import java.io.IOException;
+import org.netbeans.api.project.Project;
+
+/**
+ * Project Rename/Move Operation. Allows to gather information necessary for project
+ * move and also provides callbacks to the project type to handle special
+ * checkpoints during the delete.
+ *
+ * An implementation of this interface may be registered in the project's lookup to support
+ * move operation in the following cases:
+ *
+ *
+ *
+ * The project type is not required to put an implementation of this interface into the project's
+ * lookup if the above two cases should not be supported.
+ *
+ * @author Jan Lahoda
+ * @since 1.7
+ */
+public interface MoveOperationImplementation extends DataFilesProviderImplementation {
+
+ /**Pre-move notification. The exact meaning is left on the project implementors, but
+ * typically this means to undeloy the application and remove all artifacts
+ * created by the build project.
+ *
+ * @throws IOException if an I/O operation fails.
+ */
+ public void notifyMoving() throws IOException;
+
+ /**Notification that the move operation has finished. Is supposed to fix the
+ * newly created (moved) project into the correct state (including changing its display name
+ * to nueName) and call {@link ProjectState#notifyDeleted} on the original project.
+ * Should be called on both original and newly created project (in this order).
+ *
+ * @param original the original project
+ * @param originalPath the project folder of the original project
+ * @param nueName new name for the newly created project.
+ *
+ * @throws IOException if an I/O operation fails.
+ */
+ public void notifyMoved(Project original, File originalPath, String nueName) throws IOException;
+
+}
Index: projects/projectapi/src/org/netbeans/spi/project/ProjectOperationsImplementation.java
===================================================================
RCS file: projects/projectapi/src/org/netbeans/spi/project/ProjectOperationsImplementation.java
diff -N projects/projectapi/src/org/netbeans/spi/project/ProjectOperationsImplementation.java
--- projects/projectapi/src/org/netbeans/spi/project/ProjectOperationsImplementation.java 11 Jul 2005 12:18:08 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,84 +0,0 @@
-/*
- * Sun Public License Notice
- *
- * The contents of this file are subject to the Sun Public License
- * Version 1.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://www.sun.com/
- *
- * The Original Code is NetBeans. The Initial Developer of the Original
- * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.project;
-
-import java.io.IOException;
-import java.util.List;
-import org.netbeans.api.project.ProjectOperations;
-
-/**This is only a scope class that holds several project operation interfaces.
- * See particular interface for more information:
- * {@link DeleteOperationImplementation DeleteOperationImplementation}
- * is*Supported
methods
+ * return true
.
+ *
+ * @param prj project to test
+ * @return list of metadata files/folders
+ */
+ public static List/*is*Supported
methods
+ * return true
.
+ *
+ * @param prj project to test
+ * @return list of data files/folders
+ */
+ public static List/*true
if the project supports delete operation,
+ * false
otherwise
+ */
+ public static boolean isDeleteOperationSupported(Project prj) {
+ return !getDeleteOperationImplementation(prj).isEmpty();
+ }
+
+ /**Notification that the project is about to be deleted.
+ * Should be called immediatelly before the project is deleted.
+ *
+ * The project is supposed to do all required cleanup to allow the project to be deleted.
+ *
+ * @param prj project to notify
+ * @throws IOException is some error occurs
+ */
+ public static void notifyDeleting(Project prj) throws IOException {
+ for (Iterator i = getDeleteOperationImplementation(prj).iterator(); i.hasNext(); ) {
+ ((DeleteOperationImplementation) i.next()).notifyDeleting();
+ }
+ }
+
+ /**Notification that the project has been deleted.
+ * Should be called immediatelly after the project is deleted.
+ *
+ * @param prj project to notify
+ * @throws IOException is some error occurs
+ */
+ public static void notifyDeleted(Project prj) throws IOException {
+ for (Iterator i = getDeleteOperationImplementation(prj).iterator(); i.hasNext(); ) {
+ ((DeleteOperationImplementation) i.next()).notifyDeleted();
+ }
+ }
+
+ /**Test whether the copy operation is supported on the given project.
+ *
+ * @param prj project to test
+ * @return true
if the project supports the copy operation,
+ * false
otherwise
+ */
+ public static boolean isCopyOperationSupported(Project prj) {
+ return !getCopyOperationImplementation(prj).isEmpty();
+ }
+
+ /**Notification that the project is about to be copyied.
+ * Should be called immediatelly before the project is copied.
+ *
+ * The project is supposed to do all required cleanup to allow the project to be copied.
+ *
+ * @param prj project to notify
+ * @throws IOException is some error occurs
+ */
+ public static void notifyCopying(Project prj) throws IOException {
+ for (Iterator i = getCopyOperationImplementation(prj).iterator(); i.hasNext(); ) {
+ ((CopyOperationImplementation) i.next()).notifyCopying();
+ }
+ }
+
+ /**Notification that the project has been copied.
+ * Should be called immediatelly after the project is copied.
+ *
+ * The project is supposed to do all necessary fixes to the project's structure to
+ * form a valid project.
+ *
+ * Both original and newly created project (copy) are notified, in this order.
+ *
+ * @param original original project
+ * @param nue new project (copy)
+ * @param originalPath the project folder of the original project (for consistency with notifyMoved)
+ * @param name new name of the project
+ * @throws IOException is some error occurs
+ */
+ public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException {
+ for (Iterator i = getCopyOperationImplementation(original).iterator(); i.hasNext(); ) {
+ ((CopyOperationImplementation) i.next()).notifyCopied(original, originalPath, name);
+ }
+ for (Iterator i = getCopyOperationImplementation(nue).iterator(); i.hasNext(); ) {
+ ((CopyOperationImplementation) i.next()).notifyCopied(original, originalPath, name);
+ }
+ }
+
+ /**Notification that the project is about to be moved.
+ * Should be called immediatelly before the project is moved.
+ *
+ * The project is supposed to do all required cleanup to allow the project to be moved.
+ *
+ * @param prj project to notify
+ * @throws IOException is some error occurs
+ */
+ public static void notifyMoving(Project prj) throws IOException {
+ for (Iterator i = getMoveOperationImplementation(prj).iterator(); i.hasNext(); ) {
+ ((MoveOperationImplementation) i.next()).notifyMoving();
+ }
+ }
+
+ /**Notification that the project has been moved.
+ * Should be called immediatelly after the project is moved.
+ *
+ * The project is supposed to do all necessary fixes to the project's structure to
+ * form a valid project.
+ *
+ * Both original and moved project are notified, in this order.
+ *
+ * @param original original project
+ * @param nue moved project
+ * @param originalPath the project folder of the original project
+ * @param name new name of the project
+ * @throws IOException is some error occurs
+ */
+ public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException {
+ for (Iterator i = getMoveOperationImplementation(original).iterator(); i.hasNext(); ) {
+ ((MoveOperationImplementation) i.next()).notifyMoved(original, originalPath, name);
+ }
+ for (Iterator i = getMoveOperationImplementation(nue).iterator(); i.hasNext(); ) {
+ ((MoveOperationImplementation) i.next()).notifyMoved(original, originalPath, name);
+ }
+ }
+
+ /**Test whether the move operation is supported on the given project.
+ *
+ * @param prj project to test
+ * @return true
if the project supports the move operation,
+ * false
otherwise
+ */
+ public static boolean isMoveOperationSupported(Project prj) {
+ return true;
+ }
+
+ private static Collection/*