mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use SchemeManager in the RunManager to manage run configurations
(cherry picked from commit cd8400fa3230e58b3d3f9e7503c214a0dbbf28db)
This commit is contained in:
@@ -49,7 +49,7 @@ class UISettings : BaseState(), PersistentStateComponent<UISettings> {
|
||||
// should be stored or shouldn't by the provided filter only.
|
||||
@get:Property(filter = FontFilter::class)
|
||||
@get:OptionTag("FONT_FACE")
|
||||
var fontFace by storedProperty<String?>()
|
||||
var fontFace by string()
|
||||
|
||||
@get:Property(filter = FontFilter::class)
|
||||
@get:OptionTag("FONT_SIZE")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -19,7 +19,7 @@ import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @see RefactoringListenerProvider
|
||||
*/
|
||||
public interface RunConfiguration extends RunProfile, JDOMExternalizable, Cloneable {
|
||||
public interface RunConfiguration extends RunProfile, Cloneable {
|
||||
DataKey<RunConfiguration> DATA_KEY = DataKey.create("runtimeConfiguration");
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,9 @@ public interface RunConfiguration extends RunProfile, JDOMExternalizable, Clonea
|
||||
* @return the unique ID of the configuration.
|
||||
*/
|
||||
@Deprecated
|
||||
int getUniqueID();
|
||||
default int getUniqueID() {
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the run configuration settings are valid.
|
||||
@@ -123,4 +125,10 @@ public interface RunConfiguration extends RunProfile, JDOMExternalizable, Clonea
|
||||
* to execute the run configuration.
|
||||
*/
|
||||
void checkConfiguration() throws RuntimeConfigurationException;
|
||||
|
||||
default void readExternal(Element element) {
|
||||
}
|
||||
|
||||
default void writeExternal(Element element) {
|
||||
}
|
||||
}
|
||||
|
||||
+1
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -67,11 +67,6 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
|
||||
myIcon = factory.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUniqueID() {
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConfigurationFactory getFactory() {
|
||||
return myFactory;
|
||||
|
||||
+17
-2
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.configurationStore.XmlSerializer;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionException;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -379,7 +381,14 @@ public class RunnerAndConfigurationSettingsImpl implements Cloneable, RunnerAndC
|
||||
PathMacroManager.getInstance(module).expandPaths(element);
|
||||
}
|
||||
}
|
||||
myConfiguration.readExternal(element);
|
||||
|
||||
if (myConfiguration instanceof PersistentStateComponent) {
|
||||
XmlSerializer.deserializeAndLoadState((PersistentStateComponent)myConfiguration, element);
|
||||
}
|
||||
else {
|
||||
myConfiguration.readExternal(element);
|
||||
}
|
||||
|
||||
myRunnerSettings.loadState(element);
|
||||
myConfigurationPerRunnerSettings.loadState(element);
|
||||
}
|
||||
@@ -414,7 +423,13 @@ public class RunnerAndConfigurationSettingsImpl implements Cloneable, RunnerAndC
|
||||
}
|
||||
}
|
||||
|
||||
myConfiguration.writeExternal(element);
|
||||
if (myConfiguration instanceof PersistentStateComponent) {
|
||||
//noinspection ConstantConditions
|
||||
XmlSerializer.serializeInto(((PersistentStateComponent)myConfiguration).getState(), element);
|
||||
}
|
||||
else {
|
||||
myConfiguration.writeExternal(element);
|
||||
}
|
||||
|
||||
if (!(myConfiguration instanceof UnknownRunConfiguration)) {
|
||||
myRunnerSettings.getState(element);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.execution.impl
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.options.SchemeManagerFactory
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
internal class WorkspaceRunManager(project: Project, propertiesComponent: PropertiesComponent, schemeManagerFactory: SchemeManagerFactory) : RunManagerImpl(project, propertiesComponent) {
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
<project-components>
|
||||
<component>
|
||||
<interface-class>com.intellij.execution.RunManager</interface-class>
|
||||
<implementation-class>com.intellij.execution.impl.RunManagerImpl</implementation-class>
|
||||
<implementation-class>com.intellij.execution.impl.WorkspaceRunManager</implementation-class>
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
<component>
|
||||
|
||||
@@ -57,16 +57,21 @@ fun <T : Any> T.serialize(filter: SerializationFilter? = SkipDefaultsSerializati
|
||||
|
||||
inline fun <reified T: Any> Element.deserialize(): T = deserialize(T::class.java)
|
||||
|
||||
fun <T> Element.deserialize(aClass: Class<T>): T {
|
||||
fun <T> Element.deserialize(clazz: Class<T>): T {
|
||||
if (clazz == Element::class.java) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return this as T
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
try {
|
||||
return (serializer.getClassBinding(aClass) as NotNullDeserializeBinding).deserialize(null, this) as T
|
||||
return (serializer.getClassBinding(clazz) as NotNullDeserializeBinding).deserialize(null, this) as T
|
||||
}
|
||||
catch (e: XmlSerializationException) {
|
||||
throw e
|
||||
}
|
||||
catch (e: Exception) {
|
||||
throw XmlSerializationException("Cannot deserialize class ${aClass.name}", e)
|
||||
throw XmlSerializationException("Cannot deserialize class ${clazz.name}", e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,17 +108,24 @@ fun PersistentStateComponent<*>.deserializeAndLoadState(element: Element) {
|
||||
(this as PersistentStateComponent<Any>).loadState(state)
|
||||
}
|
||||
|
||||
fun <T : Any> T.serializeInto(element: Element) {
|
||||
try {
|
||||
val binding = serializer.getClassBinding(javaClass)
|
||||
(binding as BeanBinding).serializeInto(this, element, null)
|
||||
}
|
||||
catch (e: XmlSerializationException) {
|
||||
throw e
|
||||
}
|
||||
catch (e: Exception) {
|
||||
throw XmlSerializationException(e)
|
||||
fun <T : Any> T.serializeInto(target: Element) {
|
||||
if (this is Element) {
|
||||
val iterator = children.iterator()
|
||||
for (child in iterator) {
|
||||
iterator.remove()
|
||||
target.addContent(child)
|
||||
}
|
||||
|
||||
val attributeIterator = attributes.iterator()
|
||||
for (attribute in attributeIterator) {
|
||||
attributeIterator.remove()
|
||||
target.setAttribute(attribute)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val binding = serializer.getClassBinding(javaClass)
|
||||
(binding as BeanBinding).serializeInto(this, target, null)
|
||||
}
|
||||
|
||||
private val serializer = object : XmlSerializerImpl.XmlSerializerBase() {
|
||||
|
||||
@@ -24,9 +24,6 @@ public interface Serializer {
|
||||
@NotNull
|
||||
Binding getClassBinding(@NotNull Class<?> aClass, @NotNull Type originalType, @Nullable MutableAccessor accessor);
|
||||
|
||||
@NotNull
|
||||
Binding getClassBinding(@NotNull Class<?> aClass, @NotNull Type originalType);
|
||||
|
||||
Binding getClassBinding(@NotNull Class<?> aClass);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -62,12 +62,6 @@ public final class XmlSerializerImpl {
|
||||
return getBinding(typeToClass(type), type, accessor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final Binding getClassBinding(@NotNull Class<?> aClass, @NotNull Type originalType) {
|
||||
return getClassBinding(aClass, originalType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Binding getClassBinding(@NotNull Class<?> aClass) {
|
||||
return getClassBinding(aClass, aClass, null);
|
||||
|
||||
Reference in New Issue
Block a user