Line 17
Link Here
|
|
|
17 |
import java.io.*; |
Line 18
Link Here
|
|
|
19 |
import java.util.*; |
Line 25
Link Here
|
|
|
27 |
import org.netbeans.api.java.project.*; |
28 |
import org.netbeans.api.project.*; |
Line 31
Link Here
|
|
|
35 |
import org.openide.filesystems.*; |
Line 87
Link Here
|
|
|
92 |
|
Line 88
Link Here
|
|
|
94 |
|
95 |
// Set properties to the selected file if the command is *-single or debug.fix. |
96 |
|
97 |
Properties p = null; |
98 |
|
99 |
if (COMMAND_COMPILE_SINGLE.equals(command) || COMMAND_RUN_SINGLE.equals(command) |
100 |
|| COMMAND_DEBUG_SINGLE.equals(command) || JavaProjectConstants.COMMAND_DEBUG_FIX.equals(command)) { |
101 |
FileObject root = null; |
102 |
String path = null; |
103 |
// First, assume that it is a Java source file. |
104 |
SourceGroup[] groups = ProjectUtils.getSources(project).getSourceGroups("java"); |
105 |
for (int gi = 0; gi < groups.length; ++gi) { |
106 |
root = groups[gi].getRootFolder(); |
107 |
FileObject[] files = ActionUtils.findSelectedFiles(context, root, ".java", true); // NOI18N |
108 |
if (files != null && files.length > 0) { |
109 |
path = FileUtil.getRelativePath(root, files[0]); |
110 |
break; |
111 |
} |
112 |
} |
113 |
// Didn't find it. Perhaps it is a JSP file. |
114 |
if (path == null && COMMAND_COMPILE_SINGLE.equals(command)) { |
115 |
root = null; |
116 |
groups = ProjectUtils.getSources(project).getSourceGroups("doc_root"); |
117 |
for (int gi = 0; gi < groups.length; ++gi) { |
118 |
root = groups[gi].getRootFolder(); |
119 |
FileObject[] files = ActionUtils.findSelectedFiles(context, root, ".jsp", true); // NOI18N |
120 |
if (files != null && files.length > 0) { |
121 |
path = FileUtil.getRelativePath(root, files[0]); |
122 |
break; |
123 |
} |
124 |
} |
125 |
// What else? Replace the command with e g 'compile-single-jsp'? For now the Ant script will have |
126 |
// to make the distinction. |
127 |
} |
128 |
// If found, set properties. |
129 |
if (path != null) { |
130 |
p = new Properties(); |
131 |
p.setProperty("context.path", path); |
132 |
if (path.endsWith(".java")) { |
133 |
String base = path.substring(0, path.length()-5); |
134 |
p.setProperty("context.base", base); |
135 |
String clazz = base.replace('/', '.'); |
136 |
p.setProperty("context.class", clazz); |
137 |
} |
138 |
String relRoot = FileUtil.getRelativePath(project.getProjectDirectory(), root); |
139 |
p.setProperty("context.root", relRoot); |
140 |
} |
141 |
} |
142 |
|
143 |
|
Line 97
Link Here
|
97 |
runConfiguredAction(project, actionEl); |
153 |
runConfiguredAction(project, actionEl, p); |
98 |
-- |
|
|
Line 107
Link Here
|
107 |
private static void runConfiguredAction(FreeformProject project, Element actionEl) { |
163 |
private static void runConfiguredAction(FreeformProject project, Element actionEl, Properties props) { |
108 |
-- |
|
|
Line 138
Link Here
|
138 |
ActionUtils.runTarget(scriptFile, targetNameArray, null); |
194 |
ActionUtils.runTarget(scriptFile, targetNameArray, props); |
139 |
-- |
|
|
Line 200
Link Here
|
200 |
runConfiguredAction(p, actionEl); |
256 |
runConfiguredAction(p, actionEl, null); |
201 |
-- |
|
|