Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 195706 | Differences between
and this patch

Collapse All | Expand All

(-)php.project/nbproject/project.xml (+17 lines)
 Lines 47-52    Link Here 
47
            <code-name-base>org.netbeans.modules.php.project</code-name-base>
47
            <code-name-base>org.netbeans.modules.php.project</code-name-base>
48
            <module-dependencies>
48
            <module-dependencies>
49
                <dependency>
49
                <dependency>
50
                    <code-name-base>org.apache.tools.ant.module</code-name-base>
51
                    <build-prerequisite/>
52
                    <compile-dependency/>
53
                    <run-dependency>
54
                        <release-version>3</release-version>
55
                        <specification-version>3.39</specification-version>
56
                    </run-dependency>
57
                </dependency>
58
                <dependency>
50
                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
59
                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
51
                    <build-prerequisite/>
60
                    <build-prerequisite/>
52
                    <compile-dependency/>
61
                    <compile-dependency/>
 Lines 255-260    Link Here 
255
                    </run-dependency>
264
                    </run-dependency>
256
                </dependency>
265
                </dependency>
257
                <dependency>
266
                <dependency>
267
                    <code-name-base>org.openide.execution</code-name-base>
268
                    <build-prerequisite/>
269
                    <compile-dependency/>
270
                    <run-dependency>
271
                        <specification-version>1.17</specification-version>
272
                    </run-dependency>
273
                </dependency>
274
                <dependency>
258
                    <code-name-base>org.openide.explorer</code-name-base>
275
                    <code-name-base>org.openide.explorer</code-name-base>
259
                    <build-prerequisite/>
276
                    <build-prerequisite/>
260
                    <compile-dependency/>
277
                    <compile-dependency/>
(-)php.project/src/org/netbeans/modules/php/project/PhpActionProvider.java (+7 lines)
 Lines 37-42    Link Here 
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 *
40
 */
41
 */
41
package org.netbeans.modules.php.project;
42
package org.netbeans.modules.php.project;
42
43
 Lines 60-65    Link Here 
60
import org.netbeans.modules.php.project.ui.actions.RunTestCommand;
61
import org.netbeans.modules.php.project.ui.actions.RunTestCommand;
61
import org.netbeans.modules.php.project.ui.actions.TestProjectCommand;
62
import org.netbeans.modules.php.project.ui.actions.TestProjectCommand;
62
import org.netbeans.modules.php.project.ui.actions.UploadCommand;
63
import org.netbeans.modules.php.project.ui.actions.UploadCommand;
64
import org.netbeans.modules.php.project.ui.actions.AddAntSupportCommand;
65
import org.netbeans.modules.php.project.ui.actions.BuildProjectCommand;
66
import org.netbeans.modules.php.project.ui.actions.RebuildProjectCommand;
63
import org.netbeans.spi.project.ActionProvider;
67
import org.netbeans.spi.project.ActionProvider;
64
import org.netbeans.spi.project.ui.support.FileSensitiveActions;
68
import org.netbeans.spi.project.ui.support.FileSensitiveActions;
65
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
69
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
 Lines 87-92    Link Here 
87
            new CopyCommand(project),
91
            new CopyCommand(project),
88
            new MoveCommand(project),
92
            new MoveCommand(project),
89
            new RenameCommand(project),
93
            new RenameCommand(project),
94
            new AddAntSupportCommand(project),
95
            new BuildProjectCommand(project),
96
            new RebuildProjectCommand(project),
90
97
91
            // file sensitive actions
98
            // file sensitive actions
92
            new DownloadCommand(project),
99
            new DownloadCommand(project),
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/AddAntSupportCommand.java (+49 lines)
Added Link Here 
1
package org.netbeans.modules.php.project.ui.actions;
2
3
import org.netbeans.modules.php.project.ui.actions.support.Displayable;
4
import org.netbeans.modules.php.project.PhpProject;
5
import org.netbeans.modules.php.project.ui.ProjectNameProvider;
6
import org.netbeans.modules.php.project.ui.actions.support.AntBuildExecutionSupportItem;
7
import org.netbeans.modules.php.project.ui.actions.support.ConfigAction;
8
import org.netbeans.spi.project.ActionProvider;
9
import org.openide.nodes.Node;
10
import org.openide.util.Lookup;
11
import org.openide.util.NbBundle;
12
import org.openide.windows.TopComponent;
13
14
/**
15
 * @author Phil Lello
16
 */
