This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 207488
Collapse All | Expand All

(-)a/java.j2seproject/nbproject/project.xml (-1 / +1 lines)
Lines 203-209 Link Here
203
                    <compile-dependency/>
203
                    <compile-dependency/>
204
                    <run-dependency>
204
                    <run-dependency>
205
                        <release-version>1</release-version>
205
                        <release-version>1</release-version>
206
                        <specification-version>1.38</specification-version>
206
                        <specification-version>1.43</specification-version>
207
                    </run-dependency>
207
                    </run-dependency>
208
                </dependency>
208
                </dependency>
209
                <dependency>
209
                <dependency>
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java (-7 / +14 lines)
Lines 46-51 Link Here
46
46
47
import java.io.File;
47
import java.io.File;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.net.URI;
49
import java.util.ArrayList;
50
import java.util.ArrayList;
50
import java.util.Arrays;
51
import java.util.Arrays;
51
import java.util.HashMap;
52
import java.util.HashMap;
Lines 61-69 Link Here
61
import org.netbeans.modules.java.api.common.project.ProjectProperties;
62
import org.netbeans.modules.java.api.common.project.ProjectProperties;
62
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
63
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
63
import org.netbeans.spi.project.ActionProvider;
64
import org.netbeans.spi.project.ActionProvider;
64
import org.netbeans.spi.project.CopyOperationImplementation;
65
import org.netbeans.spi.project.CopyOperationImplementation2;
65
import org.netbeans.spi.project.DeleteOperationImplementation;
66
import org.netbeans.spi.project.DeleteOperationImplementation;
66
import org.netbeans.spi.project.MoveOrRenameOperationImplementation;
67
import org.netbeans.spi.project.MoveOperationImplementation2;
67
import org.netbeans.spi.project.support.ant.AntProjectHelper;
68
import org.netbeans.spi.project.support.ant.AntProjectHelper;
68
import org.netbeans.spi.project.support.ant.EditableProperties;
69
import org.netbeans.spi.project.support.ant.EditableProperties;
69
import org.netbeans.spi.project.support.ant.PropertyUtils;
70
import org.netbeans.spi.project.support.ant.PropertyUtils;
Lines 78-84 Link Here
78
 *
79
 *
79
 * @author Jan Lahoda
80
 * @author Jan Lahoda
80
 */
81
 */
81
public class J2SEProjectOperations implements DeleteOperationImplementation, CopyOperationImplementation, MoveOrRenameOperationImplementation {
82
public class J2SEProjectOperations implements DeleteOperationImplementation, CopyOperationImplementation2, MoveOperationImplementation2 {
82
    
83
    
83
    private final J2SEProject project;
84
    private final J2SEProject project;
84
    
85
    
Lines 171-177 Link Here
171
        rememberConfigurations();
172
        rememberConfigurations();
172
    }
173
    }
173
    
174
    
174
    public void notifyCopied(Project original, File originalPath, String nueName) {
175
    @Override public void notifyCopied(Project original, URI originalPath, String nueName) {
175
        if (original == null) {
176
        if (original == null) {
176
            //do nothing for the original project.
177
            //do nothing for the original project.
177
            return ;
178
            return ;
Lines 181-187 Link Here
181
        fixPrivateProperties(origOperations);
182
        fixPrivateProperties(origOperations);
182
        fixDistJarProperty (nueName);
183
        fixDistJarProperty (nueName);
183
        fixApplicationTitle(nueName);
184
        fixApplicationTitle(nueName);
184
        project.getReferenceHelper().fixReferences(originalPath);        
185
        if ("file".equals(originalPath.getScheme())) {
186
            File f = new File(originalPath);
187
            project.getReferenceHelper().fixReferences(f);
188
        }
185
        project.setName(nueName);
189
        project.setName(nueName);
186
        restoreConfigurations(origOperations);
190
        restoreConfigurations(origOperations);
187
    }
191
    }
Lines 197-203 Link Here
197
        clean();
201
        clean();
198
    }
202
    }
199
            
203
            
