-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6752c35
commit 6589f8e
Showing
31 changed files
with
916 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/fi/aalto/cs/apluscourses/intellij/actions/OpenExerciseItemAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package fi.aalto.cs.apluscourses.intellij.actions; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import fi.aalto.cs.apluscourses.intellij.notifications.Notifier; | ||
import fi.aalto.cs.apluscourses.intellij.services.MainViewModelProvider; | ||
import fi.aalto.cs.apluscourses.model.ExercisesTree; | ||
import fi.aalto.cs.apluscourses.model.UrlRenderer; | ||
import fi.aalto.cs.apluscourses.presentation.base.BaseTreeViewModel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class OpenExerciseItemAction extends OpenItemAction<ExercisesTree> { | ||
|
||
public static final String ACTION_ID = OpenExerciseItemAction.class.getCanonicalName(); | ||
|
||
/** | ||
* Construct an {@link OpenExerciseItemAction} instance with the given parameters. This constructor | ||
* is mainly useful for testing purposes. | ||
*/ | ||
public OpenExerciseItemAction(@NotNull MainViewModelProvider mainViewModelProvider, | ||
@NotNull UrlRenderer urlRenderer, | ||
@NotNull Notifier notifier) { | ||
super(mainViewModelProvider, urlRenderer, notifier); | ||
} | ||
|
||
/** | ||
* Construct an {@link OpenExerciseItemAction} instance with reasonable defaults. | ||
*/ | ||
public OpenExerciseItemAction() { | ||
super(); | ||
} | ||
|
||
@Override | ||
BaseTreeViewModel<ExercisesTree> getTreeViewModel(@NotNull Project project) { | ||
return mainViewModelProvider.getMainViewModel(project).exercisesViewModel.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/fi/aalto/cs/apluscourses/intellij/actions/OpenNewsItemAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package fi.aalto.cs.apluscourses.intellij.actions; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import fi.aalto.cs.apluscourses.intellij.notifications.Notifier; | ||
import fi.aalto.cs.apluscourses.intellij.services.MainViewModelProvider; | ||
import fi.aalto.cs.apluscourses.model.NewsTree; | ||
import fi.aalto.cs.apluscourses.model.UrlRenderer; | ||
import fi.aalto.cs.apluscourses.presentation.base.BaseTreeViewModel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class OpenNewsItemAction extends OpenItemAction<NewsTree> { | ||
|
||
public static final String ACTION_ID = OpenNewsItemAction.class.getCanonicalName(); | ||
|
||
/** | ||
* Construct an {@link OpenNewsItemAction} instance with the given parameters. This constructor | ||
* is mainly useful for testing purposes. | ||
*/ | ||
public OpenNewsItemAction(@NotNull MainViewModelProvider mainViewModelProvider, | ||
@NotNull UrlRenderer urlRenderer, | ||
@NotNull Notifier notifier) { | ||
super(mainViewModelProvider, urlRenderer, notifier); | ||
} | ||
|
||
/** | ||
* Construct an {@link OpenNewsItemAction} instance with reasonable defaults. | ||
*/ | ||
public OpenNewsItemAction() { | ||
super(); | ||
} | ||
|
||
@Override | ||
BaseTreeViewModel<NewsTree> getTreeViewModel(@NotNull Project project) { | ||
return mainViewModelProvider.getMainViewModel(project).newsTreeViewModel.get(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/fi/aalto/cs/apluscourses/intellij/actions/ReadAllNewsAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package fi.aalto.cs.apluscourses.intellij.actions; | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.project.DumbAwareAction; | ||
import fi.aalto.cs.apluscourses.intellij.services.MainViewModelProvider; | ||
import fi.aalto.cs.apluscourses.intellij.services.PluginSettings; | ||
import fi.aalto.cs.apluscourses.model.News; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ReadAllNewsAction extends DumbAwareAction { | ||
@NotNull | ||
private final MainViewModelProvider mainViewModelProvider; | ||
|
||
protected ReadAllNewsAction(@NotNull MainViewModelProvider mainViewModelProvider) { | ||
|
||
this.mainViewModelProvider = mainViewModelProvider; | ||
} | ||
|
||
/** | ||
* Construct an {@link OpenItemAction} instance with reasonable defaults. | ||
*/ | ||
protected ReadAllNewsAction() { | ||
this( | ||
PluginSettings.getInstance() | ||
); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
var project = e.getProject(); | ||
var mainViewModel = mainViewModelProvider.getMainViewModel(project); | ||
var newsViewModel = mainViewModel.newsTreeViewModel.get(); | ||
if (newsViewModel == null) { | ||
return; | ||
} | ||
newsViewModel.getModel().getNews().forEach(News::setRead); | ||
mainViewModel.newsTreeViewModel.valueChanged(); | ||
} | ||
|
||
@Override | ||
public void update(@NotNull AnActionEvent e) { | ||
var project = e.getProject(); | ||
var mainViewModel = mainViewModelProvider.getMainViewModel(project); | ||
e.getPresentation().setEnabled(mainViewModel.newsTreeViewModel.get() != null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.