1 11 12 package org.eclipse.ant.internal.ui.editor.model; 13 14 import org.apache.tools.ant.BuildException; 15 import org.apache.tools.ant.Task; 16 import org.eclipse.ant.internal.ui.editor.outline.XMLProblem; 17 import org.eclipse.ant.internal.ui.model.AntUIImages; 18 import org.eclipse.ant.internal.ui.model.IAntUIConstants; 19 import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants; 20 import org.eclipse.jface.resource.ImageDescriptor; 21 22 23 public class AntTaskNode extends AntElementNode { 24 25 private Task fTask= null; 26 private String fLabel= null; 27 private String fId= null; 28 protected boolean configured= false; 29 30 public AntTaskNode(Task task) { 31 super(task.getTaskName()); 32 fTask= task; 33 } 34 35 public AntTaskNode(Task task, String label) { 36 super(task.getTaskName()); 37 fTask= task; 38 fLabel= label; 39 } 40 41 public String getLabel() { 42 StringBuffer label= new StringBuffer (); 43 if (fLabel != null) { 44 label.append(fLabel); 45 } else if (fId != null) { 46 label.append(fId); 47 } else { 48 label.append(fTask.getTaskName()); 49 } 50 if (isExternal()) { 51 appendEntityName(label); 52 } 53 return label.toString(); 54 } 55 56 public void setLabel(String label) { 57 fLabel= label; 58 } 59 60 public Task getTask() { 61 return fTask; 62 } 63 64 public void setTask(Task task) { 65 fTask= task; 66 } 67 68 protected ImageDescriptor getBaseImageDescriptor() { 69 if (fId != null) { 70 return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_TYPE); 71 } 72 73 return super.getBaseImageDescriptor(); 74 } 75 76 80 public void setId(String id) { 81 fId= id; 82 } 83 84 89 public String getId() { 90 return fId; 91 } 92 93 100 public boolean configure(boolean validateFully) { 101 if (!validateFully || (getParentNode() instanceof AntTaskNode)) { 102 return false; 103 } 104 if (configured) { 105 return false; 106 } 107 try { 108 getTask().maybeConfigure(); 109 nodeSpecificConfigure(); 110 configured= true; 111 return true; 112 } catch (BuildException be) { 113 handleBuildException(be, AntEditorPreferenceConstants.PROBLEM_TASKS); 114 } 115 return false; 116 } 117 118 protected void nodeSpecificConfigure() { 119 } 121 122 protected void handleBuildException(BuildException be, String preferenceKey) { 123 int severity= XMLProblem.getSeverity(preferenceKey); 124 if (severity != XMLProblem.NO_PROBLEM) { 125 getAntModel().handleBuildException(be, this, severity); 126 } 127 } 128 } | Popular Tags |