1 12 13 package org.eclipse.ant.internal.ui.datatransfer; 14 15 import java.util.HashMap ; 16 import java.util.Iterator ; 17 import java.util.Map ; 18 19 import org.eclipse.core.runtime.CoreException; 20 import org.eclipse.core.runtime.IProgressMonitor; 21 import org.eclipse.debug.core.ILaunch; 22 import org.eclipse.debug.core.ILaunchConfiguration; 23 import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate; 24 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 25 26 33 public class AppletUtil 34 { 35 private AppletUtil() {} 36 37 private static AbstractJavaLaunchConfigurationDelegate fgDelegate = new AbstractJavaLaunchConfigurationDelegate() 39 { 40 public void launch(ILaunchConfiguration configuration, String mode, 41 ILaunch launch, IProgressMonitor monitor) throws CoreException 42 { 43 } 44 }; 45 46 52 public static String buildHTMLFile(ILaunchConfiguration configuration) throws CoreException 53 { 54 String name = getMainTypeName(configuration); 55 StringBuffer b = new StringBuffer (); 56 b.append("<!--" + BuildFileCreator.WARNING + " -->" + ExportUtil.NEWLINE); b.append("<html>" + ExportUtil.NEWLINE); b.append(" <body>" + ExportUtil.NEWLINE); b.append(" <applet code="); b.append(getQuotedString(name + ".class")); String appletName = configuration.getAttribute( 62 IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); if (appletName.length() != 0) 64 { 65 b.append(" name=\"" + appletName + "\""); } 67 b.append(" width=\""); b.append(Integer.toString(configuration.getAttribute( 69 IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, 200))); 70 b.append("\" height=\""); b.append(Integer.toString(configuration.getAttribute( 72 IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, 200))); 73 b.append("\">" + ExportUtil.NEWLINE); Map parameters = configuration.getAttribute( 75 IJavaLaunchConfigurationConstants.ATTR_APPLET_PARAMETERS, 76 new HashMap ()); 77 if (parameters.size() != 0) 78 { 79 Iterator iterator = parameters.entrySet().iterator(); 80 while (iterator.hasNext()) 81 { 82 Map.Entry next = (Map.Entry ) iterator.next(); 83 b.append(" <param name="); b.append(getQuotedString((String ) next.getKey())); 85 b.append(" value="); b.append(getQuotedString((String ) next.getValue())); 87 b.append(">" + ExportUtil.NEWLINE); } 89 } 90 b.append(" </applet>" + ExportUtil.NEWLINE); b.append(" </body>" + ExportUtil.NEWLINE); b.append("</html>" + ExportUtil.NEWLINE); return b.toString(); 94 } 95 96 private static String getQuotedString(String string) 97 { 98 if (string.indexOf('"') == -1) 99 { 100 return '"' + string + '"'; 101 } 102 return '\'' + string + '\''; 103 } 104 105 116 public static String getMainTypeName(ILaunchConfiguration configuration) 117 throws CoreException 118 { 119 return fgDelegate.getMainTypeName(configuration); 120 } 121 } | Popular Tags |