1 19 20 package org.netbeans.modules.ruby.railsprojects.ui; 21 22 23 import org.openide.nodes.Node; 24 import org.openide.util.NbBundle; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.actions.NodeAction; 27 import org.netbeans.modules.ruby.spi.project.support.rake.EditableProperties; 28 29 import java.util.Iterator ; 30 31 37 final class RemoveClassPathRootAction extends NodeAction { 38 39 44 static interface Removable { 45 49 public boolean canRemove (); 50 51 54 public abstract void remove (); 55 } 56 57 protected void performAction(Node[] activatedNodes) { 58 for (int i=0; i<activatedNodes.length; i++) { 59 Removable removable = (Removable) activatedNodes[i].getLookup().lookup(Removable.class); 60 if (removable!=null) { 61 removable.remove(); 62 } 63 } 64 } 65 66 protected boolean enable(Node[] activatedNodes) { 67 for (int i=0; i<activatedNodes.length; i++) { 68 Removable removable = (Removable) activatedNodes[i].getLookup().lookup(Removable.class); 69 if (removable==null) { 70 return false; 71 } 72 if (!removable.canRemove()) { 73 return false; 74 } 75 } 76 return true; 77 } 78 79 public String getName() { 80 return NbBundle.getMessage (RemoveClassPathRootAction.class,"CTL_RemoveProject"); 81 } 82 83 public HelpCtx getHelpCtx() { 84 return new HelpCtx (RemoveClassPathRootAction.class); 85 } 86 87 protected boolean asynchronous() { 88 return false; 89 } 90 91 98 public static boolean isReferenced (EditableProperties[] props, String reference) { 99 for (int i=0; i< props.length; i++) { 100 for (Iterator it = props[i].values().iterator(); it.hasNext();) { 101 String value = (String ) it.next (); 102 if (value != null && value.indexOf(reference)>=0) { 103 return true; 104 } 105 } 106 } 107 return false; 108 } 109 } 110 | Popular Tags |