Index: projectapi/apichanges.xml =================================================================== RCS file: /cvs/projects/projectapi/apichanges.xml,v retrieving revision 1.2 diff -u -r1.2 apichanges.xml --- projectapi/apichanges.xml 23 Dec 2004 22:01:28 -0000 1.2 +++ projectapi/apichanges.xml 13 May 2005 10:07:18 -0000 @@ -76,6 +76,28 @@ + + + notifyDeleted method added to the ProjectState + + + + +

+ As only the ProjectManager is allowed to implement ProjectState interface, + this change should not directly affect any clients. +

+
+ +

+ The notifyDeleted action is added to the ProjectState, + allowing the project implmentation to let the ProjectManager + know that the project has been deleted. +

+
+ +
+ Switched to major release version 1 Index: projectapi/src/org/netbeans/api/project/ProjectManager.java =================================================================== RCS file: /cvs/projects/projectapi/src/org/netbeans/api/project/ProjectManager.java,v retrieving revision 1.14 diff -u -r1.14 ProjectManager.java --- projectapi/src/org/netbeans/api/project/ProjectManager.java 5 Apr 2005 00:19:20 -0000 1.14 +++ projectapi/src/org/netbeans/api/project/ProjectManager.java 13 May 2005 10:07:19 -0000 @@ -15,6 +15,7 @@ import java.io.IOException; import java.lang.ref.Reference; +import java.net.URI; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -455,7 +456,20 @@ } }); } - + + public void notifyDeleted() { + assert p != null; + mutex().writeAccess(new Mutex.Action() { + public Object run() { + assert proj2Factory.get(p) != null; + dir2Proj.remove(p.getProjectDirectory()); + proj2Factory.remove(p); + modifiedProjects.remove(p); + return null; + } + }); + } + } /** Index: projectapi/src/org/netbeans/spi/project/ActionProvider.java =================================================================== RCS file: /cvs/projects/projectapi/src/org/netbeans/spi/project/ActionProvider.java,v retrieving revision 1.6 diff -u -r1.6 ActionProvider.java --- projectapi/src/org/netbeans/spi/project/ActionProvider.java 2 Jun 2004 03:49:09 -0000 1.6 +++ projectapi/src/org/netbeans/spi/project/ActionProvider.java 13 May 2005 10:07:19 -0000 @@ -86,7 +86,11 @@ */ String COMMAND_DEBUG_STEP_INTO = "debug.stepinto"; // NOI18N - + /** + * Standard command for deleting the project. + */ + String COMMAND_DELETE = "delete"; // NOI18N + /** * Get a list of all commands which this project supports. * @return a list of command names suitable for {@link #invokeAction} Index: projectapi/src/org/netbeans/spi/project/ProjectState.java =================================================================== RCS file: /cvs/projects/projectapi/src/org/netbeans/spi/project/ProjectState.java,v retrieving revision 1.3 diff -u -r1.3 ProjectState.java --- projectapi/src/org/netbeans/spi/project/ProjectState.java 26 Apr 2004 22:12:18 -0000 1.3 +++ projectapi/src/org/netbeans/spi/project/ProjectState.java 13 May 2005 10:07:19 -0000 @@ -19,8 +19,9 @@ /** * Callback permitting {@link Project}s to inform the {@link ProjectManager} * of important lifecycle events. - * Currently the only available event is modification of the project metadata. - * However in the future other events may be added, such as moving or deleting + * Currently the only available events are modification of the project metadata + * and project deletion notification. + * However in the future other events may be added, such as moving * the project, which the project manager would need to be informed of. *

* This interface may only be implemented by the project manager. A @@ -38,5 +39,20 @@ *

