[IFT] Translate Java Occurrences lesson from XML to DSL
authorAlexey Merkulov <alexey.merkulov@jetbrains.com>
Mon, 21 Sep 2020 18:37:22 +0000 (21:37 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 23 Sep 2020 09:21:52 +0000 (09:21 +0000)
GitOrigin-RevId: 21733957e5cebf2d5653cc7db9ea125a3e9826e0

ide-features-trainer/res/data/modules/java/Navigation.xml
ide-features-trainer/res/data/modules/java/Navigation/04.Occurrences.xml [deleted file]
ide-features-trainer/res/messages/LessonsBundle.properties
ide-features-trainer/src/training/learn/lesson/java/navigation/JavaOccurrencesLesson.kt [new file with mode: 0644]

index c661c2eeeeef298ab0135987535edefcfce5d2b6..d81df9041e01a65c15e15c759889ca765d5efb1b 100755 (executable)
@@ -3,6 +3,6 @@
   <lesson-kt implementationClass="training.learn.lesson.java.navigation.JavaFileStructureLesson"/>
   <lesson-kt implementationClass="training.learn.lesson.java.navigation.JavaDeclarationAndUsagesLesson"/>
   <lesson-kt implementationClass="training.learn.lesson.java.navigation.JavaInheritanceHierarchyLesson"/>
-  <lesson filename="04.Occurrences.xml" solution="training.training.solutions.Navigation.OccurrencesSolution"/>
+  <lesson-kt implementationClass="training.learn.lesson.java.navigation.JavaOccurrencesLesson"/>
 </module>
 
diff --git a/ide-features-trainer/res/data/modules/java/Navigation/04.Occurrences.xml b/ide-features-trainer/res/data/modules/java/Navigation/04.Occurrences.xml
deleted file mode 100755 (executable)
index 4264cb0..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<xml type="Scenario" name="Next/previous occurrences" id="Navigation.Next/PreviousOccurrences" lang="JAVA">
-    <MouseBlock>
-        <CopyText><![CDATA[class FileStructureDemo{
-
-
-    final private String DATABASE = "MyDataBase";
-    DataEntry myPerson;
-
-    FileStructureDemo(String name, int age, String cellphone){
-        myPerson = new Person(name, age, cellphone);
-    }
-
-    interface DataEntry{
-        String getCellphone();
-        String getName();
-    }
-
-    class Person implements DataEntry {
-
-        public Person(String name, int age, String cellphone) {
-            this.name = name;
-            this.age = age;
-            this.cellphone = cellphone;
-        }
-
-        private String name;
-        private int age;
-        private String cellphone;
-
-        public String getCellphone() {
-            return cellphone;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-    }
-}]]></CopyText>
-    </MouseBlock>
-    <Try trigger="Find"><ide/> allows you to navigate between occurrences. First of all, select <code>cellphone</code> in the code, and press <action>Find</action> to call the Find action.</Try>
-    <Try trigger="com.intellij.find.editorHeaderActions.NextOccurrenceAction">To find next occurrences use <action>EditorEnter</action> or <action>FindNext</action></Try>
-    <Try trigger="com.intellij.find.editorHeaderActions.PrevOccurrenceAction">For previous occurrences press <action>FindPrevious</action></Try>
-    <Try check="training.check.CheckFindBar" trigger="FindNext">With the search panel closed you can still use these shortcuts to navigate between occurrences of the item being searched for earlier. Close search panel by pressing <action>EditorEscape</action> and try to find next occurrence with <action>FindNext</action></Try>
-    <Try trigger="FindPrevious">And <action>FindPrevious</action> in a back way.</Try>
-    <Win/>
-</xml>
\ No newline at end of file
index a9670a12c56acd82b1e2c7d8d8cc717ebe008761..fbf72167657592c575f87b9ab7b9faf4f9a3f805 100644 (file)
@@ -227,6 +227,18 @@ java.inheritance.hierarchy.open.class.hierarchy=To overview the class hierarchy
 java.inheritance.hierarchy.last.note=<strong>Note:</strong> Actions {0} and {1} can be applied to classes also. \
   Actions {2} and {3} may be used rarely but you always can find them with {4} by the {5} filter.
 
+java.find.occurrences.lesson.name=Next/previous occurrences
+java.find.occurrences.invoke.find=For this lesson, we selected {0}. Press {1} to start the textual search through the current file.
+java.find.occurrences.find.previous=For previous occurrences, press {0}.
+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 occurrences \
+  of the item being searched for earlier. Let''s close the search panel by pressing {0}.
+java.find.occurrences.find.next.in.editor=Try to find the next occurrence with {0}.
+java.find.occurrences.find.previous.in.editor=And {0} in a back way.
+java.find.occurrences.note.about.cyclic=<strong>Note:</strong> The search is cyclic and pressing twice {0} at the last occurrence will set \
+  the selection for the last occurrence. {1} is cyclic also.
+
 java.debug.workflow.rebuild=For big programs rerun can take much time. When you find some mistake in pure method you can just rebuild \
   the project and apply <strong>Hot Swap</strong> JVM feature. Let''s build project: {0} or {1}.
 java.debug.workflow.confirm.hot.swap=Confirm <strong>Hot Swap</strong> replacement.
diff --git a/ide-features-trainer/src/training/learn/lesson/java/navigation/JavaOccurrencesLesson.kt b/ide-features-trainer/src/training/learn/lesson/java/navigation/JavaOccurrencesLesson.kt
new file mode 100644 (file)
index 0000000..a24d800
--- /dev/null
@@ -0,0 +1,97 @@
+// 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 training.learn.lesson.java.navigation
+
+import com.intellij.testGuiFramework.framework.GuiTestUtil
+import com.intellij.testGuiFramework.impl.actionButton
+import com.intellij.testGuiFramework.util.Key
+import com.intellij.usageView.UsageViewBundle
+import training.learn.LessonsBundle
+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.parseLessonSample
+
+class JavaOccurrencesLesson(module: Module)
+  : KLesson("java.occurrences.lesson", LessonsBundle.message("java.find.occurrences.lesson.name"), module, "JAVA") {
+  val sample = parseLessonSample("""
+    class OccurrencesDemo {
+        final private String DATABASE = "MyDataBase";
+        DataEntry myPerson;
+
+        OccurrencesDemo(String name, int age, String <select>cellphone</select>){
+            myPerson = new Person(name, age, "Cellphone: " + cellphone);
+        }
+
+        interface DataEntry{
+            String getCellphone();
+            String getName();
+        }
+
+        class Person implements DataEntry {
+
+            public Person(String name, int age, String cellphone) {
+                this.name = name;
+                this.age = age;
+                this.cellphone = cellphone;
+            }
+
+            private String name;
+            private int age;
+            private String cellphone;
+
+            public String getCellphone() {
+                return cellphone;
+            }
+
+            public String getName() {
+                return name;
+            }
+
+        }
+    }
+  """.trimIndent())
+
+
+  override val lessonContent: LessonContext.() -> Unit = {
+    prepareSample(sample)
+
+    actionTask("Find") {
+      LessonsBundle.message("java.find.occurrences.invoke.find", code("cellphone"), action(it))
+    }
+    task("FindNext") {
+      trigger("com.intellij.find.editorHeaderActions.NextOccurrenceAction")
+      text(LessonsBundle.message("java.find.occurrences.find.next", LessonUtil.rawEnter(), action(it)))
+      test {
+        ideFrame {
+          actionButton(UsageViewBundle.message("action.next.occurrence")).click()
+        }
+      }
+    }
+    task("FindPrevious") {
+      trigger("com.intellij.find.editorHeaderActions.PrevOccurrenceAction")
+      text(LessonsBundle.message("java.find.occurrences.find.previous", action("FindPrevious")))
+      test {
+        ideFrame {
+          actionButton(UsageViewBundle.message("action.previous.occurrence")).click()
+        }
+      }
+    }
+    task("EditorEscape") {
+      text(LessonsBundle.message("java.find.occurrences.close.search.tool", action(it)))
+      stateCheck {
+        editor.headerComponent == null
+      }
+      test { GuiTestUtil.shortcut(Key.ESCAPE) }
+    }
+    actionTask("FindNext") {
+      LessonsBundle.message("java.find.occurrences.find.next.in.editor", action(it))
+    }
+    actionTask("FindPrevious") {
+      LessonsBundle.message("java.find.occurrences.find.previous.in.editor", action(it))
+    }
+    task {
+      text(LessonsBundle.message("java.find.occurrences.note.about.cyclic", action("FindNext"), action("FindPrevious")))
+    }
+  }
+}
\ No newline at end of file