17
public class AddAntSupportCommand extends Command implements Displayable {
18
    public static final String ID = "add_ant_support";
19
    public static final String DISPLAY_NAME = NbBundle.getMessage(AddAntSupportCommand.class, "LBL_AddAntSupportToProject");
20
21
    /**
22
     * @param project
23
     */
24
    public AddAntSupportCommand(PhpProject project) {
25
        super(project);
26
    }
27
28
    @Override
29
    public void invokeAction(Lookup context) {
30
        AntBuildExecutionSupportItem.addToProject(getProject());
31
    }
32
33
    @Override
34
    public boolean isActionEnabled(Lookup context) {
35
        // As this action is only on the menu when ant support is missing,
36
        // it is always enabled.
37
        return true;
38
    }
39
40
    @Override
41
    public String getCommandId() {
42
        return ID;
43
    }
44
45
    @Override
46
    public String getDisplayName() {
47
        return DISPLAY_NAME;
48
    }
49
}
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/BuildProjectCommand.java (+49 lines)
Added Link Here 
1
package org.netbeans.modules.php.project.ui.actions;
2
3
import org.netbeans.modules.php.project.ui.actions.support.Displayable;
4
import org.netbeans.modules.php.project.PhpProject;
5
import org.netbeans.modules.php.project.ui.actions.support.AntBuildExecutionSupportItem;
6
import org.netbeans.modules.php.project.ui.actions.support.ConfigAction;
7
import org.netbeans.spi.project.ActionProvider;
8
import org.openide.util.Exceptions;
9
import org.openide.util.Lookup;
10
import org.openide.util.NbBundle;
11
12
/**
13
 * @author Phil Lello
14
 */
15
public class BuildProjectCommand extends Command implements Displayable {
16
    public static final String ID = ActionProvider.COMMAND_BUILD;
17
    public static final String DISPLAY_NAME = NbBundle.getMessage(BuildProjectCommand.class, "LBL_BuildProject");
18
19
    /**
20
     * @param project
21
     */
22
    public BuildProjectCommand(PhpProject project) {
23
        super(project);
24
    }
25
26
    @Override
27
    public void invokeAction(Lookup context) {
28
        try {
29
            AntBuildExecutionSupportItem.invokeTarget(getProject(), "build");
30
        } catch (Exception ex) {
31
            Exceptions.printStackTrace(ex);
32
        }
33
    }
34
35
    @Override
36
    public boolean isActionEnabled(Lookup context) {
37
        return AntBuildExecutionSupportItem.hasTarget(getProject(), "build");
38
    }
39
40
    @Override
41
    public String getCommandId() {
42
        return ID;
43
    }
44
45
    @Override
46
    public String getDisplayName() {
47
        return DISPLAY_NAME;
48
    }
49
}
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/Bundle.properties (+3 lines)
 Lines 38-45    Link Here 
38
# made subject to such option by the copyright holder.
38
# made subject to such option by the copyright holder.
39
39
40
#DefaultAntProjectOperations:
40
#DefaultAntProjectOperations:
41
LBL_AddAntSupportToProject=Add Ant Support
41
LBL_RunProject=Run
42
LBL_RunProject=Run
42
LBL_DebugProject=Debug
43
LBL_DebugProject=Debug
44
LBL_BuildProject=Build
45
LBL_RebuildProject=Rebuild
43
LBL_TestProject=Test
46
LBL_TestProject=Test
44
LBL_TestFile=Test
47
LBL_TestFile=Test
45
LBL_UploadCommand=Upload
48
LBL_UploadCommand=Upload
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/RebuildProjectCommand.java (+49 lines)
Added Link Here 
1
package org.netbeans.modules.php.project.ui.actions;
2
3
import org.netbeans.modules.php.project.ui.actions.support.Displayable;
4
import org.netbeans.modules.php.project.PhpProject;
5
import org.netbeans.modules.php.project.ui.actions.support.AntBuildExecutionSupportItem;
6
import org.netbeans.modules.php.project.ui.actions.support.ConfigAction;
7
import org.netbeans.spi.project.ActionProvider;
8
import org.openide.util.Exceptions;
9
import org.openide.util.Lookup;
10
import org.openide.util.NbBundle;
11
12
/**
13
 * @author Phil Lello
14
 */
