migrate AppletConfiguration and BndRunConfiguration to BaseState

This commit is contained in:
Vladimir Krivosheev
2017-12-06 13:40:44 +01:00
parent 07c8033e60
commit 6bc7ed1c72
27 changed files with 333 additions and 556 deletions
@@ -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()
}
@@ -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);
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2011 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.ui;
import com.intellij.openapi.editor.Document;
@@ -21,6 +7,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
public class EditorTextFieldWithBrowseButton extends ComponentWithBrowseButton<EditorTextField> implements TextAccessor {
public EditorTextFieldWithBrowseButton(Project project, boolean isClassAccepted) {
@@ -73,6 +60,7 @@ public class EditorTextFieldWithBrowseButton extends ComponentWithBrowseButton<E
}
@Override
@NotNull
public String getText() {
return getChildComponent().getText();
}
@@ -1,25 +1,8 @@
/*
* 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.configurations;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.xmlb.annotations.Attribute;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,18 +14,30 @@ import org.jetbrains.annotations.Nullable;
* @author yole
*/
public abstract class LocatableConfigurationBase extends RunConfigurationBase implements LocatableConfiguration {
private static final String ATTR_NAME_IS_GENERATED = "nameIsGenerated";
private boolean myNameIsGenerated;
protected LocatableConfigurationBase(@NotNull Project project, @NotNull ConfigurationFactory factory, String name) {
super(project, factory, name);
}
@NotNull
@Override
protected RunConfigurationOptions createOptions() {
return new LocatableRunConfigurationOptions();
}
@Override
protected LocatableRunConfigurationOptions getOptions() {
return (LocatableRunConfigurationOptions)super.getOptions();
}
@Override
Class<LocatableRunConfigurationOptions> getOptionsClass() {
return LocatableRunConfigurationOptions.class;
}
@Override
@Attribute("nameIsGenerated")
public boolean isGeneratedName() {
return myNameIsGenerated && suggestedName() != null;
return getOptions().isNameGenerated() && suggestedName() != null;
}
/**
@@ -50,29 +45,11 @@ public abstract class LocatableConfigurationBase extends RunConfigurationBase im
*/
public void setGeneratedName() {
setName(suggestedName());
myNameIsGenerated = true;
getOptions().setNameGenerated(true);
}
public void setNameChangedByUser(boolean nameChangedByUser) {
myNameIsGenerated = !nameChangedByUser;
}
@Override
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
if (!isNewSerializationUsed()) {
myNameIsGenerated = "true".equals(element.getAttributeValue(ATTR_NAME_IS_GENERATED));
}
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
super.writeExternal(element);
if (!isNewSerializationUsed() && myNameIsGenerated && suggestedName() != null) {
element.setAttribute(ATTR_NAME_IS_GENERATED, "true");
}
getOptions().setNameGenerated(!nameChangedByUser);
}
/**
@@ -1,19 +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.configurations;
import com.intellij.openapi.application.ReadAction;
@@ -24,10 +9,8 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.ArrayUtil;
import com.intellij.util.xmlb.annotations.Property;
import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -40,44 +23,57 @@ import java.util.*;
public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunConfigurationModule> extends LocatableConfigurationBase implements Cloneable, ModuleRunConfiguration {
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.configurations.ModuleBasedConfiguration");
@Property(surroundWithTag = false)
private final ConfigurationModule myModule;
@NonNls
protected static final String TO_CLONE_ELEMENT_NAME = "toClone";
public ModuleBasedConfiguration(final String name,
@NotNull ConfigurationModule configurationModule, @NotNull ConfigurationFactory factory) {
public ModuleBasedConfiguration(String name, @NotNull ConfigurationModule configurationModule, @NotNull ConfigurationFactory factory) {
super(configurationModule.getProject(), factory, name);
myModule = configurationModule;
ModuleBasedConfigurationOptions<ConfigurationModule> options = getOptions();
options.setModule(configurationModule);
options.resetModificationCount();
}
public ModuleBasedConfiguration(final ConfigurationModule configurationModule, final ConfigurationFactory factory) {
@NotNull
@Override
protected ModuleBasedConfigurationOptions<ConfigurationModule> createOptions() {
return new ModuleBasedConfigurationOptions<>();
}
@Override
protected ModuleBasedConfigurationOptions<ConfigurationModule> getOptions() {
//noinspection unchecked
return (ModuleBasedConfigurationOptions<ConfigurationModule>)super.getOptions();
}
public ModuleBasedConfiguration(@NotNull ConfigurationModule configurationModule, @NotNull ConfigurationFactory factory) {
super(configurationModule.getProject(), factory, "");
myModule = configurationModule;
ModuleBasedConfigurationOptions<ConfigurationModule> options = getOptions();
options.setModule(configurationModule);
options.resetModificationCount();
}
public abstract Collection<Module> getValidModules();
public ConfigurationModule getConfigurationModule() {
return myModule;
return getOptions().getModule();
}
public void setModule(final Module module) {
myModule.setModule(module);
getConfigurationModule().setModule(module);
}
public void setModuleName(@Nullable String moduleName) {
myModule.setModuleName(moduleName);
getConfigurationModule().setModuleName(moduleName);
}
protected void readModule(final Element element) {
myModule.readExternal(element);
getConfigurationModule().readExternal(element);
}
protected void writeModule(@NotNull Element element) {
//if (myModule.getModule() != null) {
myModule.writeExternal(element);
getConfigurationModule().writeExternal(element);
//}
}
@@ -86,16 +82,18 @@ public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunCo
}
/**
* @deprecated method {@link com.intellij.execution.configurations.ConfigurationFactory#createTemplateConfiguration(com.intellij.openapi.project.Project)}
* @deprecated method {@link ConfigurationFactory#createTemplateConfiguration(com.intellij.openapi.project.Project)}
* would be used instead to avoid wrong custom 'cloning'
*/
protected ModuleBasedConfiguration createInstance() {
@SuppressWarnings("unchecked")
ModuleBasedConfiguration<ConfigurationModule> configuration =
(ModuleBasedConfiguration<ConfigurationModule>)getFactory().createTemplateConfiguration(getProject());
configuration.setName(getName());
return configuration;
}
@SuppressWarnings("MethodDoesntCallSuperMethod")
@Override
public ModuleBasedConfiguration clone() {
final Element element = new Element(TO_CLONE_ELEMENT_NAME);
@@ -1,25 +1,14 @@
/*
* 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.configurations;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.configurationStore.XmlSerializer;
import com.intellij.diagnostic.logging.LogConsole;
import com.intellij.execution.BeforeRunTask;
import com.intellij.execution.ExecutionTarget;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
@@ -39,39 +28,41 @@ import java.util.List;
/**
* Standard base class for run configuration implementations.
*
* @author dyoma
*/
public abstract class RunConfigurationBase extends UserDataHolderBase implements RunConfiguration, TargetAwareRunProfile {
private static final String LOG_FILE = "log_file";
private static final String PREDEFINED_LOG_FILE_ELEMENT = "predefined_log_file";
private static final String FILE_OUTPUT = "output_file";
private static final String SAVE = "is_save";
private static final String OUTPUT_FILE = "path";
private static final String SHOW_CONSOLE_ON_STD_OUT = "show_console_on_std_out";
private static final String SHOW_CONSOLE_ON_STD_ERR = "show_console_on_std_err";
private final ConfigurationFactory myFactory;
private final Project myProject;
private String myName = "";
private String myName;
private final Icon myIcon;
private RunConfigurationOptions myOptions = createOptions();
private List<LogFileOptions> myLogFiles = new SmartList<>();
private List<PredefinedLogFile> myPredefinedLogFiles = new SmartList<>();
private boolean mySaveOutput = false;
private boolean myShowConsoleOnStdOut = false;
private boolean myShowConsoleOnStdErr = false;
private String myFileOutputPath = null;
private List<BeforeRunTask> myBeforeRunTasks = Collections.emptyList();
protected RunConfigurationBase(@NotNull Project project, @NotNull ConfigurationFactory factory, final String name) {
protected RunConfigurationBase(@NotNull Project project, @NotNull ConfigurationFactory factory, String name) {
myProject = project;
myFactory = factory;
myName = name;
myIcon = factory.getIcon();
}
@NotNull
protected RunConfigurationOptions createOptions() {
return new RunConfigurationOptions();
}
protected RunConfigurationOptions getOptions() {
return myOptions;
}
@Override
@NotNull
@Transient
@@ -137,10 +128,7 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
final RunConfigurationBase runConfiguration = (RunConfigurationBase)super.clone();
runConfiguration.myLogFiles = new ArrayList<>(myLogFiles);
runConfiguration.myPredefinedLogFiles = new ArrayList<>(myPredefinedLogFiles);
runConfiguration.myFileOutputPath = myFileOutputPath;
runConfiguration.mySaveOutput = mySaveOutput;
runConfiguration.myShowConsoleOnStdOut = myShowConsoleOnStdOut;
runConfiguration.myShowConsoleOnStdErr = myShowConsoleOnStdErr;
runConfiguration.myOptions.copyFrom(myOptions);
copyCopyableDataTo(runConfiguration);
myBeforeRunTasks = myBeforeRunTasks.isEmpty() ? Collections.emptyList() : new SmartList<>(myBeforeRunTasks);
@@ -182,11 +170,12 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
return myLogFiles;
}
public void addLogFile(String file, String alias, boolean checked){
@SuppressWarnings("unused")
public void addLogFile(String file, String alias, boolean checked) {
myLogFiles.add(new LogFileOptions(alias, file, checked, true, false));
}
public void addLogFile(String file, String alias, boolean checked, boolean skipContent, final boolean showAll){
public void addLogFile(String file, String alias, boolean checked, boolean skipContent, final boolean showAll) {
myLogFiles.add(new LogFileOptions(alias, file, checked, skipContent, showAll));
}
@@ -216,83 +205,77 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
logFile.readExternal(fileElement);
myPredefinedLogFiles.add(logFile);
}
final Element fileOutputElement = element.getChild(FILE_OUTPUT);
if (fileOutputElement != null) {
myFileOutputPath = fileOutputElement.getAttributeValue(OUTPUT_FILE);
String isSave = fileOutputElement.getAttributeValue(SAVE);
mySaveOutput = isSave != null && Boolean.parseBoolean(isSave);
}
if (!isNewSerializationUsed()) {
myShowConsoleOnStdOut = Boolean.parseBoolean(element.getAttributeValue(SHOW_CONSOLE_ON_STD_OUT));
myShowConsoleOnStdErr = Boolean.parseBoolean(element.getAttributeValue(SHOW_CONSOLE_ON_STD_ERR));
if (this instanceof PersistentStateComponent) {
PersistentStateComponent instance = (PersistentStateComponent)this;
myOptions = XmlSerializer.deserialize(element, ComponentSerializationUtil.getStateClass(instance.getClass()));
}
else {
myOptions = XmlSerializer.deserialize(element, getOptionsClass());
}
}
Class<? extends RunConfigurationOptions> getOptionsClass() {
return RunConfigurationOptions.class;
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
JDOMExternalizerUtil.addChildren(element, LOG_FILE, myLogFiles);
JDOMExternalizerUtil.addChildren(element, PREDEFINED_LOG_FILE_ELEMENT, myPredefinedLogFiles);
if (myFileOutputPath != null || mySaveOutput) {
Element fileOutputPathElement = new Element(FILE_OUTPUT);
if (myFileOutputPath != null) {
fileOutputPathElement.setAttribute(OUTPUT_FILE, myFileOutputPath);
}
if (mySaveOutput) {
fileOutputPathElement.setAttribute(SAVE, String.valueOf(mySaveOutput));
}
element.addContent(fileOutputPathElement);
}
if (!isNewSerializationUsed()) {
if (myShowConsoleOnStdOut) {//default value shouldn't be written
element.setAttribute(SHOW_CONSOLE_ON_STD_OUT, String.valueOf(true));
}
if (myShowConsoleOnStdErr) {//default value shouldn't be written
element.setAttribute(SHOW_CONSOLE_ON_STD_ERR, String.valueOf(true));
}
}
public void writeExternal(@NotNull Element element) throws WriteExternalException {
writeState(element);
}
protected boolean isNewSerializationUsed() {
return false;
protected void writeState(@NotNull Element element) {
JDOMExternalizerUtil.addChildren(element, LOG_FILE, myLogFiles);
JDOMExternalizerUtil.addChildren(element, PREDEFINED_LOG_FILE_ELEMENT, myPredefinedLogFiles);
XmlSerializer.serializeObjectInto(myOptions, element);
}
@Transient
public boolean isSaveOutputToFile() {
return mySaveOutput;
RunConfigurationOptions.OutputFileOptions fileOutput = myOptions.getFileOutput();
return fileOutput != null && fileOutput.isSaveOutput();
}
public void setSaveOutputToFile(boolean redirectOutput) {
mySaveOutput = redirectOutput;
RunConfigurationOptions.OutputFileOptions fileOutput = myOptions.getFileOutput();
if (fileOutput == null) {
fileOutput = new RunConfigurationOptions.OutputFileOptions();
myOptions.setFileOutput(fileOutput);
}
fileOutput.setSaveOutput(redirectOutput);
}
@Attribute(SHOW_CONSOLE_ON_STD_OUT)
public boolean isShowConsoleOnStdOut() {
return myShowConsoleOnStdOut;
return myOptions.isShowConsoleOnStdOut();
}
public void setShowConsoleOnStdOut(boolean showConsoleOnStdOut) {
myShowConsoleOnStdOut = showConsoleOnStdOut;
myOptions.setShowConsoleOnStdOut(showConsoleOnStdOut);
}
@Attribute(SHOW_CONSOLE_ON_STD_ERR)
public boolean isShowConsoleOnStdErr() {
return myShowConsoleOnStdErr;
return myOptions.isShowConsoleOnStdErr();
}
public void setShowConsoleOnStdErr(boolean showConsoleOnStdErr) {
myShowConsoleOnStdErr = showConsoleOnStdErr;
myOptions.setShowConsoleOnStdErr(showConsoleOnStdErr);
}
@Transient
public String getOutputFilePath() {
return myFileOutputPath;
RunConfigurationOptions.OutputFileOptions output = myOptions.getFileOutput();
return output == null ? null : output.getFileOutputPath();
}
public void setFileOutputPath(String fileOutputPath) {
myFileOutputPath = fileOutputPath;
RunConfigurationOptions.OutputFileOptions fileOutput = myOptions.getFileOutput();
if (fileOutput == null) {
fileOutput = new RunConfigurationOptions.OutputFileOptions();
myOptions.setFileOutput(fileOutput);
}
fileOutput.setFileOutputPath(fileOutputPath);
}
public boolean collectOutputFromProcessHandler() {
@@ -0,0 +1,41 @@
// 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.configurations
import com.intellij.openapi.components.BaseState
import com.intellij.util.xmlb.Accessor
import com.intellij.util.xmlb.annotations.Attribute
import com.intellij.util.xmlb.annotations.Property
import com.intellij.util.xmlb.annotations.Tag
open class RunConfigurationOptions : BaseState() {
@Tag("output_file")
class OutputFileOptions : BaseState() {
@get:Attribute("path") var fileOutputPath by string()
@get:Attribute("is_save") var isSaveOutput by storedProperty(false)
}
// we use object instead of 2 fields because XML serializer cannot reuse tag for several fields
@get:Property(surroundWithTag = false) var fileOutput by storedProperty<OutputFileOptions>()
@get:Attribute("show_console_on_std_out") var isShowConsoleOnStdOut by storedProperty(false)
@get:Attribute("show_console_on_std_err") var isShowConsoleOnStdErr by storedProperty(false)
}
open class LocatableRunConfigurationOptions : RunConfigurationOptions() {
@get:Attribute("nameIsGenerated") var isNameGenerated by storedProperty(false)
}
open class ModuleBasedConfigurationOptions<ConfigurationModule : RunConfigurationModule> : LocatableRunConfigurationOptions() {
@get:Property(surroundWithTag = false)
var module by storedProperty<ConfigurationModule>()
override fun accepts(accessor: Accessor, bean: Any): Boolean {
if (accessor.name == "module") {
val module = module
return module != null && module.moduleName.isNotEmpty()
}
else {
return super.accepts(accessor, bean)
}
}
}
@@ -1,23 +1,10 @@
/*
* 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.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFileManager;
@@ -57,6 +44,6 @@ public class ExternalizablePath implements JDOMExternalizable {
}
public static String localPathValue(@Nullable String url) {
return StringUtil.isEmptyOrSpaces(url) ? "" : VirtualFileManager.extractPath(url.trim()).replace('/', File.separatorChar);
return StringUtil.isEmptyOrSpaces(url) ? "" : FileUtilRt.toSystemDependentName(VirtualFileManager.extractPath(url.trim()));
}
}
@@ -1,26 +1,12 @@
/*
* Copyright 2000-2015 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.facet.impl;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.facet.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.InvalidDataException;
@@ -1,22 +1,8 @@
/*
* 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.ui;
public interface TextAccessor {
void setText(String text);
String getText();
}
@@ -30,6 +30,7 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ex.AbstractDelegatingToRootTraversalPolicy;
import com.intellij.psi.PsiDocumentManager;
@@ -138,6 +139,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
setDocument(myDocument); // reinit editor.
}
@NotNull
@Override
public String getText() {
return myDocument.getText();
@@ -233,7 +235,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
public void setText(@Nullable final String text) {
ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(getProject(), () -> {
myDocument.replaceString(0, myDocument.getTextLength(), text == null ? "" : text);
myDocument.replaceString(0, myDocument.getTextLength(), StringUtil.notNullize(text));
if (myEditor != null) {
final CaretModel caretModel = myEditor.getCaretModel();
if (caretModel.getOffset() >= myDocument.getTextLength()) {
@@ -1,6 +1,7 @@
// 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.openapi.components;
package com.intellij.configurationStore;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.xmlb.XmlSerializer;
import org.jdom.Element;
@@ -1,23 +1,8 @@
/*
* 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.
@file:JvmName("XmlSerializer")
package com.intellij.configurationStore
import com.intellij.openapi.components.BaseState
import com.intellij.openapi.components.ComponentSerializationUtil
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.util.JDOMUtil
import com.intellij.reference.SoftReference
@@ -123,11 +108,6 @@ fun PersistentStateComponent<*>.serializeStateInto(element: Element) {
state?.let { serializeObjectInto(it, element) }
}
@Deprecated("")
fun <T : Any> T.serializeInto(target: Element) {
serializeObjectInto(this, target)
}
fun serializeObjectInto(o: Any, target: Element) {
if (o is Element) {
val iterator = o.children.iterator()
@@ -145,10 +125,11 @@ fun serializeObjectInto(o: Any, target: Element) {
}
val binding = serializer.getClassBinding(o.javaClass)
(binding as BeanBinding).serializeInto(o, target, getDefaultSerializationFilter())
(binding as BeanBinding).serializeInto(o, target, if (o is BaseState) null else getDefaultSerializationFilter())
}
private val serializer = object : XmlSerializerImpl.XmlSerializerBase() {
@Suppress("ObjectPropertyName")
private var _bindingCache: SoftReference<MutableMap<BindingCacheKey, Binding>>? = null
private val bindingCache: MutableMap<BindingCacheKey, Binding>
@@ -5,6 +5,7 @@ import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.util.ModificationTracker
import com.intellij.util.SmartList
import com.intellij.util.xmlb.Accessor
import com.intellij.util.xmlb.PropertyAccessor
import com.intellij.util.xmlb.SerializationFilter
import com.intellij.util.xmlb.annotations.Transient
import kotlin.reflect.KProperty
@@ -62,8 +63,9 @@ abstract class BaseState : SerializationFilter, ModificationTracker {
}
override fun accepts(accessor: Accessor, bean: Any): Boolean {
val getterName = (accessor as? PropertyAccessor)?.getterName
for (property in properties) {
if (property.name == accessor.name) {
if (property.name == accessor.name || property.name == getterName) {
return property.value != property.defaultValue
}
}
@@ -1,23 +1,9 @@
/*
* 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.openapi.roots.impl.libraries;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.components.StateSplitterEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
@@ -1,21 +1,7 @@
/*
* 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.remoteServer.impl.configuration;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
@@ -1,27 +1,13 @@
/*
* 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.remoteServer.impl.configuration.deployment;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.*;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.options.SettingsEditorGroup;
@@ -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.util.xmlb;
import com.intellij.util.ExceptionUtil;
@@ -28,7 +14,7 @@ import java.lang.reflect.Type;
import static com.intellij.util.xmlb.Binding.LOG;
class PropertyAccessor implements MutableAccessor {
public class PropertyAccessor implements MutableAccessor {
private final String myName;
private final Class<?> myType;
private final Method myReadMethod;
@@ -53,6 +39,11 @@ class PropertyAccessor implements MutableAccessor {
catch (SecurityException ignored) { }
}
@NotNull
public String getGetterName() {
return myReadMethod.getName();
}
@Override
public Object read(@NotNull Object o) {
try {
@@ -1,24 +1,10 @@
/*
* 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.xdebugger.impl.breakpoints;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.editor.markup.GutterDraggableObject;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.project.DumbAware;
@@ -1,21 +1,7 @@
/*
* 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.xdebugger.impl.settings;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
@@ -1,23 +1,9 @@
/*
* 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 org.jetbrains.idea.eclipse.conversion;
import com.intellij.configurationStore.ComponentSerializationUtil;
import com.intellij.configurationStore.XmlSerializer;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
@@ -1,6 +1,4 @@
// 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.
// 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.jetbrains
import com.intellij.codeInsight.completion.CompletionResultSet
@@ -55,22 +53,21 @@ class PySymbolFieldWithBrowseButton(contextAnchor: ContextAnchor,
dialog.showDialog()
val element = dialog.selected
if (element is PyQualifiedNameOwner) {
childComponent.text = element.qualifiedName
childComponent.setText(element.qualifiedName)
}
if (element is PyFile) {
childComponent.text = element.getQName()?.toString()
childComponent.setText(element.getQName()?.toString())
}
}
}
override fun setText(text: String?) {
childComponent.text = text
childComponent.setText(text)
}
override fun getText() = childComponent.text!!
override fun getText() = childComponent.text
}
private fun PyType.getVariants(element: PsiElement): Array<LookupElement> =
this.getCompletionVariants("", element, ProcessingContext()).filterIsInstance(LookupElement::class.java).toTypedArray()
-6
View File
@@ -11,13 +11,7 @@
</configuration>
<configuration name="&lt;template&gt;" type="Applet" default="true" selected="false">
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
</configuration>
<configuration name="&lt;template&gt;" type="JUnit" default="true" selected="false">