200
    public void notifyMoved(Project original, File originalPath, String nueName) {        
204
    @Override public void notifyMoved(Project original, URI originalPath, String nueName) {
201
        if (original == null) {
205
        if (original == null) {
202
            project.getAntProjectHelper().notifyDeleted();
206
            project.getAntProjectHelper().notifyDeleted();
203
            return ;
207
            return ;
Lines 208-214 Link Here
208
        fixDistJarProperty (nueName);
212
        fixDistJarProperty (nueName);
209
        fixApplicationTitle(nueName);
213
        fixApplicationTitle(nueName);
210
        project.setName(nueName);        
214
        project.setName(nueName);        
211
	project.getReferenceHelper().fixReferences(originalPath);
215
        if ("file".equals(originalPath.getScheme())) {
216
            File f = new File(originalPath);
217
            project.getReferenceHelper().fixReferences(f);
218
        }
212
        restoreConfigurations(origOperations);
219
        restoreConfigurations(origOperations);
213
    }
220
    }
214
221
(-)a/maven/nbproject/project.xml (-1 / +1 lines)
Lines 233-239 Link Here
233
                    <compile-dependency/>
233
                    <compile-dependency/>
234
                    <run-dependency>
234
                    <run-dependency>
235
                        <release-version>1</release-version>
235
                        <release-version>1</release-version>
236
                        <specification-version>1.40</specification-version>
236
                        <specification-version>1.43</specification-version>
237
                    </run-dependency>
237
                    </run-dependency>
238
                </dependency>
238
                </dependency>
239
                <dependency>
239
                <dependency>
(-)a/maven/src/org/netbeans/modules/maven/operations/OperationsImpl.java (-13 / +26 lines)
Lines 42-49 Link Here
42
42
43
package org.netbeans.modules.maven.operations;
43
package org.netbeans.modules.maven.operations;
44
44
45
import java.io.File;
46
import java.io.IOException;
45
import java.io.IOException;
46
import java.net.URI;
47
import java.net.URISyntaxException;
47
import java.util.ArrayList;
48
import java.util.ArrayList;
48
import java.util.Collections;
49
import java.util.Collections;
49
import java.util.List;
50
import java.util.List;
Lines 57-65 Link Here
57
import org.netbeans.modules.maven.model.ModelOperation;
58
import org.netbeans.modules.maven.model.ModelOperation;
58
import org.netbeans.modules.maven.model.Utilities;
59
import org.netbeans.modules.maven.model.Utilities;
59
import org.netbeans.modules.maven.model.pom.POMModel;
60
import org.netbeans.modules.maven.model.pom.POMModel;
60
import org.netbeans.spi.project.CopyOperationImplementation;
61
import org.netbeans.spi.project.CopyOperationImplementation2;
61
import org.netbeans.spi.project.DeleteOperationImplementation;
62
import org.netbeans.spi.project.DeleteOperationImplementation;
62
import org.netbeans.spi.project.MoveOperationImplementation;
63
import org.netbeans.spi.project.MoveOperationImplementation2;
63
import org.netbeans.spi.project.ProjectServiceProvider;
64
import org.netbeans.spi.project.ProjectServiceProvider;
64
import org.netbeans.spi.project.ProjectState;
65
import org.netbeans.spi.project.ProjectState;
65
import org.openide.execution.ExecutorTask;
66
import org.openide.execution.ExecutorTask;
Lines 72-79 Link Here
72
 * makes sure the project is removed from the possible module section of the parent..
73
 * makes sure the project is removed from the possible module section of the parent..
73
 * @author mkleint
74
 * @author mkleint
74
 */
75
 */
75
@ProjectServiceProvider(service={DeleteOperationImplementation.class, MoveOperationImplementation.class, CopyOperationImplementation.class}, projectType="org-netbeans-modules-maven")
76
@ProjectServiceProvider(service={DeleteOperationImplementation.class, MoveOperationImplementation2.class, CopyOperationImplementation2.class}, projectType="org-netbeans-modules-maven")
76
public class OperationsImpl implements DeleteOperationImplementation, MoveOperationImplementation, CopyOperationImplementation {
77
public class OperationsImpl implements DeleteOperationImplementation, MoveOperationImplementation2, CopyOperationImplementation2 {
77
78
78
    private final Project project;
79
    private final Project project;
79
80
Lines 139-147 Link Here
139
    public void notifyMoving() throws IOException {
140
    public void notifyMoving() throws IOException {
140
        notifyDeleting();
141
        notifyDeleting();
141
    }
142
    }
142
    
143
143
    @Override
144
    @Override
144
    public void notifyMoved(Project original, File originalLoc, final String newName) throws IOException {
145
    public void notifyMoved(Project original, URI originalLoc, final String newName) throws IOException {
145
        if (original == null) {
146
        if (original == null) {
146
            //old project call..
147
            //old project call..
147
            project.getLookup().lookup(ProjectState.class).notifyDeleted();
148
            project.getLookup().lookup(ProjectState.class).notifyDeleted();
Lines 158-181 Link Here
158
                Utilities.performPOMModelOperations(pomFO, Collections.singletonList(operation));
159
                Utilities.performPOMModelOperations(pomFO, Collections.singletonList(operation));
159
                NbMavenProject.fireMavenProjectReload(project);
160
                NbMavenProject.fireMavenProjectReload(project);
160
            }
161
            }
161
            checkParentProject(project.getProjectDirectory(), false, newName, originalLoc.getName());
162
            checkParentProject(project.getProjectDirectory(), false, newName, originalLoc);
162
        }
163
        }
163
    }
164
    }
164
    
165
    
166
    @Override public void notifyRenaming() throws IOException {
167
        notifyDeleting();
168
    }
169
170
    @Override public void notifyRenamed(String nueName) throws IOException {
171
        try {
172
            checkParentProject(project.getProjectDirectory(), false, nueName, project.getProjectDirectory().getURL().toURI());
173
        } catch (URISyntaxException x) {
174
            assert false : x;
175
        }
176
    }
177
165
    @Override
178
    @Override
166
    public void notifyCopying() throws IOException {
179
    public void notifyCopying() throws IOException {
167
    }
180
    }
168
    
181
    
169
    @Override
182
    @Override
170
    public void notifyCopied(Project original, File originalLoc, String newName) throws IOException {
183
    public void notifyCopied(Project original, URI originalLoc, String newName) throws IOException {
171
        if (original == null) {
184
        if (original == null) {
172
            //old project call..
185
            //old project call..
173
        } else {
186
        } else {
174
            checkParentProject(project.getProjectDirectory(), false, newName, originalLoc.getName());
187
            checkParentProject(project.getProjectDirectory(), false, newName, originalLoc);
175
        }
188
        }
176
    }
189
    }
177
    
190
    
178
    private void checkParentProject(FileObject projectDir, final boolean delete, final String newName, final String oldName) throws IOException {
191
    private void checkParentProject(FileObject projectDir, final boolean delete, final String newName, final URI originalLoc) throws IOException {
179
        final String prjLoc = projectDir.getNameExt();
192
        final String prjLoc = projectDir.getNameExt();
180
        FileObject fo = projectDir.getParent();
193
        FileObject fo = projectDir.getParent();
181
        Project possibleParent = ProjectManager.getDefault().findProject(fo);
194
        Project possibleParent = ProjectManager.getDefault().findProject(fo);
Lines 196-203 Link Here
196
                                model.getProject().addModule(prjLoc);
209
                                model.getProject().addModule(prjLoc);
197
                            }
210
                            }
198
                        }
211
                        }