Acquires write access. */ void markModified(); + + /** + *

Inform the manager that the project has been deleted. The project will + * be removed from any {@link ProjectManager}'s mappings. + * If {@link ProjectManager#findProject} is called on the project directory, + * the {@link ProjectFactory ProjectFactories} are asked again to recognize + * the project.

+ * + *

The project is no longer recognized as created by the {@link ProjectManager}.

+ * + *

Acquires write access.

+ * + * @since 1.4 + */ + void notifyDeleted(); } Index: projectapi/test/unit/src/org/netbeans/api/project/ProjectManagerTest.java =================================================================== RCS file: /cvs/projects/projectapi/test/unit/src/org/netbeans/api/project/ProjectManagerTest.java,v retrieving revision 1.9 diff -u -r1.9 ProjectManagerTest.java --- projectapi/test/unit/src/org/netbeans/api/project/ProjectManagerTest.java 5 Apr 2005 00:19:20 -0000 1.9 +++ projectapi/test/unit/src/org/netbeans/api/project/ProjectManagerTest.java 13 May 2005 10:07:20 -0000 @@ -373,4 +373,50 @@ } } + public void testNotifyDeleted() throws Exception { + FileObject p1 = scratch.createFolder("p1"); + FileObject p1TestProject = p1.createFolder("testproject"); + + Project project1 = pm.findProject(p1); + + assertNotNull("project1 is recognized", project1); + p1TestProject.delete(); + TestUtil.notifyDeleted(project1); + + assertNull("project1 is deleted", pm.findProject(p1)); + + FileObject p2 = scratch.createFolder("p2"); + FileObject p2TestProject = p2.createFolder("testproject"); + + Project project2 = pm.findProject(p2); + + assertNotNull("project2 is recognized", project2); + TestUtil.notifyDeleted(project2); + + Project project2b = pm.findProject(p2); + + assertTrue("project2 is newly recognized", project2b != project2); + assertNotNull("project2 is newly recognized", project2b); + + FileObject p3 = scratch.createFolder("p3"); + FileObject p3TestProject = p3.createFolder("testproject"); + + Project project3 = pm.findProject(p3); + + assertNotNull("project3 is recognized", project3); + TestUtil.modify(project3); + assertTrue("project3 is modified", pm.isModified(project3)); + TestUtil.notifyDeleted(project3); + + boolean wasException = false; + try { + assertFalse("project3 is not modified", pm.isModified(project3)); + } catch (IllegalArgumentException e) { + //the project is no longer recognized by the ProjectManager. + wasException = true; + } + + assertTrue("the project is no longer recognized by the ProjectManager", wasException); + } + } Index: projectapi/test/unit/src/org/netbeans/api/project/TestUtil.java =================================================================== RCS file: /cvs/projects/projectapi/test/unit/src/org/netbeans/api/project/TestUtil.java,v retrieving revision 1.10 diff -u -r1.10 TestUtil.java --- projectapi/test/unit/src/org/netbeans/api/project/TestUtil.java 18 Apr 2005 22:17:13 -0000 1.10 +++ projectapi/test/unit/src/org/netbeans/api/project/TestUtil.java 13 May 2005 10:07:20 -0000 @@ -192,6 +192,14 @@ } /** + * Mark a test project as modified. + * @param p a test project + */ + public static void notifyDeleted(Project p) { + ((TestProject)p).state.notifyDeleted(); + } + + /** * If set to something non-null, loading a broken project will wait for * notification on this monitor before throwing an exception. * @see ProjectManagerTest#testLoadExceptionWithConcurrentLoad Index: projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java =================================================================== RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java,v retrieving revision 1.32 diff -u -r1.32 OpenProjectList.java --- projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java 12 May 2005 09:00:24 -0000 1.32 +++ projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java 13 May 2005 10:07:21 -0000 @@ -708,7 +708,7 @@ } public ProjectReference( Project p ) { - this.projectReference = new WeakReference( p ); +// this.projectReference = new WeakReference( p ); try { projectURL = p.getProjectDirectory().getURL(); } Index: projectui/src/org/netbeans/modules/project/ui/actions/Actions.java =================================================================== RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/actions/Actions.java,v retrieving revision 1.20 diff -u -r1.20 Actions.java --- projectui/src/org/netbeans/modules/project/ui/actions/Actions.java 5 Apr 2005 18:31:35 -0000 1.20 +++ projectui/src/org/netbeans/modules/project/ui/actions/Actions.java 13 May 2005 10:07:21 -0000 @@ -48,6 +48,7 @@ private static Action OPEN_SUBPROJECTS; private static Action CLOSE_PROJECT; private static Action NEW_FILE; + private static Action DELETE_PROJECT; public synchronized Action setAsMainProjectAction() { if ( SET_AS_MAIN_PROJECT == null ) { @@ -84,6 +85,10 @@ return NEW_FILE; } + public Action deleteProjectAction() { + return deleteProject(); + } + public Action projectCommandAction(String command, String namePattern, Icon icon ) { return new ProjectAction( command, namePattern, icon, null ); } @@ -157,6 +162,18 @@ return a; } + public static synchronized Action deleteProject() { + if (DELETE_PROJECT == null) { + DELETE_PROJECT = new ProjectAction ( + ActionProvider.COMMAND_DELETE, + NbBundle.getMessage(Actions.class, "LBL_DeleteProjectAction_Name" ), // NOI18N + null, + null ); + } + + return DELETE_PROJECT; + } + // 1-off actions ----------------------------------------------------------- public static Action compileSingle() { @@ -252,5 +269,5 @@ a.putValue("iconBase","org/netbeans/modules/project/ui/resources/debugProject.gif"); //NOI18N return a; } - + } Index: projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties =================================================================== RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties,v retrieving revision 1.21 diff -u -r1.21 Bundle.properties --- projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties 24 Nov 2004 20:06:56 -0000 1.21 +++ projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties 13 May 2005 10:07:22 -0000 @@ -42,6 +42,7 @@ LBL_TestProjectAction_Name=Test {0,choice,0#Project|1#"{1}"|1<{0} Projects} LBL_CompileSingleAction_Name=Co&mpile {0,choice,0#File|1#"{1}"|1