15
public class RebuildProjectCommand extends Command implements Displayable {
16
    public static final String ID = ActionProvider.COMMAND_REBUILD;
17
    public static final String DISPLAY_NAME = NbBundle.getMessage(RebuildProjectCommand.class, "LBL_RebuildProject");
18
19
    /**
20
     * @param project
21
     */
22
    public RebuildProjectCommand(PhpProject project) {
23
        super(project);
24
    }
25
26
    @Override
27
    public void invokeAction(Lookup context) {
28
        try {
29
            AntBuildExecutionSupportItem.invokeTarget(getProject(), "rebuild");
30
        } catch (Exception ex) {
31
            Exceptions.printStackTrace(ex);
32
        }
33
    }
34
35
    @Override
36
    public boolean isActionEnabled(Lookup context) {
37
        return AntBuildExecutionSupportItem.hasTarget(getProject(), "rebuild");
38
    }
39
40
    @Override
41
    public String getCommandId() {
42
        return ID;
43
    }
44
45
    @Override
46
    public String getDisplayName() {
47
        return DISPLAY_NAME;
48
    }
49
}
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/support/AntBuildExecutionSupportItem.java (+136 lines)
Added Link Here 
1
package org.netbeans.modules.php.project.ui.actions.support;
2
3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.io.OutputStream;
6
import java.util.List;
7
import org.apache.tools.ant.module.api.AntProjectCookie;
8
import org.apache.tools.ant.module.api.AntTargetExecutor;
9
import org.apache.tools.ant.module.api.AntTargetExecutor.Env;
10
import org.apache.tools.ant.module.api.support.AntScriptUtils;
11
import org.netbeans.modules.php.project.PhpProject;
12
import org.netbeans.spi.project.ui.support.BuildExecutionSupport;
13
import org.openide.execution.ExecutorTask;
14
import org.openide.filesystems.FileObject;
15
import org.openide.loaders.DataObject;
16
import org.openide.loaders.DataObjectNotFoundException;
17
import org.openide.util.Exceptions;
18
import org.openide.util.Task;
19
import org.openide.util.TaskListener;
20
21
/**
22
 *
23
 * @author Phil Lello
24
 */
