use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.
the class StudyProjectComponent method registerShortcuts.
private void registerShortcuts() {
StudyToolWindow window = StudyUtils.getStudyToolWindow(project);
if (window != null) {
List<AnAction> actionsOnToolbar = window.getActions(true);
if (actionsOnToolbar != null) {
actionsOnToolbar.stream().filter(action -> action instanceof StudyActionWithShortcut).map(action -> (StudyActionWithShortcut) action).forEach(action -> {
String id = action.getActionId();
String[] shortcuts = action.getShortcuts();
if (shortcuts != null) {
addShortcut(id, shortcuts);
}
});
} else {
logger.warn("Actions on toolbar are nulls");
}
}
}
use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.
the class StepikProjectManager method setSelected.
public void setSelected(@Nullable 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);
if (selected != null && !project.isDisposed()) {
ProjectView.getInstance(project).refresh();
VirtualFile file = project.getBaseDir().findFileByRelativePath(selected.getPath());
ProjectView.getInstance(project).select(null, file, true);
}
});
}
}
}
use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.
the class StudyProjectComponent method registerStudyToolWindow.
public void registerStudyToolWindow() {
if (!StepikProjectManager.isStepikProject(project)) {
return;
}
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
registerToolWindows(toolWindowManager);
final ToolWindow studyToolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
if (studyToolWindow != null) {
studyToolWindow.show(null);
StudyUtils.initToolWindows(project);
}
}
use of org.stepik.core.ui.StudyToolWindow in project intellij-plugins by StepicOrg.
the class StudyUtils method getStudyToolWindow.
@Nullable
static StudyToolWindow getStudyToolWindow(@NotNull final Project project) {
if (project.isDisposed()) {
return null;
}
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
if (toolWindowManager == null) {
return null;
}
ToolWindow toolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
if (toolWindow != null) {
Content[] contents = toolWindow.getContentManager().getContents();
for (Content content : contents) {
JComponent component = content.getComponent();
if (component != null && component instanceof StudyToolWindow) {
return (StudyToolWindow) component;
}
}
}
return null;
}
Aggregations