Index: Actions.java =================================================================== RCS file: /cvs/ant/freeform/src/org/netbeans/modules/ant/freeform/Actions.java,v --- Actions.java 1.4 +++ Actions.java @@ -17,0 +17,1 @@ +import java.io.*; @@ -18,0 +19,1 @@ +import java.util.*; @@ -25,0 +27,2 @@ +import org.netbeans.api.java.project.*; +import org.netbeans.api.project.*; @@ -31,0 +35,1 @@ +import org.openide.filesystems.*; @@ -87,0 +92,1 @@ + @@ -88,0 +94,29 @@ + + // Set properties to the selected file if the command is *-single or debug.fix. + + Properties p = null; + + if (COMMAND_COMPILE_SINGLE.equals(command) || COMMAND_RUN_SINGLE.equals(command) + || COMMAND_DEBUG_SINGLE.equals(command) || JavaProjectConstants.COMMAND_DEBUG_FIX.equals(command)) { + String path = null; + SourceGroup[] groups = ProjectUtils.getSources(project).getSourceGroups("java"); + for (int gi = 0; gi < groups.length; ++gi) { + FileObject root = groups[gi].getRootFolder(); + FileObject[] files = ActionUtils.findSelectedFiles(context, root, ".java", true); // NOI18N + if (files != null && files.length > 0) { + path = FileUtil.getRelativePath(root, files[0]); + } + } + if (path != null) { + p = new Properties(); + p.setProperty("context.path", path); + if (path.endsWith(".java")) { + String base = path.substring(0, path.length()-5); + p.setProperty("context.base", base); + String clazz = base.replace('/', '.'); + p.setProperty("context.class", clazz); + } + } + } + + @@ -97,1 +132,1 @@ - runConfiguredAction(project, actionEl); --- + runConfiguredAction(project, actionEl, p); @@ -107,1 +142,1 @@ - private static void runConfiguredAction(FreeformProject project, Element actionEl) { --- + private static void runConfiguredAction(FreeformProject project, Element actionEl, Properties props) { @@ -138,1 +173,1 @@ - ActionUtils.runTarget(scriptFile, targetNameArray, null); --- + ActionUtils.runTarget(scriptFile, targetNameArray, props); @@ -200,1 +235,1 @@ - runConfiguredAction(p, actionEl); --- + runConfiguredAction(p, actionEl, null);