25
26
public class AntBuildExecutionSupportItem implements BuildExecutionSupport.Item, TaskListener {
27
    private final AntTargetExecutor mTargetExecutor;
28
    private final String[] mTargets;
29
    private final AntProjectCookie mProjectCookie;
30
    private ExecutorTask mExecutorTask;
31
    private final DataObject mBuildDataObject;
32
    private final FileObject mBuildFileObject;
33
34
    AntBuildExecutionSupportItem(FileObject buildFileObject, String[] targets) throws DataObjectNotFoundException {
35
        mBuildFileObject = buildFileObject;
36
        mBuildDataObject = DataObject.find(mBuildFileObject);
37
        mProjectCookie = mBuildDataObject.getCookie(AntProjectCookie.class);
38
        mTargets = targets;
39
        mTargetExecutor = AntTargetExecutor.createTargetExecutor(new Env());
40
    }
41
42
    @Override
43
    public String getDisplayName() {
44
        return "Running Ant Build";
45
    }
46
47
    @Override
48
    public void repeatExecution() {
49
        stopRunning();
50
        try {
51
            startRunning();
52
        } catch (IOException ex) {
53
            Exceptions.printStackTrace(ex);
54
        }
55
    }
56
57
    @Override
58
    public boolean isRunning() {
59
        return (mExecutorTask == null)?false:true;
60
    }
61
62
    @Override
63
    public void stopRunning() {
64
        if (mExecutorTask != null) mExecutorTask.stop();
65
        mExecutorTask.waitFinished();
66
        taskFinished(mExecutorTask);
67
    }
68
69
    public void startRunning() throws IOException {
70
        mExecutorTask = mTargetExecutor.execute(mProjectCookie, mTargets);
71
        mExecutorTask.addTaskListener(this);
72
        BuildExecutionSupport.registerRunningItem(this);
73
    }
74
75
    @Override
76
    public void taskFinished(Task task) {
77
        mExecutorTask = null;
78
        BuildExecutionSupport.registerFinishedItem(this);
79
    }
80
81
    public static AntBuildExecutionSupportItem invokeTarget(PhpProject project, String target)
82
           throws Exception {
83
        return invokeTarget(getBuildFileObject(project), target);
84
    }
85
86
    public static AntBuildExecutionSupportItem invokeTarget(FileObject antFile, String target)
87
           throws Exception {
88
        AntBuildExecutionSupportItem item;
89
        item = new AntBuildExecutionSupportItem(antFile, new String[]{target});
90
        item.startRunning();
91
        return item;
92
    }
93
94
    public static boolean hasTarget(PhpProject project, String target) {
95
        return hasTarget(getBuildFileObject(project), target);
96
    }
97
98
    public static boolean hasTarget(FileObject antFile, String target) {
99
        boolean present = false;
100
        List<String> targets;
101
        try {
102
          targets = AntScriptUtils.getCallableTargetNames(antFile);
103
          present = targets.contains(target);
104
        } catch (Exception e) {
105
          // Any error means we can't run target, so we don't care what it is.
106
        }
107
        return present;
108
    }
109
110
    public static FileObject getBuildFileObject(PhpProject project) {
111
        FileObject buildXml = project.getProjectDirectory().getFileObject("build.xml");
112
        return buildXml;
113
    }
114
115
    public static void addToProject(PhpProject project) {
116
        try {
117
            FileObject buildFile = project.getProjectDirectory().createData("build.xml");
118
            InputStream is = AntBuildExecutionSupportItem.class.getResourceAsStream("build.template.xml");
119
            OutputStream os = buildFile.getOutputStream();
120
            while (is.available() != 0) {
121
                os.write(is.read());
122
            }
123
            os.close();
124
            is.close();
125
        } catch (IOException ex) {
126
            Exceptions.printStackTrace(ex);
127
        }
128
    }
129
130
    /**
131
     * @return the mTargetExecutor
132
     */
133
    public ExecutorTask getExecutorTask() {
134
        return mExecutorTask;
135
    }
136
}
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/support/AntConfigAction.java (+95 lines)
Added Link Here 
1
package org.netbeans.modules.php.project.ui.actions.support;
2
3
import org.netbeans.modules.php.project.PhpProject;
4
import org.openide.execution.ExecutorTask;
5
import org.openide.util.Exceptions;
6
import org.openide.util.Lookup;
7
import org.openide.util.Task;
8
import org.openide.util.TaskListener;
9
10
/**
11
 *
12
 * @author Phil Lello
13
 */
14
public class AntConfigAction extends ConfigAction {
15
    ConfigAction mDelegate;
16
17
    protected AntConfigAction(PhpProject project, ConfigAction delegate) {
18
        super(project);
19
        mDelegate = delegate;
20
    }
21
22
    @Override
23
    public boolean isValid(boolean indexFileNeeded) {
24
        return mDelegate.isValid(indexFileNeeded);
25
    }
26
27
    @Override
28
    public boolean isRunFileEnabled(Lookup context) {
29
        return mDelegate.isRunFileEnabled(context);
30
    }
31
32
    @Override
33
    public boolean isDebugFileEnabled(Lookup context) {
34
        return mDelegate.isDebugFileEnabled(context);
35
    }
36
37
    @Override
38
    public void runProject() {
39
        build(new Runnable() {
40
            @Override
41
            public void run() {
42
                mDelegate.runProject();
43
            }
44
        });
45
    }
46
47
    @Override
48
    public void debugProject() {
49
        build(new Runnable() {
50
            @Override
51
            public void run() {
52
                mDelegate.debugProject();
53
            }
54
        });
55
    }
56
57
    @Override
58
    public void runFile(final Lookup context) {
59
        build(new Runnable() {
60
            @Override
61
            public void run() {
62
                mDelegate.runFile(context);
63
            }
64
        });
65
    }
66
67
    @Override
68
    public void debugFile(final Lookup context) {
69
        build(new Runnable() {
70
            @Override
71
            public void run() {
72
                mDelegate.debugFile(context);
73
            }
74
        });
75
    }
76
77
    public void build(final Runnable runOnSuccess) {
78
        if (AntBuildExecutionSupportItem.hasTarget(project, "build")) {
79
           try {
80
                AntBuildExecutionSupportItem invokeTarget = AntBuildExecutionSupportItem.invokeTarget(project, "build");
81
                invokeTarget.getExecutorTask().addTaskListener(new TaskListener() {
82
                    @Override
83
                    public void taskFinished(Task task) {
84
                        if (((ExecutorTask)task).result() == 0)
85
                            runOnSuccess.run();
86
                    }
87
                });
88
           } catch (Exception ex) {
89
                Exceptions.printStackTrace(ex);
90
            }
91
        } else {
92
            runOnSuccess.run();
93
        }
94
    }
95
}
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/support/ConfigAction.java (+1 lines)
 Lines 111-116    Link Here 
