Skip to content

Commit

Permalink
Fix bugs and prepare refactoring course (#100)
Browse files Browse the repository at this point in the history
* [ML4SE-343] New directory

* [ML4SE-343] Changed plugin description. Added possibility to send files from the plugin directory.

* [ML4SE-343] Changed assistant directory.

* [ML4SE-372] Fixed recursive scenario problems, resolved conflicts with filenames, fixed problem with file sending.

* [ML4SE-372] Added timeout for the sendFile function.

* [ML4SE-516] fix some bugs and prepare refactoring course
  • Loading branch information
mikrise2 authored Mar 13, 2024
1 parent 7a51b85 commit c9e66e1
Show file tree
Hide file tree
Showing 9 changed files with 404 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ inline fun <reified T : BaseConfig> buildBaseConfig(
require(config == null) {
"The ${config?.configName} config was already parsed"
}
logger.info("Building ${config?.configName} config...")
return configBuilder(configFile)
return configBuilder(configFile).also {
logger.info("Building ${it.configName} config...")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import java.io.File

object FileRequests {

private val client = HttpClient(CIO)
private val client = HttpClient(CIO) {
install(HttpTimeout)
}
private val logger: Logger = Logger.getInstance(FileRequests::class.java)
private const val TIMEOUT: Long = 15_000 // 15 seconds
private const val TIMEOUT: Long = 120_000 // 2 minutes

@Suppress("TooGenericExceptionCaught")
@Suppress("TooGenericExceptionCaught", "ReturnCount")
suspend fun sendFile(file: File, logFileType: String): Boolean {
if (!file.exists() || file.length() == 0L) {
return true
}
try {
val researchId = GlobalPluginStorage.currentResearchId
?: error("ResearchId is undefined")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class MainPluginPanelFactory : ToolWindowFactory {
mainWindow = project.getService(MainWindowService::class.java).mainWindow
trackingService = project.getService(TrackingService::class.java)
mainWindow.jComponent.size = JBUI.size(toolWindow.component.width, toolWindow.component.height)
mainWindow.onError {
nextButton.text = UIBundle.message("ui.button.welcome")
setNextAction { agreementAcceptance() }
}
agreementAcceptance()
val buttonPanel = JBPanel<JBPanel<*>>(FlowLayout()).apply {
add(backButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import org.intellij.lang.annotations.Language
import org.jetbrains.concurrency.Promise
import org.jetbrains.research.tasktracker.ui.main.panel.models.LinkType
import org.jetbrains.research.tasktracker.ui.main.panel.models.Theme
import org.jetbrains.research.tasktracker.ui.main.panel.template.DefaultErrorPage
import org.jetbrains.research.tasktracker.ui.main.panel.template.HtmlTemplate
import org.jetbrains.research.tasktracker.ui.main.panel.template.MainPageTemplate
import org.jetbrains.research.tasktracker.ui.main.panel.template.ServerErrorPage
import javax.swing.JComponent

class MainPluginWindow(service: MainWindowService) {
Expand All @@ -28,9 +28,6 @@ class MainPluginWindow(service: MainWindowService) {

init {
windowBrowser.jbCefClient.setProperty(JBCefClient.Properties.JS_QUERY_POOL_SIZE, JS_QUERY_POOL_SIZE)
windowBrowser.setErrorPage { errorCode, errorText, failedUrl ->
DefaultErrorPage(errorCode.code.toString(), errorText, failedUrl).htmlContent
}
loadHtmlTemplate(currentTemplate)
val app = ApplicationManager.getApplication().messageBus
app.connect().subscribe(
Expand All @@ -46,6 +43,13 @@ class MainPluginWindow(service: MainWindowService) {
Disposer.register(service, windowBrowser)
}

fun onError(action: () -> Unit) {
windowBrowser.setErrorPage { errorCode, errorText, failedUrl ->
action.invoke()
ServerErrorPage().htmlContent
}
}

private fun getJsElementByIdCommand(elementId: String) = "document.getElementById('$elementId')"

fun getElementValue(elementId: String): Promise<JsExpressionResult> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fun Panel.agreementAcceptance() {
project,
UIBundle.message("ui.connection.lose")
)
return@runOnSuccess
}
}
GlobalPluginStorage.currentResearchId = IdRequests.getResearchId()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
agreements:
- text: |
Multiline
example
required: false
- text: "Example <a href=\"https://github.com/JetBrains-Research/tasktracker-3\">link</a>"
- text: "Example link in JCEF <a href=\"https://github.com/JetBrains-Research/tasktracker-3\">link</a>"
openLinkInDefaultBrowser: false
- text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,"
- text: I agree to save my name and email in the taskTracker plugin database.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginName: "Kotlin Introduction"
pluginDescription: "We want to track your progress through the kotlin introduction course in order to collect data on file changes during the course completion. Please, when you are ready, press the next button."
researchId: "Kotlin Introduction"
pluginName: "Kotlin Refactoring course"
pluginDescription: "We want to track your progress through the kotlin refactoring course in order to collect data on file changes during the course completion. Please, when you are ready, press the next button."
researchId: "Kotlin Refactoring"
logs:
- logPaths:
- "edu-assistant/eduAssistant.log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defaultMessageTemplate: " No worries, though! You can still send us your tracke
Copy this link: <i>%s</i>
Open the folder using the link.
Once you're in the folder, please send us all its files.
Once you're in the folder, please send us all files in this folder
to the email [email protected].
We appreciate your assistance!"
Loading

0 comments on commit c9e66e1

Please sign in to comment.