199
                        if (newName != null && oldName != null) {
212
                        if (newName != null && originalLoc != null) {
200
                            if (oldName.equals(model.getProject().getArtifactId())) {
213
                            if (originalLoc.getPath().endsWith("/" + model.getProject().getArtifactId() + "/")) {
201
                                // is this condition necessary.. why not just overwrite the artifactID always..
214
                                // is this condition necessary.. why not just overwrite the artifactID always..
202
                                model.getProject().setArtifactId(newName);
215
                                model.getProject().setArtifactId(newName);
203
                            }
216
                            }
(-)a/projectapi/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
3
OpenIDE-Module-Install: org/netbeans/modules/projectapi/Installer.class
3
OpenIDE-Module-Install: org/netbeans/modules/projectapi/Installer.class
4
OpenIDE-Module-Specification-Version: 1.42
4
OpenIDE-Module-Specification-Version: 1.43
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
6
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
6
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
7
7
(-)a/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java (-21 / +2 lines)
Lines 48-75 Link Here
48
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
49
49
50
/**
50
/**
51
 * Project Copy Operation. Allows to gather information necessary for project
51
 * @deprecated use {@link CopyOperationImplementation2} instead
52
 * copy and also provides callbacks to the project type to handle special
53
 * checkpoints during the copy process.
54
 *
55
 * An implementation of this interface may be registered in the project's lookup to support
56
 * copy operation in the following cases:
57
 * <ul>
58
 *     <li>The project type wants to use
59
 * <a href="@org-netbeans-modules-projectuiapi@/org/netbeans/spi/project/ui/support/DefaultProjectOperations.html"><code>DefaultProjectOperations</code></a>
60
 *         to perform the copy operation.
61
 *    </li>
62
 *    <li>If this project may be part of of a compound project (like EJB project is a part of a J2EE project),
63
 *        and the compound project wants to copy all the sub-projects.
64
 *    </li>
65
 * </ul>
66
 *
67
 * The project type is not required to put an implementation of this interface into the project's
68
 * lookup if the above two cases should not be supported.
69
 *
70
 * @author Jan Lahoda
71
 * @since 1.7
72
 */
52
 */
53
@Deprecated
73
public interface CopyOperationImplementation extends DataFilesProviderImplementation {
54
public interface CopyOperationImplementation extends DataFilesProviderImplementation {
74
    
55
    
75
    /**Pre-copy notification. The exact meaning is left on the project implementors, but
56
    /**Pre-copy notification. The exact meaning is left on the project implementors, but
(-)a/projectapi/src/org/netbeans/spi/project/CopyOperationImplementation.java (-6 / +5 lines)
Lines 43-50 Link Here
43
 */
43
 */
44
package org.netbeans.spi.project;
44
package org.netbeans.spi.project;
45
45
46
import java.io.File;
47
import java.io.IOException;
46
import java.io.IOException;
47
import java.net.URI;
48
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
49
49
50
/**
50
/**
Lines 67-76 Link Here
67
 * The project type is not required to put an implementation of this interface into the project's
67
 * The project type is not required to put an implementation of this interface into the project's
68
 * lookup if the above two cases should not be supported.
68
 * lookup if the above two cases should not be supported.
69
 *
69
 *
70
 * @author Jan Lahoda
70
 * @since 1.43
71
 * @since 1.7
72
 */
71
 */
73
public interface CopyOperationImplementation extends DataFilesProviderImplementation {
72
public interface CopyOperationImplementation2 extends DataFilesProviderImplementation {
74
    
73
    
75
    /**Pre-copy notification. The exact meaning is left on the project implementors, but
74
    /**Pre-copy notification. The exact meaning is left on the project implementors, but
76
     * typically this means to undeploy the application and remove all artifacts
75
     * typically this means to undeploy the application and remove all artifacts
Lines 86-96 Link Here
86
     *
85
     *
87
     * @param original <code>null</code> when called on the original project, the original project when called on the new project
86
     * @param original <code>null</code> when called on the original project, the original project when called on the new project
88
     * @param originalPath the project folder of the original project (for consistency
87
     * @param originalPath the project folder of the original project (for consistency
89
     *                     with MoveOperationImplementation.notifyMoved)
88
     *                     with {@link MoveOperationImplementation2#notifyMoved})
90
     * @param nueName new name for the newly created project.
89
     * @param nueName new name for the newly created project.
91
     *
90
     *
92
     * @throws IOException if an I/O operation fails.
91
     * @throws IOException if an I/O operation fails.
93
     */
92
     */
94
    public void notifyCopied(Project original, File originalPath, String nueName)  throws IOException;
93
    public void notifyCopied(Project original, URI originalPath, String nueName)  throws IOException;
95
    
94
    
96
}
95
}
(-)a/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java (-23 / +2 lines)
Lines 48-77 Link Here
48
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
49
49
50
/**
50
/**
51
 * Project Rename/Move Operation. Allows to gather information necessary for project
51
 * @deprecated use {@link MoveOperationImplementation2} instead
52
 * move and also provides callbacks to the project type to handle special
53
 * checkpoints during the delete.
54
 *
55
 * An implementation of this interface may be registered in the project's lookup to support
56
 * move operation in the following cases:
57
 * <ul>
58
 *     <li>The project type wants to use
59
 * <a href="@org-netbeans-modules-projectuiapi@/org/netbeans/spi/project/ui/support/DefaultProjectOperations.html"><code>DefaultProjectOperations</code></a>
60
 *         to perform the rename/move operation.
61
 *    </li>
62
 *    <li>If this project may be part of of a compound project (like EJB project is a part of a J2EE project),
63
 *        and the compound project wants to rename/move all the sub-projects.
64
 *    </li>
65
 * </ul>
66
 *
67
 * The project type is not required to put an implementation of this interface into the project's
68
 * lookup if the above two cases should not be supported.
69
 *
70
 * <p><strong>Implementations are encouraged to implement {@link MoveOrRenameOperationImplementation} instead.</strong>
71
 *
72
 * @author Jan Lahoda
73
 * @since 1.7
74
 */
52
 */
53
@Deprecated
75
public interface MoveOperationImplementation extends DataFilesProviderImplementation {
54
public interface MoveOperationImplementation extends DataFilesProviderImplementation {
76
    
55
    
77
    /**Pre-move notification. The exact meaning is left on the project implementors, but
56
    /**Pre-move notification. The exact meaning is left on the project implementors, but
(-)a/projectapi/src/org/netbeans/spi/project/MoveOperationImplementation.java (-9 / +27 lines)
Lines 43-50 Link Here
43
 */
43
 */
44
package org.netbeans.spi.project;
44
package org.netbeans.spi.project;
45
45
46
import java.io.File;
47
import java.io.IOException;
46
import java.io.IOException;
47
import java.net.URI;
48
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
49
49
50
/**
50
/**
Lines 67-85 Link Here
67
 * The project type is not required to put an implementation of this interface into the project's
67
 * The project type is not required to put an implementation of this interface into the project's
68
 * lookup if the above two cases should not be supported.
68
 * lookup if the above two cases should not be supported.
69
 *
69
 *
70
 * <p><strong>Implementations are encouraged to implement {@link MoveOrRenameOperationImplementation} instead.</strong>
70
 * @since 1.43
71
 *
72
 * @author Jan Lahoda
73
 * @since 1.7
74
 */
71
 */
75
public interface MoveOperationImplementation extends DataFilesProviderImplementation {
72
public interface MoveOperationImplementation2 extends DataFilesProviderImplementation {
76
    
73
    
77
    /**Pre-move notification. The exact meaning is left on the project implementors, but
74
    /**Pre-move notification. The exact meaning is left on the project implementors, but
78
     * typically this means to undeploy the application and remove all artifacts
75
     * typically this means to undeploy the application and remove all artifacts
79
     * created by the build project.
76
     * created by the build project.
80
     *
77
     *
81
     * @throws IOException if an I/O operation fails.
78
     * @throws IOException if an I/O operation fails.
82
     * @see MoveOrRenameOperationImplementation#notifyRenaming
83
     */
79
     */
84
    public void notifyMoving() throws IOException;
80
    public void notifyMoving() throws IOException;
85
    
81
    
Lines 93-100 Link Here
93
     * @param nueName new name for the newly created project.
89
     * @param nueName new name for the newly created project.
94
     *
90
     *
95
     * @throws IOException if an I/O operation fails.
91
     * @throws IOException if an I/O operation fails.
96
     * @see MoveOrRenameOperationImplementation#notifyRenamed
97
     */
92
     */
98
    public void notifyMoved(Project original, File originalPath, String nueName) throws IOException;
93
    public void notifyMoved(Project original, URI originalPath, String nueName) throws IOException;
99
    
94
    
95
    /**
96
     * Pre-rename notification.
97
     * The exact meaning is left to the project's implementation;
98
     * it might for example undeploy an application and remove all artifacts
99
     * created by the build, in case they used the old name.
100
     * <p>Used in case the project can behave more simply, efficiently, and robustly when it is simply
101
     * being renamed (code and/or display name) without actually being moved to a new location.
102
     * In this case, {@link #notifyMoving} will not be called.
103
     * @throws IOException if an I/O operation fails
104
     */
105
    void notifyRenaming() throws IOException;
106
107
    /**
108
     * Notification that the rename operation has finished.
109
     * The project might for example change its display name in metadata.
110
     * <p>Used in case the project can behave more simply, efficiently, and robustly when it is simply
111
     * being renamed (code and/or display name) without actually being moved to a new location.
112
     * In this case, {@link #notifyMoved} will not be called.
113
     * @param nueName new name for the project
114
     * @throws IOException if an I/O operation fails
115
     */
116
    void notifyRenamed(String nueName) throws IOException;
117
100
}
118
}
(-)a/projectapi/src/org/netbeans/spi/project/MoveOrRenameOperationImplementation.java (-5 / +2 lines)
Lines 45-56 Link Here
45
import java.io.IOException;
45
import java.io.IOException;
46
46
47
/**
47
/**
48
 * A preferred substitute for {@code MoveOperationImplementation} to be used when
48
 * @deprecated use {@link MoveOperationImplementation2} instead
49
 * the project can behave more simply, efficiently, and robustly when it is simply
50
 * being renamed (code and/or display name) without actually being moved to a new location.
51
 * In this case, {@link #notifyMoving} and {@link #notifyMoved} will not be called.
52
 * @since org.netbeans.modules.projectapi/1 1.31
53
 */
49
 */
50
@Deprecated
54
public interface MoveOrRenameOperationImplementation extends MoveOperationImplementation {
51
public interface MoveOrRenameOperationImplementation extends MoveOperationImplementation {
55
52
56
    /**
53
    /**
(-)a/projectapi/src/org/netbeans/spi/project/support/ProjectOperations.java (-23 / +68 lines)
Lines 46-59 Link Here
46
46
47
import java.io.File;
47
import java.io.File;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.net.URI;
49
import java.util.ArrayList;
50
import java.util.ArrayList;
50
import java.util.List;
51
import java.util.List;
51
import org.netbeans.api.project.Project;
52
import org.netbeans.api.project.Project;
52
import org.netbeans.spi.project.CopyOperationImplementation;
53
import org.netbeans.spi.project.CopyOperationImplementation2;
53
import org.netbeans.spi.project.DataFilesProviderImplementation;
54
import org.netbeans.spi.project.DataFilesProviderImplementation;
54
import org.netbeans.spi.project.DeleteOperationImplementation;
55
import org.netbeans.spi.project.DeleteOperationImplementation;
55
import org.netbeans.spi.project.MoveOperationImplementation;
56
import org.netbeans.spi.project.MoveOperationImplementation2;
56
import org.netbeans.spi.project.MoveOrRenameOperationImplementation;
57
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileObject;
58
58
59
/**
59
/**
Lines 146-156 Link Here
146
    /**Test whether the copy operation is supported on the given project.
146
    /**Test whether the copy operation is supported on the given project.
147
     * 
147
     * 
148
     * @param prj project to test
148
     * @param prj project to test
149
     * @return <code>true</code> if the project has a {@link CopyOperationImplementation},
149
     * @return <code>true</code> if the project has a {@link CopyOperationImplementation2},
150
     *         <code>false</code> otherwise
150
     *         <code>false</code> otherwise
151
     */
151
     */
152
    @SuppressWarnings("deprecation")
152
    public static boolean isCopyOperationSupported(Project prj) {
153
    public static boolean isCopyOperationSupported(Project prj) {
153
        return prj.getLookup().lookup(CopyOperationImplementation.class) != null;
154
        return prj.getLookup().lookup(CopyOperationImplementation2.class) != null ||
155
               prj.getLookup().lookup(org.netbeans.spi.project.CopyOperationImplementation.class) != null;
154
    }
156
    }
155
    
157
    
156
    /**Notification that the project is about to be copyied.
158
    /**Notification that the project is about to be copyied.
Lines 160-173 Link Here
160
     *
162
     *
161
     * @param prj project to notify
163
     * @param prj project to notify
162
     * @throws IOException is some error occurs
164
     * @throws IOException is some error occurs
163
     * @see CopyOperationImplementation#notifyCopying
165
     * @see CopyOperationImplementation2#notifyCopying
164
     */
166
     */
167
    @SuppressWarnings("deprecation")
165
    public static void notifyCopying(Project prj) throws IOException {
168
    public static void notifyCopying(Project prj) throws IOException {
166
        for (CopyOperationImplementation i : prj.getLookup().lookupAll(CopyOperationImplementation.class)) {
169
        for (CopyOperationImplementation2 i : prj.getLookup().lookupAll(CopyOperationImplementation2.class)) {
170
            i.notifyCopying();
171
        }
172
        for (org.netbeans.spi.project.CopyOperationImplementation i : prj.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) {
167
            i.notifyCopying();
173
            i.notifyCopying();
168
        }
174
        }
169
    }
175
    }
170
    
176
177
    /**
178
     * @deprecated use {@link #notifyCopied(Project, Project, URI, String)} instead
179
     */
180
    @Deprecated
181
    public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException {
182
        notifyCopied(original, nue, originalPath.toURI(), name);
183
    }
171
    /**Notification that the project has been copied.
184
    /**Notification that the project has been copied.
172
     * Should be called immediatelly after the project is copied.
185
     * Should be called immediatelly after the project is copied.
173
     *
186
     *
Lines 181-215 Link Here
181
     * @param originalPath the project folder of the original project (for consistency with notifyMoved)
194
     * @param originalPath the project folder of the original project (for consistency with notifyMoved)
182
     * @param name     new name of the project
195
     * @param name     new name of the project
183
     * @throws IOException is some error occurs
196
     * @throws IOException is some error occurs
184
     * @see CopyOperationImplementation#notifyCopied
197
     * @see CopyOperationImplementation2#notifyCopied
198
     * @since 1.43
185
     */
199
     */
186
    public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException {
200
    @SuppressWarnings("deprecation")
187
        for (CopyOperationImplementation i : original.getLookup().lookupAll(CopyOperationImplementation.class)) {
201
    public static void notifyCopied(Project original, Project nue, URI originalPath, String name) throws IOException {
202
        for (CopyOperationImplementation2 i : original.getLookup().lookupAll(CopyOperationImplementation2.class)) {
188
            i.notifyCopied(null, originalPath, name);
203
            i.notifyCopied(null, originalPath, name);
189
        }
204
        }
190
        for (CopyOperationImplementation i : nue.getLookup().lookupAll(CopyOperationImplementation.class)) {
205
        for (CopyOperationImplementation2 i : nue.getLookup().lookupAll(CopyOperationImplementation2.class)) {
191
            i.notifyCopied(original, originalPath, name);
206
            i.notifyCopied(original, originalPath, name);
192
        }
207
        }
208
        if ("file".equals(originalPath.getScheme())) {
209
            File f = new File(originalPath);
210
            for (org.netbeans.spi.project.CopyOperationImplementation i : original.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) {
211
                i.notifyCopied(null, f, name);
212
            }
213
            for (org.netbeans.spi.project.CopyOperationImplementation i : nue.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) {
214
                i.notifyCopied(original, f, name);
215
            }
216
        }
193
    }
217
    }
194
    
218
    
195
    /**Notification that the project is about to be moved.
219
    /**Notification that the project is about to be moved.
196
     * Should be called immediately before the project is moved.
220
     * Should be called immediately before the project is moved.
197
     * {@link MoveOrRenameOperationImplementation#notifyRenaming} may be called instead.
221
     * {@link MoveOperationImplementation2#notifyRenaming} may be called instead.
198
     * The project is supposed to do all required cleanup to allow the project to be moved.
222
     * The project is supposed to do all required cleanup to allow the project to be moved.
199
     *
223
     *
200
     * @param prj project to notify
224
     * @param prj project to notify
201
     * @throws IOException is some error occurs
225
     * @throws IOException is some error occurs
202
     * @see MoveOperationImplementation#notifyMoving
226
     * @see MoveOperationImplementation2#notifyMoving
203
     */
227
     */
228
    @SuppressWarnings("deprecation")
204
    public static void notifyMoving(Project prj) throws IOException {
229
    public static void notifyMoving(Project prj) throws IOException {
205
        for (MoveOperationImplementation i : prj.getLookup().lookupAll(MoveOperationImplementation.class)) {
230
        for (org.netbeans.spi.project.MoveOperationImplementation i : prj.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) {
206
            i.notifyMoving();
231
            i.notifyMoving();
207
        }
232
        }
208
    }
233
    }
209
    
234
235
    /**
236
     * @deprecated use {@link #notifyMoved(Project, Project, URI, String)} instead
237
     */
238
    @Deprecated
239
    public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException {
240
        notifyMoved(original, nue, originalPath.toURI(), name);
241
    }
210
    /**Notification that the project has been moved.
242
    /**Notification that the project has been moved.
211
     * Should be called immediatelly after the project is moved.
243
     * Should be called immediatelly after the project is moved.
212
     * {@link MoveOrRenameOperationImplementation#notifyRenamed} may be called instead.
244
     * {@link MoveOperationImplementation2#notifyRenamed} may be called instead.
213
     *
245
     *
214
     * The project is supposed to do all necessary fixes to the project's structure to
246
     * The project is supposed to do all necessary fixes to the project's structure to
215
     * form a valid project.
247
     * form a valid project.
Lines 221-246 Link Here
221
     * @param originalPath the project folder of the original project
253
     * @param originalPath the project folder of the original project
222
     * @param name     new name of the project
254
     * @param name     new name of the project
223
     * @throws IOException is some error occurs
255
     * @throws IOException is some error occurs
224
     * @see MoveOperationImplementation#notifyMoved
256
     * @see MoveOperationImplementation2#notifyMoved
257
     * @since 1.43
225
     */
258
     */
226
    public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException {
259
    @SuppressWarnings("deprecation")
227
        for (MoveOperationImplementation i : original.getLookup().lookupAll(MoveOperationImplementation.class)) {
260
    public static void notifyMoved(Project original, Project nue, URI originalPath, String name) throws IOException {
261
        for (MoveOperationImplementation2 i : original.getLookup().lookupAll(MoveOperationImplementation2.class)) {
228
            i.notifyMoved(null, originalPath, name);
262
            i.notifyMoved(null, originalPath, name);
229
        }
263
        }
230
        for (MoveOperationImplementation i : nue.getLookup().lookupAll(MoveOperationImplementation.class)) {
264
        for (MoveOperationImplementation2 i : nue.getLookup().lookupAll(MoveOperationImplementation2.class)) {
231
            i.notifyMoved(original, originalPath, name);
265
            i.notifyMoved(original, originalPath, name);
232
        }
266
        }
267
        if ("file".equals(originalPath.getScheme())) {
268
            File f = new File(originalPath);
269
            for (org.netbeans.spi.project.MoveOperationImplementation i : original.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) {
270
                i.notifyMoved(null, f, name);
271
            }
272
            for (org.netbeans.spi.project.MoveOperationImplementation i : nue.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) {
273
                i.notifyMoved(original, f, name);
274
            }
275
        }
233
    }
276
    }
234
    
277
    
235
    /**
278
    /**
236
     * Tests whether the move or rename operations are supported on the given project.
279
     * Tests whether the move or rename operations are supported on the given project.
237
     * 
280
     * 
238
     * @param prj project to test
281
     * @param prj project to test
239
     * @return <code>true</code> if the project has a {@link MoveOperationImplementation},
282
     * @return <code>true</code> if the project has a {@link MoveOperationImplementation2},
240
     *         <code>false</code> otherwise
283
     *         <code>false</code> otherwise
241
     */
284
     */
285
    @SuppressWarnings("deprecation")
242
    public static boolean isMoveOperationSupported(Project prj) {
286
    public static boolean isMoveOperationSupported(Project prj) {
243
        return prj.getLookup().lookup(MoveOperationImplementation.class) != null;
287
        return prj.getLookup().lookup(MoveOperationImplementation2.class) != null ||
288
               prj.getLookup().lookup(org.netbeans.spi.project.MoveOperationImplementation.class) != null;
244
    }
289
    }
245
    
290
    
246
}
291
}
(-)a/projectuiapi/nbproject/project.xml (-1 / +1 lines)
Lines 73-79 Link Here
73
                    <compile-dependency/>
73
                    <compile-dependency/>
74
                    <run-dependency>
74
                    <run-dependency>
75
                        <release-version>1</release-version>
75
                        <release-version>1</release-version>
76
                        <specification-version>1.31</specification-version>
76
                        <specification-version>1.43</specification-version>
77
                    </run-dependency>
77
                    </run-dependency>
78
                </dependency>
78
                </dependency>
79
                <dependency>
79
                <dependency>
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectOperationsImplementation.java (-16 / +24 lines)
Lines 78-87 Link Here
78
import org.netbeans.api.project.ProjectUtils;
78
import org.netbeans.api.project.ProjectUtils;
79
import org.netbeans.api.project.ui.OpenProjects;
79
import org.netbeans.api.project.ui.OpenProjects;
80
import org.netbeans.api.queries.SharabilityQuery;
80
import org.netbeans.api.queries.SharabilityQuery;
81
import org.netbeans.spi.project.MoveOperationImplementation;
82
import org.netbeans.spi.project.support.ProjectOperations;
81
import org.netbeans.spi.project.support.ProjectOperations;
83
import org.netbeans.api.queries.VisibilityQuery;
82
import org.netbeans.api.queries.VisibilityQuery;
84
import org.netbeans.spi.project.MoveOrRenameOperationImplementation;
83
import org.netbeans.spi.project.MoveOperationImplementation2;
85
import org.openide.DialogDescriptor;
84
import org.openide.DialogDescriptor;
86
import org.openide.DialogDisplayer;
85
import org.openide.DialogDisplayer;
87
import org.openide.LifecycleManager;
86
import org.openide.LifecycleManager;
Lines 301-307 Link Here
301
            
300
            
302
            handle.progress((int) (currentWorkDone += totalWork * FIND_PROJECT_WORK));
301
            handle.progress((int) (currentWorkDone += totalWork * FIND_PROJECT_WORK));
303
            
302
            
304
            ProjectOperations.notifyCopied(project, nue, FileUtil.toFile(project.getProjectDirectory()), nueName);
303
            ProjectOperations.notifyCopied(project, nue, project.getProjectDirectory().getURL().toURI(), nueName);
305
            
304
            
306
            handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK));
305
            handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK));
307
            
306
            
Lines 375-384 Link Here
375
        });
