From facc5e4dfbf06f2a7cddb677c81272a9a2afcb21 Mon Sep 17 00:00:00 2001 From: Jaakko Nakaza Date: Tue, 27 Aug 2024 10:54:08 +0300 Subject: [PATCH] UI details --- .../activities/InitializationActivity.kt | 4 +++- .../cs/apluscourses/generator/APlusModuleBuilder.kt | 4 ++-- .../services/ProjectInitializationTracker.kt | 11 +++++++++++ .../apluscourses/services/exercise/ShowFeedback.kt | 3 ++- .../ui/exercise/SubmitExerciseDialog.kt | 13 +++++++++++-- .../cs/apluscourses/ui/module/ModuleRenderer.kt | 4 ++++ .../cs/apluscourses/ui/overview/OverviewView.kt | 4 +++- src/main/resources/messages/resources.properties | 1 + 8 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/fi/aalto/cs/apluscourses/activities/InitializationActivity.kt b/src/main/kotlin/fi/aalto/cs/apluscourses/activities/InitializationActivity.kt index ea00d299d..f59ee22e2 100644 --- a/src/main/kotlin/fi/aalto/cs/apluscourses/activities/InitializationActivity.kt +++ b/src/main/kotlin/fi/aalto/cs/apluscourses/activities/InitializationActivity.kt @@ -66,7 +66,9 @@ internal class InitializationActivity() : ) { val moduleModel = course.getComponentIfExists(module.name) if (moduleModel is fi.aalto.cs.apluscourses.model.component.Module) { - moduleModel.loadToProject() + DumbService.getInstance(project).runWhenSmart { + moduleModel.loadToProject() + } } } CourseManager.getInstance(project).refreshModuleStatuses() diff --git a/src/main/kotlin/fi/aalto/cs/apluscourses/generator/APlusModuleBuilder.kt b/src/main/kotlin/fi/aalto/cs/apluscourses/generator/APlusModuleBuilder.kt index f10fcac79..ab4491a09 100644 --- a/src/main/kotlin/fi/aalto/cs/apluscourses/generator/APlusModuleBuilder.kt +++ b/src/main/kotlin/fi/aalto/cs/apluscourses/generator/APlusModuleBuilder.kt @@ -197,7 +197,7 @@ internal class APlusModuleBuilder : ModuleBuilder() { inner class CourseSettingsStep( val wizardContext: WizardContext ) : ModuleWizardStep() { - private var mainPanel = panel {} + private var mainPanel = JBScrollPane() private val selectedLanguage = AtomicProperty("") private val dontImportSettings = AtomicProperty(false) private var selectedSdk: AtomicProperty? = null @@ -209,7 +209,7 @@ internal class APlusModuleBuilder : ModuleBuilder() { @NonNls val finnishCode = "fi" if (languages.contains(finnishCode)) selectedLanguage.set(finnishCode) else selectedLanguage.set(languages.first()) - mainPanel = panel { + mainPanel = JBScrollPane(panel { panel { group(message("generator.APlusModuleBuilder.language")) { row { diff --git a/src/main/kotlin/fi/aalto/cs/apluscourses/services/ProjectInitializationTracker.kt b/src/main/kotlin/fi/aalto/cs/apluscourses/services/ProjectInitializationTracker.kt index 43408990e..2b2c1a82d 100644 --- a/src/main/kotlin/fi/aalto/cs/apluscourses/services/ProjectInitializationTracker.kt +++ b/src/main/kotlin/fi/aalto/cs/apluscourses/services/ProjectInitializationTracker.kt @@ -2,9 +2,11 @@ package fi.aalto.cs.apluscourses.services import com.intellij.openapi.components.Service import com.intellij.openapi.project.Project +import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.launch @Service(Service.Level.PROJECT) class ProjectInitializationTracker(val project: Project, val cs: CoroutineScope) { @@ -14,6 +16,15 @@ class ProjectInitializationTracker(val project: Project, val cs: CoroutineScope) initializationTasks.add(task) } + fun addInitializationTask(task: suspend () -> Unit) { + val deferred = CompletableDeferred() + initializationTasks.add(deferred) + cs.launch { + task() + deferred.complete(true) + } + } + suspend fun waitForAllTasks() { initializationTasks.awaitAll() } diff --git a/src/main/kotlin/fi/aalto/cs/apluscourses/services/exercise/ShowFeedback.kt b/src/main/kotlin/fi/aalto/cs/apluscourses/services/exercise/ShowFeedback.kt index ed7a73076..21d168c8c 100644 --- a/src/main/kotlin/fi/aalto/cs/apluscourses/services/exercise/ShowFeedback.kt +++ b/src/main/kotlin/fi/aalto/cs/apluscourses/services/exercise/ShowFeedback.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.impl.HTMLEditorProvider.Companion.openEditor import com.intellij.openapi.project.Project import com.intellij.ui.JBColor +import com.intellij.ui.jcef.JBCefScrollbarsHelper import com.intellij.util.ui.JBFont import fi.aalto.cs.apluscourses.MyBundle.message import fi.aalto.cs.apluscourses.api.APlusApi @@ -76,7 +77,7 @@ class ShowFeedback( .replace(Regex("(--font-name:\\s*)(.*;)"), "$1\"$fontName\";"), Safelist.none() ) - }" + }${JBCefScrollbarsHelper.buildScrollbarsStyle()}" document.head().append(style) diff --git a/src/main/kotlin/fi/aalto/cs/apluscourses/ui/exercise/SubmitExerciseDialog.kt b/src/main/kotlin/fi/aalto/cs/apluscourses/ui/exercise/SubmitExerciseDialog.kt index aedb652cb..3ce1687bf 100644 --- a/src/main/kotlin/fi/aalto/cs/apluscourses/ui/exercise/SubmitExerciseDialog.kt +++ b/src/main/kotlin/fi/aalto/cs/apluscourses/ui/exercise/SubmitExerciseDialog.kt @@ -80,10 +80,19 @@ class SubmitExerciseDialog( } } row { - text(message("ui.SubmitExerciseDialog.description", submissionNumber, exercise.maxSubmissions)) + text( + if (exercise.maxSubmissions < 1) message( + "ui.SubmitExerciseDialog.descriptionOptional", + submissionNumber + ) else message( + "ui.SubmitExerciseDialog.description", + submissionNumber, + exercise.maxSubmissions + ) + ) } row { - if (submissionNumber >= exercise.maxSubmissions) { + if (!exercise.isOptional && submissionNumber >= exercise.maxSubmissions) { text( if (submissionNumber == exercise.maxSubmissions) message("ui.SubmitExerciseDialog.warning.lastSubmission") else message("ui.SubmitExerciseDialog.warning.submissionsExceeded") diff --git a/src/main/kotlin/fi/aalto/cs/apluscourses/ui/module/ModuleRenderer.kt b/src/main/kotlin/fi/aalto/cs/apluscourses/ui/module/ModuleRenderer.kt index a13421414..74b8477f6 100644 --- a/src/main/kotlin/fi/aalto/cs/apluscourses/ui/module/ModuleRenderer.kt +++ b/src/main/kotlin/fi/aalto/cs/apluscourses/ui/module/ModuleRenderer.kt @@ -22,6 +22,7 @@ import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import fi.aalto.cs.apluscourses.MyBundle.message import fi.aalto.cs.apluscourses.icons.CoursesIcons +import fi.aalto.cs.apluscourses.model.component.Component import fi.aalto.cs.apluscourses.model.component.Module import fi.aalto.cs.apluscourses.services.CoursesClient import fi.aalto.cs.apluscourses.services.Opener @@ -144,6 +145,9 @@ class ModuleRenderer( } private fun Panel.available() { + if (module.status == Component.Status.LOADING) { + installing.set(true) + } row { info(zipSizeText.get()) .bindText(zipSizeText) diff --git a/src/main/kotlin/fi/aalto/cs/apluscourses/ui/overview/OverviewView.kt b/src/main/kotlin/fi/aalto/cs/apluscourses/ui/overview/OverviewView.kt index db92c8adc..22b73c9c8 100644 --- a/src/main/kotlin/fi/aalto/cs/apluscourses/ui/overview/OverviewView.kt +++ b/src/main/kotlin/fi/aalto/cs/apluscourses/ui/overview/OverviewView.kt @@ -49,6 +49,7 @@ class OverviewView(private val project: Project) : SimpleToolWindowPanel(true, t val content = JBScrollPane(panel) content.horizontalScrollBarPolicy = if (isMainPanel) ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED else ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER + content.verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED setContent(content) } @@ -267,7 +268,8 @@ class OverviewView(private val project: Project) : SimpleToolWindowPanel(true, t } }.customize(UnscaledGaps(16, 32, 16, 32)) } - mainPanel.preferredSize = Dimension(mainPanelMaxWidth, Int.MAX_VALUE) + mainPanel.preferredSize = Dimension(mainPanelMaxWidth, mainPanel.preferredSize.height) +// mainPanel.maximumSize = Dimension(mainPanelMaxWidth, Int.MAX_VALUE) return mainPanel } diff --git a/src/main/resources/messages/resources.properties b/src/main/resources/messages/resources.properties index 76851f072..f8e58ee1d 100755 --- a/src/main/resources/messages/resources.properties +++ b/src/main/resources/messages/resources.properties @@ -119,6 +119,7 @@ ui.SubmitExerciseDialog.group=Group: ui.SubmitExerciseDialog.groupDefaultButton=Set as Default ui.SubmitExerciseDialog.cantChangeGroup=You cannot change the group after submitting. ui.SubmitExerciseDialog.description=You are about to make submission {0} out of {1}. +ui.SubmitExerciseDialog.descriptionOptional=You are about to make submission {0}. ui.SubmitExerciseDialog.warning.lastSubmission=This is your last available submission for this assignment. Make sure to test your solution thoroughly before submitting. If needed, discuss any remaining issues with the course staff. ui.SubmitExerciseDialog.warning.submissionsExceeded=You have already used up all your submission attempts for this assignment. You can still submit, but further submissions won't count towards your point total. # Module