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.model.AntUIImages; 17 import org.eclipse.ant.internal.ui.model.AntUtil; 18 import org.eclipse.ant.internal.ui.model.IAntUIConstants; 19 import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants; 20 import org.eclipse.core.resources.IFile; 21 import org.eclipse.jface.resource.ImageDescriptor; 22 import org.xml.sax.Attributes ; 23 24 public class AntImportNode extends AntTaskNode { 25 26 private String fFile= null; 27 28 public AntImportNode(Task task, Attributes attributes) { 29 super(task); 30 fFile= attributes.getValue(IAntModelConstants.ATTR_FILE); 31 } 32 33 public String getFile() { 34 return fFile; 35 } 36 37 40 protected ImageDescriptor getBaseImageDescriptor() { 41 return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_IMPORT); 42 } 43 44 public String getLabel() { 45 StringBuffer label= new StringBuffer (getTask().getTaskName()); 46 label.append(' '); 47 label.append(fFile); 48 49 if (isExternal()) { 50 appendEntityName(label); 51 } 52 return label.toString(); 53 } 54 55 59 public boolean configure(boolean validateFully) { 60 if (configured) { 61 return false; 62 } 63 try { 64 getTask().maybeConfigure(); 65 getTask().execute(); 66 configured= true; 67 return true; 68 } catch (BuildException be) { 69 handleBuildException(be, AntEditorPreferenceConstants.PROBLEM_IMPORTS); 70 } 71 return false; 72 } 73 74 public IFile getIFile() { 75 IFile file; 76 if (isExternal()) { 77 file= AntUtil.getFileForLocation(getFilePath(), null); 78 } else { 79 String path= getFile(); 80 file= AntUtil.getFileForLocation(path, getAntModel().getEditedFile().getParentFile()); 81 } 82 return file; 83 } 84 } | Popular Tags |