374
        });
376
    }
375
    }
377
376
377
    @SuppressWarnings("deprecation")
378
    private static void doRenameProject(ProgressHandle handle, Project project, String nueName) throws Exception {
378
    private static void doRenameProject(ProgressHandle handle, Project project, String nueName) throws Exception {
379
        Collection<? extends MoveOperationImplementation> operations = project.getLookup().lookupAll(MoveOperationImplementation.class);
379
        Collection<? extends MoveOperationImplementation2> operations2 = project.getLookup().lookupAll(MoveOperationImplementation2.class);
380
        for (MoveOperationImplementation o : operations) {
380
        Collection<? extends org.netbeans.spi.project.MoveOperationImplementation> operations = project.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class);
381
            if (!(o instanceof MoveOrRenameOperationImplementation)) {
381
        for (org.netbeans.spi.project.MoveOperationImplementation o : operations) {
382
            if (!(o instanceof org.netbeans.spi.project.MoveOrRenameOperationImplementation)) {
382
                Logger.getLogger(DefaultProjectOperationsImplementation.class.getName()).log(Level.WARNING,
383
                Logger.getLogger(DefaultProjectOperationsImplementation.class.getName()).log(Level.WARNING,
383
                        "{0} should implement MoveOrRenameOperationImplementation", o.getClass().getName());
384
                        "{0} should implement MoveOrRenameOperationImplementation", o.getClass().getName());
384
                doRenameProjectOld(handle, project, nueName, operations);
385
                doRenameProjectOld(handle, project, nueName, operations);
Lines 390-401 Link Here
390
            handle.switchToDeterminate(4);
391
            handle.switchToDeterminate(4);
391
            int currentWorkDone = 0;
392
            int currentWorkDone = 0;
392
            handle.progress(++currentWorkDone);
393
            handle.progress(++currentWorkDone);
393
            for (MoveOperationImplementation o : operations) {
394
            for (MoveOperationImplementation2 o : operations2) {
394
                ((MoveOrRenameOperationImplementation) o).notifyRenaming();
395
                o.notifyRenaming();
396
            }
397
            for (org.netbeans.spi.project.MoveOperationImplementation o : operations) {
398
                ((org.netbeans.spi.project.MoveOrRenameOperationImplementation) o).notifyRenaming();
395
            }
399
            }
396
            handle.progress(++currentWorkDone);
400
            handle.progress(++currentWorkDone);
397
            for (MoveOperationImplementation o : operations) {
401
            for (MoveOperationImplementation2 o : operations2) {
398
                ((MoveOrRenameOperationImplementation) o).notifyRenamed(nueName);
402
                o.notifyRenamed(nueName);
403
            }
404
            for (org.netbeans.spi.project.MoveOperationImplementation o : operations) {
405
                ((org.netbeans.spi.project.MoveOrRenameOperationImplementation) o).notifyRenamed(nueName);
399
            }
406
            }
400
            handle.progress(++currentWorkDone);
407
            handle.progress(++currentWorkDone);
401
            ProjectManager.getDefault().saveProject(project);
408
            ProjectManager.getDefault().saveProject(project);
Lines 407-414 Link Here
407
        }
414
        }
408
    }
415
    }
409
416
417
    @SuppressWarnings("deprecation")
410
    private static void doRenameProjectOld(ProgressHandle handle, Project project, String nueName,
418
    private static void doRenameProjectOld(ProgressHandle handle, Project project, String nueName,
411
            Collection<? extends MoveOperationImplementation> operations) throws Exception {
419
            Collection<? extends org.netbeans.spi.project.MoveOperationImplementation> operations) throws Exception {
412
        boolean originalOK = true;
420
        boolean originalOK = true;
413
        Project main = OpenProjects.getDefault().getMainProject();
421
        Project main = OpenProjects.getDefault().getMainProject();
414
        boolean wasMain = main != null && project.getProjectDirectory().equals(main.getProjectDirectory());
422
        boolean wasMain = main != null && project.getProjectDirectory().equals(main.getProjectDirectory());
Lines 421-431 Link Here
421
            File projectDirectoryFile = FileUtil.toFile(project.getProjectDirectory());
429
            File projectDirectoryFile = FileUtil.toFile(project.getProjectDirectory());
422
            close(project);
430
            close(project);
423
            handle.progress(++currentWorkDone);
431
            handle.progress(++currentWorkDone);
424
            for (MoveOperationImplementation o : operations) {
432
            for (org.netbeans.spi.project.MoveOperationImplementation o : operations) {
425
                o.notifyMoving();
433
                o.notifyMoving();
426
            }
434
            }
427
            handle.progress(++currentWorkDone);
435
            handle.progress(++currentWorkDone);
428
            for (MoveOperationImplementation o : operations) {
436
            for (org.netbeans.spi.project.MoveOperationImplementation o : operations) {
429
                o.notifyMoved(null, projectDirectoryFile, nueName);
437
                o.notifyMoved(null, projectDirectoryFile, nueName);
430
            }
438
            }
431
            handle.progress(++currentWorkDone);
439
            handle.progress(++currentWorkDone);
Lines 435-442 Link Here
435
            assert nue != null;
443
            assert nue != null;
436
            originalOK = false;
444
            originalOK = false;
437
            handle.progress(++currentWorkDone);
445
            handle.progress(++currentWorkDone);
438
            operations = nue.getLookup().lookupAll(MoveOperationImplementation.class);
446
            operations = nue.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class);
439
            for (MoveOperationImplementation o : operations) {
447
            for (org.netbeans.spi.project.MoveOperationImplementation o : operations) {
440
                o.notifyMoved(project, projectDirectoryFile, nueName);
448
                o.notifyMoved(project, projectDirectoryFile, nueName);
441
            }
449
            }
442
            ProjectManager.getDefault().saveProject(project);
450
            ProjectManager.getDefault().saveProject(project);
Lines 512-518 Link Here
512
            assert nue != project : "got same Project for " + projectDirectory + " and " + target;
520
            assert nue != project : "got same Project for " + projectDirectory + " and " + target;
513
            LOG.log(Level.FINE, "doMoveProject 2/2: {0} @{1}", new Object[] {target, nue.hashCode()});
521
            LOG.log(Level.FINE, "doMoveProject 2/2: {0} @{1}", new Object[] {target, nue.hashCode()});
514
522
515
            ProjectOperations.notifyMoved(project, nue, FileUtil.toFile(project.getProjectDirectory()), nueProjectName);
523
            ProjectOperations.notifyMoved(project, nue, project.getProjectDirectory().getURL().toURI(), nueProjectName);
516
            
524
            
517
            handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK));
525
            handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK));
518
            
526
            

Return to bug 207488