Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004, 2006 Richard Hoefter and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Richard Hoefter (richard.hoefter@web.de) - initial API and implementation IBM Corporation - nlsing and incorporating into Eclipse /
 
 
 package org.eclipse.ant.internal.ui.datatransfer;
 
 import java.util.Map;
 
Helper class to access private method org.eclipse.jdt.internal.launching.JavaAppletLaunchConfigurationDelegate}.buildHTMLFile().

Source was copied and slighlty modified.

 
 public class AppletUtil
 {
     private AppletUtil() {}
     
     // create instance to access helper method
     {
         public void launch(ILaunchConfiguration configurationString mode,
                 ILaunch launchIProgressMonitor monitorthrows CoreException
         {
         }
     };

    
Using the specified launch configuration, build an HTML file that specifies the applet to launch.

Returns:
the created HTML file
 
     public static String buildHTMLFile(ILaunchConfiguration configurationthrows CoreException
     {
         String name = getMainTypeName(configuration);
         StringBuffer b = new StringBuffer();
         b.append("<!--" + . + " -->" + .); //$NON-NLS-1$ //$NON-NLS-2$
         b.append("<html>" + .); //$NON-NLS-1$
         b.append("    <body>" + .); //$NON-NLS-1$
         b.append("        <applet code="); //$NON-NLS-1$
         b.append(getQuotedString(name + ".class")); //$NON-NLS-1$
         String appletName = configuration.getAttribute(
                 .""); //$NON-NLS-1$
         if (appletName.length() != 0)
         {
             b.append(" name=\"" + appletName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
         }
         b.append(" width=\""); //$NON-NLS-1$
         b.append(Integer.toString(configuration.getAttribute(
                 ., 200)));
         b.append("\" height=\""); //$NON-NLS-1$
         b.append(Integer.toString(configuration.getAttribute(
                 ., 200)));
         b.append("\">" + .); //$NON-NLS-1$
         Map parameters = configuration.getAttribute(
                 new HashMap());
         if (parameters.size() != 0)
         {
             Iterator iterator = parameters.entrySet().iterator();
             while (iterator.hasNext())
             {
                 Map.Entry next = (Map.Entryiterator.next();
                 b.append("            <param name="); //$NON-NLS-1$
                 b.append(getQuotedString((Stringnext.getKey()));
                 b.append(" value="); //$NON-NLS-1$
                 b.append(getQuotedString((Stringnext.getValue()));
                 b.append(">" + .); //$NON-NLS-1$
             }
         }
         b.append("        </applet>" + .); //$NON-NLS-1$
         b.append("    </body>" + .); //$NON-NLS-1$
         b.append("</html>" + .); //$NON-NLS-1$
         return b.toString();
     }
 
     private static String getQuotedString(String string)
     {
         if (string.indexOf('"') == -1)
         {
            return '"' + string + '"';
        }
        return '\'' + string + '\'';
    }

    
Returns the main type name specified by the given launch configuration, or null if none.

Parameters:
configuration launch configuration
Returns:
the main type name specified by the given launch configuration, or null if none
Throws:
org.eclipse.core.runtime.CoreException if unable to retrieve the attribute
    public static String getMainTypeName(ILaunchConfiguration configuration)
            throws CoreException
    {
        return .getMainTypeName(configuration);
    }
New to GrepCode? Check out our FAQ X