Commit 5bce63b1 authored by Sergey Simonchik's avatar Sergey Simonchik
Browse files

terminal: use kotlin properly; fix tests (IDEA-CR-46423)

parent 15adb6be
Showing with 23 additions and 32 deletions
+23 -32
......@@ -143,11 +143,11 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP
}
public KeyStroke[] getMoveTabRightKeyStrokes() {
return getKeyStrokesByActionId("Terminal.MoveToolwindowTabRight");
return getKeyStrokesByActionId("Terminal.MoveToolWindowTabRight");
}
public KeyStroke[] getMoveTabLeftKeyStrokes() {
return getKeyStrokesByActionId("Terminal.MoveToolwindowTabLeft");
return getKeyStrokesByActionId("Terminal.MoveToolWindowTabLeft");
}
protected static int consoleFontSize(MyColorSchemeDelegate colorScheme) {
......
......@@ -86,8 +86,8 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{ "shift control F8", "ViewBreakpoints", "EditBreakpoint"},
{ "shift control G", "ClassTemplateNavigation", "GoToClass"},
{ "shift control H", "ChangesView.ShelveSilently", "MethodHierarchy"},
{ "shift control LEFT", "EditorPreviousWordWithSelection", "ResizeToolWindowLeft", },
{ "shift control RIGHT", "EditorNextWordWithSelection", "ResizeToolWindowRight", },
{ "shift control LEFT", "EditorPreviousWordWithSelection", "ResizeToolWindowLeft", "Terminal.MoveToolWindowTabLeft"},
{ "shift control RIGHT", "EditorNextWordWithSelection", "ResizeToolWindowRight", "Terminal.MoveToolWindowTabRight"},
{ "shift control T", "GotoTest", "Images.ShowThumbnails", "RunDashboard.ShowConfigurations"},
{ "shift control UP", "ResizeToolWindowUp", "MoveStatementUp"},
{ "shift control alt D", "UML.ShowChanges", "Console.TableResult.CloneColumn"},
......@@ -129,8 +129,8 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{ "shift ctrl RIGHT", "Diff.ApplyLeftSide", "NextEditorTab"},
{ "shift meta G", "ClassTemplateNavigation", "GoToClass", "FindPrevious"},
{ "shift meta M", "ChangesView.Move", "Vcs.MoveChangedLinesToChangelist"},
{ "shift meta LEFT", "EditorLineStartWithSelection", "ResizeToolWindowLeft", },
{ "shift meta RIGHT", "EditorLineEndWithSelection", "ResizeToolWindowRight", },
{ "shift meta LEFT", "EditorLineStartWithSelection", "ResizeToolWindowLeft", "Terminal.MoveToolWindowTabLeft"},
{ "shift meta RIGHT", "EditorLineEndWithSelection", "ResizeToolWindowRight", "Terminal.MoveToolWindowTabRight"},
{ "shift meta CLOSE_BRACKET", "Diff.NextChange", "NextTab"},
{ "shift meta OPEN_BRACKET", "Diff.PrevChange", "PreviousTab"},
{ "alt R", "Django.RunManageTaskAction", "org.jetbrains.plugins.ruby.tasks.rake.actions.RakeTasksPopupAction"},
......@@ -157,8 +157,8 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{ "meta 3", "ActivateFindToolWindow", "FileChooser.GotoModule"},
{ "shift ctrl LEFT", "Diff.ApplyRightSide", "PreviousEditorTab"},
{ "shift ctrl RIGHT", "Diff.ApplyLeftSide", "NextEditorTab"},
{ "shift meta LEFT", "EditorLineStartWithSelection", "ResizeToolWindowLeft", },
{ "shift meta RIGHT", "EditorLineEndWithSelection", "ResizeToolWindowRight", },
{ "shift meta LEFT", "EditorLineStartWithSelection", "ResizeToolWindowLeft", "Terminal.MoveToolWindowTabLeft"},
{ "shift meta RIGHT", "EditorLineEndWithSelection", "ResizeToolWindowRight", "Terminal.MoveToolWindowTabRight"},
{ "alt R", "Django.RunManageTaskAction", "org.jetbrains.plugins.ruby.tasks.rake.actions.RakeTasksPopupAction"},
});
put("Emacs", new String[][] {
......
......@@ -22,12 +22,12 @@
<action id="Terminal.MoveToEditor" class="org.jetbrains.plugins.terminal.action.MoveTerminalSessionToEditorAction" text="Move to Editor">
<add-to-group group-id="ToolWindowContextMenu" anchor="last"/>
</action>
<action id="Terminal.MoveToolwindowTabLeft" class="org.jetbrains.plugins.terminal.action.MoveTerminalToolwindowTabLeftAction"
<action id="Terminal.MoveToolWindowTabLeft" class="org.jetbrains.plugins.terminal.action.MoveTerminalToolWindowTabLeftAction"
text="Move Left">
<keyboard-shortcut first-keystroke="control shift LEFT" keymap="$default"/>
<add-to-group group-id="ToolWindowContextMenu" anchor="last"/>
</action>
<action id="Terminal.MoveToolwindowTabRight" class="org.jetbrains.plugins.terminal.action.MoveTerminalToolwindowTabRightAction"
<action id="Terminal.MoveToolWindowTabRight" class="org.jetbrains.plugins.terminal.action.MoveTerminalToolWindowTabRightAction"
text="Move Right">
<keyboard-shortcut first-keystroke="control shift RIGHT" keymap="$default"/>
<add-to-group group-id="ToolWindowContextMenu" anchor="last"/>
......
......@@ -52,8 +52,8 @@ import com.intellij.util.ObjectUtils;
import com.intellij.util.text.UniqueNameGenerator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.terminal.action.MoveTerminalToolwindowTabLeftAction;
import org.jetbrains.plugins.terminal.action.MoveTerminalToolwindowTabRightAction;
import org.jetbrains.plugins.terminal.action.MoveTerminalToolWindowTabLeftAction;
import org.jetbrains.plugins.terminal.action.MoveTerminalToolWindowTabRightAction;
import org.jetbrains.plugins.terminal.action.RenameTerminalSessionAction;
import org.jetbrains.plugins.terminal.arrangement.TerminalArrangementManager;
import org.jetbrains.plugins.terminal.arrangement.TerminalArrangementState;
......@@ -205,8 +205,8 @@ public class TerminalView {
}
JBTerminalWidget finalTerminalWidget = terminalWidget;
MoveTerminalToolwindowTabLeftAction moveTabLeftAction = new MoveTerminalToolwindowTabLeftAction();
MoveTerminalToolwindowTabRightAction moveTabRightAction = new MoveTerminalToolwindowTabRightAction();
MoveTerminalToolWindowTabLeftAction moveTabLeftAction = new MoveTerminalToolWindowTabLeftAction();
MoveTerminalToolWindowTabRightAction moveTabRightAction = new MoveTerminalToolWindowTabRightAction();
terminalWidget.setListener(new JBTerminalWidgetListener() {
@Override
public void onNewSession() {
......
// Copyright 2000-2019 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 org.jetbrains.plugins.terminal.action
import com.intellij.openapi.project.DumbAware
class MoveTerminalToolwindowTabLeftAction : MoveTerminalToolwindowTabLeftRightAction(true) {
}
\ No newline at end of file
......@@ -5,11 +5,10 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.wm.ToolWindow
import com.intellij.ui.content.Content
import java.util.*
open class MoveTerminalToolwindowTabLeftRightAction(private val moveLeft: Boolean) : TerminalSessionContextMenuActionBase(), DumbAware {
override fun actionPerformed(e: AnActionEvent, toolWindow: ToolWindow, content: Content?) {
move(content);
move(content)
}
override fun update(e: AnActionEvent, activeToolWindow: ToolWindow, selectedContent: Content?) {
......@@ -22,16 +21,20 @@ open class MoveTerminalToolwindowTabLeftRightAction(private val moveLeft: Boolea
fun isAvailable(content: Content?) : Boolean {
val manager = content?.manager ?: return false
val ind = manager.getIndexOfContent(content)
return if (moveLeft) ind > 0 else ind >= 0 && ind < manager.getContentCount() - 1
return if (moveLeft) ind > 0 else ind >= 0 && ind < manager.contentCount - 1
}
fun move(content: Content?) {
val manager = content?.manager ?: return
val ind = manager.getIndexOfContent(content)
val otherInd = if (moveLeft) ind - 1 else ind + 1
if (ind >= 0 && otherInd >= 0 && otherInd < manager.getContentCount()) {
val otherContent = Objects.requireNonNull<Content>(manager.getContent(otherInd))
if (ind >= 0 && otherInd >= 0 && otherInd < manager.contentCount) {
val otherContent = manager.getContent(otherInd)!!
manager.removeContent(otherContent, false, false, false).doWhenDone { manager.addContent(otherContent, ind) }
}
}
}
\ No newline at end of file
}
class MoveTerminalToolWindowTabLeftAction : MoveTerminalToolwindowTabLeftRightAction(true)
class MoveTerminalToolWindowTabRightAction : MoveTerminalToolwindowTabLeftRightAction(false)
\ No newline at end of file
// Copyright 2000-2019 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 org.jetbrains.plugins.terminal.action
class MoveTerminalToolwindowTabRightAction : MoveTerminalToolwindowTabLeftRightAction(false) {
}
\ No newline at end of file
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