1 19 20 package org.netbeans.modules.project.ui.actions; 21 22 import org.netbeans.api.project.Project; 23 import org.netbeans.modules.project.ui.OpenProjectList; 24 import org.netbeans.spi.project.SubprojectProvider; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.NbBundle; 27 import org.openide.util.actions.NodeAction; 28 29 31 public class OpenSubprojects extends NodeAction { 32 33 private static final String ICON = "org/netbeans/modules/project/ui/resources/openProject.gif"; 35 36 public OpenSubprojects() { 37 } 38 39 public String getName() { 40 return NbBundle.getMessage( OpenSubprojects.class, "LBL_OpenSubprojectsAction_Name" ); } 42 43 public String iconResource() { 44 return ICON; 45 } 46 47 public HelpCtx getHelpCtx() { 48 return HelpCtx.DEFAULT_HELP; 49 } 50 51 protected boolean asynchronous() { 52 return false; 53 } 54 55 protected boolean enable(org.openide.nodes.Node[] activatedNodes) { 56 57 if ( activatedNodes == null || activatedNodes.length == 0 ) { 58 return false; } 60 61 boolean someSubprojects = false; for( int i = 0; i < activatedNodes.length; i++ ) { 64 Project p = (Project)activatedNodes[i].getLookup().lookup( Project.class ); 65 if ( p == null ) { 66 return false; 67 } 68 else { 69 70 SubprojectProvider spp = (SubprojectProvider)p.getLookup().lookup( SubprojectProvider.class ); 71 72 if ( spp != null && !spp.getSubprojects().isEmpty() ) { 73 someSubprojects = true; 74 } 75 } 76 } 77 78 return someSubprojects; 79 } 80 81 protected void performAction(org.openide.nodes.Node[] activatedNodes) { 82 83 for( int i = 0; i < activatedNodes.length; i++ ) { 84 Project p = (Project)activatedNodes[i].getLookup().lookup( Project.class ); 85 if ( p != null ) { 86 OpenProjectList.getDefault().open(new Project[] {p}, true, true); 87 } 88 } 89 90 } 91 92 } 93 | Popular Tags |