mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[gui-tests] Make frame not nullable
This commit is contained in:
@@ -38,18 +38,16 @@ object Writer {
|
||||
|
||||
private fun write(str: String) {
|
||||
print(str)
|
||||
if (GuiRecorderComponent.frame != null && GuiRecorderComponent.frame!!.isSyncToEditor())
|
||||
if (GuiRecorderComponent.syncEditor)
|
||||
writeToEditor(str)
|
||||
else
|
||||
scriptBuffer.append(str)
|
||||
}
|
||||
|
||||
private fun writeToEditor(str: String) {
|
||||
if (GuiRecorderComponent.frame != null && GuiRecorderComponent.frame!!.getEditor() != null) {
|
||||
val editor = GuiRecorderComponent.frame!!.getEditor()
|
||||
val document = editor.document
|
||||
WriteCommandAction.runWriteCommandAction(null, { document.insertString(document.textLength, str) })
|
||||
}
|
||||
val editor = GuiRecorderComponent.frame.getEditor()
|
||||
val document = editor.document
|
||||
WriteCommandAction.runWriteCommandAction(null, { document.insertString(document.textLength, str) })
|
||||
}
|
||||
|
||||
fun writeWithIndent(code: String){
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ class ShowGuiEditorWindowAction() : AnAction() {
|
||||
|
||||
override fun actionPerformed(p0: AnActionEvent?) {
|
||||
val frame = GuiRecorderComponent.frame
|
||||
if (frame == null) {
|
||||
GuiScriptEditorFrame()
|
||||
if (!frame.isShowing()) {
|
||||
frame.show()
|
||||
}
|
||||
else {
|
||||
frame.toFront()
|
||||
|
||||
+2
-3
@@ -26,11 +26,10 @@ import com.intellij.testGuiFramework.recorder.ui.Notifier
|
||||
*/
|
||||
class SyncEditorAction : ToggleAction(null, "Synchronize Editor with Generated GUI Script", AllIcons.Actions.Refresh) {
|
||||
|
||||
override fun isSelected(e: AnActionEvent?): Boolean = if (GuiRecorderComponent.frame != null) GuiRecorderComponent.frame!!.isSyncToEditor() else false
|
||||
override fun isSelected(e: AnActionEvent?): Boolean = GuiRecorderComponent.syncEditor
|
||||
|
||||
override fun setSelected(e: AnActionEvent?, toSync: Boolean) {
|
||||
val frame = GuiRecorderComponent.frame ?: return
|
||||
frame.setSyncToEditor(toSync)
|
||||
GuiRecorderComponent.syncEditor = toSync
|
||||
if (toSync)
|
||||
Notifier.updateStatus("Synchronization is on")
|
||||
else
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import com.intellij.testGuiFramework.recorder.ui.Notifier
|
||||
class UpdateEditorAction : AnAction(null, "Update GUI Script Editor (get recorded from buffer)", AllIcons.Actions.NextOccurence) {
|
||||
|
||||
override fun actionPerformed(actionEvent: AnActionEvent?) {
|
||||
val editor = GuiRecorderComponent.frame!!.getEditor()
|
||||
val editor = GuiRecorderComponent.frame.getEditor()
|
||||
ApplicationManager.getApplication().runWriteAction { editor.document.setText(getGuiScriptBuffer()) }
|
||||
Notifier.updateStatus("GUI script updated")
|
||||
}
|
||||
|
||||
+9
-4
@@ -29,12 +29,17 @@ object GuiRecorderComponent : ApplicationComponent, Disposable {
|
||||
enum class States {IDLE, COMPILING, COMPILATION_ERROR, COMPILATION_DONE, RUNNING, RUNNING_ERROR, TEST_INIT }
|
||||
|
||||
var state: States = States.IDLE
|
||||
var frame: GuiScriptEditorFrame? = null
|
||||
lateinit var frame: GuiScriptEditorFrame
|
||||
var currentTask: Future<*>? = null
|
||||
//let editor be synchronised by default
|
||||
var syncEditor = true
|
||||
|
||||
override fun initComponent() {
|
||||
frame = GuiScriptEditorFrame()
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
frame?.dispose()
|
||||
frame = null
|
||||
frame.dispose()
|
||||
}
|
||||
|
||||
override fun getComponentName() = "GuiRecorderComponent"
|
||||
@@ -43,7 +48,7 @@ object GuiRecorderComponent : ApplicationComponent, Disposable {
|
||||
if (currentTask != null && !currentTask!!.isDone) currentTask!!.cancel(true)
|
||||
}
|
||||
|
||||
fun getEditor() = frame!!.getGuiScriptEditorPanel().editor
|
||||
fun getEditor() = frame.getGuiScriptEditorPanel().editor
|
||||
|
||||
fun placeCaretToEnd() {
|
||||
val caretModel = getEditor().caretModel
|
||||
|
||||
-2
@@ -32,8 +32,6 @@ import kotlin.with
|
||||
class GuiScriptEditor {
|
||||
|
||||
val myEditor: EditorEx
|
||||
//let editor be synchronised by default
|
||||
var syncEditor = true
|
||||
|
||||
fun getPanel() = myEditor.component
|
||||
|
||||
|
||||
+4
-8
@@ -49,15 +49,17 @@ class GuiScriptEditorFrame : Disposable {
|
||||
|
||||
myFrame.contentPane = myContentPanel
|
||||
myFrame.pack()
|
||||
myFrame.isVisible = true
|
||||
|
||||
GuiRecorderComponent.frame = this
|
||||
myFrame.addWindowListener(object : WindowAdapter() {
|
||||
override fun windowClosing(e: WindowEvent?) {
|
||||
dispose()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun isShowing() = myFrame.isShowing
|
||||
fun show() {
|
||||
myFrame.isVisible = true
|
||||
val recAction = StartPauseRecAction()
|
||||
recAction.setSelected(null, true)
|
||||
}
|
||||
@@ -69,10 +71,4 @@ class GuiScriptEditorFrame : Disposable {
|
||||
fun getGuiScriptEditorPanel() = guiScriptEditorPanel
|
||||
|
||||
fun getEditor() = guiScriptEditorPanel.editor
|
||||
|
||||
fun setSyncToEditor(toSync: Boolean) {
|
||||
guiScriptEditorPanel.syncToEditor = toSync
|
||||
}
|
||||
|
||||
fun isSyncToEditor() = guiScriptEditorPanel.syncToEditor
|
||||
}
|
||||
|
||||
-8
@@ -114,18 +114,10 @@ public class GuiScriptEditorPanel {
|
||||
progressIcon = new AsyncProcessIcon("Progress");
|
||||
}
|
||||
|
||||
public boolean getSyncToEditor() {
|
||||
return myEditor.getSyncEditor();
|
||||
}
|
||||
|
||||
private class MyTextPanel extends TextPanel {
|
||||
MyTextPanel(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSyncToEditor(boolean toSync){
|
||||
myEditor.setSyncEditor(toSync);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ object Notifier {
|
||||
|
||||
fun updateStatus(statusMessage: String) {
|
||||
|
||||
if (GuiRecorderComponent.frame == null) return
|
||||
val guiScriptEditorPanel = GuiRecorderComponent.frame!!.getGuiScriptEditorPanel()
|
||||
val guiScriptEditorPanel = GuiRecorderComponent.frame.getGuiScriptEditorPanel()
|
||||
|
||||
val statusHandler: (String) -> Unit = { status ->
|
||||
if (status.startsWith(LONG_OPERATION_PREFIX)) {
|
||||
|
||||
Reference in New Issue
Block a user