Unverified Commit 9816a8be authored by Vladimir Krivosheev's avatar Vladimir Krivosheev
Browse files

reduce findConfigurationByName

parent 8d1c8cf2
Branches unavailable Tags unavailable
No related merge requests found
Showing with 16 additions and 10 deletions
+16 -10
......@@ -202,6 +202,8 @@ abstract class RunManager {
abstract fun findConfigurationByName(name: String?): RunnerAndConfigurationSettings?
abstract fun findSettings(configuration: RunConfiguration): RunnerAndConfigurationSettings?
fun findConfigurationByTypeAndName(typeId: String, name: String) = allSettings.firstOrNull { typeId == it.type.id && name == it.name }
fun findConfigurationByTypeAndName(type: ConfigurationType?, name: String) = type?.let { findConfigurationByTypeAndName(it.id, name) }
......
......@@ -849,6 +849,10 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
return allSettings.firstOrNull { it.name == name }
}
override fun findSettings(configuration: RunConfiguration): RunnerAndConfigurationSettings? {
return allSettings.firstOrNull { it.configuration === configuration } ?: findConfigurationByName(configuration.name)
}
override fun <T : BeforeRunTask<*>> getBeforeRunTasks(settings: RunConfiguration, taskProviderId: Key<T>): List<T> {
if (settings is WrappingRunConfiguration<*>) {
return getBeforeRunTasks(settings.peer, taskProviderId)
......
......@@ -13,6 +13,8 @@ import com.intellij.openapi.util.Key
import javax.swing.Icon
class MockRunManager : RunManagerEx() {
override fun findSettings(configuration: RunConfiguration): RunnerAndConfigurationSettings? = null
override fun getConfigurationType(typeName: String) = TODO("not implemented")
override fun hasSettings(settings: RunnerAndConfigurationSettings) = false
......
/*
* 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-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.coverage.view;
import com.intellij.CommonBundle;
......@@ -52,7 +50,7 @@ public class CoverageView extends BorderLayoutPanel implements DataProvider, Dis
private final CoverageViewBuilder myBuilder;
private final Project myProject;
private final CoverageViewManager.StateBean myStateBean;
public CoverageView(final Project project, final CoverageDataManager dataManager, CoverageViewManager.StateBean stateBean) {
myProject = project;
......@@ -70,12 +68,12 @@ public class CoverageView extends BorderLayoutPanel implements DataProvider, Dis
emptyText.appendText(" Click ");
emptyText.appendText("Edit", SimpleTextAttributes.LINK_ATTRIBUTES, new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final String configurationName = configuration.getName();
final RunnerAndConfigurationSettings configurationSettings = RunManager.getInstance(project).findConfigurationByName(configurationName);
final RunnerAndConfigurationSettings configurationSettings = RunManager.getInstance(project).findSettings(configuration);
if (configurationSettings != null) {
RunDialog.editConfiguration(project, configurationSettings, "Edit Run Configuration");
} else {
Messages.showErrorDialog(project, "Configuration \'" + configurationName + "\' was not found", CommonBundle.getErrorTitle());
}
else {
Messages.showErrorDialog(project, "Configuration \'" + configuration.getName() + "\' was not found", CommonBundle.getErrorTitle());
}
}
});
......@@ -208,7 +206,7 @@ public class CoverageView extends BorderLayoutPanel implements DataProvider, Dis
public void updateParentTitle() {
myBuilder.updateParentTitle();
}
private AbstractTreeNode getSelectedValue() {
return (AbstractTreeNode)myBuilder.getSelectedValue();
}
......@@ -286,7 +284,7 @@ public class CoverageView extends BorderLayoutPanel implements DataProvider, Dis
myBuilder.updateParentTitle();
}
}
private class GoUpAction extends DumbAwareAction {
private final CoverageViewTreeStructure myTreeStructure;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment