@Override public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { File workingDir = verifyWorkingDirectory(configuration); // Construct the HTML file and set its name as a program argument File htmlFile = buildHTMLFile(configuration, workingDir); if (htmlFile == null) { abort(LaunchingMessages.JavaAppletLaunchConfigurationDelegate_Could_not_build_HTML_file_for_applet_launch_1, null, IJavaLaunchConfigurationConstants.ERR_COULD_NOT_BUILD_HTML); } // Add a debug listener if necessary if (fgLaunchToFileMap.isEmpty()) { DebugPlugin.getDefault().addDebugEventListener(this); } // Add a mapping of the launch to the html file fgLaunchToFileMap.put(fLaunch, htmlFile); return htmlFile.getName(); }
@Override public synchronized void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { try { fLaunch = launch; super.launch(configuration, mode, launch, monitor); } catch (CoreException e) { cleanup(launch); throw e; } fLaunch = null; }
private String getQuotedString(String string) { int singleQuotes = count(string, '\''); int doubleQuotes = count(string, '"'); if (doubleQuotes == 0) { return '"' + string + '"'; } else if (singleQuotes == 0) { return '\'' + string + '\''; } else { return '"' + convertToHTMLContent(string) + '"'; } }
@Override public String getVMArguments(ILaunchConfiguration configuration) throws CoreException { StringBuffer arguments = new StringBuffer(super.getVMArguments(configuration)); File workingDir = verifyWorkingDirectory(configuration); String javaPolicyFile = getJavaPolicyFile(workingDir); arguments.append(" "); //$NON-NLS-1$ arguments.append(javaPolicyFile); return arguments.toString(); }
String name = getAppletMainTypeName(configuration); File tempFile = new File(dir, name + System.currentTimeMillis() + ".html"); //$NON-NLS-1$ try (FileOutputStream stream = new FileOutputStream(tempFile)) { String encoding = getLaunchManager().getEncoding(configuration); StringBuilder buf = new StringBuilder(); buf.append("<html>\n"); //$NON-NLS-1$ Entry<String, String> next = iterator.next(); buf.append("<param name="); //$NON-NLS-1$ buf.append(getQuotedString(next.getKey())); buf.append(" value="); //$NON-NLS-1$ buf.append(getQuotedString(next.getValue())); buf.append(">\n"); //$NON-NLS-1$
/** * Returns the contents of the given file as a byte array. * @param file the file * @return the byte array form the file * @throws IOException if a problem occurred reading the file. */ protected static byte[] getFileByteContent(File file) throws IOException { try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) { return getInputStreamAsByteArray(stream, (int) file.length()); } }
/** * Returns the system property string for the policy file * * @param workingDir the working directory * @return system property for the policy file */ public String getJavaPolicyFile(File workingDir) { File file = new File(workingDir, "java.policy.applet");//$NON-NLS-1$ if (!file.exists()) { // copy it to the working directory File test = LaunchingPlugin.getFileInPlugin(new Path("java.policy.applet")); //$NON-NLS-1$ try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file))) { byte[] bytes = getFileByteContent(test); outputStream.write(bytes); } catch (IOException e) { return "";//$NON-NLS-1$ } } return "-Djava.security.policy=java.policy.applet";//$NON-NLS-1$ }
String name = getAppletMainTypeName(configuration); File tempFile = new File(dir, name + System.currentTimeMillis() + ".html"); //$NON-NLS-1$ try (FileOutputStream stream = new FileOutputStream(tempFile)) { String encoding = getLaunchManager().getEncoding(configuration); StringBuffer buf = new StringBuffer(); buf.append("<html>\n"); //$NON-NLS-1$ Entry<String, String> next = iterator.next(); buf.append("<param name="); //$NON-NLS-1$ buf.append(getQuotedString(next.getKey())); buf.append(" value="); //$NON-NLS-1$ buf.append(getQuotedString(next.getValue())); buf.append(">\n"); //$NON-NLS-1$
@Override public String getVMArguments(ILaunchConfiguration configuration) throws CoreException { StringBuilder arguments = new StringBuilder(super.getVMArguments(configuration)); File workingDir = verifyWorkingDirectory(configuration); String javaPolicyFile = getJavaPolicyFile(workingDir); arguments.append(" "); //$NON-NLS-1$ arguments.append(javaPolicyFile); return arguments.toString(); }
/** * Returns the contents of the given file as a byte array. * @param file the file * @return the byte array form the file * @throws IOException if a problem occurred reading the file. */ protected static byte[] getFileByteContent(File file) throws IOException { try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) { return getInputStreamAsByteArray(stream, (int) file.length()); } }
/** * Returns the system property string for the policy file * * @param workingDir the working directory * @return system property for the policy file */ public String getJavaPolicyFile(File workingDir) { File file = new File(workingDir, "java.policy.applet");//$NON-NLS-1$ if (!file.exists()) { // copy it to the working directory File test = LaunchingPlugin.getFileInPlugin(new Path("java.policy.applet")); //$NON-NLS-1$ try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file))) { byte[] bytes = getFileByteContent(test); outputStream.write(bytes); } catch (IOException e) { return "";//$NON-NLS-1$ } } return "-Djava.security.policy=java.policy.applet";//$NON-NLS-1$ }
@Override public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { File workingDir = verifyWorkingDirectory(configuration); // Construct the HTML file and set its name as a program argument File htmlFile = buildHTMLFile(configuration, workingDir); if (htmlFile == null) { abort(LaunchingMessages.JavaAppletLaunchConfigurationDelegate_Could_not_build_HTML_file_for_applet_launch_1, null, IJavaLaunchConfigurationConstants.ERR_COULD_NOT_BUILD_HTML); } // Add a debug listener if necessary if (fgLaunchToFileMap.isEmpty()) { DebugPlugin.getDefault().addDebugEventListener(this); } // Add a mapping of the launch to the html file fgLaunchToFileMap.put(fLaunch, htmlFile); return htmlFile.getName(); }
private String getQuotedString(String string) { int singleQuotes = count(string, '\''); int doubleQuotes = count(string, '"'); if (doubleQuotes == 0) { return '"' + string + '"'; } else if (singleQuotes == 0) { return '\'' + string + '\''; } else { return '"' + convertToHTMLContent(string) + '"'; } }
@Override public synchronized void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { try { fLaunch = launch; super.launch(configuration, mode, launch, monitor); } catch (CoreException e) { cleanup(launch); throw e; } fLaunch = null; }
@Override public void handleDebugEvents(DebugEvent[] events) { for (int i = 0; i < events.length; i++) { DebugEvent event = events[i]; Object eventSource = event.getSource(); switch(event.getKind()) { // Delete the HTML file used for the launch case DebugEvent.TERMINATE : if (eventSource != null) { ILaunch launch = null; if (eventSource instanceof IProcess) { IProcess process = (IProcess) eventSource; launch = process.getLaunch(); } else if (eventSource instanceof IDebugTarget) { IDebugTarget debugTarget = (IDebugTarget) eventSource; launch = debugTarget.getLaunch(); } if (launch != null) { cleanup(launch); } } break; } } }
@Override public void handleDebugEvents(DebugEvent[] events) { for (int i = 0; i < events.length; i++) { DebugEvent event = events[i]; Object eventSource = event.getSource(); switch(event.getKind()) { // Delete the HTML file used for the launch case DebugEvent.TERMINATE : if (eventSource != null) { ILaunch launch = null; if (eventSource instanceof IProcess) { IProcess process = (IProcess) eventSource; launch = process.getLaunch(); } else if (eventSource instanceof IDebugTarget) { IDebugTarget debugTarget = (IDebugTarget) eventSource; launch = debugTarget.getLaunch(); } if (launch != null) { cleanup(launch); } } break; } } }