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

(-)j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java (+6 lines)
Lines 80-85 Link Here
80
        COMMAND_DEBUG_TEST_SINGLE, 
80
        COMMAND_DEBUG_TEST_SINGLE, 
81
        JavaProjectConstants.COMMAND_DEBUG_FIX,
81
        JavaProjectConstants.COMMAND_DEBUG_FIX,
82
        COMMAND_DEBUG_STEP_INTO,
82
        COMMAND_DEBUG_STEP_INTO,
83
        COMMAND_DELETE,
83
    };
84
    };
84
    
85
    
85
    // Project
86
    // Project
Lines 124-129 Link Here
124
    }
125
    }
125
    
126
    
126
    public void invokeAction( String command, Lookup context ) throws IllegalArgumentException {
127
    public void invokeAction( String command, Lookup context ) throws IllegalArgumentException {
128
        if (COMMAND_DELETE.equals(command)) {
129
            project.getAntProjectHelper().performDefaultDeleteOperation();
130
            return ;
131
        }
132
        
127
        Properties p = new Properties();
133
        Properties p = new Properties();
128
        String[] targetNames;
134
        String[] targetNames;
129
        
135
        
(-)j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (+5 lines)
Lines 122-127 Link Here
122
    public Lookup getLookup() {
122
    public Lookup getLookup() {
123
        return lookup;
123
        return lookup;
124
    }
124
    }
125
    
126
    public AntProjectHelper getAntProjectHelper() {
127
        return helper;
128
    }
125
129
126
    private Lookup createLookup(AuxiliaryConfiguration aux) {
130
    private Lookup createLookup(AuxiliaryConfiguration aux) {
127
        SubprojectProvider spp = refHelper.createSubprojectProvider();
131
        SubprojectProvider spp = refHelper.createSubprojectProvider();
Lines 148-153 Link Here
148
            new RecommendedTemplatesImpl (this.updateHelper),
152
            new RecommendedTemplatesImpl (this.updateHelper),
149
            new J2SEProjectClassPathExtender(this, this.updateHelper, eval,refHelper),
153
            new J2SEProjectClassPathExtender(this, this.updateHelper, eval,refHelper),
150
            this, // never cast an externally obtained Project to J2SEProject - use lookup instead
154
            this, // never cast an externally obtained Project to J2SEProject - use lookup instead
155
            new J2SEProjectOperation(this),
151
        });
156
        });
152
    }
157
    }
153
158
(-)j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperation.java (+105 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.modules.java.j2seproject;
15
16
import java.io.IOException;
17
import java.util.ArrayList;
18
import java.util.List;
19
import java.util.Properties;
20
import org.apache.tools.ant.module.api.support.ActionUtils;
21
import org.netbeans.spi.project.ActionProvider;
22
import org.netbeans.spi.project.ProjectOperationsImplementation.DeleteOperationImplementation;
23
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
24
import org.openide.ErrorManager;
25
import org.openide.filesystems.FileObject;
26
import org.openide.filesystems.FileUtil;
27
import org.openide.util.Lookup;
28
import org.openide.util.lookup.Lookups;
29
30
/**
31
 *
32
 * @author Jan Lahoda
33
 */
34
public class J2SEProjectOperation implements DeleteOperationImplementation {
35
    
36
    private J2SEProject project;
37
    
38
    public J2SEProjectOperation(J2SEProject project) {
39
        this.project = project;
40
    }
41
    
42
    private static void addFile(FileObject projectDirectory, String fileName, List/*<FileObject>*/ result) {
43
        FileObject file = projectDirectory.getFileObject(fileName);
44
        
45
        if (file != null) {
46
            result.add(file);
47
        }
48
    }
49
    
50
    public List/*<FileObject>*/ getMetadataFiles() {
51
        FileObject projectDirectory = project.getProjectDirectory();
52
        List/*<FileObject>*/ files = new ArrayList();
53
        
54
        addFile(projectDirectory, "nbproject", files); // NOI18N
55
        addFile(projectDirectory, "build.xml", files); // NOI18N
56
        
57
        return files;
58
    }
59
    
60
    public List/*<FileObject>*/ getDataFiles() {
61
        FileObject projectDirectory = project.getProjectDirectory();
62
        List/*<FileObject>*/ files = new ArrayList();
63
        
64
        SourceRoots src = project.getSourceRoots();
65
        FileObject[] srcRoots = src.getRoots();
66
        
67
        for (int cntr = 0; cntr < srcRoots.length; cntr++) {
68
            if (FileUtil.isParentOf(projectDirectory, srcRoots[cntr]))
69
                files.add(srcRoots[cntr]);
70
        }
71
        
72
        SourceRoots test = project.getTestSourceRoots();
73
        FileObject[] testRoots = test.getRoots();
74
        
75
        for (int cntr = 0; cntr < testRoots.length; cntr++) {
76
            if (FileUtil.isParentOf(projectDirectory, testRoots[cntr]))
77
                files.add(testRoots[cntr]);
78
        }
79
        
80
        addFile(projectDirectory, "manifest.mf", files); // NOI18N
81
        
82
        return files;
83
    }
84
    
85
    public void performClean() throws IOException {
86
        J2SEActionProvider ap = (J2SEActionProvider) project.getLookup().lookup(J2SEActionProvider.class);
87
        
88
        assert ap != null;
89
        
90
        Lookup context = Lookups.fixed(new Object[0]);
91
        Properties p = new Properties();
92
        String[] targetNames = ap.getTargetNames(ActionProvider.COMMAND_CLEAN, context, p);
93
        FileObject buildXML = project.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH);
94
        
95
        assert targetNames != null;
96
        assert targetNames.length > 0;
97
        
98
        ActionUtils.runTarget(buildXML, targetNames, p).waitFinished();
99
    }
100
    
101
    public void notifyDeleted() throws IOException {
102
        project.getAntProjectHelper().notifyDeleted();
103
    }
104
    
105
}
(-)j2seproject/src/org/netbeans/modules/java/j2seproject/ui/J2SEPhysicalViewProvider.java (+2 lines)
Lines 495-500 Link Here
495
            actions.add(CommonProjectActions.openSubprojectsAction());
495
            actions.add(CommonProjectActions.openSubprojectsAction());
496
            actions.add(CommonProjectActions.closeProjectAction());
496
            actions.add(CommonProjectActions.closeProjectAction());
497
            actions.add(null);
497
            actions.add(null);
498
            actions.add(CommonProjectActions.deleteProjectAction());
499
            actions.add(null);
498
            actions.add(SystemAction.get( org.openide.actions.FindAction.class ));
500
            actions.add(SystemAction.get( org.openide.actions.FindAction.class ));
499
                /*
501
                /*
500
                null,
502
                null,

Return to bug 58866