1 19 20 package org.netbeans.modules.apisupport.project.ui; 21 22 import java.awt.event.ActionEvent ; 23 import java.io.IOException ; 24 import java.util.ArrayList ; 25 import java.util.HashMap ; 26 import java.util.HashSet ; 27 import java.util.List ; 28 import java.util.Map ; 29 import java.util.Properties ; 30 import java.util.Set ; 31 import java.util.regex.Pattern ; 32 import javax.swing.AbstractAction ; 33 import javax.swing.Action ; 34 import javax.swing.JSeparator ; 35 import org.apache.tools.ant.module.api.support.ActionUtils; 36 import org.netbeans.api.java.project.JavaProjectConstants; 37 import org.netbeans.api.project.ProjectManager; 38 import org.netbeans.modules.apisupport.project.NbModuleProject; 39 import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; 40 import org.netbeans.modules.apisupport.project.Util; 41 import org.netbeans.modules.apisupport.project.suite.SuiteProject; 42 import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerProviderImpl; 43 import org.netbeans.modules.apisupport.project.ui.customizer.SuiteProperties; 44 import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils; 45 import org.netbeans.modules.apisupport.project.universe.NbPlatform; 46 import org.netbeans.spi.project.ActionProvider; 47 import org.netbeans.spi.project.support.ant.AntProjectHelper; 48 import org.netbeans.spi.project.support.ant.EditableProperties; 49 import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; 50 import org.netbeans.spi.project.ui.support.CommonProjectActions; 51 import org.netbeans.spi.project.ui.support.DefaultProjectOperations; 52 import org.netbeans.spi.project.ui.support.ProjectSensitiveActions; 53 import org.openide.DialogDisplayer; 54 import org.openide.ErrorManager; 55 import org.openide.NotifyDescriptor; 56 import org.openide.actions.FindAction; 57 import org.openide.actions.ToolsAction; 58 import org.openide.filesystems.FileObject; 59 import org.openide.filesystems.FileUtil; 60 import org.openide.filesystems.Repository; 61 import org.openide.loaders.DataFolder; 62 import org.openide.loaders.FolderLookup; 63 import org.openide.util.Lookup; 64 import org.openide.util.Mutex; 65 import org.openide.util.NbBundle; 66 import org.openide.util.actions.SystemAction; 67 68 public final class ModuleActions implements ActionProvider { 69 70 static Action [] getProjectActions(NbModuleProject project) { 71 List <Action > actions = new ArrayList <Action >(); 72 actions.add(CommonProjectActions.newFileAction()); 73 actions.add(null); 74 actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_BUILD, NbBundle.getMessage(ModuleActions.class, "ACTION_build"), null)); 75 actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_REBUILD, NbBundle.getMessage(ModuleActions.class, "ACTION_rebuild"), null)); 76 actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_CLEAN, NbBundle.getMessage(ModuleActions.class, "ACTION_clean"), null)); 77 actions.add(null); 78 boolean isNetBeansOrg = Util.getModuleType(project) == NbModuleProvider.NETBEANS_ORG; 79 if (isNetBeansOrg) { 80 String path = project.getPathWithinNetBeansOrg(); 81 actions.add(createMasterAction(project, new String [] {"init", "all-" + path}, NbBundle.getMessage(ModuleActions.class, "ACTION_build_with_deps"))); 82 actions.add(createMasterAction(project, new String [] {"init", "all-" + path, "tryme"}, NbBundle.getMessage(ModuleActions.class, "ACTION_build_with_deps_tryme"))); 83 } else { 84 actions.add(createSimpleAction(project, new String [] {"run"}, NbBundle.getMessage(ModuleActions.class, "ACTION_run"))); 85 } 86 actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, NbBundle.getMessage(ModuleActions.class, "ACTION_debug"), null)); 87 actions.add(null); 88 if (project.supportsUnitTests()) { 89 actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, NbBundle.getMessage(ModuleActions.class, "ACTION_test"), null)); 90 actions.add(null); 91 } 92 actions.add(ProjectSensitiveActions.projectCommandAction(JavaProjectConstants.COMMAND_JAVADOC, NbBundle.getMessage(ModuleActions.class, "ACTION_javadoc"), null)); 93 actions.add(createArchAction(project)); 94 actions.add(null); 95 if (isNetBeansOrg) { 96 actions.add(createCheckBundleAction(project, NbBundle.getMessage(ModuleActions.class, "ACTION_unused_bundle_keys"))); 97 actions.add(null); 98 } 99 actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_RUN, NbBundle.getMessage(ModuleActions.class, "ACTION_reload"), null)); 100 actions.add(createReloadInIDEAction(project, new String [] {"reload-in-ide"}, NbBundle.getMessage(ModuleActions.class, "ACTION_reload_in_ide"))); 101 actions.add(createSimpleAction(project, new String [] {"nbm"}, NbBundle.getMessage(ModuleActions.class, "ACTION_nbm"))); 102 actions.add(null); 103 actions.add(CommonProjectActions.setAsMainProjectAction()); 104 actions.add(CommonProjectActions.openSubprojectsAction()); 105 actions.add(CommonProjectActions.closeProjectAction()); 106 actions.add(null); 107 actions.add(SystemAction.get(FindAction.class)); 108 actions.add(null); 109 actions.add(CommonProjectActions.renameProjectAction()); 110 actions.add(CommonProjectActions.moveProjectAction()); 111 actions.add(CommonProjectActions.copyProjectAction()); 112 actions.add(CommonProjectActions.deleteProjectAction()); 113 114 FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource("Projects/Actions"); if (fo != null && fo.isFolder()) { 117 actions.add(null); 118 for (Object next : new FolderLookup(DataFolder.findFolder(fo)).getLookup().lookupAll(Object .class)) { 119 if (next instanceof Action ) { 120 actions.add((Action ) next); 121 } else if (next instanceof JSeparator ) { 122 actions.add(null); 123 } 124 } 125 } 126 127 actions.add(null); 128 actions.add(SystemAction.get(ToolsAction.class)); 129 actions.add(null); 130 actions.add(CommonProjectActions.customizeProjectAction()); 131 return actions.toArray(new Action [actions.size()]); 132 } 133 134 private final NbModuleProject project; 135 private final Map <String ,String []> globalCommands = new HashMap <String ,String []>(); 136 private final String [] supportedActions; 137 138 public ModuleActions(NbModuleProject project) { 139 this.project = project; 140 Set <String > supportedActionsSet = new HashSet <String >(); 141 globalCommands.put(ActionProvider.COMMAND_BUILD, new String [] {"netbeans"}); globalCommands.put(ActionProvider.COMMAND_CLEAN, new String [] {"clean"}); globalCommands.put(ActionProvider.COMMAND_REBUILD, new String [] {"clean", "netbeans"}); globalCommands.put(ActionProvider.COMMAND_DEBUG, new String [] {"debug"}); globalCommands.put(ActionProvider.COMMAND_RUN, new String [] {"reload"}); globalCommands.put("profile", new String [] {"profile"}); globalCommands.put(JavaProjectConstants.COMMAND_JAVADOC, new String [] {"javadoc-nb"}); if (project.supportsUnitTests()) { 149 globalCommands.put(ActionProvider.COMMAND_TEST, new String [] {"test"}); } 151 supportedActionsSet.addAll(globalCommands.keySet()); 152 supportedActionsSet.add(ActionProvider.COMMAND_COMPILE_SINGLE); 153 supportedActionsSet.add(JavaProjectConstants.COMMAND_DEBUG_FIX); if (project.supportsUnitTests()) { 155 supportedActionsSet.add(ActionProvider.COMMAND_TEST_SINGLE); 156 supportedActionsSet.add(ActionProvider.COMMAND_DEBUG_TEST_SINGLE); 157 supportedActionsSet.add(ActionProvider.COMMAND_RUN_SINGLE); 158 supportedActionsSet.add(ActionProvider.COMMAND_DEBUG_SINGLE); 159 } 160 if (project.getFunctionalTestSourceDirectory() != null) { 161 supportedActionsSet.add(ActionProvider.COMMAND_RUN_SINGLE); 162 } 163 if (project.getPerformanceTestSourceDirectory() != null) { 164 supportedActionsSet.add(ActionProvider.COMMAND_RUN_SINGLE); 165 } 166 supportedActionsSet.add(ActionProvider.COMMAND_RENAME); 167 supportedActionsSet.add(ActionProvider.COMMAND_MOVE); 168 supportedActionsSet.add(ActionProvider.COMMAND_COPY); 169 supportedActionsSet.add(ActionProvider.COMMAND_DELETE); 170 supportedActions = supportedActionsSet.toArray(new String [supportedActionsSet.size()]); 171 } 172 173 public String [] getSupportedActions() { 174 return supportedActions; 175 } 176 177 private static FileObject findBuildXml(NbModuleProject project) { 178 return project.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH); 179 } 180 181 private static FileObject findTestBuildXml(NbModuleProject project) { 182 return project.getProjectDirectory().getFileObject("test/build.xml"); } 184 185 private static FileObject findMasterBuildXml(NbModuleProject project) { 186 return project.getNbrootFileObject("nbbuild/build.xml"); } 188 189 public boolean isActionEnabled(String command, Lookup context) { 190 if (ActionProvider.COMMAND_DELETE.equals(command) || 191 ActionProvider.COMMAND_RENAME.equals(command) || 192 ActionProvider.COMMAND_MOVE.equals(command) || 193 ActionProvider.COMMAND_COPY.equals(command)) { 194 return true; 195 } else if (command.equals(COMMAND_COMPILE_SINGLE)) { 196 return findBuildXml(project) != null && 197 (findSources(context) != null || findTestSources(context, false) != null); 198 } else if (command.equals(COMMAND_TEST_SINGLE)) { 199 return findBuildXml(project) != null && findTestSourcesForSources(context) != null; 200 } else if (command.equals(COMMAND_DEBUG_TEST_SINGLE)) { 201 FileObject[] files = findTestSourcesForSources(context); 202 return findBuildXml(project) != null && files != null && files.length == 1; 203 } else if (command.equals(COMMAND_RUN_SINGLE)) { 204 FileObject[] files = findFunctionalTestSources(context); 205 if (files != null && files.length == 1 && findTestBuildXml(project) != null) { 206 return true; 207 } 208 files = findPerformanceTestSources(context); 209 if (files != null && files.length == 1 && findTestBuildXml(project) != null) { 210 return true; 211 } 212 files = findTestSources(context, false); 213 return files != null; 214 } else if (command.equals(COMMAND_DEBUG_SINGLE)) { 215 FileObject[] files = findTestSources(context, false); 216 return files != null && files.length == 1; 217 } else if (command.equals(JavaProjectConstants.COMMAND_DEBUG_FIX)) { 218 FileObject[] files = findSources(context); 219 if (files != null && files.length == 1 && findBuildXml(project) != null) { 220 return true; 221 } 222 files = findTestSources(context, false); 223 return files != null && files.length == 1 && findBuildXml(project) != null; 224 } else { 225 return findBuildXml(project) != null; 227 } 228 } 229 230 private static final Pattern SRCDIRJAVA = Pattern.compile("\\.java$"); private static final String SUBST = "Test.java"; 233 private FileObject[] findSources(Lookup context) { 234 FileObject srcDir = project.getSourceDirectory(); 235 if (srcDir != null) { 236 FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); return files; 239 } else { 240 return null; 241 } 242 } 243 244 private FileObject[] findTestSources(Lookup context, boolean checkInSrcDir) { 245 FileObject testSrcDir = project.getTestSourceDirectory(); 246 if (testSrcDir != null) { 247 FileObject[] files = ActionUtils.findSelectedFiles(context, testSrcDir, ".java", true); if (files != null) { 249 return files; 250 } 251 } 252 if (checkInSrcDir && testSrcDir != null) { 254 FileObject srcDir = project.getSourceDirectory(); 255 if (srcDir != null) { 257 FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); if (files != null) { 260 FileObject[] files2 = ActionUtils.regexpMapFiles(files, srcDir, SRCDIRJAVA, testSrcDir, SUBST, true); 261 if (files2 != null) { 263 return files2; 264 } 265 } 266 } 267 } 268 return null; 269 } 270 271 273 private FileObject[] findTestSourcesForSources(Lookup context) { 274 FileObject[] sourceFiles = findSources(context); 275 if (sourceFiles == null) { 276 return null; 277 } 278 FileObject testSrcDir = project.getTestSourceDirectory(); 279 FileObject srcDir = project.getSourceDirectory(); 280 return ActionUtils.regexpMapFiles(sourceFiles, srcDir, SRCDIRJAVA, testSrcDir, SUBST, true); 281 } 282 283 private FileObject[] findFunctionalTestSources(Lookup context) { 284 FileObject srcDir = project.getFunctionalTestSourceDirectory(); 285 if (srcDir != null) { 286 FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); return files; 288 } else { 289 return null; 290 } 291 } 292 293 private FileObject[] findPerformanceTestSources(Lookup context) { 294 FileObject srcDir = project.getPerformanceTestSourceDirectory(); 295 if (srcDir != null) { 296 FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); return files; 298 } else { 299 return null; 300 } 301 } 302 303 public void invokeAction(String command, Lookup context) throws IllegalArgumentException { 304 if (ActionProvider.COMMAND_DELETE.equals(command)) { 305 if (ModuleOperations.canRun(project, true)) { 306 DefaultProjectOperations.performDefaultDeleteOperation(project); 307 } 308 return; 309 } else if (ActionProvider.COMMAND_RENAME.equals(command)) { 310 if (ModuleOperations.canRun(project, true)) { 311 DefaultProjectOperations.performDefaultRenameOperation(project, null); 312 } 313 return; 314 } else if (ActionProvider.COMMAND_MOVE.equals(command)) { 315 if (ModuleOperations.canRun(project, true)) { 316 DefaultProjectOperations.performDefaultMoveOperation(project); 317 } 318 return; 319 } else if (ActionProvider.COMMAND_COPY.equals(command)) { 320 if (ModuleOperations.canRun(project, true)) { 321 DefaultProjectOperations.performDefaultCopyOperation(project); 322 } 323 return; 324 } 325 NbPlatform plaf = project.getPlatform(false); 326 if (plaf != null && plaf.getHarnessVersion() != NbPlatform.HARNESS_VERSION_UNKNOWN && plaf.getHarnessVersion() < project.getMinimumHarnessVersion()) { 327 promptForNewerHarness(); 328 return; 329 } 330 Properties p; 331 String [] targetNames; 332 FileObject buildScript = null; 333 if (command.equals(COMMAND_COMPILE_SINGLE)) { 334 FileObject[] files = findSources(context); 335 p = new Properties (); 336 if (files != null) { 337 p.setProperty("javac.includes", ActionUtils.antIncludesList(files, project.getSourceDirectory())); targetNames = new String [] {"compile-single"}; } else { 340 files = findTestSources(context, false); 341 p.setProperty("javac.includes", ActionUtils.antIncludesList(files, project.getTestSourceDirectory())); targetNames = new String [] {"compile-test-single"}; } 344 } else if (command.equals(COMMAND_TEST_SINGLE)) { 345 p = new Properties (); 346 FileObject[] files = findTestSourcesForSources(context); 347 targetNames = setupTestSingle(p, files); 348 } else if (command.equals(COMMAND_DEBUG_TEST_SINGLE)) { 349 p = new Properties (); 350 FileObject[] files = findTestSourcesForSources(context); 351 targetNames = setupDebugTestSingle(p, files); 352 } else if (command.equals(COMMAND_RUN_SINGLE)) { 353 FileObject[] files = findFunctionalTestSources(context); 354 if (files != null) { 355 String path = FileUtil.getRelativePath(project.getFunctionalTestSourceDirectory(), files[0]); 356 p = new Properties (); 357 p.setProperty("xtest.testtype", "qa-functional"); p.setProperty("classname", path.substring(0, path.length() - 5).replace('/', '.')); targetNames = new String [] {"internal-execution"}; buildScript = findTestBuildXml(project); 361 } else if ((files = findPerformanceTestSources(context)) != null) { 362 String path = FileUtil.getRelativePath(project.getPerformanceTestSourceDirectory(), files[0]); 363 p = new Properties (); 364 p.setProperty("xtest.testtype", "qa-performance"); p.setProperty("classname", path.substring(0, path.length() - 5).replace('/', '.')); targetNames = new String [] {"internal-execution"}; buildScript = findTestBuildXml(project); 368 } else { 369 files = findTestSources(context, false); 370 p = new Properties (); 371 targetNames = setupTestSingle(p, files); 372 } 373 } else if (command.equals(COMMAND_DEBUG_SINGLE)) { 374 FileObject[] files = findTestSources(context, false); 375 p = new Properties (); 376 targetNames = setupDebugTestSingle(p, files); 377 } else if (command.equals(JavaProjectConstants.COMMAND_DEBUG_FIX)) { 378 FileObject[] files = findSources(context); 379 String path = null; 380 if (files != null) { 381 path = FileUtil.getRelativePath(project.getSourceDirectory(), files[0]); 382 assert path != null; 383 assert path.endsWith(".java"); 384 targetNames = new String [] {"debug-fix-nb"}; } else { 386 files = findTestSources(context, false); 387 path = FileUtil.getRelativePath(project.getTestSourceDirectory(), files[0]); 388 assert path != null; 389 assert path.endsWith(".java"); 390 targetNames = new String [] {"debug-fix-test-nb"}; } 392 String clazzSlash = path.substring(0, path.length() - 5); 393 p = new Properties (); 394 p.setProperty("fix.class", clazzSlash); buildScript = findBuildXml(project); 396 } else if (command.equals(JavaProjectConstants.COMMAND_JAVADOC) && !project.supportsJavadoc()) { 397 promptForPublicPackagesToDocument(); 398 return; 399 } else { 400 p = null; 401 targetNames = globalCommands.get(command); 402 if (targetNames == null) { 403 throw new IllegalArgumentException (command); 404 } 405 } 406 if (buildScript == null) { 407 buildScript = findBuildXml(project); 408 } 409 try { 410 ActionUtils.runTarget(buildScript, targetNames, p); 411 } catch (IOException e) { 412 Util.err.notify(e); 413 } 414 } 415 416 private void promptForPublicPackagesToDocument() { 417 if (UIUtil.showAcceptCancelDialog( 419 NbBundle.getMessage(ModuleActions.class, "TITLE_javadoc_disabled"), 420 NbBundle.getMessage(ModuleActions.class, "ERR_javadoc_disabled"), 421 NbBundle.getMessage(ModuleActions.class, "LBL_configure_pubpkg"), 422 null, 423 NotifyDescriptor.WARNING_MESSAGE)) { 424 CustomizerProviderImpl cpi = project.getLookup().lookup(CustomizerProviderImpl.class); 425 cpi.showCustomizer(CustomizerProviderImpl.CATEGORY_VERSIONING, CustomizerProviderImpl.SUBCATEGORY_VERSIONING_PUBLIC_PACKAGES); 426 } 427 } 428 429 static void promptForNewerHarness() { 430 NotifyDescriptor d = new NotifyDescriptor.Message(NbBundle.getMessage(ModuleActions.class, "ERR_harness_too_old"), NotifyDescriptor.ERROR_MESSAGE); 432 d.setTitle(NbBundle.getMessage(ModuleActions.class, "TITLE_harness_too_old")); 433 DialogDisplayer.getDefault().notify(d); 434 } 435 436 private String [] setupTestSingle(Properties p, FileObject[] files) { 437 p.setProperty("test.includes", ActionUtils.antIncludesList(files, project.getTestSourceDirectory())); return new String [] {"test-single"}; } 440 441 private String [] setupDebugTestSingle(Properties p, FileObject[] files) { 442 String path = FileUtil.getRelativePath(project.getTestSourceDirectory(), files[0]); 443 p.setProperty("test.class", path.substring(0, path.length() - 5).replace('/', '.')); return new String [] {"debug-test-single-nb"}; } 447 448 private static Action createSimpleAction(final NbModuleProject project, final String [] targetNames, String displayName) { 449 return new AbstractAction (displayName) { 450 public boolean isEnabled() { 451 return findBuildXml(project) != null; 452 } 453 public void actionPerformed(ActionEvent ignore) { 454 try { 455 ActionUtils.runTarget(findBuildXml(project), targetNames, null); 456 } catch (IOException e) { 457 Util.err.notify(e); 458 } 459 } 460 }; 461 } 462 463 private static Action createMasterAction(final NbModuleProject project, final String [] targetNames, String displayName) { 464 return new AbstractAction (displayName) { 465 public boolean isEnabled() { 466 return findMasterBuildXml(project) != null; 467 } 468 public void actionPerformed(ActionEvent ignore) { 469 try { 470 ActionUtils.runTarget(findMasterBuildXml(project), targetNames, null); 471 } catch (IOException e) { 472 Util.err.notify(e); 473 } 474 } 475 }; 476 } 477 478 private static Action createCheckBundleAction(final NbModuleProject project, String displayName) { 479 return new AbstractAction (displayName) { 480 public boolean isEnabled() { 481 return findMonitorXml() != null && project.getPathWithinNetBeansOrg() != null; 482 } 483 public void actionPerformed(ActionEvent ignore) { 484 Properties props = new Properties (); 485 props.put("modules", project.getPathWithinNetBeansOrg()); props.put("fixedmodules", ""); try { 488 ActionUtils.runTarget(findMonitorXml(), new String [] {"check-bundle-usage"}, props); } catch (IOException e) { 490 Util.err.notify(e); 491 } 492 } 493 private FileObject findMonitorXml() { 494 return project.getNbrootFileObject("nbbuild/monitor.xml"); } 496 }; 497 } 498 499 private static Action createReloadInIDEAction(final NbModuleProject project, final String [] targetNames, String displayName) { 500 return new AbstractAction (displayName) { 501 public boolean isEnabled() { 502 if (findBuildXml(project) == null) { 503 return false; 504 } 505 NbModuleProvider.NbModuleType type = Util.getModuleType(project); 506 if (type == NbModuleProvider.NETBEANS_ORG) { 507 return true; 508 } else if (type == NbModuleProvider.STANDALONE) { 509 NbPlatform p = project.getPlatform(false); 510 return p != null && p.isDefault(); 511 } else { 512 assert type == NbModuleProvider.SUITE_COMPONENT : type; 513 try { 514 SuiteProject suite = SuiteUtils.findSuite(project); 515 if (suite == null) { 516 return false; 517 } 518 NbPlatform p = suite.getPlatform(false); 519 if (p == null || !p.isDefault()) { 520 return false; 521 } 522 return SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.ENABLED_CLUSTERS_PROPERTY).length == 0 && 523 SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.DISABLED_CLUSTERS_PROPERTY).length == 0 && 524 SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.DISABLED_MODULES_PROPERTY).length == 0; 525 } catch (IOException e) { 526 Util.err.notify(ErrorManager.INFORMATIONAL, e); 527 return false; 528 } 529 } 530 } 531 public void actionPerformed(ActionEvent ignore) { 532 if (ModuleUISettings.getDefault().getConfirmReloadInIDE()) { 533 NotifyDescriptor d = new NotifyDescriptor.Confirmation( 534 NbBundle.getMessage(ModuleActions.class, "LBL_reload_in_ide_confirm"), 535 NbBundle.getMessage(ModuleActions.class, "LBL_reload_in_ide_confirm_title"), 536 NotifyDescriptor.OK_CANCEL_OPTION); 537 if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.OK_OPTION) { 538 return; 539 } 540 ModuleUISettings.getDefault().setConfirmReloadInIDE(false); } 542 try { 543 ActionUtils.runTarget(findBuildXml(project), targetNames, null); 544 } catch (IOException e) { 545 Util.err.notify(e); 546 } 547 } 548 }; 549 } 550 551 private static Action createArchAction(final NbModuleProject project) { 552 return new AbstractAction (NbBundle.getMessage(ModuleActions.class, "ACTION_arch")) { 553 public boolean isEnabled() { 554 return findBuildXml(project) != null; 555 } 556 public void actionPerformed(ActionEvent ignore) { 557 ProjectManager.mutex().writeAccess(new Mutex.Action<Void >() { 558 public Void run() { 559 String prop = "javadoc.arch"; if (project.evaluator().getProperty(prop) == null) { 561 EditableProperties props = project.getHelper().getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 563 props.setProperty(prop, "${basedir}/arch.xml"); project.getHelper().putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); 565 try { 566 ProjectManager.getDefault().saveProject(project); 567 } catch (IOException e) { 568 Util.err.notify(e); 569 } 570 } 571 return null; 572 } 573 }); 574 try { 575 ActionUtils.runTarget(findBuildXml(project), new String [] {"arch-nb"}, null); } catch (IOException e) { 577 Util.err.notify(e); 578 } 579 } 580 }; 581 } 582 583 } 584 | Popular Tags |