mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ability to have invisible and managed externally run configurations
This commit is contained in:
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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-2018 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.extensions.ExtensionPointName;
|
||||
@@ -73,4 +59,11 @@ public interface ConfigurationType extends PossiblyDumbAware {
|
||||
* @return the run configuration factories.
|
||||
*/
|
||||
ConfigurationFactory[] getConfigurationFactories();
|
||||
|
||||
/**
|
||||
* Is configuration fully managed by RunManager.
|
||||
*/
|
||||
default boolean isManaged() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -9,14 +9,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class UnknownConfigurationType extends ConfigurationTypeBase {
|
||||
public final class UnknownConfigurationType extends ConfigurationTypeBase {
|
||||
@NotNull
|
||||
public static final UnknownConfigurationType INSTANCE = new UnknownConfigurationType();
|
||||
|
||||
protected UnknownConfigurationType() {
|
||||
private UnknownConfigurationType() {
|
||||
this(AllIcons.RunConfigurations.Unknown);
|
||||
}
|
||||
|
||||
protected UnknownConfigurationType(@NotNull Icon icon) {
|
||||
private UnknownConfigurationType(@NotNull Icon icon) {
|
||||
super(NAME, NAME, ExecutionBundle.message("run.configuration.unknown.description"), icon);
|
||||
|
||||
addFactory(new ConfigurationFactory(this) {
|
||||
@@ -40,4 +41,9 @@ public class UnknownConfigurationType extends ConfigurationTypeBase {
|
||||
public static ConfigurationFactory getFactory() {
|
||||
return INSTANCE.getConfigurationFactories()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManaged() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -1,12 +1,9 @@
|
||||
/*
|
||||
* Copyright 2000-2018 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-2018 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.impl
|
||||
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings
|
||||
import com.intellij.execution.compound.CompoundRunConfiguration
|
||||
import com.intellij.execution.configurations.RunConfiguration
|
||||
import com.intellij.execution.configurations.UnknownConfigurationType
|
||||
import com.intellij.openapi.util.text.NaturalComparator
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
@@ -33,7 +30,7 @@ internal class RunConfigurationListManagerHelper(val manager: RunManagerImpl) {
|
||||
var immutableSortedSettingsList: List<RunnerAndConfigurationSettings>? = emptyList()
|
||||
|
||||
fun setOrder(comparator: Comparator<RunnerAndConfigurationSettings>) {
|
||||
val sorted = idToSettings.values.filterTo(ArrayList(idToSettings.size)) { it.type !is UnknownConfigurationType }
|
||||
val sorted = idToSettings.values.filterTo(ArrayList(idToSettings.size)) { it.type.isManaged }
|
||||
sorted.sortWith(comparator)
|
||||
customOrder.clear()
|
||||
customOrder.ensureCapacity(sorted.size)
|
||||
@@ -151,7 +148,6 @@ internal class RunConfigurationListManagerHelper(val manager: RunManagerImpl) {
|
||||
fun checkIfDependenciesAreStable(configuration: RunConfiguration, list: List<RunnerAndConfigurationSettings>) {
|
||||
for (runTask in configuration.beforeRunTasks) {
|
||||
val runTaskSettings = (runTask as? RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask)?.settings
|
||||
|
||||
if (runTaskSettings?.isTemporary == true) {
|
||||
manager.makeStable(runTaskSettings)
|
||||
checkIfDependenciesAreStable(runTaskSettings.configuration, list)
|
||||
|
||||
@@ -195,7 +195,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
override val configurationFactories by lazy { idToType.values.toTypedArray() }
|
||||
|
||||
override val configurationFactoriesWithoutUnknown: List<ConfigurationType>
|
||||
get() = idToType.values.filterSmart { it !is UnknownConfigurationType }
|
||||
get() = idToType.values.filterSmart { it.isManaged }
|
||||
|
||||
/**
|
||||
* Template configuration is not included
|
||||
@@ -404,10 +404,8 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
if (!isFirstLoadState.get()) {
|
||||
lock.read {
|
||||
val list = idToSettings.values.toList()
|
||||
for (settings in list) {
|
||||
if (settings.type !is UnknownConfigurationType) {
|
||||
listManager.checkIfDependenciesAreStable(settings.configuration, list)
|
||||
}
|
||||
list.forEachManaged {
|
||||
listManager.checkIfDependenciesAreStable(it.configuration, list)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,12 +423,8 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
}
|
||||
|
||||
val listElement = Element("list")
|
||||
for (settings in idToSettings.values) {
|
||||
if (settings.type is UnknownConfigurationType) {
|
||||
continue
|
||||
}
|
||||
|
||||
listElement.addContent(Element("item").setAttribute("itemvalue", settings.uniqueID))
|
||||
idToSettings.values.forEachManaged {
|
||||
listElement.addContent(Element("item").setAttribute("itemvalue", it.uniqueID))
|
||||
}
|
||||
|
||||
if (!listElement.isEmpty()) {
|
||||
@@ -439,11 +433,8 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
}
|
||||
|
||||
val recentList = SmartList<String>()
|
||||
for (settings in recentlyUsedTemporaries) {
|
||||
if (settings.type is UnknownConfigurationType) {
|
||||
continue
|
||||
}
|
||||
recentList.add(settings.uniqueID)
|
||||
recentlyUsedTemporaries.forEachManaged {
|
||||
recentList.add(it.uniqueID)
|
||||
}
|
||||
if (!recentList.isEmpty()) {
|
||||
val recent = Element(RECENT)
|
||||
@@ -758,21 +749,21 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
override fun getConfigurationType(typeName: String) = idToType.get(typeName)
|
||||
|
||||
@JvmOverloads
|
||||
fun getFactory(typeId: String?, _factoryId: String?, checkUnknown: Boolean = false): ConfigurationFactory? {
|
||||
var type = idToType.get(typeId)
|
||||
fun getFactory(typeId: String?, factoryId: String?, checkUnknown: Boolean = false): ConfigurationFactory? {
|
||||
val type = idToType.get(typeId)
|
||||
if (type == null) {
|
||||
if (checkUnknown && typeId != null) {
|
||||
UnknownFeaturesCollector.getInstance(project).registerUnknownRunConfiguration(typeId, _factoryId)
|
||||
UnknownFeaturesCollector.getInstance(project).registerUnknownRunConfiguration(typeId, factoryId)
|
||||
}
|
||||
type = idToType.get(UnknownConfigurationType.NAME) ?: return null
|
||||
return UnknownConfigurationType.getFactory()
|
||||
}
|
||||
|
||||
if (type is UnknownConfigurationType || _factoryId == null) {
|
||||
return type.configurationFactories.get(0)
|
||||
if (type is UnknownConfigurationType) {
|
||||
return type.configurationFactories.firstOrNull()
|
||||
}
|
||||
|
||||
return type.configurationFactories.firstOrNull {
|
||||
it.id == _factoryId
|
||||
factoryId == null || it.id == factoryId
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1013,4 +1004,12 @@ internal class IprRunManagerImpl(private val project: Project) : PersistentState
|
||||
}
|
||||
}
|
||||
|
||||
private fun getNameWeight(n1: String) = if (n1.startsWith("<template> of ") || n1.startsWith("_template__ ")) 0 else 1
|
||||
private fun getNameWeight(n1: String) = if (n1.startsWith("<template> of ") || n1.startsWith("_template__ ")) 0 else 1
|
||||
|
||||
private inline fun Collection<RunnerAndConfigurationSettings>.forEachManaged(handler: (settings: RunnerAndConfigurationSettings) -> Unit) {
|
||||
for (settings in this) {
|
||||
if (settings.type.isManaged) {
|
||||
handler(settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user