[IFT] Edit lessons, add restores and warnings

GitOrigin-RevId: a7aaabfac08d966dd48480a6bbfb8cd7802b3891
This commit is contained in:
Konstantin Hudyakov
2020-12-11 18:52:37 +03:00
committed by intellij-monorepo-bot
parent e4af561bcb
commit 6c835f4c51
24 changed files with 233 additions and 122 deletions

View File

@@ -59,8 +59,9 @@ java.inheritance.hierarchy.last.note=<strong>Note:</strong> Actions {0} and {1}
Actions {2} and {3} are rarely used, but you can always find them with {4} using the {5} filter.
java.find.occurrences.lesson.name=Next/previous occurrence
java.find.occurrences.invoke.find=For this lesson, we selected {0}. Press {1} to start full-text search through the current file.
java.find.occurrences.invoke.find=In this lesson, you selected {0}. Press {1} to start a full-text search through the current file.
java.find.occurrences.find.previous=To jump to the previous occurrence, press {0}.
java.find.occurrences.search.closed.warning=Press {0} to open the search field again.
java.find.occurrences.find.next=<ide/> automatically copies the selected text into the search field. Let''s find the next occurrence. \
Press {0} or {1}.
java.find.occurrences.close.search.tool=With the search panel closed, you can still use these shortcuts to navigate between \

View File

@@ -52,16 +52,17 @@ class JavaBasicCompletionLesson(module: Module)
}
}
caret(19, 36)
actionTask("CodeCompletion") {
task("CodeCompletion") {
text(JavaLessonsBundle.message("java.basic.completion.activate", action(it)))
triggerByListItemAndHighlight(false, false) { item -> item.toString() == "i" }
restoreIfModifiedOrMoved()
JavaLessonsBundle.message("java.basic.completion.activate", action(it))
}
task("EditorChooseLookupItem") {
text(JavaLessonsBundle.message("java.basic.completion.choose.item", code("i"), action(it)))
trigger(it) {
editor.document.charsSequence.contains("Random(i)")
}
restoreIfModifiedOrMoved()
restoreByUi()
}
actionTask("EditorCompleteStatement") {
restoreIfModifiedOrMoved()

View File

@@ -6,6 +6,7 @@ import com.intellij.icons.AllIcons
import com.intellij.ide.IdeBundle
import com.intellij.java.analysis.JavaAnalysisBundle
import com.intellij.java.ift.JavaLessonsBundle
import com.intellij.openapi.editor.impl.EditorComponentImpl
import com.intellij.openapi.wm.ToolWindowId
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.openapi.wm.impl.content.BaseLabel
@@ -16,11 +17,8 @@ import com.intellij.ui.UIBundle
import training.commands.kotlin.TaskContext
import training.commands.kotlin.TaskRuntimeContext
import training.learn.interfaces.Module
import training.learn.lesson.kimpl.KLesson
import training.learn.lesson.kimpl.LessonContext
import training.learn.lesson.kimpl.LessonUtil
import training.learn.lesson.kimpl.*
import training.learn.lesson.kimpl.LessonUtil.restoreIfModifiedOrMoved
import training.learn.lesson.kimpl.closeAllFindTabs
class JavaInheritanceHierarchyLesson(module: Module)
: KLesson("java.inheritance.hierarchy.lesson", JavaLessonsBundle.message("java.inheritance.hierarchy.lesson.name"), module, "JAVA") {
@@ -41,7 +39,9 @@ class JavaInheritanceHierarchyLesson(module: Module)
(virtualFile.name == "DerivedClass1.java" || virtualFile.name == "DerivedClass2.java") && atDeclarationPosition()
}
restoreIfModifiedOrMoved()
restoreAfterStateBecomeFalse {
focusOwner is EditorComponentImpl
}
test {
Thread.sleep(1000)
@@ -75,12 +75,15 @@ class JavaInheritanceHierarchyLesson(module: Module)
closeAllFindTabs()
}
text(JavaLessonsBundle.message("java.inheritance.hierarchy.open.in.find.tool.window", findToolWindow(),
icon(ToolWindowManager.getInstance(project).getLocationIcon(ToolWindowId.FIND, AllIcons.General.Pin_tab))))
icon(ToolWindowManager.getInstance(project).getLocationIcon(ToolWindowId.FIND,
AllIcons.General.Pin_tab))))
triggerByUiComponentAndHighlight(highlightBorder = false, highlightInside = false) { ui: BaseLabel ->
ui.text == (CodeInsightBundle.message("goto.implementation.findUsages.title", "foo")) ||
ui.text == (JavaAnalysisBundle.message("navigate.to.overridden.methods.title", "foo"))
}
restoreIfModifiedOrMoved()
restoreState(delayMillis = defaultRestoreDelay) {
focusOwner is EditorComponentImpl
}
test {
ideFrame {

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2020 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.java.ift.lesson.navigation
import com.intellij.find.SearchTextArea
import com.intellij.java.ift.JavaLessonsBundle
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.impl.actionButton
@@ -58,13 +59,16 @@ class JavaOccurrencesLesson(module: Module)
override val lessonContent: LessonContext.() -> Unit = {
prepareSample(sample)
actionTask("Find") {
task("Find") {
text(JavaLessonsBundle.message("java.find.occurrences.invoke.find", code("cellphone"), action(it)))
triggerByUiComponentAndHighlight(false, false) { _: SearchTextArea -> true }
restoreIfModifiedOrMoved()
JavaLessonsBundle.message("java.find.occurrences.invoke.find", code("cellphone"), action(it))
test { actions(it) }
}
task("FindNext") {
trigger("com.intellij.find.editorHeaderActions.NextOccurrenceAction")
text(JavaLessonsBundle.message("java.find.occurrences.find.next", LessonUtil.rawEnter(), action(it)))
restoreByUi()
test {
ideFrame {
actionButton(UsageViewBundle.message("action.next.occurrence")).click()
@@ -74,6 +78,9 @@ class JavaOccurrencesLesson(module: Module)
task("FindPrevious") {
trigger("com.intellij.find.editorHeaderActions.PrevOccurrenceAction")
text(JavaLessonsBundle.message("java.find.occurrences.find.previous", action("FindPrevious")))
showWarning(JavaLessonsBundle.message("java.find.occurrences.search.closed.warning", action("Find"))) {
editor.headerComponent == null
}
test {
ideFrame {
actionButton(UsageViewBundle.message("action.previous.occurrence")).click()

View File

@@ -107,7 +107,7 @@ class JavaRenameLesson(module: Module)
val shouldBe = fieldName?.let { replaceTemplate(it).replace("<caret>", "").replace("<caret id=2/>", "") }
fieldName != initialName && editor.document.text == shouldBe
}
restoreAfterStateBecomeFalse(startId) {
restoreAfterStateBecomeFalse(restoreId = startId) {
!Thread.currentThread().stackTrace.any {
it.className.contains(RenameProcessor::class.simpleName!!)
}