From 4b27480b329ba982f0c88ce8cee6e5c905126a34 Mon Sep 17 00:00:00 2001 From: meanmail Date: Sun, 19 Mar 2017 02:37:38 +0700 Subject: [PATCH 1/4] Removed unused progress bar from browser --- .../tmp/learning/ui/StudyBrowserWindow.java | 52 ++----------------- .../learning/ui/StudyJavaFxToolWindow.java | 2 +- 2 files changed, 5 insertions(+), 49 deletions(-) diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java index 11f77120..c022a1ad 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java @@ -25,7 +25,6 @@ import javafx.concurrent.Worker; import javafx.embed.swing.JFXPanel; import javafx.scene.Scene; -import javafx.scene.control.ProgressBar; import javafx.scene.layout.StackPane; import javafx.scene.web.WebEngine; import javafx.scene.web.WebHistory; @@ -65,16 +64,10 @@ class StudyBrowserWindow extends JFrame { private JFXPanel panel; private WebView webComponent; private StackPane pane; - private WebEngine engine; - private ProgressBar progressBar; - private boolean linkInNewBrowser = true; - private boolean showProgress = false; - StudyBrowserWindow(@NotNull Project project, final boolean linkInNewWindow, final boolean showProgress) { + StudyBrowserWindow(@NotNull Project project) { this.project = project; - linkInNewBrowser = linkInNewWindow; - this.showProgress = showProgress; setSize(new Dimension(900, 800)); setLayout(new BorderLayout()); setPanel(new JFXPanel()); @@ -117,17 +110,8 @@ private void initComponents() { pane = new StackPane(); webComponent = new WebView(); engine = webComponent.getEngine(); - - if (showProgress) { - progressBar = makeProgressBarWithListener(); - webComponent.setVisible(false); - pane.getChildren().addAll(webComponent, progressBar); - } else { - pane.getChildren().add(webComponent); - } - if (linkInNewBrowser) { - initHyperlinkListener(); - } + pane.getChildren().add(webComponent); + initHyperlinkListener(); Scene scene = new Scene(pane); panel.setScene(scene); panel.setVisible(true); @@ -140,10 +124,7 @@ private void initComponents() { void loadContent(@NotNull final String content) { String withCodeHighlighting = createHtmlWithCodeHighlighting(content); - Platform.runLater(() -> { - updateLookWithProgressBarIfNeeded(); - engine.loadContent(withCodeHighlighting); - }); + Platform.runLater(() -> engine.loadContent(withCodeHighlighting)); } @Nullable @@ -168,13 +149,6 @@ private String getExternalURL(@NotNull String internalPath) { return getClass().getResource(internalPath).toExternalForm(); } - private void updateLookWithProgressBarIfNeeded() { - if (showProgress) { - progressBar.setVisible(true); - webComponent.setVisible(false); - } - } - private void initHyperlinkListener() { engine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> { if (newState == Worker.State.SUCCEEDED) { @@ -382,24 +356,6 @@ public void mouseClicked(MouseEvent e) { return button; } - - private ProgressBar makeProgressBarWithListener() { - final ProgressBar progress = new ProgressBar(); - progress.progressProperty().bind(webComponent.getEngine().getLoadWorker().progressProperty()); - - webComponent.getEngine().getLoadWorker().stateProperty().addListener( - (ov, oldState, newState) -> { - if (webComponent.getEngine() - .getLocation() - .contains("http") && newState == Worker.State.SUCCEEDED) { - progressBar.setVisible(false); - webComponent.setVisible(true); - } - }); - - return progress; - } - JFXPanel getPanel() { return panel; } diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java index 0761d827..4cb36c5f 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java @@ -29,7 +29,7 @@ public class StudyJavaFxToolWindow extends StudyToolWindow { @Override public JComponent createStepInfoPanel(Project project) { - browserWindow = new StudyBrowserWindow(project, true, false); + browserWindow = new StudyBrowserWindow(project); browserWindow.addBackAndOpenButtons(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); From f21fe404cd2cc6f28122a7764c037b834766fd6f Mon Sep 17 00:00:00 2001 From: meanmail Date: Sun, 19 Mar 2017 02:44:01 +0700 Subject: [PATCH 2/4] Removed unused buttons from browser --- .../tmp/learning/ui/StudyBrowserWindow.java | 54 ------------------- .../learning/ui/StudyJavaFxToolWindow.java | 1 - 2 files changed, 55 deletions(-) diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java index c022a1ad..7a8976e0 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyBrowserWindow.java @@ -1,6 +1,5 @@ package com.jetbrains.tmp.learning.ui; -import com.intellij.icons.AllIcons; import com.intellij.ide.BrowserUtil; import com.intellij.ide.ui.LafManager; import com.intellij.ide.ui.LafManagerListener; @@ -27,7 +26,6 @@ import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.scene.web.WebEngine; -import javafx.scene.web.WebHistory; import javafx.scene.web.WebView; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,8 +45,6 @@ import javax.swing.*; import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -306,56 +302,6 @@ private String getLinkFromNodeWithCodeTag(@NotNull Element element) { }; } - void addBackAndOpenButtons() { - ApplicationManager.getApplication().invokeLater(() -> { - final JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - - final JButton backButton = makeGoButton("Click to go back", AllIcons.Actions.Back, -1); - final JButton forwardButton = makeGoButton("Click to go forward", AllIcons.Actions.Forward, 1); - final JButton openInBrowser = new JButton(AllIcons.Actions.Browser_externalJavaDoc); - openInBrowser.addActionListener(e -> BrowserUtil.browse(engine.getLocation())); - openInBrowser.setToolTipText("Click to open link in browser"); - addButtonsAvailabilityListeners(backButton, forwardButton); - - panel.setMaximumSize(new Dimension(40, getPanel().getHeight())); - panel.add(backButton); - panel.add(forwardButton); - panel.add(openInBrowser); - - add(panel, BorderLayout.PAGE_START); - }); - } - - private void addButtonsAvailabilityListeners(JButton backButton, JButton forwardButton) { - Platform.runLater(() -> engine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> { - if (newState == Worker.State.SUCCEEDED) { - final WebHistory history = engine.getHistory(); - boolean isGoBackAvailable = history.getCurrentIndex() > 0; - boolean isGoForwardAvailable = history.getCurrentIndex() < history.getEntries().size() - 1; - ApplicationManager.getApplication().invokeLater(() -> { - backButton.setEnabled(isGoBackAvailable); - forwardButton.setEnabled(isGoForwardAvailable); - }); - } - })); - } - - private JButton makeGoButton(@NotNull final String toolTipText, @NotNull final Icon icon, final int direction) { - final JButton button = new JButton(icon); - button.setEnabled(false); - button.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 1) { - Platform.runLater(() -> engine.getHistory().go(direction)); - } - } - }); - button.setToolTipText(toolTipText); - return button; - } - JFXPanel getPanel() { return panel; } diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java index 4cb36c5f..005fae1f 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java @@ -30,7 +30,6 @@ public class StudyJavaFxToolWindow extends StudyToolWindow { @Override public JComponent createStepInfoPanel(Project project) { browserWindow = new StudyBrowserWindow(project); - browserWindow.addBackAndOpenButtons(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.add(browserWindow.getPanel()); From 5522c6bb574d7f7eec1cbfb38b04c83aec3ca4d2 Mon Sep 17 00:00:00 2001 From: meanmail Date: Sun, 19 Mar 2017 04:40:34 +0700 Subject: [PATCH 3/4] Now the StepikProjectManager manage selected step --- .../tmp/learning/StepikProjectManager.java | 57 ++++++++++++++- .../learning/StudyBasePluginConfigurator.java | 28 ++++---- .../tmp/learning/StudyPluginConfigurator.java | 5 +- .../tmp/learning/StudyProjectComponent.java | 6 +- .../jetbrains/tmp/learning/StudyUtils.java | 50 -------------- .../tmp/learning/ui/FormListener.java | 4 +- .../learning/ui/StudyJavaFxToolWindow.java | 43 ------------ .../tmp/learning/ui/StudySwingToolWindow.java | 69 ------------------- .../tmp/learning/ui/StudyToolWindow.java | 25 ++++--- .../learning/ui/StudyToolWindowFactory.java | 4 +- .../org/stepik/plugin/actions/SendAction.java | 4 +- .../stepik/plugin/utils/NavigationUtils.java | 5 +- .../main/resources/templates/quiz/dataset.ftl | 7 +- .../actions/step/AbstractStepAction.java | 17 ++--- .../actions/step/DownloadSubmission.java | 8 ++- .../actions/step/InsertStepikDirectives.java | 20 +++++- .../actions/step/StepikJavaPostAction.java | 11 +-- .../actions/step/StepikResetStepAction.java | 23 +++++-- .../projectView/StepikDirectoryNode.java | 3 +- 19 files changed, 152 insertions(+), 237 deletions(-) delete mode 100644 core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java delete mode 100644 core/src/main/java/com/jetbrains/tmp/learning/ui/StudySwingToolWindow.java diff --git a/core/src/main/java/com/jetbrains/tmp/learning/StepikProjectManager.java b/core/src/main/java/com/jetbrains/tmp/learning/StepikProjectManager.java index 1f3314ee..86f68f52 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/StepikProjectManager.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/StepikProjectManager.java @@ -27,6 +27,7 @@ import com.jetbrains.tmp.learning.serialization.StudySerializationUtils; import com.jetbrains.tmp.learning.serialization.StudyUnrecognizedFormatException; import com.jetbrains.tmp.learning.serialization.SupportedLanguagesConverter; +import com.jetbrains.tmp.learning.ui.StudyToolWindow; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStreamException; import com.thoughtworks.xstream.annotations.XStreamOmitField; @@ -59,8 +60,8 @@ import java.util.UUID; import static com.jetbrains.tmp.learning.SupportedLanguages.INVALID; -import static org.stepik.core.utils.ProjectFilesUtils.getOrCreateSrcDirectory; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.stepik.core.utils.ProjectFilesUtils.getOrCreateSrcDirectory; @State(name = "StepikStudySettings", storages = @Storage("stepik_study_project.xml")) public class StepikProjectManager implements PersistentStateComponent, DumbAware { @@ -79,6 +80,7 @@ public class StepikProjectManager implements PersistentStateComponent, @XStreamOmitField private final Project project; private StudyNode root; + private StudyNode selected; private boolean showHint = false; private long createdBy; private SupportedLanguages defaultLang = INVALID; @@ -176,6 +178,59 @@ private static Element toElement(ByteArrayOutputStream out) } } + public static void setSelected(@NotNull Project project, @Nullable StudyNode studyNode, boolean force) { + StepikProjectManager instance = getInstance(project); + if (instance != null) { + instance.setSelected(studyNode, force); + } + } + + public static void setSelected(@NotNull Project project, @Nullable StudyNode studyNode) { + setSelected(project, studyNode, false); + } + + public static void updateSelection(@NotNull Project project) { + StepikProjectManager instance = getInstance(project); + if (instance != null) { + instance.updateSelection(); + } + } + + @Nullable + public static StudyNode getSelected(@Nullable Project project) { + if (project == null) { + return null; + } + StepikProjectManager instance = getInstance(project); + if (instance != null) { + return instance.getSelected(); + } + + return null; + } + + public StudyNode getSelected() { + return selected; + } + + public void setSelected(StudyNode selected) { + setSelected(selected, false); + } + + public void setSelected(StudyNode selected, boolean force) { + this.selected = selected; + if (project != null) { + StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(project); + if (toolWindow != null) { + ApplicationManager.getApplication().invokeLater(() -> toolWindow.setStepNode(selected, force)); + } + } + } + + public void updateSelection() { + setSelected(selected, true); + } + public void setRootNode(@Nullable StudyNode root) { this.root = root; } diff --git a/core/src/main/java/com/jetbrains/tmp/learning/StudyBasePluginConfigurator.java b/core/src/main/java/com/jetbrains/tmp/learning/StudyBasePluginConfigurator.java index bfef8789..1aecaa7f 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/StudyBasePluginConfigurator.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/StudyBasePluginConfigurator.java @@ -1,13 +1,12 @@ package com.jetbrains.tmp.learning; import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.fileEditor.FileEditorManagerAdapter; import com.intellij.openapi.fileEditor.FileEditorManagerEvent; import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.jetbrains.tmp.learning.courseFormat.StudyNode; -import com.jetbrains.tmp.learning.ui.StudyToolWindow; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -34,23 +33,20 @@ public Map getAdditionalPanels(Project project) { @NotNull @Override - public FileEditorManagerListener getFileEditorManagerListener( - @NotNull Project project, - @NotNull StudyToolWindow toolWindow) { - - return new FileEditorManagerListener() { + public FileEditorManagerListener getFileEditorManagerListener(@NotNull Project project) { + return new FileEditorManagerAdapter() { @Override - public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { - } + public void selectionChanged(@NotNull FileEditorManagerEvent event) { + VirtualFile file = event.getNewFile(); + if (file == null) { + return; + } - @Override - public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { - } + StudyNode stepNode = StudyUtils.getStudyNode(project, file); - @Override - public void selectionChanged(@NotNull FileEditorManagerEvent event) { - StudyNode stepNode = StudyUtils.getSelectedNode(event.getManager().getProject()); - toolWindow.setStepNode(stepNode); + if (stepNode != null) { + StepikProjectManager.setSelected(project, stepNode); + } } }; } diff --git a/core/src/main/java/com/jetbrains/tmp/learning/StudyPluginConfigurator.java b/core/src/main/java/com/jetbrains/tmp/learning/StudyPluginConfigurator.java index 5bbf9372..96895439 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/StudyPluginConfigurator.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/StudyPluginConfigurator.java @@ -4,7 +4,6 @@ import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.project.Project; -import com.jetbrains.tmp.learning.ui.StudyToolWindow; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -28,9 +27,7 @@ public interface StudyPluginConfigurator { Map getAdditionalPanels(Project project); @NotNull - FileEditorManagerListener getFileEditorManagerListener( - @NotNull final Project project, - @NotNull final StudyToolWindow toolWindow); + FileEditorManagerListener getFileEditorManagerListener(@NotNull final Project project); boolean accept(@NotNull final Project project); } diff --git a/core/src/main/java/com/jetbrains/tmp/learning/StudyProjectComponent.java b/core/src/main/java/com/jetbrains/tmp/learning/StudyProjectComponent.java index a05ba026..2e603efd 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/StudyProjectComponent.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/StudyProjectComponent.java @@ -51,10 +51,8 @@ public void projectOpened() { if (!StepikProjectManager.isStepikProject(project)) { return; } - // Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside. - if (StudyUtils.hasJavaFx()) { - Platform.setImplicitExit(false); - } + + Platform.setImplicitExit(false); registerStudyToolWindow(); ApplicationManager.getApplication().invokeLater( diff --git a/core/src/main/java/com/jetbrains/tmp/learning/StudyUtils.java b/core/src/main/java/com/jetbrains/tmp/learning/StudyUtils.java index 49470019..17d96338 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/StudyUtils.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/StudyUtils.java @@ -5,8 +5,6 @@ import com.intellij.ide.projectView.impl.AbstractProjectViewPane; import com.intellij.ide.ui.LafManager; import com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; @@ -59,11 +57,6 @@ public class StudyUtils { private StudyUtils() { } - public static void updateToolWindows(@NotNull final Project project) { - StudyNode stepNode = getSelectedNode(project); - setStudyNode(project, stepNode, true); - } - static void initToolWindows(@NotNull final Project project) { final ToolWindowManager windowManager = ToolWindowManager.getInstance(project); windowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW) @@ -89,17 +82,6 @@ static StudyToolWindow getStudyToolWindow(@NotNull final Project project) { return null; } - public static void setStudyNode(@NotNull final Project project, @Nullable StudyNode studyNode) { - setStudyNode(project, studyNode, false); - } - - public static void setStudyNode(@NotNull final Project project, @Nullable StudyNode studyNode, boolean force) { - StudyToolWindow toolWindow = getStudyToolWindow(project); - if (toolWindow != null) { - ApplicationManager.getApplication().invokeLater(() -> toolWindow.setStepNode(studyNode, force)); - } - } - @NotNull public static String getVideoStepText( @NotNull VideoStepNodeHelper videoStepNode, @@ -268,29 +250,6 @@ private static String getRelativePath(@NotNull Project project, @NotNull Virtual return ProjectFilesUtils.getRelativePath(basePath, path); } - @Nullable - public static StepNode getSelectedStep(@NotNull Project project) { - VirtualFile[] files = FileEditorManager.getInstance(project).getSelectedFiles(); - if (files.length == 0) { - return null; - } - - StudyNode studyNode = getStudyNode(project, files[0]); - - return studyNode instanceof StepNode ? (StepNode) studyNode : null; - } - - @Nullable - static StudyNode getSelectedNode(@NotNull Project project) { - StudyNode studyNode = getSelectedStep(project); - - if (studyNode == null) { - studyNode = getSelectedNodeInTree(project); - } - - return studyNode; - } - @Nullable public static StudyNode getSelectedNodeInTree(@NotNull Project project) { PsiElement element = getSelectedPsiElement(project); @@ -340,15 +299,6 @@ private static PsiElement getSelectedPsiElement(@NotNull Project project) { } } - public static boolean hasJavaFx() { - try { - Class.forName("javafx.application.Platform"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } - @Nullable public static StudyNode getStudyNode(@NotNull Project project, @NotNull VirtualFile nodeVF) { String path = getRelativePath(project, nodeVF); diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/FormListener.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/FormListener.java index f5bd87b5..b0768ba1 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/FormListener.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/ui/FormListener.java @@ -83,7 +83,7 @@ public void handleEvent(Event event) { boolean locked = elements.isLocked(); if (!locked) { getAttempt(stepNode); - StudyUtils.setStudyNode(project, node, true); + StepikProjectManager.updateSelection(project); } break; case "active": @@ -210,7 +210,7 @@ public void run(@NotNull ProgressIndicator indicator) { } } catch (StepikClientException e) { logger.warn("Failed send step from browser", e); - StudyUtils.updateToolWindows(project); + StepikProjectManager.updateSelection(project); } } }); diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java deleted file mode 100644 index 005fae1f..00000000 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyJavaFxToolWindow.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.tmp.learning.ui; - -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -public class StudyJavaFxToolWindow extends StudyToolWindow { - private StudyBrowserWindow browserWindow; - - StudyJavaFxToolWindow() { - super(); - } - - @Override - public JComponent createStepInfoPanel(Project project) { - browserWindow = new StudyBrowserWindow(project); - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); - panel.add(browserWindow.getPanel()); - return panel; - } - - @Override - public void setText(@NotNull String text) { - browserWindow.loadContent(text); - } -} diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudySwingToolWindow.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudySwingToolWindow.java deleted file mode 100644 index 0e82d45f..00000000 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudySwingToolWindow.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.tmp.learning.ui; - -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.project.Project; -import com.intellij.ui.BrowserHyperlinkListener; -import com.intellij.ui.ColorUtil; -import com.intellij.ui.components.JBScrollPane; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import javax.swing.border.EmptyBorder; -import javax.swing.text.html.HTMLDocument; -import javax.swing.text.html.HTMLEditorKit; -import java.awt.*; - -public class StudySwingToolWindow extends StudyToolWindow { - private JTextPane stepTextPane; - - StudySwingToolWindow() { - super(); - } - - @Override - public JComponent createStepInfoPanel(Project project) { - stepTextPane = new JTextPane(); - final JBScrollPane scrollPane = new JBScrollPane(stepTextPane); - stepTextPane.setContentType(new HTMLEditorKit().getContentType()); - final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); - int fontSize = editorColorsScheme.getEditorFontSize(); - final String fontName = editorColorsScheme.getEditorFontName(); - final Font font = new Font(fontName, Font.PLAIN, fontSize); - String bodyRule = "body { font-family: " + font.getFamily() + "; " + - "font-size: " + font.getSize() + "pt; }" + - "pre {font-family: Courier; display: inline; ine-height: 50px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; background-color:" - + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}" + - "code {font-family: Courier; display: flex; float: left; background-color:" - + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}"; - ((HTMLDocument) stepTextPane.getDocument()).getStyleSheet().addRule(bodyRule); - stepTextPane.setEditable(false); - if (!UIUtil.isUnderDarcula()) { - stepTextPane.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground()); - } - stepTextPane.setBorder(new EmptyBorder(20, 20, 0, 10)); - stepTextPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE); - return scrollPane; - } - - public void setText(@NotNull String text) { - stepTextPane.setText(text); - } -} - diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindow.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindow.java index a3d1dafd..b75e6729 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindow.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindow.java @@ -57,7 +57,7 @@ import static com.jetbrains.tmp.learning.courseFormat.StepType.VIDEO; import static org.stepik.core.utils.PluginUtils.PLUGIN_ID; -public abstract class StudyToolWindow extends SimpleToolWindowPanel implements DataProvider, Disposable, ActionListener { +public class StudyToolWindow extends SimpleToolWindowPanel implements DataProvider, Disposable, ActionListener { private static final Logger logger = Logger.getInstance(StudyToolWindow.class); private static final String STEP_INFO_ID = "stepInfo"; private static final String EMPTY_STEP_TEXT = "Please, open any step to see step description"; @@ -73,6 +73,7 @@ public abstract class StudyToolWindow extends SimpleToolWindowPanel implements D private final ActionListener qualityListener; private Project project; private StepNode stepNode; + private StudyBrowserWindow browserWindow; StudyToolWindow() { super(true, true); @@ -109,6 +110,18 @@ private static DefaultActionGroup getActionGroup(@NotNull final Project project) } } + private JComponent createStepInfoPanel(Project project) { + browserWindow = new StudyBrowserWindow(project); + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); + panel.add(browserWindow.getPanel()); + return panel; + } + + private void setText(@NotNull String text) { + browserWindow.loadContent(text); + } + private JPanel createToolbarPanel(ActionGroup group) { final ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar("Study", group, true); BorderLayoutPanel toolBar = JBUI.Panels.simplePanel(actionToolBar.getComponent()); @@ -135,7 +148,7 @@ void init(@NotNull final Project project) { StudyPluginConfigurator configurator = StudyUtils.getConfigurator(project); if (configurator != null) { - final FileEditorManagerListener listener = configurator.getFileEditorManagerListener(project, this); + final FileEditorManagerListener listener = configurator.getFileEditorManagerListener(project); project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener); } @@ -143,7 +156,7 @@ void init(@NotNull final Project project) { videoQualityBox.addItem(loadVideoQuality()); videoQualityBox.setSelectedIndex(0); - StepNode stepNode = StudyUtils.getSelectedStep(project); + StudyNode stepNode = StepikProjectManager.getSelected(project); setStepNode(stepNode); } @@ -166,9 +179,7 @@ public void dispose() { setStepNode(null); } - public abstract JComponent createStepInfoPanel(Project project); - - public void setStepNode(@Nullable StudyNode studyNode) { + private void setStepNode(@Nullable StudyNode studyNode) { setStepNode(studyNode, false); } @@ -301,8 +312,6 @@ private void storeVideoQuality(int quality) { PropertiesComponent.getInstance().setValue(VIDEO_QUALITY_PROPERTY_NAME, String.valueOf(quality)); } - protected abstract void setText(@NotNull String text); - @Override public void actionPerformed(ActionEvent e) { if (stepNode == null) { diff --git a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindowFactory.java b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindowFactory.java index 569d175d..eb8e6a0e 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindowFactory.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/ui/StudyToolWindowFactory.java @@ -9,7 +9,6 @@ import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; import com.jetbrains.tmp.learning.StepikProjectManager; -import com.jetbrains.tmp.learning.StudyUtils; import icons.AllStepikIcons; import org.jetbrains.annotations.NotNull; @@ -26,8 +25,7 @@ public void createToolWindowContent(@NotNull final Project project, @NotNull fin return; } - final StudyToolWindow studyToolWindow; - studyToolWindow = StudyUtils.hasJavaFx() ? new StudyJavaFxToolWindow() : new StudySwingToolWindow(); + final StudyToolWindow studyToolWindow = new StudyToolWindow(); studyToolWindow.init(project); final ContentManager contentManager = toolWindow.getContentManager(); final Content content = contentManager.getFactory().createContent(studyToolWindow, null, false); diff --git a/core/src/main/java/org/stepik/plugin/actions/SendAction.java b/core/src/main/java/org/stepik/plugin/actions/SendAction.java index 0d42746c..9ab52df0 100644 --- a/core/src/main/java/org/stepik/plugin/actions/SendAction.java +++ b/core/src/main/java/org/stepik/plugin/actions/SendAction.java @@ -6,7 +6,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; -import com.jetbrains.tmp.learning.StudyUtils; +import com.jetbrains.tmp.learning.StepikProjectManager; import com.jetbrains.tmp.learning.courseFormat.StepNode; import com.jetbrains.tmp.learning.courseFormat.StudyStatus; import com.jetbrains.tmp.learning.stepik.StepikConnectorLogin; @@ -89,7 +89,7 @@ public static void checkStepStatus( notify(project, stepNode, stepStatus, hint); ApplicationManager.getApplication().invokeLater(() -> { ProjectView.getInstance(project).refresh(); - StudyUtils.updateToolWindows(project); + StepikProjectManager.updateSelection(project); }); logger.info(String.format("Finish check a status for step: %s with status: %s", stepIdString, stepStatus)); } diff --git a/core/src/main/java/org/stepik/plugin/utils/NavigationUtils.java b/core/src/main/java/org/stepik/plugin/utils/NavigationUtils.java index 88ac5cbc..a6d8a8a0 100644 --- a/core/src/main/java/org/stepik/plugin/utils/NavigationUtils.java +++ b/core/src/main/java/org/stepik/plugin/utils/NavigationUtils.java @@ -12,7 +12,7 @@ import com.intellij.psi.PsiFileSystemItem; import com.intellij.psi.PsiManager; import com.intellij.util.ui.tree.TreeUtil; -import com.jetbrains.tmp.learning.StudyUtils; +import com.jetbrains.tmp.learning.StepikProjectManager; import com.jetbrains.tmp.learning.courseFormat.StepNode; import com.jetbrains.tmp.learning.courseFormat.StudyNode; import org.jetbrains.annotations.NotNull; @@ -68,8 +68,7 @@ public static void navigate(@NotNull Project project, StudyNode targetNode) { updateProjectView(project, mainFile); } Metrics.navigateAction(project, targetNode, SUCCESSFUL); - - StudyUtils.setStudyNode(project, targetNode); + StepikProjectManager.setSelected(project, targetNode); ToolWindow runToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.RUN); if (runToolWindow != null) { diff --git a/core/src/main/resources/templates/quiz/dataset.ftl b/core/src/main/resources/templates/quiz/dataset.ftl index 8a872033..127ee5a8 100644 --- a/core/src/main/resources/templates/quiz/dataset.ftl +++ b/core/src/main/resources/templates/quiz/dataset.ftl @@ -60,11 +60,10 @@ var active = false; - if (time_left > 0) { - clock.innerHTML = timeToString(time_left); - } - if (active) { + if (time_left > 0) { + clock.innerHTML = timeToString(time_left); + } var timerId = setInterval(function () { time_left--; diff --git a/stepik-union/src/main/java/org/stepik/plugin/actions/step/AbstractStepAction.java b/stepik-union/src/main/java/org/stepik/plugin/actions/step/AbstractStepAction.java index 655e36c6..4d845eae 100644 --- a/stepik-union/src/main/java/org/stepik/plugin/actions/step/AbstractStepAction.java +++ b/stepik-union/src/main/java/org/stepik/plugin/actions/step/AbstractStepAction.java @@ -1,11 +1,10 @@ package org.stepik.plugin.actions.step; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.openapi.project.Project; -import com.jetbrains.tmp.learning.StudyUtils; +import com.jetbrains.tmp.learning.StepikProjectManager; import com.jetbrains.tmp.learning.actions.StudyActionWithShortcut; import com.jetbrains.tmp.learning.courseFormat.StepNode; +import com.jetbrains.tmp.learning.courseFormat.StudyNode; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -20,15 +19,7 @@ abstract class AbstractStepAction extends StudyActionWithShortcut { @Override public void update(AnActionEvent e) { - final Presentation presentation = e.getPresentation(); - presentation.setEnabled(false); - - Project project = e.getProject(); - if (project == null) { - return; - } - - StepNode targetStepNode = StudyUtils.getSelectedStep(project); - presentation.setEnabled(targetStepNode != null && !targetStepNode.getWasDeleted()); + StudyNode targetStepNode = StepikProjectManager.getSelected(e.getProject()); + e.getPresentation().setEnabled((targetStepNode instanceof StepNode) && !targetStepNode.getWasDeleted()); } } diff --git a/stepik-union/src/main/java/org/stepik/plugin/actions/step/DownloadSubmission.java b/stepik-union/src/main/java/org/stepik/plugin/actions/step/DownloadSubmission.java index 69a55453..25ead86c 100644 --- a/stepik-union/src/main/java/org/stepik/plugin/actions/step/DownloadSubmission.java +++ b/stepik-union/src/main/java/org/stepik/plugin/actions/step/DownloadSubmission.java @@ -20,7 +20,7 @@ import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.ui.popup.PopupChooserBuilder; import com.intellij.openapi.vfs.VirtualFile; -import com.jetbrains.tmp.learning.StudyUtils; +import com.jetbrains.tmp.learning.StepikProjectManager; import com.jetbrains.tmp.learning.SupportedLanguages; import com.jetbrains.tmp.learning.courseFormat.StepNode; import com.jetbrains.tmp.learning.courseFormat.StudyNode; @@ -90,11 +90,13 @@ private void downloadSubmission(@Nullable Project project) { return; } - StepNode stepNode = StudyUtils.getSelectedStep(project); - if (stepNode == null) { + StudyNode studyNode = StepikProjectManager.getSelected(project); + if (!(studyNode instanceof StepNode)) { return; } + StepNode stepNode = (StepNode) studyNode; + String title = "Download submission"; List submissions = ProgressManager.getInstance() diff --git a/stepik-union/src/main/java/org/stepik/plugin/actions/step/InsertStepikDirectives.java b/stepik-union/src/main/java/org/stepik/plugin/actions/step/InsertStepikDirectives.java index f702c998..87d17dd4 100644 --- a/stepik-union/src/main/java/org/stepik/plugin/actions/step/InsertStepikDirectives.java +++ b/stepik-union/src/main/java/org/stepik/plugin/actions/step/InsertStepikDirectives.java @@ -3,6 +3,7 @@ import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.KeyboardShortcut; +import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditorManager; @@ -11,9 +12,9 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.jetbrains.tmp.learning.StepikProjectManager; -import com.jetbrains.tmp.learning.StudyUtils; import com.jetbrains.tmp.learning.SupportedLanguages; import com.jetbrains.tmp.learning.courseFormat.StepNode; +import com.jetbrains.tmp.learning.courseFormat.StudyNode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.stepik.core.metrics.Metrics; @@ -22,6 +23,7 @@ import javax.swing.*; +import static com.jetbrains.tmp.learning.courseFormat.StepType.CODE; import static org.stepik.core.metrics.MetricsStatus.SUCCESSFUL; import static org.stepik.core.utils.ProjectFilesUtils.getOrCreateSrcDirectory; import static org.stepik.plugin.utils.DirectivesUtils.insertAmbientCode; @@ -59,11 +61,13 @@ public void actionPerformed(AnActionEvent e) { return; } - StepNode targetStepNode = StudyUtils.getSelectedStep(project); - if (targetStepNode == null) { + StudyNode selectedNode = StepikProjectManager.getSelected(project); + if (!(selectedNode instanceof StepNode) || ((StepNode) selectedNode).getType() != CODE) { return; } + StepNode targetStepNode = (StepNode) selectedNode; + FileDocumentManager documentManager = FileDocumentManager.getInstance(); for (VirtualFile file : FileEditorManager.getInstance(project).getOpenFiles()) { Document document = documentManager.getDocument(file); @@ -105,4 +109,14 @@ public void actionPerformed(AnActionEvent e) { } } } + + @Override + public void update(AnActionEvent e) { + super.update(e); + Presentation presentation = e.getPresentation(); + StudyNode selectedNode = StepikProjectManager.getSelected(e.getProject()); + boolean enabled = presentation.isEnabled(); + boolean canEnabled = (selectedNode instanceof StepNode) && (((StepNode) selectedNode).getType() == CODE); + presentation.setEnabled(enabled && canEnabled); + } } diff --git a/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikJavaPostAction.java b/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikJavaPostAction.java index 1c2c94ca..c157f58e 100644 --- a/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikJavaPostAction.java +++ b/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikJavaPostAction.java @@ -6,9 +6,10 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; -import com.jetbrains.tmp.learning.StudyUtils; +import com.jetbrains.tmp.learning.StepikProjectManager; import com.jetbrains.tmp.learning.SupportedLanguages; import com.jetbrains.tmp.learning.courseFormat.StepNode; +import com.jetbrains.tmp.learning.courseFormat.StudyNode; import com.jetbrains.tmp.learning.stepik.StepikConnectorLogin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -160,12 +161,14 @@ private static void notifyFailed( @Override public void check(@NotNull Project project) { logger.info("Start checking step"); - StepNode stepNode = StudyUtils.getSelectedStep(project); - if (stepNode == null) { - logger.info("Stop checking step: step is null"); + StudyNode selected = StepikProjectManager.getSelected(project); + if (!(selected instanceof StepNode)) { + logger.info("Stop checking step: step is null or is not StepNode "); return; } + StepNode stepNode = (StepNode) selected; + String title = "Checking Step: " + stepNode.getName(); ProgressManager.getInstance().run(new Task.Backgroundable(project, title) { diff --git a/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikResetStepAction.java b/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikResetStepAction.java index df55531b..311d317d 100644 --- a/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikResetStepAction.java +++ b/stepik-union/src/main/java/org/stepik/plugin/actions/step/StepikResetStepAction.java @@ -3,6 +3,7 @@ import com.intellij.ide.projectView.ProjectView; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.KeyboardShortcut; +import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; @@ -11,8 +12,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.problems.WolfTheProblemSolver; -import com.jetbrains.tmp.learning.StudyUtils; +import com.jetbrains.tmp.learning.StepikProjectManager; import com.jetbrains.tmp.learning.courseFormat.StepNode; +import com.jetbrains.tmp.learning.courseFormat.StudyNode; import icons.AllStepikIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,6 +23,7 @@ import javax.swing.*; +import static com.jetbrains.tmp.learning.courseFormat.StepType.CODE; import static org.stepik.core.utils.ProjectFilesUtils.getOrCreateSrcDirectory; public class StepikResetStepAction extends AbstractStepAction { @@ -39,11 +42,13 @@ private static void reset(@NotNull final Project project) { } private static void resetFile(@NotNull final Project project) { - StepNode stepNode = StudyUtils.getSelectedStep(project); - if (stepNode == null) { + StudyNode selected = StepikProjectManager.getSelected(project); + if (!(selected instanceof StepNode) || ((StepNode) selected).getType() != CODE) { return; } + StepNode stepNode = (StepNode) selected; + VirtualFile src = getOrCreateSrcDirectory(project, stepNode, true); if (src == null) { return; @@ -58,7 +63,7 @@ private static void resetFile(@NotNull final Project project) { if (document != null) { resetDocument(project, document, stepNode); ProjectView.getInstance(project).refresh(); - StudyUtils.updateToolWindows(project); + StepikProjectManager.updateSelection(project); WolfTheProblemSolver.getInstance(project).clearProblems(mainFile); } } @@ -99,4 +104,14 @@ public String getActionId() { public String[] getShortcuts() { return new String[]{SHORTCUT}; } + + @Override + public void update(AnActionEvent e) { + super.update(e); + Presentation presentation = e.getPresentation(); + StudyNode selectedNode = StepikProjectManager.getSelected(e.getProject()); + boolean enabled = presentation.isEnabled(); + boolean canEnabled = (selectedNode instanceof StepNode) && (((StepNode) selectedNode).getType() == CODE); + presentation.setEnabled(enabled && canEnabled); + } } diff --git a/stepik-union/src/main/java/org/stepik/plugin/projectView/StepikDirectoryNode.java b/stepik-union/src/main/java/org/stepik/plugin/projectView/StepikDirectoryNode.java index 1b12c90b..40ecb559 100644 --- a/stepik-union/src/main/java/org/stepik/plugin/projectView/StepikDirectoryNode.java +++ b/stepik-union/src/main/java/org/stepik/plugin/projectView/StepikDirectoryNode.java @@ -6,6 +6,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDirectory; +import com.jetbrains.tmp.learning.StepikProjectManager; import com.jetbrains.tmp.learning.StudyUtils; import com.jetbrains.tmp.learning.courseFormat.StudyNode; import org.jetbrains.annotations.NotNull; @@ -69,7 +70,7 @@ public void navigate(boolean requestFocus) { StudyNode studyNode; if (virtualFile != null) { studyNode = StudyUtils.getStudyNode(myProject, virtualFile); - StudyUtils.setStudyNode(myProject, studyNode); + StepikProjectManager.setSelected(myProject, studyNode); } } } From 5a6165f5f6c08d554bcfe85d4c10be3e65a0172d Mon Sep 17 00:00:00 2001 From: meanmail Date: Sun, 19 Mar 2017 05:02:36 +0700 Subject: [PATCH 4/4] Corrected step navigation --- .../java/com/jetbrains/tmp/learning/courseFormat/Node.java | 2 +- .../plugin/actions/navigation/StepikStepNavigationAction.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/jetbrains/tmp/learning/courseFormat/Node.java b/core/src/main/java/com/jetbrains/tmp/learning/courseFormat/Node.java index bc70c584..5351b5b2 100644 --- a/core/src/main/java/com/jetbrains/tmp/learning/courseFormat/Node.java +++ b/core/src/main/java/com/jetbrains/tmp/learning/courseFormat/Node.java @@ -47,7 +47,7 @@ public abstract class Node< private StudyNode getLastNode() { List children = getChildren(); - for (int i = children.size() - 1; i > 0; i--) { + for (int i = children.size() - 1; i >= 0; i--) { C child = children.get(i); if (!child.getWasDeleted()) { return child; diff --git a/stepik-union/src/main/java/org/stepik/plugin/actions/navigation/StepikStepNavigationAction.java b/stepik-union/src/main/java/org/stepik/plugin/actions/navigation/StepikStepNavigationAction.java index 64680ac3..59034274 100644 --- a/stepik-union/src/main/java/org/stepik/plugin/actions/navigation/StepikStepNavigationAction.java +++ b/stepik-union/src/main/java/org/stepik/plugin/actions/navigation/StepikStepNavigationAction.java @@ -2,7 +2,6 @@ import com.intellij.openapi.project.Project; import com.jetbrains.tmp.learning.StepikProjectManager; -import com.jetbrains.tmp.learning.StudyUtils; import com.jetbrains.tmp.learning.courseFormat.StudyNode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,7 +16,7 @@ abstract class StepikStepNavigationAction extends StudyStepNavigationAction { @Override public void navigateStep(@NotNull final Project project) { - StudyNode currentNode = StudyUtils.getSelectedNodeInTree(project); + StudyNode currentNode = StepikProjectManager.getSelected(project); if (currentNode == null) { currentNode = StepikProjectManager.getProjectRoot(project); }