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 58489
Collapse All | Expand All

(-)projectui/src/org/netbeans/modules/project/ui/actions/Actions.java (+5 lines)
Lines 84-89 Link Here
84
        return NEW_FILE;
84
        return NEW_FILE;
85
    }    
85
    }    
86
    
86
    
87
    public synchronized Action newProjectAction() {
88
        return new NewProject();
89
    }
90
    
91
    
87
    public Action projectCommandAction(String command, String namePattern, Icon icon ) {
92
    public Action projectCommandAction(String command, String namePattern, Icon icon ) {
88
        return new ProjectAction( command, namePattern, icon, null );
93
        return new ProjectAction( command, namePattern, icon, null );
89
    }
94
    }
(-)projectui/src/org/netbeans/modules/project/ui/actions/NewProject.java (-3 / +14 lines)
Lines 14-19 Link Here
14
package org.netbeans.modules.project.ui.actions;
14
package org.netbeans.modules.project.ui.actions;
15
15
16
import java.awt.event.ActionEvent;
16
import java.awt.event.ActionEvent;
17
import java.io.File;
17
import java.io.IOException;
18
import java.io.IOException;
18
import java.util.Iterator;
19
import java.util.Iterator;
19
import java.util.LinkedList;
20
import java.util.LinkedList;
Lines 26-31 Link Here
26
import org.netbeans.modules.project.ui.NewProjectWizard;
27
import org.netbeans.modules.project.ui.NewProjectWizard;
27
import org.netbeans.modules.project.ui.OpenProjectList;
28
import org.netbeans.modules.project.ui.OpenProjectList;
28
import org.netbeans.modules.project.ui.ProjectUtilities;
29
import org.netbeans.modules.project.ui.ProjectUtilities;
30
import org.netbeans.spi.project.ui.support.CommonProjectActions;
29
import org.openide.ErrorManager;
31
import org.openide.ErrorManager;
30
import org.openide.filesystems.FileObject;
32
import org.openide.filesystems.FileObject;
31
import org.openide.filesystems.Repository;
33
import org.openide.filesystems.Repository;
Lines 68-76 Link Here
68
        }
70
        }
69
    }    
71
    }    
70
        
72
        
71
    private void doPerform () {
73
    /*T9Y*/ NewProjectWizard prepareWizardDescriptor(FileObject fo) {
72
        
73
        FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource( "Templates/Project" ); //NOI18N                
74
        NewProjectWizard wizard = new NewProjectWizard(fo);
74
        NewProjectWizard wizard = new NewProjectWizard(fo);
75
            
75
            
76
        if ( isPreselect ) {
76
        if ( isPreselect ) {
Lines 83-88 Link Here
83
            wizard.putProperty( "PRESELECT_TEMPLATE", null ); 
83
            wizard.putProperty( "PRESELECT_TEMPLATE", null ); 
84
        }
84
        }
85
85
86
        File folder = (File) getValue(CommonProjectActions.EXISTING_SOURCES_DIRECTORY);
87
        if (folder != null) {
88
            wizard.putProperty(CommonProjectActions.EXISTING_SOURCES_DIRECTORY, folder);
89
        }
90
        return wizard;
91
    }
92
    
93
    private void doPerform () {
94
        
95
        FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource( "Templates/Project" ); //NOI18N                
96
        NewProjectWizard wizard = prepareWizardDescriptor(fo);
86
        
97
        
87
        try {
98
        try {
88
                        
99
                        
(-)projectuiapi/nbproject/project.properties (+4 lines)
Lines 14-16 Link Here
14
javadoc.title=Project UI API
14
javadoc.title=Project UI API
15
javadoc.arch=${basedir}/arch.xml
15
javadoc.arch=${basedir}/arch.xml
16
javadoc.apichanges=${basedir}/apichanges.xml
16
javadoc.apichanges=${basedir}/apichanges.xml
17
# copy paste magic to enable unit tests
18
test.unit.src.dir=${basedir}/test/unit/src
19
test-unit-sys-prop.test.junit.jar=${junit.dir}/modules/ext/junit-3.8.1.jar
20
(-)projectuiapi/src/org/netbeans/modules/project/uiapi/ActionsFactory.java (+2 lines)
Lines 34-39 Link Here
34
    public Action closeProjectAction();
34
    public Action closeProjectAction();
35
    
35
    
36
    public Action newFileAction();
36
    public Action newFileAction();
37
    
38
    public Action newProjectAction();
37
            
39
            
38
    // Actions sensitive to project selection
40
    // Actions sensitive to project selection
39
    
41
    
(-)projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java (+17 lines)
Lines 22-27 Link Here
22
 */
22
 */
23
public class CommonProjectActions {
23
public class CommonProjectActions {
24
    
24
    
25
    /**
26
     * {@link File} property honored by newProjectAction that defines
27
     * default working directory (compare to project directory).
28
     */
29
    public static final String EXISTING_SOURCES_DIRECTORY = "existingSourcesDirectory";
30
    
25
    private CommonProjectActions() {}
31
    private CommonProjectActions() {}
26
        
32
        
27
    /**
33
    /**
Lines 90-93 Link Here
90
        return Utilities.getActionsFactory().newFileAction();
96
        return Utilities.getActionsFactory().newFileAction();
91
    }
97
    }
92
    
98
    
99
    /**
100
     * Creates action that invokes new project wizard.
101
     * It honors {@link #EXISTING_SOURCES_DIRECTORY}.
102
     *
103
     * @return an action
104
     * @see org.netbeans.spi.project.ui.PrivilegedTemplates
105
     * @see org.netbeans.spi.project.ui.RecommendedTemplates
106
     */
107
    public static Action newProjectAction() {
108
        return Utilities.getActionsFactory().newProjectAction();
109
    }    
93
}
110
}
(-)projectuiapi/test/unit/src/org/netbeans/spi/project/ui/support/CommonProjectActionsTest.java (+62 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.spi.project.ui.support;
15
import junit.framework.*;
16
import javax.swing.Action;
17
import org.netbeans.modules.project.uiapi.Utilities;
18
19
/**
20
 *
21
 * @author Petr Kuzel
22
 */
23
public class CommonProjectActionsTest extends TestCase {
24
    
25
    public CommonProjectActionsTest(String testName) {
26
        super(testName);
27
    }
28
29
    public static Test suite() {
30
        TestSuite suite = new TestSuite(CommonProjectActionsTest.class);
31
        
32
        return suite;
33
    }
34
35
    public void testSetAsMainProjectAction() {
36
    }
37
38
    public void testCustomizeProjectAction() {
39
    }
40
41
    public void testOpenSubprojectsAction() {
42
    }
43
44
    public void testCloseProjectAction() {
45
    }
46
47
    public void testNewFileAction() {
48
    }
49
50
    /**
51
     * Assure that two clients do not interact.
52
     */
53
    public void testNewProjectAction() {
54
        Action client1 = CommonProjectActions.newProjectAction();
55
        File exitingSources = new File("/tmp");
56
        client1.setValue(CommonProjectActions.EXISTING_SOURCES_DIRECTORY, exitingSources);
57
        Action client2 = CommonProjectActions.newProjectAction();
58
        Object o = client2.getValue(CommonProjectActions.EXISTING_SOURCES_DIRECTORY);
59
        assertTrue(o != exitingSources);
60
    }
61
    
62
}

Return to bug 58489