mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
migrate AppletConfiguration and BndRunConfiguration to BaseState
This commit is contained in:
@@ -1,23 +1,6 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ModuleBasedConfiguration;
|
||||
import com.intellij.execution.configurations.RunConfigurationModule;
|
||||
import com.intellij.psi.PsiClass;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.applet;
|
||||
|
||||
import com.intellij.application.options.ModulesComboBox;
|
||||
@@ -206,12 +192,12 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
|
||||
return myHtmlFile;
|
||||
}
|
||||
|
||||
private String toNull(String s) {
|
||||
private static String toNull(String s) {
|
||||
s = s.trim();
|
||||
return s.length() == 0 ? null : s;
|
||||
}
|
||||
|
||||
private String toSystemFormat(String s) {
|
||||
private static String toSystemFormat(String s) {
|
||||
s = s.trim();
|
||||
return s.length() == 0 ? null : s.replace(File.separatorChar, '/');
|
||||
}
|
||||
@@ -223,28 +209,29 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
|
||||
configuration.setAppletParameters(params);
|
||||
}
|
||||
|
||||
public void resetEditorFrom(@NotNull final AppletConfiguration configuration) {
|
||||
getClassNameComponent().setText(configuration.MAIN_CLASS_NAME);
|
||||
String presentableHtmlName = configuration.HTML_FILE_NAME;
|
||||
public void resetEditorFrom(@NotNull AppletConfiguration runConfiguration) {
|
||||
AppletConfigurationOptions configuration = runConfiguration.getOptions();
|
||||
getClassNameComponent().setText(configuration.getMainClassName());
|
||||
String presentableHtmlName = configuration.getHtmlFileName();
|
||||
if (presentableHtmlName != null && !StringUtil.startsWithIgnoreCase(presentableHtmlName, HTTP_PREFIX)) {
|
||||
presentableHtmlName = presentableHtmlName.replace('/', File.separatorChar);
|
||||
}
|
||||
getHtmlPathComponent().setText(presentableHtmlName);
|
||||
getPolicyFileComponent().setText(configuration.getPolicyFile());
|
||||
getVMParametersComponent().setText(configuration.VM_PARAMETERS);
|
||||
getWidthComponent().setText(Integer.toString(configuration.WIDTH));
|
||||
getHeightComponent().setText(Integer.toString(configuration.HEIGHT));
|
||||
getPolicyFileComponent().setText(runConfiguration.getPolicyFile());
|
||||
getVMParametersComponent().setText(configuration.getVmParameters());
|
||||
getWidthComponent().setText(Integer.toString(configuration.getWidth()));
|
||||
getHeightComponent().setText(Integer.toString(configuration.getHeight()));
|
||||
|
||||
(configuration.HTML_USED ? myURL : myMainClass).setSelected(true);
|
||||
(configuration.getHtmlUsed() ? myURL : myMainClass).setSelected(true);
|
||||
changePanel();
|
||||
|
||||
final AppletConfiguration.AppletParameter[] appletParameters = configuration.getAppletParameters();
|
||||
final AppletConfiguration.AppletParameter[] appletParameters = runConfiguration.getAppletParameters();
|
||||
if (appletParameters != null) {
|
||||
myParameters.setItems(cloneParameters(Arrays.asList(appletParameters)));
|
||||
}
|
||||
myModuleSelector.reset(configuration);
|
||||
myModuleSelector.reset(runConfiguration);
|
||||
myJrePathEditor
|
||||
.setPathOrName(configuration.ALTERNATIVE_JRE_PATH, configuration.ALTERNATIVE_JRE_PATH_ENABLED);
|
||||
.setPathOrName(configuration.getAlternativeJrePath(), configuration.getAlternativeJrePathEnabled());
|
||||
}
|
||||
|
||||
private RawCommandLineEditor getVMParametersComponent() {
|
||||
@@ -261,25 +248,26 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
public void checkEditorData(final AppletConfiguration configuration) {
|
||||
configuration.MAIN_CLASS_NAME = toNull(getClassNameComponent().getText());
|
||||
configuration.HTML_FILE_NAME = toSystemFormat(getHtmlPathComponent().getText());
|
||||
configuration.VM_PARAMETERS = toNull(getVMParametersComponent().getText());
|
||||
configuration.setPolicyFile(getPolicyFileComponent().getText());
|
||||
myModuleSelector.applyTo(configuration);
|
||||
public void checkEditorData(@NotNull AppletConfiguration runConfiguration) {
|
||||
AppletConfigurationOptions configuration = runConfiguration.getOptions();
|
||||
configuration.setMainClassName(getClassNameComponent().getText().trim());
|
||||
configuration.setHtmlFileName(toSystemFormat(getHtmlPathComponent().getText()));
|
||||
configuration.setVmParameters(getVMParametersComponent().getText().trim());
|
||||
runConfiguration.setPolicyFile(getPolicyFileComponent().getText());
|
||||
myModuleSelector.applyTo(runConfiguration);
|
||||
try {
|
||||
configuration.WIDTH = Integer.parseInt(getWidthComponent().getText());
|
||||
configuration.setWidth(Integer.parseInt(getWidthComponent().getText()));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
try {
|
||||
configuration.HEIGHT = Integer.parseInt(getHeightComponent().getText());
|
||||
configuration.setHeight(Integer.parseInt(getHeightComponent().getText()));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
configuration.HTML_USED = myURL.isSelected();
|
||||
configuration.ALTERNATIVE_JRE_PATH = myJrePathEditor.getJrePathOrName();
|
||||
configuration.ALTERNATIVE_JRE_PATH_ENABLED = myJrePathEditor.isAlternativeJreSelected();
|
||||
configuration.setHtmlUsed(myURL.isSelected());
|
||||
configuration.setAlternativeJrePath(myJrePathEditor.getJrePathOrName());
|
||||
configuration.setAlternativeJrePathEnabled(myJrePathEditor.isAlternativeJreSelected());
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.applet;
|
||||
|
||||
import com.intellij.execution.*;
|
||||
@@ -23,20 +9,18 @@ import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.xmlb.SmartSerializer;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -50,31 +34,27 @@ import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigurationModule> implements SingleClassConfiguration, RefactoringListenerProvider {
|
||||
public String MAIN_CLASS_NAME;
|
||||
public String HTML_FILE_NAME;
|
||||
public boolean HTML_USED;
|
||||
public int WIDTH;
|
||||
public int HEIGHT;
|
||||
public String POLICY_FILE;
|
||||
public String VM_PARAMETERS;
|
||||
public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigurationModule> implements SingleClassConfiguration, RefactoringListenerProvider,
|
||||
PersistentStateComponent<Element> {
|
||||
private static final String NAME_ATTR = "name";
|
||||
private static final String VALUE_ATTR = "value";
|
||||
private static final String PARAMETER_ELEMENT_NAME = "parameter";
|
||||
|
||||
private AppletParameter[] myAppletParameters;
|
||||
public boolean ALTERNATIVE_JRE_PATH_ENABLED;
|
||||
public String ALTERNATIVE_JRE_PATH;
|
||||
|
||||
@NonNls
|
||||
protected static final String NAME_ATTR = "name";
|
||||
@NonNls
|
||||
protected static final String VALUE_ATTR = "value";
|
||||
@NonNls
|
||||
protected static final String PARAMETER_ELEMENT_NAME = "parameter";
|
||||
|
||||
private final SmartSerializer mySerializer;
|
||||
|
||||
public AppletConfiguration(@NotNull Project project, ConfigurationFactory factory) {
|
||||
public AppletConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory) {
|
||||
super(new JavaRunConfigurationModule(project, false), factory);
|
||||
}
|
||||
|
||||
mySerializer = new SmartSerializer(!project.isDefault(), true);
|
||||
@NotNull
|
||||
@Override
|
||||
protected AppletConfigurationOptions createOptions() {
|
||||
return new AppletConfigurationOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AppletConfigurationOptions getOptions() {
|
||||
return (AppletConfigurationOptions)super.getOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,18 +74,16 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
protected JavaParameters createJavaParameters() throws ExecutionException {
|
||||
final JavaParameters params = new JavaParameters();
|
||||
myHtmlURL = getHtmlURL();
|
||||
if (myHtmlURL != null) {
|
||||
final int classPathType = myHtmlURL.isHttp() ? JavaParameters.JDK_ONLY : JavaParameters.JDK_AND_CLASSES;
|
||||
final RunConfigurationModule runConfigurationModule = getConfigurationModule();
|
||||
JavaParametersUtil.configureModule(runConfigurationModule, params, classPathType, ALTERNATIVE_JRE_PATH_ENABLED ? ALTERNATIVE_JRE_PATH : null);
|
||||
final String policyFileParameter = getPolicyFileParameter();
|
||||
if (policyFileParameter != null) {
|
||||
params.getVMParametersList().add(policyFileParameter);
|
||||
}
|
||||
params.getVMParametersList().addParametersString(VM_PARAMETERS);
|
||||
params.setMainClass("sun.applet.AppletViewer");
|
||||
params.getProgramParametersList().add(myHtmlURL.getUrl());
|
||||
final int classPathType = myHtmlURL.isHttp() ? JavaParameters.JDK_ONLY : JavaParameters.JDK_AND_CLASSES;
|
||||
final RunConfigurationModule runConfigurationModule = getConfigurationModule();
|
||||
JavaParametersUtil.configureModule(runConfigurationModule, params, classPathType, getOptions().getAlternativeJrePathEnabled() ? getOptions().getAlternativeJrePath() : null);
|
||||
final String policyFileParameter = getPolicyFileParameter();
|
||||
if (policyFileParameter != null) {
|
||||
params.getVMParametersList().add(policyFileParameter);
|
||||
}
|
||||
params.getVMParametersList().addParametersString(getOptions().getVmParameters());
|
||||
params.setMainClass("sun.applet.AppletViewer");
|
||||
params.getProgramParametersList().add(myHtmlURL.getUrl());
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -133,8 +111,9 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
return new AppletConfigurable(getProject());
|
||||
}
|
||||
|
||||
@NonNls private String getPolicyFileParameter() {
|
||||
if (POLICY_FILE != null && POLICY_FILE.length() > 0) {
|
||||
private String getPolicyFileParameter() {
|
||||
if (!StringUtil.isEmpty(getOptions().getPolicyFile())) {
|
||||
//noinspection SpellCheckingInspection
|
||||
return "-Djava.security.policy=" + getPolicyFile();
|
||||
}
|
||||
return null;
|
||||
@@ -142,11 +121,11 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
|
||||
@Transient
|
||||
public String getPolicyFile() {
|
||||
return ExternalizablePath.localPathValue(POLICY_FILE);
|
||||
return ExternalizablePath.localPathValue(getOptions().getPolicyFile());
|
||||
}
|
||||
|
||||
public void setPolicyFile(final String localPath) {
|
||||
POLICY_FILE = ExternalizablePath.urlValue(localPath);
|
||||
getOptions().setPolicyFile(ExternalizablePath.urlValue(localPath));
|
||||
}
|
||||
|
||||
public static class AppletParameter {
|
||||
@@ -187,75 +166,77 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
|
||||
@Override
|
||||
public Collection<Module> getValidModules() {
|
||||
return JavaRunConfigurationModule.getModulesForClass(getProject(), MAIN_CLASS_NAME);
|
||||
return JavaRunConfigurationModule.getModulesForClass(getProject(), getOptions().getMainClassName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(final Element parentNode) throws InvalidDataException {
|
||||
mySerializer.readExternal(this, parentNode);
|
||||
public Element getState() {
|
||||
Element element = new Element("state");
|
||||
super.writeState(element);
|
||||
|
||||
List<Element> paramList = parentNode.getChildren(PARAMETER_ELEMENT_NAME);
|
||||
if (myAppletParameters != null) {
|
||||
for (AppletParameter myAppletParameter : myAppletParameters) {
|
||||
Element parameterElement = new Element(PARAMETER_ELEMENT_NAME);
|
||||
element.addContent(parameterElement);
|
||||
parameterElement.setAttribute(NAME_ATTR, myAppletParameter.getName());
|
||||
parameterElement.setAttribute(VALUE_ATTR, myAppletParameter.getValue());
|
||||
}
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element element) {
|
||||
super.readExternal(element);
|
||||
|
||||
List<Element> paramList = element.getChildren(PARAMETER_ELEMENT_NAME);
|
||||
if (paramList.isEmpty()) {
|
||||
myAppletParameters = null;
|
||||
}
|
||||
else {
|
||||
List<AppletParameter> parameters = new SmartList<>();
|
||||
for (Element element : paramList) {
|
||||
parameters.add(new AppletParameter(element.getAttributeValue(NAME_ATTR), element.getAttributeValue(VALUE_ATTR)));
|
||||
for (Element child : paramList) {
|
||||
parameters.add(new AppletParameter(child.getAttributeValue(NAME_ATTR), child.getAttributeValue(VALUE_ATTR)));
|
||||
}
|
||||
myAppletParameters = parameters.toArray(new AppletParameter[parameters.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNewSerializationUsed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(final Element parentNode) throws WriteExternalException {
|
||||
mySerializer.writeExternal(this, parentNode);
|
||||
if (myAppletParameters != null) {
|
||||
for (AppletParameter myAppletParameter : myAppletParameters) {
|
||||
final Element element = new Element(PARAMETER_ELEMENT_NAME);
|
||||
parentNode.addContent(element);
|
||||
element.setAttribute(NAME_ATTR, myAppletParameter.getName());
|
||||
element.setAttribute(VALUE_ATTR, myAppletParameter.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefactoringElementListener getRefactoringElementListener(final PsiElement element) {
|
||||
if (HTML_USED) return null;
|
||||
if (getOptions().getHtmlUsed()) {
|
||||
return null;
|
||||
}
|
||||
return RefactoringListeners.getClassOrPackageListener(element, new RefactoringListeners.SingleClassConfigurationAccessor(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
public PsiClass getMainClass() {
|
||||
return getConfigurationModule().findClass(MAIN_CLASS_NAME);
|
||||
return getConfigurationModule().findClass(getOptions().getMainClassName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String suggestedName() {
|
||||
if (MAIN_CLASS_NAME == null) return null;
|
||||
return ProgramRunnerUtil.shortenName(JavaExecutionUtil.getShortClassName(MAIN_CLASS_NAME), 0);
|
||||
if (getOptions().getMainClassName() == null) {
|
||||
return null;
|
||||
}
|
||||
return ProgramRunnerUtil.shortenName(JavaExecutionUtil.getShortClassName(getOptions().getMainClassName()), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainClassName(final String qualifiedName) {
|
||||
MAIN_CLASS_NAME = qualifiedName;
|
||||
getOptions().setMainClassName(qualifiedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration() throws RuntimeConfigurationException {
|
||||
if (ALTERNATIVE_JRE_PATH_ENABLED && (StringUtil.isEmptyOrSpaces(ALTERNATIVE_JRE_PATH) || !JdkUtil.checkForJre(ALTERNATIVE_JRE_PATH))) {
|
||||
throw new RuntimeConfigurationWarning(ExecutionBundle.message("jre.not.valid.error.message", ALTERNATIVE_JRE_PATH));
|
||||
if (getOptions().getAlternativeJrePathEnabled() && (StringUtil.isEmptyOrSpaces(getOptions().getAlternativeJrePath()) || !JdkUtil.checkForJre(getOptions().getAlternativeJrePath()))) {
|
||||
throw new RuntimeConfigurationWarning(ExecutionBundle.message("jre.not.valid.error.message", getOptions().getAlternativeJrePath()));
|
||||
}
|
||||
getConfigurationModule().checkForWarning();
|
||||
if (HTML_USED) {
|
||||
if (HTML_FILE_NAME == null || HTML_FILE_NAME.length() == 0) {
|
||||
if (getOptions().getHtmlUsed()) {
|
||||
if (getOptions().getHtmlFileName() == null) {
|
||||
throw new RuntimeConfigurationWarning(ExecutionBundle.message("html.file.not.specified.error.message"));
|
||||
}
|
||||
try {
|
||||
@@ -266,12 +247,12 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
}
|
||||
}
|
||||
else {
|
||||
getConfigurationModule().checkClassName(MAIN_CLASS_NAME, ExecutionBundle.message("no.applet.class.specified.error.message"));
|
||||
getConfigurationModule().checkClassName(getOptions().getMainClassName(), ExecutionBundle.message("no.applet.class.specified.error.message"));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUrlIsValid(Exception ex) throws RuntimeConfigurationWarning {
|
||||
throw new RuntimeConfigurationWarning("URL " + HTML_FILE_NAME + " is not valid: " + ex.getLocalizedMessage());
|
||||
throw new RuntimeConfigurationWarning("URL " + getOptions().getHtmlFileName() + " is not valid: " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
@Transient
|
||||
@@ -288,14 +269,14 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
}
|
||||
|
||||
private AppletHtmlFile getHtmlURL() throws CantRunException {
|
||||
if (HTML_USED) {
|
||||
if (HTML_FILE_NAME == null || HTML_FILE_NAME.length() == 0) {
|
||||
if (getOptions().getHtmlUsed()) {
|
||||
if (getOptions().getHtmlFileName() == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("html.file.not.specified.error.message"));
|
||||
}
|
||||
return new AppletHtmlFile(HTML_FILE_NAME, null);
|
||||
return new AppletHtmlFile(getOptions().getHtmlFileName(), null);
|
||||
}
|
||||
else {
|
||||
if (MAIN_CLASS_NAME == null || MAIN_CLASS_NAME.length() == 0) {
|
||||
if (getOptions().getMainClassName() == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("class.not.specified.error.message"));
|
||||
}
|
||||
|
||||
@@ -309,19 +290,20 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private AppletHtmlFile generateAppletTempPage() throws IOException {
|
||||
final File tempFile = FileUtil.createTempFile("AppletPage", ".html");
|
||||
@NonNls final FileWriter writer = new FileWriter(tempFile);
|
||||
try {
|
||||
writer.write("<html>\n" +
|
||||
"<head>\n" +
|
||||
"<title>" + MAIN_CLASS_NAME + "</title>\n" +
|
||||
"<title>" + getOptions().getMainClassName() + "</title>\n" +
|
||||
"</head>\n" +
|
||||
"<applet codebase=\".\"\n" +
|
||||
"code=\"" + MAIN_CLASS_NAME + "\"\n" +
|
||||
"name=\"" + MAIN_CLASS_NAME + "\"\n" +
|
||||
"width=" + WIDTH + "\n" +
|
||||
"height=" + HEIGHT + "\n" +
|
||||
"code=\"" + getOptions().getMainClassName() + "\"\n" +
|
||||
"name=\"" + getOptions().getMainClassName() + "\"\n" +
|
||||
"width=" + getOptions().getWidth() + "\n" +
|
||||
"height=" + getOptions().getHeight() + "\n" +
|
||||
"align=top>\n");
|
||||
final AppletParameter[] appletParameters = getAppletParameters();
|
||||
if (appletParameters != null) {
|
||||
@@ -355,6 +337,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
public String getUrl() {
|
||||
if (!StringUtil.startsWithIgnoreCase(myHtmlFile, FILE_PREFIX) && !isHttp()) {
|
||||
try {
|
||||
//noinspection deprecation
|
||||
return new File(myHtmlFile).toURL().toString();
|
||||
}
|
||||
catch (MalformedURLException ignored) {
|
||||
@@ -369,6 +352,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
|
||||
public void deleteFile() {
|
||||
if (myFileToDelete != null) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
myFileToDelete.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.applet
|
||||
|
||||
import com.intellij.execution.configurations.JavaRunConfigurationModule
|
||||
import com.intellij.execution.configurations.ModuleBasedConfigurationOptions
|
||||
import com.intellij.util.xmlb.annotations.OptionTag
|
||||
|
||||
class AppletConfigurationOptions : ModuleBasedConfigurationOptions<JavaRunConfigurationModule>() {
|
||||
@get:OptionTag("MAIN_CLASS_NAME") var mainClassName by string()
|
||||
@get:OptionTag("HTML_FILE_NAME") var htmlFileName by string()
|
||||
@get:OptionTag("HTML_USED") var htmlUsed by storedProperty(false)
|
||||
|
||||
@get:OptionTag("WIDTH") var width by storedProperty(300)
|
||||
@get:OptionTag("HEIGHT") var height by storedProperty(400)
|
||||
|
||||
@get:OptionTag("POLICY_FILE") var policyFile by string()
|
||||
@get:OptionTag("VM_PARAMETERS") var vmParameters by string()
|
||||
|
||||
@get:OptionTag("ALTERNATIVE_JRE_PATH_ENABLED") var alternativeJrePathEnabled by storedProperty(false)
|
||||
@get:OptionTag("ALTERNATIVE_JRE_PATH") var alternativeJrePath by string()
|
||||
}
|
||||
+3
-18
@@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.applet;
|
||||
|
||||
import com.intellij.execution.JavaExecutionUtil;
|
||||
@@ -59,7 +44,7 @@ public class AppletConfigurationProducer extends JavaRuntimeConfigurationProduce
|
||||
if (myPsiClass == null) return null;
|
||||
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, context);
|
||||
final AppletConfiguration configuration = (AppletConfiguration)settings.getConfiguration();
|
||||
configuration.MAIN_CLASS_NAME = JavaExecutionUtil.getRuntimeQualifiedName(myPsiClass);
|
||||
configuration.setMainClassName(JavaExecutionUtil.getRuntimeQualifiedName(myPsiClass));
|
||||
configuration.setModule(myPsiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(myPsiClass) : null);
|
||||
configuration.setGeneratedName();
|
||||
return settings;
|
||||
@@ -112,7 +97,7 @@ public class AppletConfigurationProducer extends JavaRuntimeConfigurationProduce
|
||||
if (aClass != null) {
|
||||
for (RunnerAndConfigurationSettings existingConfiguration : existingConfigurations) {
|
||||
if (Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass),
|
||||
((AppletConfiguration)existingConfiguration.getConfiguration()).MAIN_CLASS_NAME)) {
|
||||
((AppletConfiguration)existingConfiguration.getConfiguration()).getOptions().getMainClassName())) {
|
||||
return existingConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.applet;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
@@ -27,11 +13,11 @@ import javax.swing.*;
|
||||
public class AppletConfigurationType implements ConfigurationType {
|
||||
private final ConfigurationFactory myFactory;
|
||||
|
||||
/**reflection*/
|
||||
AppletConfigurationType() {
|
||||
myFactory = new ConfigurationFactoryEx(this) {
|
||||
@NotNull
|
||||
@Override
|
||||
public RunConfiguration createTemplateConfiguration(Project project) {
|
||||
public RunConfiguration createTemplateConfiguration(@NotNull Project project) {
|
||||
return new AppletConfiguration(project, this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user