# HG changeset patch # Parent 963d842a90930832c13ab330ee7123d7e1546c9e # User Jesse Glick #207488: use URI rather than File in ProjectOperations and related APIs. diff --git a/java.j2seproject/nbproject/project.xml b/java.j2seproject/nbproject/project.xml --- a/java.j2seproject/nbproject/project.xml +++ b/java.j2seproject/nbproject/project.xml @@ -203,7 +203,7 @@ 1 - 1.38 + 1.43 diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java @@ -46,6 +46,7 @@ import java.io.File; import java.io.IOException; +import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -61,9 +62,9 @@ import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties; import org.netbeans.spi.project.ActionProvider; -import org.netbeans.spi.project.CopyOperationImplementation; +import org.netbeans.spi.project.CopyOperationImplementation2; import org.netbeans.spi.project.DeleteOperationImplementation; -import org.netbeans.spi.project.MoveOrRenameOperationImplementation; +import org.netbeans.spi.project.MoveOperationImplementation2; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.EditableProperties; import org.netbeans.spi.project.support.ant.PropertyUtils; @@ -78,7 +79,7 @@ * * @author Jan Lahoda */ -public class J2SEProjectOperations implements DeleteOperationImplementation, CopyOperationImplementation, MoveOrRenameOperationImplementation { +public class J2SEProjectOperations implements DeleteOperationImplementation, CopyOperationImplementation2, MoveOperationImplementation2 { private final J2SEProject project; @@ -171,7 +172,7 @@ rememberConfigurations(); } - public void notifyCopied(Project original, File originalPath, String nueName) { + @Override public void notifyCopied(Project original, URI originalPath, String nueName) { if (original == null) { //do nothing for the original project. return ; @@ -181,7 +182,10 @@ fixPrivateProperties(origOperations); fixDistJarProperty (nueName); fixApplicationTitle(nueName); - project.getReferenceHelper().fixReferences(originalPath); + if ("file".equals(originalPath.getScheme())) { + File f = new File(originalPath); + project.getReferenceHelper().fixReferences(f); + } project.setName(nueName); restoreConfigurations(origOperations); } @@ -197,7 +201,7 @@ clean(); } - public void notifyMoved(Project original, File originalPath, String nueName) { + @Override public void notifyMoved(Project original, URI originalPath, String nueName) { if (original == null) { project.getAntProjectHelper().notifyDeleted(); return ; @@ -208,7 +212,10 @@ fixDistJarProperty (nueName); fixApplicationTitle(nueName); project.setName(nueName); - project.getReferenceHelper().fixReferences(originalPath); + if ("file".equals(originalPath.getScheme())) { + File f = new File(originalPath); + project.getReferenceHelper().fixReferences(f); + } restoreConfigurations(origOperations); } diff --git a/maven/nbproject/project.xml b/maven/nbproject/project.xml --- a/maven/nbproject/project.xml +++ b/maven/nbproject/project.xml @@ -233,7 +233,7 @@ 1 - 1.40 + 1.43 diff --git a/maven/src/org/netbeans/modules/maven/operations/OperationsImpl.java b/maven/src/org/netbeans/modules/maven/operations/OperationsImpl.java --- a/maven/src/org/netbeans/modules/maven/operations/OperationsImpl.java +++ b/maven/src/org/netbeans/modules/maven/operations/OperationsImpl.java @@ -42,8 +42,9 @@ package org.netbeans.modules.maven.operations; -import java.io.File; import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -57,9 +58,9 @@ import org.netbeans.modules.maven.model.ModelOperation; import org.netbeans.modules.maven.model.Utilities; import org.netbeans.modules.maven.model.pom.POMModel; -import org.netbeans.spi.project.CopyOperationImplementation; +import org.netbeans.spi.project.CopyOperationImplementation2; import org.netbeans.spi.project.DeleteOperationImplementation; -import org.netbeans.spi.project.MoveOperationImplementation; +import org.netbeans.spi.project.MoveOperationImplementation2; import org.netbeans.spi.project.ProjectServiceProvider; import org.netbeans.spi.project.ProjectState; import org.openide.execution.ExecutorTask; @@ -72,8 +73,8 @@ * makes sure the project is removed from the possible module section of the parent.. * @author mkleint */ -@ProjectServiceProvider(service={DeleteOperationImplementation.class, MoveOperationImplementation.class, CopyOperationImplementation.class}, projectType="org-netbeans-modules-maven") -public class OperationsImpl implements DeleteOperationImplementation, MoveOperationImplementation, CopyOperationImplementation { +@ProjectServiceProvider(service={DeleteOperationImplementation.class, MoveOperationImplementation2.class, CopyOperationImplementation2.class}, projectType="org-netbeans-modules-maven") +public class OperationsImpl implements DeleteOperationImplementation, MoveOperationImplementation2, CopyOperationImplementation2 { private final Project project; @@ -139,9 +140,9 @@ public void notifyMoving() throws IOException { notifyDeleting(); } - + @Override - public void notifyMoved(Project original, File originalLoc, final String newName) throws IOException { + public void notifyMoved(Project original, URI originalLoc, final String newName) throws IOException { if (original == null) { //old project call.. project.getLookup().lookup(ProjectState.class).notifyDeleted(); @@ -158,24 +159,36 @@ Utilities.performPOMModelOperations(pomFO, Collections.singletonList(operation)); NbMavenProject.fireMavenProjectReload(project); } - checkParentProject(project.getProjectDirectory(), false, newName, originalLoc.getName()); + checkParentProject(project.getProjectDirectory(), false, newName, originalLoc); } } + @Override public void notifyRenaming() throws IOException { + notifyDeleting(); + } + + @Override public void notifyRenamed(String nueName) throws IOException { + try { + checkParentProject(project.getProjectDirectory(), false, nueName, project.getProjectDirectory().getURL().toURI()); + } catch (URISyntaxException x) { + assert false : x; + } + } + @Override public void notifyCopying() throws IOException { } @Override - public void notifyCopied(Project original, File originalLoc, String newName) throws IOException { + public void notifyCopied(Project original, URI originalLoc, String newName) throws IOException { if (original == null) { //old project call.. } else { - checkParentProject(project.getProjectDirectory(), false, newName, originalLoc.getName()); + checkParentProject(project.getProjectDirectory(), false, newName, originalLoc); } } - private void checkParentProject(FileObject projectDir, final boolean delete, final String newName, final String oldName) throws IOException { + private void checkParentProject(FileObject projectDir, final boolean delete, final String newName, final URI originalLoc) throws IOException { final String prjLoc = projectDir.getNameExt(); FileObject fo = projectDir.getParent(); Project possibleParent = ProjectManager.getDefault().findProject(fo); @@ -196,8 +209,8 @@ model.getProject().addModule(prjLoc); } } - if (newName != null && oldName != null) { - if (oldName.equals(model.getProject().getArtifactId())) { + if (newName != null && originalLoc != null) { + if (originalLoc.getPath().endsWith("/" + model.getProject().getArtifactId() + "/")) { // is this condition necessary.. why not just overwrite the artifactID always.. model.getProject().setArtifactId(newName); } diff --git a/projectapi/manifest.mf b/projectapi/manifest.mf --- a/projectapi/manifest.mf +++ b/projectapi/manifest.mf @@ -1,7 +1,7 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.projectapi/1 OpenIDE-Module-Install: org/netbeans/modules/projectapi/Installer.class -OpenIDE-Module-Specification-Version: 1.42 +OpenIDE-Module-Specification-Version: 1.43 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml diff --git a/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java b/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java --- a/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java +++ b/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java @@ -48,28 +48,9 @@ import org.netbeans.api.project.Project; /** - * Project Copy Operation. Allows to gather information necessary for project - * copy and also provides callbacks to the project type to handle special - * checkpoints during the copy process. - * - * An implementation of this interface may be registered in the project's lookup to support - * copy operation in the following cases: - *
    - *
  • The project type wants to use - * DefaultProjectOperations - * to perform the copy operation. - *
  • - *
  • If this project may be part of of a compound project (like EJB project is a part of a J2EE project), - * and the compound project wants to copy all the sub-projects. - *
  • - *
