mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
UX-217 Rename Defaults to Templates
This commit is contained in:
@@ -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<RunConfigurable>()
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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=<html><a href=\"add{1}\"><img src=\"{0}\" border=\"0\"></a></html>
|
||||
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>
|
||||
default.package.configuration.name=default package
|
||||
no.test.class.specified.error.text=No test class specified
|
||||
|
||||
Reference in New Issue
Block a user