From c804ff3e0482ec606eb8e2f0dfa50daaef5515b3 Mon Sep 17 00:00:00 2001 From: "Maxim.Kolmakov" Date: Fri, 6 Oct 2017 20:19:41 +0200 Subject: [PATCH] [gui-tests] Greenify --- .../testGuiFramework/recorder/GlobalActionRecorder.kt | 1 - .../com/intellij/testGuiFramework/recorder/Writer.kt | 11 +++-------- .../recorder/actions/ShowGuiEditorWindowAction.kt | 3 +-- .../recorder/actions/StartPauseRecAction.kt | 3 +-- .../recorder/actions/UpdateEditorAction.kt | 5 +---- .../recorder/ui/GuiScriptEditorPanel.java | 2 +- 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/GlobalActionRecorder.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/GlobalActionRecorder.kt index 76aabfae791e..380162958adf 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/GlobalActionRecorder.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/GlobalActionRecorder.kt @@ -37,7 +37,6 @@ object GlobalActionRecorder { private val LOG = Logger.getInstance("#${GlobalActionRecorder::class.qualifiedName}") var isActive = false - get private set private val globalActionListener = object : AnActionListener { diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/Writer.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/Writer.kt index ccff544838df..853e8a7e9ad3 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/Writer.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/Writer.kt @@ -22,7 +22,6 @@ object Writer { private val scriptBuffer = StringBuilder() val indent = 2 - val withIndent = true fun getScript(): String { return scriptBuffer.toString() @@ -32,7 +31,7 @@ object Writer { scriptBuffer.setLength(0) } - fun writeln(str: String) { + private fun writeln(str: String) { write(str + "\n") } @@ -45,16 +44,12 @@ object Writer { } private fun writeToEditor(str: String) { - val editor = GuiRecorderComponent.getEditor() - val document = editor.document + val document = GuiRecorderComponent.getEditor().document WriteCommandAction.runWriteCommandAction(null, { document.insertString(document.textLength, str) }) } fun writeWithIndent(code: String){ - var indentedString = "" - if (withIndent) { - indentedString = (0..(indent * ContextChecker.getContextDepth() - 1)).map { i -> ' ' }.joinToString(separator = "") - } + val indentedString = (0..(indent * ContextChecker.getContextDepth() - 1)).map { ' ' }.joinToString(separator = "") Writer.writeln("$indentedString$code") } diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/ShowGuiEditorWindowAction.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/ShowGuiEditorWindowAction.kt index 64f162f03e14..39879fb2e3ce 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/ShowGuiEditorWindowAction.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/ShowGuiEditorWindowAction.kt @@ -18,12 +18,11 @@ package com.intellij.testGuiFramework.recorder.actions import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.testGuiFramework.recorder.components.GuiRecorderComponent -import com.intellij.testGuiFramework.recorder.ui.GuiScriptEditorFrame /** * @author Sergey Karashevich */ -class ShowGuiEditorWindowAction() : AnAction() { +class ShowGuiEditorWindowAction : AnAction() { override fun actionPerformed(p0: AnActionEvent?) { val frame = GuiRecorderComponent.frame diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/StartPauseRecAction.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/StartPauseRecAction.kt index 2157ab54c8b0..b4aaed204db1 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/StartPauseRecAction.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/StartPauseRecAction.kt @@ -31,14 +31,13 @@ class StartPauseRecAction : ToggleAction(null, "Start/Stop GUI Script Recording" override fun isSelected(actionEvent: AnActionEvent?): Boolean = GlobalActionRecorder.isActive override fun setSelected(actionEvent: AnActionEvent?, toStart: Boolean) { + val presentation = actionEvent?.presentation ?: templatePresentation if (toStart) { - val presentation = if (actionEvent != null) actionEvent.presentation else templatePresentation presentation.description = "Stop GUI Script Recording" Notifier.updateStatus("Recording started") GlobalActionRecorder.activate() } else { - val presentation = if (actionEvent != null) actionEvent.presentation else templatePresentation presentation.description = "Start GUI Script Recording" Notifier.updateStatus("Recording paused") GlobalActionRecorder.deactivate() diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/UpdateEditorAction.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/UpdateEditorAction.kt index 58e0c72c5d67..35ff9d6f97c2 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/UpdateEditorAction.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/actions/UpdateEditorAction.kt @@ -15,10 +15,7 @@ class UpdateEditorAction : AnAction(null, "Update GUI Script Editor (get recorde override fun actionPerformed(actionEvent: AnActionEvent?) { val editor = GuiRecorderComponent.getEditor() - ApplicationManager.getApplication().runWriteAction { editor.document.setText(getGuiScriptBuffer()) } + ApplicationManager.getApplication().runWriteAction { editor.document.setText(Writer.getScript()) } Notifier.updateStatus("GUI script updated") } - - fun getGuiScriptBuffer() = Writer.getScript() - } \ No newline at end of file diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ui/GuiScriptEditorPanel.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ui/GuiScriptEditorPanel.java index 97c28b842d24..0e8bbfcda355 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ui/GuiScriptEditorPanel.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ui/GuiScriptEditorPanel.java @@ -42,7 +42,7 @@ public class GuiScriptEditorPanel implements Disposable { public static final String GUI_SCRIPT_EDITOR_PLACE = "GUI_SCRIPT_EDITOR_PLACE"; - private GuiScriptEditor myEditor; + private final GuiScriptEditor myEditor; public GuiScriptEditorPanel() { super();