- * - * 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 + * @deprecated use {@link CopyOperationImplementation2} instead */ +@Deprecated public interface CopyOperationImplementation extends DataFilesProviderImplementation { /**Pre-copy notification. The exact meaning is left on the project implementors, but diff --git a/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java b/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation2.java copy from projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java copy to projectapi/src/org/netbeans/spi/project/CopyOperationImplementation2.java --- a/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java +++ b/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation2.java @@ -43,8 +43,8 @@ */ package org.netbeans.spi.project; -import java.io.File; import java.io.IOException; +import java.net.URI; import org.netbeans.api.project.Project; /** @@ -67,10 +67,9 @@ * 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 + * @since 1.43 */ -public interface CopyOperationImplementation extends DataFilesProviderImplementation { +public interface CopyOperationImplementation2 extends DataFilesProviderImplementation { /**Pre-copy notification. The exact meaning is left on the project implementors, but * typically this means to undeploy the application and remove all artifacts @@ -86,11 +85,11 @@ * * @param original null when called on the original project, the original project when called on the new project * @param originalPath the project folder of the original project (for consistency - * with MoveOperationImplementation.notifyMoved) + * with {@link MoveOperationImplementation2#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; + public void notifyCopied(Project original, URI originalPath, String nueName) throws IOException; } diff --git a/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java b/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java --- a/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java +++ b/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java @@ -48,30 +48,9 @@ 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 wants to use - * DefaultProjectOperations - * to perform the rename/move operation. - *
  • - *
  • If this project may be part of of a compound project (like EJB project is a part of a J2EE project), - * and the compound project wants to rename/move all the sub-projects. - *
  • - *
- * - * 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. - * - *

Implementations are encouraged to implement {@link MoveOrRenameOperationImplementation} instead. - * - * @author Jan Lahoda - * @since 1.7 + * @deprecated use {@link MoveOperationImplementation2} instead */ +@Deprecated public interface MoveOperationImplementation extends DataFilesProviderImplementation { /**Pre-move notification. The exact meaning is left on the project implementors, but diff --git a/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java b/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation2.java copy from projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java copy to projectapi/src/org/netbeans/spi/project/MoveOperationImplementation2.java --- a/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java +++ b/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation2.java @@ -43,8 +43,8 @@ */ package org.netbeans.spi.project; -import java.io.File; import java.io.IOException; +import java.net.URI; import org.netbeans.api.project.Project; /** @@ -67,19 +67,15 @@ * 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. * - *

Implementations are encouraged to implement {@link MoveOrRenameOperationImplementation} instead. - * - * @author Jan Lahoda - * @since 1.7 + * @since 1.43 */ -public interface MoveOperationImplementation extends DataFilesProviderImplementation { +public interface MoveOperationImplementation2 extends DataFilesProviderImplementation { /**Pre-move notification. The exact meaning is left on the project implementors, but * typically this means to undeploy the application and remove all artifacts * created by the build project. * * @throws IOException if an I/O operation fails. - * @see MoveOrRenameOperationImplementation#notifyRenaming */ public void notifyMoving() throws IOException; @@ -93,8 +89,30 @@ * @param nueName new name for the newly created project. * * @throws IOException if an I/O operation fails. - * @see MoveOrRenameOperationImplementation#notifyRenamed */ - public void notifyMoved(Project original, File originalPath, String nueName) throws IOException; + public void notifyMoved(Project original, URI originalPath, String nueName) throws IOException; + /** + * Pre-rename notification. + * The exact meaning is left to the project's implementation; + * it might for example undeploy an application and remove all artifacts + * created by the build, in case they used the old name. + *

Used in case the project can behave more simply, efficiently, and robustly when it is simply + * being renamed (code and/or display name) without actually being moved to a new location. + * In this case, {@link #notifyMoving} will not be called. + * @throws IOException if an I/O operation fails + */ + void notifyRenaming() throws IOException; + + /** + * Notification that the rename operation has finished. + * The project might for example change its display name in metadata. + *

Used in case the project can behave more simply, efficiently, and robustly when it is simply + * being renamed (code and/or display name) without actually being moved to a new location. + * In this case, {@link #notifyMoved} will not be called. + * @param nueName new name for the project + * @throws IOException if an I/O operation fails + */ + void notifyRenamed(String nueName) throws IOException; + } diff --git a/projectapi/src/org/netbeans/spi/project/MoveOrRenameOperationImplementation.java b/projectapi/src/org/netbeans/spi/project/MoveOrRenameOperationImplementation.java --- a/projectapi/src/org/netbeans/spi/project/MoveOrRenameOperationImplementation.java +++ b/projectapi/src/org/netbeans/spi/project/MoveOrRenameOperationImplementation.java @@ -45,12 +45,9 @@ import java.io.IOException; /** - * A preferred substitute for {@code MoveOperationImplementation} to be used when - * the project can behave more simply, efficiently, and robustly when it is simply - * being renamed (code and/or display name) without actually being moved to a new location. - * In this case, {@link #notifyMoving} and {@link #notifyMoved} will not be called. - * @since org.netbeans.modules.projectapi/1 1.31 + * @deprecated use {@link MoveOperationImplementation2} instead */ +@Deprecated public interface MoveOrRenameOperationImplementation extends MoveOperationImplementation { /** diff --git a/projectapi/src/org/netbeans/spi/project/support/ProjectOperations.java b/projectapi/src/org/netbeans/spi/project/support/ProjectOperations.java --- a/projectapi/src/org/netbeans/spi/project/support/ProjectOperations.java +++ b/projectapi/src/org/netbeans/spi/project/support/ProjectOperations.java @@ -46,14 +46,14 @@ import java.io.File; import java.io.IOException; +import java.net.URI; import java.util.ArrayList; import java.util.List; import org.netbeans.api.project.Project; -import org.netbeans.spi.project.CopyOperationImplementation; +import org.netbeans.spi.project.CopyOperationImplementation2; import org.netbeans.spi.project.DataFilesProviderImplementation; import org.netbeans.spi.project.DeleteOperationImplementation; -import org.netbeans.spi.project.MoveOperationImplementation; -import org.netbeans.spi.project.MoveOrRenameOperationImplementation; +import org.netbeans.spi.project.MoveOperationImplementation2; import org.openide.filesystems.FileObject; /** @@ -146,11 +146,13 @@ /**Test whether the copy operation is supported on the given project. * * @param prj project to test - * @return true if the project has a {@link CopyOperationImplementation}, + * @return true if the project has a {@link CopyOperationImplementation2}, * false otherwise */ + @SuppressWarnings("deprecation") public static boolean isCopyOperationSupported(Project prj) { - return prj.getLookup().lookup(CopyOperationImplementation.class) != null; + return prj.getLookup().lookup(CopyOperationImplementation2.class) != null || + prj.getLookup().lookup(org.netbeans.spi.project.CopyOperationImplementation.class) != null; } /**Notification that the project is about to be copyied. @@ -160,14 +162,25 @@ * * @param prj project to notify * @throws IOException is some error occurs - * @see CopyOperationImplementation#notifyCopying + * @see CopyOperationImplementation2#notifyCopying */ + @SuppressWarnings("deprecation") public static void notifyCopying(Project prj) throws IOException { - for (CopyOperationImplementation i : prj.getLookup().lookupAll(CopyOperationImplementation.class)) { + for (CopyOperationImplementation2 i : prj.getLookup().lookupAll(CopyOperationImplementation2.class)) { + i.notifyCopying(); + } + for (org.netbeans.spi.project.CopyOperationImplementation i : prj.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) { i.notifyCopying(); } } - + + /** + * @deprecated use {@link #notifyCopied(Project, Project, URI, String)} instead + */ + @Deprecated + public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException { + notifyCopied(original, nue, originalPath.toURI(), name); + } /**Notification that the project has been copied. * Should be called immediatelly after the project is copied. * @@ -181,35 +194,54 @@ * @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 - * @see CopyOperationImplementation#notifyCopied + * @see CopyOperationImplementation2#notifyCopied + * @since 1.43 */ - public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException { - for (CopyOperationImplementation i : original.getLookup().lookupAll(CopyOperationImplementation.class)) { + @SuppressWarnings("deprecation") + public static void notifyCopied(Project original, Project nue, URI originalPath, String name) throws IOException { + for (CopyOperationImplementation2 i : original.getLookup().lookupAll(CopyOperationImplementation2.class)) { i.notifyCopied(null, originalPath, name); } - for (CopyOperationImplementation i : nue.getLookup().lookupAll(CopyOperationImplementation.class)) { + for (CopyOperationImplementation2 i : nue.getLookup().lookupAll(CopyOperationImplementation2.class)) { i.notifyCopied(original, originalPath, name); } + if ("file".equals(originalPath.getScheme())) { + File f = new File(originalPath); + for (org.netbeans.spi.project.CopyOperationImplementation i : original.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) { + i.notifyCopied(null, f, name); + } + for (org.netbeans.spi.project.CopyOperationImplementation i : nue.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) { + i.notifyCopied(original, f, name); + } + } } /**Notification that the project is about to be moved. * Should be called immediately before the project is moved. - * {@link MoveOrRenameOperationImplementation#notifyRenaming} may be called instead. + * {@link MoveOperationImplementation2#notifyRenaming} may be called instead. * 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 - * @see MoveOperationImplementation#notifyMoving + * @see MoveOperationImplementation2#notifyMoving */ + @SuppressWarnings("deprecation") public static void notifyMoving(Project prj) throws IOException { - for (MoveOperationImplementation i : prj.getLookup().lookupAll(MoveOperationImplementation.class)) { + for (org.netbeans.spi.project.MoveOperationImplementation i : prj.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) { i.notifyMoving(); } } - + + /** + * @deprecated use {@link #notifyMoved(Project, Project, URI, String)} instead + */ + @Deprecated + public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException { + notifyMoved(original, nue, originalPath.toURI(), name); + } /**Notification that the project has been moved. * Should be called immediatelly after the project is moved. - * {@link MoveOrRenameOperationImplementation#notifyRenamed} may be called instead. + * {@link MoveOperationImplementation2#notifyRenamed} may be called instead. * * The project is supposed to do all necessary fixes to the project's structure to * form a valid project. @@ -221,26 +253,39 @@ * @param originalPath the project folder of the original project * @param name new name of the project * @throws IOException is some error occurs - * @see MoveOperationImplementation#notifyMoved + * @see MoveOperationImplementation2#notifyMoved + * @since 1.43 */ - public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException { - for (MoveOperationImplementation i : original.getLookup().lookupAll(MoveOperationImplementation.class)) { + @SuppressWarnings("deprecation") + public static void notifyMoved(Project original, Project nue, URI originalPath, String name) throws IOException { + for (MoveOperationImplementation2 i : original.getLookup().lookupAll(MoveOperationImplementation2.class)) { i.notifyMoved(null, originalPath, name); } - for (MoveOperationImplementation i : nue.getLookup().lookupAll(MoveOperationImplementation.class)) { + for (MoveOperationImplementation2 i : nue.getLookup().lookupAll(MoveOperationImplementation2.class)) { i.notifyMoved(original, originalPath, name); } + if ("file".equals(originalPath.getScheme())) { + File f = new File(originalPath); + for (org.netbeans.spi.project.MoveOperationImplementation i : original.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) { + i.notifyMoved(null, f, name); + } + for (org.netbeans.spi.project.MoveOperationImplementation i : nue.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) { + i.notifyMoved(original, f, name); + } + } } /** * Tests whether the move or rename operations are supported on the given project. * * @param prj project to test - * @return true if the project has a {@link MoveOperationImplementation}, + * @return true if the project has a {@link MoveOperationImplementation2}, * false otherwise */ + @SuppressWarnings("deprecation") public static boolean isMoveOperationSupported(Project prj) { - return prj.getLookup().lookup(MoveOperationImplementation.class) != null; + return prj.getLookup().lookup(MoveOperationImplementation2.class) != null || + prj.getLookup().lookup(org.netbeans.spi.project.MoveOperationImplementation.class) != null; } } diff --git a/projectuiapi/nbproject/project.xml b/projectuiapi/nbproject/project.xml --- a/projectuiapi/nbproject/project.xml +++ b/projectuiapi/nbproject/project.xml @@ -73,7 +73,7 @@ 1 - 1.31 + 1.43 diff --git a/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectOperationsImplementation.java b/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectOperationsImplementation.java --- a/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectOperationsImplementation.java +++ b/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectOperationsImplementation.java @@ -78,10 +78,9 @@ import org.netbeans.api.project.ProjectUtils; import org.netbeans.api.project.ui.OpenProjects; import org.netbeans.api.queries.SharabilityQuery; -import org.netbeans.spi.project.MoveOperationImplementation; import org.netbeans.spi.project.support.ProjectOperations; import org.netbeans.api.queries.VisibilityQuery; -import org.netbeans.spi.project.MoveOrRenameOperationImplementation; +import org.netbeans.spi.project.MoveOperationImplementation2; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.LifecycleManager; @@ -301,7 +300,7 @@ handle.progress((int) (currentWorkDone += totalWork * FIND_PROJECT_WORK)); - ProjectOperations.notifyCopied(project, nue, FileUtil.toFile(project.getProjectDirectory()), nueName); + ProjectOperations.notifyCopied(project, nue, project.getProjectDirectory().getURL().toURI(), nueName); handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK)); @@ -375,10 +374,12 @@ }); } + @SuppressWarnings("deprecation") private static void doRenameProject(ProgressHandle handle, Project project, String nueName) throws Exception { - Collection operations = project.getLookup().lookupAll(MoveOperationImplementation.class); - for (MoveOperationImplementation o : operations) { - if (!(o instanceof MoveOrRenameOperationImplementation)) { + Collection operations2 = project.getLookup().lookupAll(MoveOperationImplementation2.class); + Collection operations = project.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class); + for (org.netbeans.spi.project.MoveOperationImplementation o : operations) { + if (!(o instanceof org.netbeans.spi.project.MoveOrRenameOperationImplementation)) { Logger.getLogger(DefaultProjectOperationsImplementation.class.getName()).log(Level.WARNING, "{0} should implement MoveOrRenameOperationImplementation", o.getClass().getName()); doRenameProjectOld(handle, project, nueName, operations); @@ -390,12 +391,18 @@ handle.switchToDeterminate(4); int currentWorkDone = 0; handle.progress(++currentWorkDone); - for (MoveOperationImplementation o : operations) { - ((MoveOrRenameOperationImplementation) o).notifyRenaming(); + for (MoveOperationImplementation2 o : operations2) { + o.notifyRenaming(); + } + for (org.netbeans.spi.project.MoveOperationImplementation o : operations) { + ((org.netbeans.spi.project.MoveOrRenameOperationImplementation) o).notifyRenaming(); } handle.progress(++currentWorkDone); - for (MoveOperationImplementation o : operations) { - ((MoveOrRenameOperationImplementation) o).notifyRenamed(nueName); + for (MoveOperationImplementation2 o : operations2) { + o.notifyRenamed(nueName); + } + for (org.netbeans.spi.project.MoveOperationImplementation o : operations) { + ((org.netbeans.spi.project.MoveOrRenameOperationImplementation) o).notifyRenamed(nueName); } handle.progress(++currentWorkDone); ProjectManager.getDefault().saveProject(project); @@ -407,8 +414,9 @@ } } + @SuppressWarnings("deprecation") private static void doRenameProjectOld(ProgressHandle handle, Project project, String nueName, - Collection operations) throws Exception { + Collection operations) throws Exception { boolean originalOK = true; Project main = OpenProjects.getDefault().getMainProject(); boolean wasMain = main != null && project.getProjectDirectory().equals(main.getProjectDirectory()); @@ -421,11 +429,11 @@ File projectDirectoryFile = FileUtil.toFile(project.getProjectDirectory()); close(project); handle.progress(++currentWorkDone); - for (MoveOperationImplementation o : operations) { + for (org.netbeans.spi.project.MoveOperationImplementation o : operations) { o.notifyMoving(); } handle.progress(++currentWorkDone); - for (MoveOperationImplementation o : operations) { + for (org.netbeans.spi.project.MoveOperationImplementation o : operations) { o.notifyMoved(null, projectDirectoryFile, nueName); } handle.progress(++currentWorkDone); @@ -435,8 +443,8 @@ assert nue != null; originalOK = false; handle.progress(++currentWorkDone); - operations = nue.getLookup().lookupAll(MoveOperationImplementation.class); - for (MoveOperationImplementation o : operations) { + operations = nue.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class); + for (org.netbeans.spi.project.MoveOperationImplementation o : operations) { o.notifyMoved(project, projectDirectoryFile, nueName); } ProjectManager.getDefault().saveProject(project); @@ -512,7 +520,7 @@ assert nue != project : "got same Project for " + projectDirectory + " and " + target; LOG.log(Level.FINE, "doMoveProject 2/2: {0} @{1}", new Object[] {target, nue.hashCode()}); - ProjectOperations.notifyMoved(project, nue, FileUtil.toFile(project.getProjectDirectory()), nueProjectName); + ProjectOperations.notifyMoved(project, nue, project.getProjectDirectory().getURL().toURI(), nueProjectName); handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK));