1 11 12 package org.eclipse.ant.internal.ui.editor.model; 13 14 import java.util.Enumeration ; 15 import java.util.Map ; 16 17 import org.apache.tools.ant.Target; 18 import org.eclipse.ant.internal.ui.editor.outline.XMLProblem; 19 import org.eclipse.ant.internal.ui.model.AntUIImages; 20 import org.eclipse.ant.internal.ui.model.IAntUIConstants; 21 import org.eclipse.jface.resource.ImageDescriptor; 22 23 public class AntTargetNode extends AntElementNode { 24 25 private Target fTarget= null; 26 27 public AntTargetNode(Target target) { 28 super("target"); fTarget= target; 30 } 31 32 35 public String getLabel() { 36 String targetName= fTarget.getName(); 37 if (targetName == null) { 38 targetName= "target"; setProblemSeverity(XMLProblem.SEVERITY_ERROR); 40 } 41 42 StringBuffer displayName= new StringBuffer (targetName); 43 if (isDefaultTarget()) { 44 displayName.append(AntModelMessages.getString("AntTargetNode.2")); } 46 if (isExternal()) { 47 appendEntityName(displayName); 48 } 49 50 return displayName.toString(); 51 } 52 53 public Target getTarget() { 54 return fTarget; 55 } 56 57 public boolean isDefaultTarget() { 58 String targetName= fTarget.getName(); 59 if (targetName == null) { 60 return false; 61 } 62 return targetName.equals(fTarget.getProject().getDefaultTarget()); 63 } 64 65 68 protected ImageDescriptor getBaseImageDescriptor() { 69 ImageDescriptor base= null; 70 if (isDefaultTarget()) { 71 base = AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_DEFAULT_TARGET); 72 } else if (getTarget().getDescription() == null) { 73 base = AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_TARGET_INTERNAL); 74 } else { 75 base = AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_TARGET); 76 } 77 return base; 78 } 79 82 public void setTarget(Target target) { 83 fTarget = target; 84 } 85 86 89 public void reset() { 90 super.reset(); 91 Map currentTargets = fTarget.getProject().getTargets(); 92 if (currentTargets.get(fTarget.getName()) != null) { 93 currentTargets.remove(fTarget.getName()); 94 } 95 } 96 97 101 public String checkDependencies() { 102 Enumeration dependencies= fTarget.getDependencies(); 103 while (dependencies.hasMoreElements()) { 104 String dependency = (String ) dependencies.nextElement(); 105 if (fTarget.getProject().getTargets().get(dependency) == null) { 106 return dependency; 107 } 108 } 109 return null; 110 } 111 } | Popular Tags |