1 17 18 package org.apache.tools.ant.taskdefs.optional.ide; 19 20 21 import com.ibm.ivj.util.base.Project; 22 import com.ibm.ivj.util.base.ToolData; 23 import org.apache.tools.ant.BuildException; 24 25 26 34 public class VAJAntTool { 35 private static final String TOOL_DATA_KEY = "AntTool"; 36 37 38 47 public static VAJBuildInfo loadBuildData(String projectName) { 48 VAJBuildInfo result = null; 49 try { 50 Project project = 51 VAJLocalUtil.getWorkspace().loadedProjectNamed(projectName); 52 if (project.testToolRepositoryData(TOOL_DATA_KEY)) { 53 ToolData td = project.getToolRepositoryData(TOOL_DATA_KEY); 54 String data = (String ) td.getData(); 55 result = VAJBuildInfo.parse(data); 56 } else { 57 result = new VAJBuildInfo(); 58 } 59 result.setVAJProjectName(projectName); 60 } catch (Throwable t) { 61 throw new BuildException("BuildInfo for Project " 62 + projectName + " could not be loaded" + t); 63 } 64 return result; 65 } 66 67 68 75 public static void main(java.lang.String [] args) { 76 try { 77 VAJBuildInfo info; 78 if (args.length >= 2 && args[1] instanceof String ) { 79 String projectName = (String ) args[1]; 80 info = loadBuildData(projectName); 81 } else { 82 info = new VAJBuildInfo(); 83 } 84 85 VAJAntToolGUI mainFrame = new VAJAntToolGUI(info); 86 mainFrame.show(); 87 } catch (Throwable t) { 88 t.printStackTrace(); 91 } 92 } 93 94 95 100 public static void saveBuildData(VAJBuildInfo info) { 101 String data = info.asDataString(); 102 try { 103 ToolData td = new ToolData(TOOL_DATA_KEY, data); 104 VAJLocalUtil.getWorkspace().loadedProjectNamed( 105 info.getVAJProjectName()).setToolRepositoryData(td); 106 } catch (Throwable t) { 107 throw new BuildException("BuildInfo for Project " 108 + info.getVAJProjectName() + " could not be saved", t); 109 } 110 } 111 } 112 | Popular Tags |