111
            default:
111
            default:
112
                throw new IllegalArgumentException("Unknown type: " + type);
112
                throw new IllegalArgumentException("Unknown type: " + type);
113
        }
113
        }
114
        action = new AntConfigAction(project, action);
114
        assert action != null;
115
        assert action != null;
115
        return action;
116
        return action;
116
    }
117
    }
(-)php.project/src/org/netbeans/modules/php/project/ui/actions/support/build.template.xml (+13 lines)
Added Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project default="build">
3
    <property file="nbproject/private/private.properties" />
4
    <property file="nbproject/private/config.properties" />
5
    <property file="nbproject/project.properties" />
6
    <target name="build" description="Generate content">
7
        <echo>Generated content should be output into $${web.root}, which is ${web.root}</echo>
8
    </target>
9
    <target name="clean" description="Delete generated content">
10
    </target>
11
    <target name="rebuild" depends="clean,build" description="Regenerate content">
12
    </target>
13
</project>
(-)php.project/src/org/netbeans/modules/php/project/ui/logicalview/PhpLogicalViewProvider.java (+6 lines)
 Lines 54-61    Link Here 
54
import org.netbeans.modules.php.project.PhpActionProvider;
54
import org.netbeans.modules.php.project.PhpActionProvider;
55
import org.netbeans.modules.php.project.PhpProject;
55
import org.netbeans.modules.php.project.PhpProject;
56
import org.netbeans.modules.php.project.ui.actions.support.CommandUtils;
56
import org.netbeans.modules.php.project.ui.actions.support.CommandUtils;
57
import org.netbeans.modules.php.project.ui.actions.support.AntBuildExecutionSupportItem;
57
import org.netbeans.modules.php.project.ui.customizer.CustomizerProviderImpl;
58
import org.netbeans.modules.php.project.ui.customizer.CustomizerProviderImpl;
58
import org.netbeans.modules.php.project.phpunit.PhpUnit;
59
import org.netbeans.modules.php.project.phpunit.PhpUnit;
60
import org.netbeans.modules.php.project.ui.actions.AddAntSupportCommand;
59
import org.netbeans.modules.php.spi.phpmodule.PhpFrameworkProvider;
61
import org.netbeans.modules.php.spi.phpmodule.PhpFrameworkProvider;
60
import org.netbeans.modules.php.spi.phpmodule.PhpModuleActionsExtender;
62
import org.netbeans.modules.php.spi.phpmodule.PhpModuleActionsExtender;
61
import org.netbeans.spi.project.ActionProvider;
63
import org.netbeans.spi.project.ActionProvider;
 Lines 206-211    Link Here 
206
            List<Action> actions = new ArrayList<Action>();
208
            List<Action> actions = new ArrayList<Action>();
207
            actions.add(CommonProjectActions.newFileAction());
209
            actions.add(CommonProjectActions.newFileAction());
208
            actions.add(null);
210
            actions.add(null);
211
            if (AntBuildExecutionSupportItem.getBuildFileObject(project) == null)
212
                actions.add(provider.getAction(AddAntSupportCommand.ID));
213
            actions.add(provider.getAction(ActionProvider.COMMAND_BUILD));
214
            actions.add(provider.getAction(ActionProvider.COMMAND_REBUILD));
209
            actions.add(provider.getAction(ActionProvider.COMMAND_RUN));
215
            actions.add(provider.getAction(ActionProvider.COMMAND_RUN));
210
            actions.add(provider.getAction(ActionProvider.COMMAND_DEBUG));
216
            actions.add(provider.getAction(ActionProvider.COMMAND_DEBUG));
211
            actions.add(provider.getAction(ActionProvider.COMMAND_TEST));
217
            actions.add(provider.getAction(ActionProvider.COMMAND_TEST));

Return to bug 195706
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo