From b633735c6b4dd5e61f3efa5e423538760db34bab Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 25 Apr 2018 15:25:16 +0200 Subject: [PATCH] UX-217 Rename Defaults to Templates --- .../execution/impl/RunConfigurable.kt | 45 ++++++++++--------- .../execution/impl/runConfigurableHelper.kt | 17 +------ .../src/messages/ExecutionBundle.properties | 7 ++- 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.kt b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.kt index 1351de518751..427296618e81 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.kt +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.kt @@ -53,16 +53,19 @@ import javax.swing.* import javax.swing.event.DocumentEvent import javax.swing.tree.* -private val DEFAULTS = object : Any() { - override fun toString() = "Defaults" +private const val TEMPLATE_GROUP_NODE_NAME = "Templates" + +private val TEMPLATES = object : Any() { + override fun toString() = TEMPLATE_GROUP_NODE_NAME } + private const val INITIAL_VALUE_KEY = "initialValue" private val LOG = logger() private fun getName(userObject: Any): String { return when { userObject is ConfigurationType -> userObject.displayName - userObject === DEFAULTS -> "Defaults" + userObject === TEMPLATES -> TEMPLATE_GROUP_NODE_NAME userObject is ConfigurationFactory -> userObject.name //Folder objects are strings else -> if (userObject is SingleConfigurationConfigurable<*>) userObject.nameText else (userObject as? RunnerAndConfigurationSettingsImpl)?.name ?: userObject.toString() @@ -151,7 +154,7 @@ open class RunConfigurable @JvmOverloads constructor(private val myProject: Proj append(name, if ((value.parent as DefaultMutableTreeNode).isRoot) SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES else SimpleTextAttributes.REGULAR_ATTRIBUTES) icon = userObject.icon } - else if (userObject === DEFAULTS) { + else if (userObject === TEMPLATES) { append(name, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES) icon = AllIcons.General.Settings } @@ -218,20 +221,20 @@ open class RunConfigurable @JvmOverloads constructor(private val myProject: Proj } } - // add defaults - val defaults = DefaultMutableTreeNode(DEFAULTS) + // add templates + val templates = DefaultMutableTreeNode(TEMPLATES) for (type in RunManagerImpl.getInstanceImpl(myProject).configurationFactoriesWithoutUnknown) { val configurationFactories = type.configurationFactories val typeNode = DefaultMutableTreeNode(type) - defaults.add(typeNode) + templates.add(typeNode) if (configurationFactories.size != 1) { for (factory in configurationFactories) { typeNode.add(DefaultMutableTreeNode(factory)) } } } - if (defaults.childCount > 0) { - root.add(defaults) + if (templates.childCount > 0) { + root.add(templates) } tree.addTreeSelectionListener { @@ -247,10 +250,10 @@ open class RunConfigurable @JvmOverloads constructor(private val myProject: Proj showFolderField(node, userObject) } else { - if (userObject is ConfigurationType || userObject === DEFAULTS) { + if (userObject is ConfigurationType || userObject === TEMPLATES) { val parent = node.parent as DefaultMutableTreeNode if (parent.isRoot) { - drawPressAddButtonMessage(if (userObject === DEFAULTS) null else userObject as ConfigurationType) + drawPressAddButtonMessage(if (userObject === TEMPLATES) null else userObject as ConfigurationType) } else { val factories = (userObject as ConfigurationType).configurationFactories @@ -386,8 +389,8 @@ open class RunConfigurable @JvmOverloads constructor(private val myProject: Proj val userObject2 = o2.userObject when { userObject1 is ConfigurationType && userObject2 is ConfigurationType -> (userObject1).displayName.compareTo(userObject2.displayName, true) - userObject1 === DEFAULTS && userObject2 is ConfigurationType -> 1 - userObject2 === DEFAULTS && userObject1 is ConfigurationType -> - 1 + userObject1 === TEMPLATES && userObject2 is ConfigurationType -> 1 + userObject2 === TEMPLATES && userObject1 is ConfigurationType -> - 1 else -> 0 } } @@ -498,7 +501,7 @@ open class RunConfigurable @JvmOverloads constructor(private val myProject: Proj moveDownAction) .addExtraAction(AnActionButton.fromAction(MyCopyAction())) .addExtraAction(AnActionButton.fromAction(MySaveAction())) - .addExtraAction(AnActionButton.fromAction(MyEditDefaultsAction())) + .addExtraAction(AnActionButton.fromAction(MyEditTemplatesAction())) .addExtraAction(AnActionButton.fromAction(MyCreateFolderAction())) .addExtraAction(AnActionButton.fromAction(MySortFolderAction())) .setMinimumSize(JBDimension(200, 200)) @@ -1264,12 +1267,12 @@ open class RunConfigurable @JvmOverloads constructor(private val myProject: Proj override fun isEnabled(e: AnActionEvent) = getAvailableDropPosition(myDirection) != null } - private inner class MyEditDefaultsAction : AnAction(ExecutionBundle.message("run.configuration.edit.default.configuration.settings.text"), - ExecutionBundle.message( + private inner class MyEditTemplatesAction : AnAction(ExecutionBundle.message("run.configuration.edit.default.configuration.settings.text"), + ExecutionBundle.message( "run.configuration.edit.default.configuration.settings.description"), - AllIcons.General.Settings) { + AllIcons.General.Settings) { override fun actionPerformed(e: AnActionEvent) { - var defaults = TreeUtil.findNodeWithObject(DEFAULTS, tree.model, root) ?: return + var defaults = TreeUtil.findNodeWithObject(TEMPLATES, tree.model, root) ?: return selectedConfigurationType?.let { defaults = TreeUtil.findNodeWithObject(it, tree.model, defaults) ?: return } @@ -1281,15 +1284,15 @@ open class RunConfigurable @JvmOverloads constructor(private val myProject: Proj } override fun update(e: AnActionEvent) { - var isEnabled = TreeUtil.findNodeWithObject(DEFAULTS, tree.model, root) != null + var isEnabled = TreeUtil.findNodeWithObject(TEMPLATES, tree.model, root) != null val path = tree.selectionPath if (path != null) { var o = path.lastPathComponent - if (o is DefaultMutableTreeNode && o.userObject == DEFAULTS) { + if (o is DefaultMutableTreeNode && o.userObject == TEMPLATES) { isEnabled = false } o = path.parentPath.lastPathComponent - if (o is DefaultMutableTreeNode && o.userObject == DEFAULTS) { + if (o is DefaultMutableTreeNode && o.userObject == TEMPLATES) { isEnabled = false } } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/runConfigurableHelper.kt b/platform/lang-impl/src/com/intellij/execution/impl/runConfigurableHelper.kt index 6a077dad9a9f..d7d7600c62b4 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/runConfigurableHelper.kt +++ b/platform/lang-impl/src/com/intellij/execution/impl/runConfigurableHelper.kt @@ -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-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.Executor import com.intellij.execution.RunnerAndConfigurationSettings -import com.intellij.execution.configurations.ConfigurationType internal class RunConfigurationBean { val settings: RunnerAndConfigurationSettings diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index 92f422992657..2b58446385a9 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -64,8 +64,8 @@ remove.run.configuration.action.name=Remove Configuration no.parameters=No parameters -run.configuration.edit.default.configuration.settings.text=Edit Defaults -run.configuration.edit.default.configuration.settings.description=Edit defaults settings +run.configuration.edit.default.configuration.settings.text=Edit Templates +run.configuration.edit.default.configuration.settings.description=Edit templates run.configuration.create.folder.text=Create New Folder run.configuration.create.folder.description=Create new folder run.configuration.sort.folder.text=Sort Configurations @@ -73,7 +73,6 @@ run.configuration.sort.folder.description=Sort configurations alphabetically run.configuration.create.folder.description.move=Move into new folder run.configuration.rename.folder=Rename folder ''{0}'' run.configuration.rename.folder.disclaimer=Note: empty folders won't be saved -default.settings.editor.dialog.title=Default Settings clear.all.from.console.action.name=Clear All copy.selected.content.action.name=Copy Selected Content copy.content.action.name=Copy Content @@ -262,7 +261,7 @@ action.name.save.configuration=Save Configuration #2 - configuration type description empty.run.configuration.panel.text.label1=Press the empty.run.configuration.panel.text.label2= -empty.run.configuration.panel.text.label3=button to create a new {0} based on default settings +empty.run.configuration.panel.text.label3=button to create a new {0} based on templates default.package.presentable.name= default.package.configuration.name=default package no.test.class.specified.error.text=No test class specified