mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-197022 Port Tasks Configurable to Kotlin UI DSL
GitOrigin-RevId: ee4c06d072aae335fe5fff2f87031c006570e55e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
67f6d6fefc
commit
ad2fe6a446
-60
@@ -1,60 +0,0 @@
|
||||
// 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.openapi.options.binding;
|
||||
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*
|
||||
* @deprecated Use {@see com.intellij.openapi.options.BoundConfigurable} instead
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(forRemoval = true)
|
||||
public abstract class BindableConfigurable implements UnnamedConfigurable {
|
||||
|
||||
protected ControlBinder myBinder;
|
||||
|
||||
protected BindableConfigurable(ControlBinder binder) {
|
||||
myBinder = binder;
|
||||
}
|
||||
|
||||
protected BindableConfigurable() {
|
||||
|
||||
}
|
||||
|
||||
protected void bindAnnotations() {
|
||||
getBinder().bindAnnotations(this);
|
||||
}
|
||||
|
||||
protected void bindControl(JComponent control, String propertyName, boolean instant) {
|
||||
getBinder().bindControl(control, propertyName, instant);
|
||||
}
|
||||
|
||||
protected void bindControl(ControlValueAccessor controlAccessor, String propertyName, boolean instant) {
|
||||
getBinder().bindControl(controlAccessor, propertyName, instant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return getBinder().isModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
getBinder().apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
getBinder().reset();
|
||||
}
|
||||
|
||||
protected ControlBinder getBinder() {
|
||||
return myBinder;
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,9 @@ settings.connection.timeout=Connection &timeout:
|
||||
settings.milliseconds=milliseconds
|
||||
settings.always.display.task.combo.in.toolbar=Show task &widget if there are no active tasks
|
||||
settings.save.context.on.commit=&Save context on commit
|
||||
settings.issue.cache=Issue cache
|
||||
settings.issue.cache=Issue Cache
|
||||
settings.enable.cache=&Enable cache
|
||||
settings.Update=\ &Update
|
||||
settings.Update=&Update
|
||||
settings.issues.every=issues e&very
|
||||
settings.minutes=minutes
|
||||
settings.change.list.name.format.should.not.be.empty=Change list name format should not be empty
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.tasks.config.TaskConfigurable">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="9" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="565" height="420"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="5bcde" class="javax.swing.JTextField" binding="myHistoryLength">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="70" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="11"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b5a6c" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="5bcde"/>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.task.history.length"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="3f700">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="6f93" class="javax.swing.JCheckBox" binding="mySaveContextOnCommit">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.save.context.on.commit"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="89ca" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<anchor value=""/>
|
||||
<labelFor value="ef62"/>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.changelist.name.format"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ef62" class="com.intellij.ui.EditorTextField" binding="myChangelistNameFormat" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="6010f" class="com.intellij.ui.components.JBCheckBox" binding="myAlwaysDisplayTaskCombo">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.always.display.task.combo.in.toolbar"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f47eb" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="c5184"/>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.connection.timeout"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c5184" class="javax.swing.JTextField" binding="myConnectionTimeout">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="70" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="3000"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="737ae" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="4" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.milliseconds"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="fa297" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="511" height="58"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="e4d1f" binding="myCacheSettings" layout-manager="GridLayoutManager" row-count="1" column-count="7" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/TaskBundle" title-key="settings.issue.cache"/>
|
||||
<children>
|
||||
<component id="e53da" class="javax.swing.JCheckBox" binding="myUpdateCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.enable.cache"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="a1a54">
|
||||
<constraints>
|
||||
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="f757b" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="4"/>
|
||||
<labelFor value="b5108"/>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.Update"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b5108" class="javax.swing.JTextField" binding="myUpdateCount">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="11"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1c14" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="4"/>
|
||||
<labelFor value="7e29b"/>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.issues.every"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7e29b" class="javax.swing.JTextField" binding="myUpdateInterval">
|
||||
<constraints>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="11"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="312f0" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.minutes"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="aa62e" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="78330"/>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.feature.branch.name.format"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="78330" class="com.intellij.ui.EditorTextField" binding="myBranchNameFormat" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="acd61" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="c6d76" class="javax.swing.JCheckBox" binding="myLowerCase">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.lowercased"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="21872" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="154" height="16"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/TaskBundle" key="settings.replace.spaces.with"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7c703" class="com.intellij.ui.components.JBTextField" binding="myReplaceSpaces">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<columns value="1"/>
|
||||
<text value="-"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="84b4f">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -1,225 +1,202 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.tasks.config;
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.tasks.config
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.PlainTextFileType;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.options.binding.BindControl;
|
||||
import com.intellij.openapi.options.binding.BindableConfigurable;
|
||||
import com.intellij.openapi.options.binding.ControlBinder;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.tasks.CommitPlaceholderProvider;
|
||||
import com.intellij.tasks.TaskBundle;
|
||||
import com.intellij.tasks.TaskManager;
|
||||
import com.intellij.tasks.TaskRepository;
|
||||
import com.intellij.tasks.impl.BaseRepositoryImpl;
|
||||
import com.intellij.tasks.impl.TaskManagerImpl;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.ExtendableEditorSupport;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.components.JBTextField;
|
||||
import com.intellij.ui.components.fields.ExtendableTextComponent;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.editor.ex.EditorEx
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager
|
||||
import com.intellij.openapi.fileTypes.PlainTextFileType
|
||||
import com.intellij.openapi.options.BoundSearchableConfigurable
|
||||
import com.intellij.openapi.options.Configurable
|
||||
import com.intellij.openapi.options.Configurable.NoScroll
|
||||
import com.intellij.openapi.options.ConfigurationException
|
||||
import com.intellij.openapi.options.SearchableConfigurable
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.openapi.ui.DialogPanel
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.ui.popup.PopupStep
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep
|
||||
import com.intellij.tasks.CommitPlaceholderProvider
|
||||
import com.intellij.tasks.TaskBundle
|
||||
import com.intellij.tasks.TaskManager
|
||||
import com.intellij.tasks.impl.BaseRepositoryImpl
|
||||
import com.intellij.tasks.impl.TaskManagerImpl
|
||||
import com.intellij.ui.EditorSettingsProvider
|
||||
import com.intellij.ui.EditorTextField
|
||||
import com.intellij.ui.ExtendableEditorSupport
|
||||
import com.intellij.ui.components.fields.ExtendableTextComponent
|
||||
import com.intellij.ui.dsl.builder.*
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
class TaskConfigurable(private val project: Project) : BoundSearchableConfigurable(
|
||||
TaskBundle.message("configurable.TaskConfigurable.display.name"),
|
||||
"reference.settings.project.tasks", "tasks"), SearchableConfigurable.Parent, NoScroll {
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public class TaskConfigurable extends BindableConfigurable implements SearchableConfigurable.Parent, Configurable.NoScroll {
|
||||
private JPanel myPanel;
|
||||
private val changelistNameFormat: EditorTextField
|
||||
private val branchNameFormat: EditorTextField
|
||||
|
||||
@BindControl("updateEnabled")
|
||||
private JCheckBox myUpdateCheckBox;
|
||||
private val lazyConfigurables: Array<Configurable> by lazy { arrayOf(TaskRepositoriesConfigurable(project)) }
|
||||
|
||||
@BindControl("updateIssuesCount")
|
||||
private JTextField myUpdateCount;
|
||||
init {
|
||||
val fileType = FileTypeManager.getInstance().findFileTypeByName("VTL") ?: PlainTextFileType.INSTANCE
|
||||
val defaultProject = ProjectManager.getInstance().getDefaultProject()
|
||||
branchNameFormat = EditorTextField(defaultProject, fileType)
|
||||
setupAddAction(branchNameFormat)
|
||||
changelistNameFormat = EditorTextField(defaultProject, fileType)
|
||||
setupAddAction(changelistNameFormat)
|
||||
|
||||
@BindControl("updateInterval")
|
||||
private JTextField myUpdateInterval;
|
||||
}
|
||||
|
||||
@BindControl("taskHistoryLength")
|
||||
private JTextField myHistoryLength;
|
||||
private JPanel myCacheSettings;
|
||||
override fun createPanel(): DialogPanel {
|
||||
val settings = TaskSettings.getInstance()
|
||||
val config = getConfig()
|
||||
|
||||
@BindControl("saveContextOnCommit")
|
||||
private JCheckBox mySaveContextOnCommit;
|
||||
|
||||
@BindControl("changelistNameFormat")
|
||||
private EditorTextField myChangelistNameFormat;
|
||||
|
||||
private JBCheckBox myAlwaysDisplayTaskCombo;
|
||||
private JTextField myConnectionTimeout;
|
||||
|
||||
@BindControl("branchNameFormat")
|
||||
private EditorTextField myBranchNameFormat;
|
||||
private JCheckBox myLowerCase;
|
||||
private JBTextField myReplaceSpaces;
|
||||
|
||||
private final Project myProject;
|
||||
private Configurable[] myConfigurables;
|
||||
private final NotNullLazyValue<ControlBinder> myControlBinder;
|
||||
|
||||
public TaskConfigurable(Project project) {
|
||||
super();
|
||||
myProject = project;
|
||||
myUpdateCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
enableCachePanel();
|
||||
return panel {
|
||||
row(TaskBundle.message("settings.changelist.name.format")) {
|
||||
cell(changelistNameFormat)
|
||||
.bindText(config::changelistNameFormat)
|
||||
.align(AlignX.FILL)
|
||||
}
|
||||
});
|
||||
myControlBinder = NotNullLazyValue.lazy(() -> new ControlBinder(getConfig()));
|
||||
}
|
||||
row(TaskBundle.message("settings.feature.branch.name.format")) {
|
||||
cell(branchNameFormat)
|
||||
.bindText(config::branchNameFormat)
|
||||
.align(AlignX.FILL)
|
||||
}
|
||||
row("") {
|
||||
checkBox(TaskBundle.message("settings.lowercased"))
|
||||
.bindSelected(settings::LOWER_CASE_BRANCH)
|
||||
.resizableColumn()
|
||||
|
||||
private TaskManagerImpl.Config getConfig() {
|
||||
return ((TaskManagerImpl)TaskManager.getManager(myProject)).getState();
|
||||
}
|
||||
textField()
|
||||
.bindText(settings::REPLACE_SPACES)
|
||||
.columns(1)
|
||||
.label(TaskBundle.message("settings.replace.spaces.with"))
|
||||
}
|
||||
row(TaskBundle.message("settings.task.history.length")) {
|
||||
intTextField()
|
||||
.columns(COLUMNS_TINY)
|
||||
.bindIntText(config::taskHistoryLength)
|
||||
}
|
||||
row(TaskBundle.message("settings.connection.timeout")) {
|
||||
intTextField()
|
||||
.columns(COLUMNS_TINY)
|
||||
.bindIntText(settings::CONNECTION_TIMEOUT)
|
||||
.gap(RightGap.SMALL)
|
||||
|
||||
@Override
|
||||
protected ControlBinder getBinder() {
|
||||
return myControlBinder.getValue();
|
||||
}
|
||||
@Suppress("DialogTitleCapitalization")
|
||||
label(TaskBundle.message("settings.milliseconds"))
|
||||
}
|
||||
row {
|
||||
checkBox(TaskBundle.message("settings.always.display.task.combo.in.toolbar"))
|
||||
.bindSelected(settings::ALWAYS_DISPLAY_COMBO)
|
||||
}
|
||||
row {
|
||||
checkBox(TaskBundle.message("settings.save.context.on.commit"))
|
||||
.bindSelected(config::saveContextOnCommit)
|
||||
}
|
||||
|
||||
private void enableCachePanel() {
|
||||
myUpdateCount.setEnabled(myUpdateCheckBox.isSelected());
|
||||
myUpdateInterval.setEnabled(myUpdateCheckBox.isSelected());
|
||||
}
|
||||
group(TaskBundle.message("settings.issue.cache")) {
|
||||
row {
|
||||
val updateCheckBox = checkBox(TaskBundle.message("settings.enable.cache"))
|
||||
.bindSelected(config::updateEnabled)
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
enableCachePanel();
|
||||
myAlwaysDisplayTaskCombo.setSelected(TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO);
|
||||
myConnectionTimeout.setText(Integer.toString(TaskSettings.getInstance().CONNECTION_TIMEOUT));
|
||||
myLowerCase.setSelected(TaskSettings.getInstance().LOWER_CASE_BRANCH);
|
||||
myReplaceSpaces.setText(TaskSettings.getInstance().REPLACE_SPACES);
|
||||
}
|
||||
intTextField()
|
||||
.bindIntText(config::updateIssuesCount)
|
||||
.enabledIf(updateCheckBox.selected)
|
||||
.label(TaskBundle.message("settings.Update"))
|
||||
.columns(4)
|
||||
.gap(RightGap.SMALL)
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
if (myChangelistNameFormat.getText().trim().isEmpty()) {
|
||||
throw new ConfigurationException(TaskBundle.message("settings.change.list.name.format.should.not.be.empty"));
|
||||
}
|
||||
if (myBranchNameFormat.getText().trim().isEmpty()) {
|
||||
throw new ConfigurationException(TaskBundle.message("settings.Branch.name.format.should.not.be.empty"));
|
||||
}
|
||||
boolean oldUpdateEnabled = getConfig().updateEnabled;
|
||||
super.apply();
|
||||
TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO = myAlwaysDisplayTaskCombo.isSelected();
|
||||
int oldConnectionTimeout = TaskSettings.getInstance().CONNECTION_TIMEOUT;
|
||||
int connectionTimeout = Integer.parseInt(myConnectionTimeout.getText());
|
||||
TaskSettings.getInstance().CONNECTION_TIMEOUT = connectionTimeout;
|
||||
TaskSettings.getInstance().LOWER_CASE_BRANCH = myLowerCase.isSelected();
|
||||
TaskSettings.getInstance().REPLACE_SPACES = myReplaceSpaces.getText();
|
||||
@Suppress("DialogTitleCapitalization")
|
||||
intTextField()
|
||||
.bindIntText(config::updateInterval)
|
||||
.enabledIf(updateCheckBox.selected)
|
||||
.label(TaskBundle.message("settings.issues.every"))
|
||||
.columns(4)
|
||||
.gap(RightGap.SMALL)
|
||||
|
||||
if (myProject.isDefault()) return;
|
||||
TaskManager manager = TaskManager.getManager(myProject);
|
||||
if (getConfig().updateEnabled && !oldUpdateEnabled) {
|
||||
manager.updateIssues(null);
|
||||
}
|
||||
if (connectionTimeout != oldConnectionTimeout) {
|
||||
for (TaskRepository repository : manager.getAllRepositories()) {
|
||||
if (repository instanceof BaseRepositoryImpl) {
|
||||
((BaseRepositoryImpl)repository).reconfigureClient();
|
||||
@Suppress("DialogTitleCapitalization")
|
||||
label(TaskBundle.message("settings.minutes"))
|
||||
.enabledIf(updateCheckBox.selected)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return super.isModified() ||
|
||||
TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO != myAlwaysDisplayTaskCombo.isSelected() ||
|
||||
TaskSettings.getInstance().CONNECTION_TIMEOUT != Integer.parseInt(myConnectionTimeout.getText()) ||
|
||||
TaskSettings.getInstance().LOWER_CASE_BRANCH != myLowerCase.isSelected() ||
|
||||
!Objects.equals(TaskSettings.getInstance().REPLACE_SPACES, myReplaceSpaces.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return TaskBundle.message("configurable.TaskConfigurable.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return "reference.settings.project.tasks";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
bindAnnotations();
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "tasks";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOwnContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configurable @NotNull [] getConfigurables() {
|
||||
if (myConfigurables == null) {
|
||||
myConfigurables = new Configurable[] { new TaskRepositoriesConfigurable(myProject) };
|
||||
@Throws(ConfigurationException::class)
|
||||
override fun apply() {
|
||||
if (changelistNameFormat.getText().trim().isEmpty()) {
|
||||
throw ConfigurationException(TaskBundle.message("settings.change.list.name.format.should.not.be.empty"))
|
||||
}
|
||||
return myConfigurables;
|
||||
}
|
||||
if (branchNameFormat.getText().trim().isEmpty()) {
|
||||
throw ConfigurationException(TaskBundle.message("settings.Branch.name.format.should.not.be.empty"))
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
FileType fileType = FileTypeManager.getInstance().findFileTypeByName("VTL");
|
||||
if (fileType == null) {
|
||||
fileType = PlainTextFileType.INSTANCE;
|
||||
val oldConnectionTimeout = TaskSettings.getInstance().CONNECTION_TIMEOUT
|
||||
val oldUpdateEnabled = getConfig().updateEnabled
|
||||
|
||||
super.apply()
|
||||
|
||||
if (project.isDefault()) {
|
||||
return
|
||||
}
|
||||
|
||||
val manager = TaskManager.getManager(project)
|
||||
if (getConfig().updateEnabled && !oldUpdateEnabled) {
|
||||
manager.updateIssues(null)
|
||||
}
|
||||
|
||||
if (TaskSettings.getInstance().CONNECTION_TIMEOUT != oldConnectionTimeout) {
|
||||
for (repository in manager.getAllRepositories()) {
|
||||
if (repository is BaseRepositoryImpl) {
|
||||
repository.reconfigureClient()
|
||||
}
|
||||
}
|
||||
}
|
||||
Project project = ProjectManager.getInstance().getDefaultProject();
|
||||
myBranchNameFormat = new EditorTextField(project, fileType);
|
||||
setupAddAction(myBranchNameFormat);
|
||||
myChangelistNameFormat = new EditorTextField(project, fileType);
|
||||
setupAddAction(myChangelistNameFormat);
|
||||
}
|
||||
|
||||
private void setupAddAction(EditorTextField field) {
|
||||
field.addSettingsProvider(editor -> {
|
||||
ExtendableTextComponent.Extension extension =
|
||||
override fun getConfigurables(): Array<out Configurable> {
|
||||
return lazyConfigurables
|
||||
}
|
||||
|
||||
override fun hasOwnContent(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getConfig(): TaskManagerImpl.Config {
|
||||
return (TaskManager.getManager(project) as TaskManagerImpl).getState()
|
||||
}
|
||||
|
||||
private fun setupAddAction(field: EditorTextField) {
|
||||
field.addSettingsProvider(EditorSettingsProvider { editor: EditorEx ->
|
||||
val extension =
|
||||
ExtendableTextComponent.Extension
|
||||
.create(AllIcons.General.InlineAdd, AllIcons.General.InlineAddHover, TaskBundle.message("settings.add.placeholder"), () -> {
|
||||
Set<String> placeholders = new HashSet<>();
|
||||
for (CommitPlaceholderProvider provider : CommitPlaceholderProvider.EXTENSION_POINT_NAME.getExtensionList()) {
|
||||
placeholders.addAll(Arrays.asList(provider.getPlaceholders(null)));
|
||||
}
|
||||
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<>(TaskBundle.message("settings.placeholders"),
|
||||
ArrayUtilRt.toStringArray(placeholders)) {
|
||||
@Override
|
||||
public PopupStep<?> onChosen(String selectedValue, boolean finalChoice) {
|
||||
WriteCommandAction.runWriteCommandAction(myProject, () -> editor.getDocument()
|
||||
.insertString(editor.getCaretModel().getOffset(), "${" + selectedValue + "}"));
|
||||
return FINAL_CHOICE;
|
||||
.create(AllIcons.General.InlineAdd, AllIcons.General.InlineAddHover, TaskBundle.message("settings.add.placeholder"), Runnable {
|
||||
val placeholders = HashSet<String>()
|
||||
for (provider in CommitPlaceholderProvider.EXTENSION_POINT_NAME.extensionList) {
|
||||
placeholders.addAll(provider.getPlaceholders(null))
|
||||
}
|
||||
}).showInBestPositionFor(editor);
|
||||
});
|
||||
ExtendableEditorSupport.setupExtension(editor, field.getBackground(), extension);
|
||||
});
|
||||
JBPopupFactory.getInstance().createListPopup(object : BaseListPopupStep<String>(TaskBundle.message("settings.placeholders"),
|
||||
placeholders.toList()) {
|
||||
override fun onChosen(selectedValue: String?, finalChoice: Boolean): PopupStep<*> {
|
||||
WriteCommandAction.runWriteCommandAction(project, Runnable {
|
||||
editor.getDocument()
|
||||
.insertString(editor.getCaretModel().offset, "\${$selectedValue}")
|
||||
})
|
||||
return FINAL_CHOICE
|
||||
}
|
||||
}).showInBestPositionFor(editor)
|
||||
})
|
||||
ExtendableEditorSupport.setupExtension(editor, field.getBackground(), extension)
|
||||
})
|
||||
}
|
||||
|
||||
private fun Cell<EditorTextField>.bindText(prop: KMutableProperty0<String>): Cell<EditorTextField> {
|
||||
return bind(
|
||||
componentGet = { component -> component.getText() },
|
||||
componentSet = { component, value -> component.setText(value) },
|
||||
prop = prop.toMutableProperty()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user