Skip to content

Commit 2cece86

Browse files
committed
One more review round
1 parent 86072d7 commit 2cece86

4 files changed

Lines changed: 12 additions & 73 deletions

File tree

ganttproject/src/main/java/biz/ganttproject/app/Dialog.kt

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class DialogControllerSwing : DialogController {
317317

318318
override fun toggleProgress(shown: Boolean): () -> Unit {
319319
val countDown = CountDownLatch(2)
320-
GlobalScope.launch(Dispatchers.JavaFx) {
320+
FXThread.runLater {
321321
val transition = createOverlayPane(this@DialogControllerSwing.content, this@DialogControllerSwing.contentStack) {pane ->
322322
pane.center = Spinner().let {
323323
it.state = Spinner.State.WAITING
@@ -400,31 +400,8 @@ class DialogControllerSwing : DialogController {
400400
}
401401

402402
override fun removeButtonBar() {
403-
// this.buttons.clear()
404-
// this.buttonNodes.clear()
405403
this.buttonBarDisabled = true
406-
//this.buttonBar = null
407-
}
408-
409-
// private fun updateButtons(buttonBar: ButtonBar) {
410-
// buttonBar.buttons.clear()
411-
// // show details button if expandable content is present
412-
// var hasDefault = false
413-
// for (cmd in buttons) {
414-
// val button = buttonNodes.computeIfAbsent(cmd, ::createButton)
415-
// // keep only first default button
416-
// val buttonType = cmd.buttonData
417-
// button.isDefaultButton = !hasDefault && buttonType != null && buttonType.isDefaultButton
418-
// button.isCancelButton = buttonType != null && buttonType.isCancelButton
419-
// hasDefault = hasDefault || buttonType != null && buttonType.isDefaultButton
420-
// buttonBar.buttons.add(button)
421-
//
422-
// button.addEventHandler(ActionEvent.ACTION) { ae: ActionEvent ->
423-
// if (ae.isConsumed) return@addEventHandler
424-
// hide()
425-
// }
426-
// }
427-
// }
404+
}
428405

429406
private fun createButton(buttonType: ButtonType): Button {
430407
val button = Button(buttonType.text)
@@ -521,15 +498,9 @@ class DialogControllerFx(private val dialogPane: DialogPaneExt, private val dial
521498
bb.height = 5.0
522499
bb.iterations = 2
523500
}
524-
// createOverlayPane(this.content, this.stackPane) {pane ->
525-
// pane.styleClass.add("overlay")
526-
// pane.center = Label("")
527-
// pane.opacity = 0.5
528-
// }
529501
}
530502
return {
531503
Platform.runLater {
532-
// this.stackPane.children.removeIf { it.styleClass.contains("overlay") }
533504
this.content.effect = null
534505
}
535506
}

ganttproject/src/main/java/biz/ganttproject/storage/cloud/GPCloudStatusBar.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ class GPCloudStatusBar(
277277
text = STATUS_BAR_LOCALIZER.formatText("mode.onlineOnly")
278278
graphic = FontAwesomeIconView(FontAwesomeIcon.CLOUD)
279279
tooltip = Tooltip(STATUS_BAR_LOCALIZER.formatText("mode.onlineOnly.tooltip"))
280+
// TODO(dbarashev): restore offline-only mode indication
280281
//Decorator.removeAllDecorations(this)
281282
isDisable = false
282283
}

ganttproject/src/main/java/net/sourceforge/ganttproject/ProjectOpenStateMachine.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,11 @@ class ProjectOpenStateMachine(val project: IGanttProject, val scope: CoroutineSc
248248
typealias ProjectOpenStateMachineBuilder = (ProjectOpenStateMachine) -> Unit
249249

250250
/**
251-
* This class creates project open activities. A new activity is created when GanttProject opens a project
252-
* document. Listeners receive an instance of the state machine and can subscribe to the state changes
251+
* This object creates project open activities. A new activity is created when GanttProject opens a project
252+
* document. Builders receive an instance of the state machine and can subscribe to the state changes
253253
* and run the appropriate code when a state machine enters into the state they are waiting for.
254+
*
255+
* This is a singleton, so builders shall be registered wisely, just one per application run.
254256
*/
255257
object ProjectOpenActivityFactory {
256258
private val builders = mutableListOf<ProjectOpenStateMachineBuilder>()

ganttproject/src/main/java/net/sourceforge/ganttproject/gui/ProjectOpenStrategy.kt

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import com.github.michaelbull.result.Ok
3030
import com.github.michaelbull.result.Result
3131
import com.github.michaelbull.result.fold
3232
import com.google.common.collect.Lists
33-
import javafx.beans.value.ChangeListener
34-
import javafx.beans.value.ObservableValue
35-
import kotlinx.coroutines.*
36-
import kotlinx.coroutines.channels.Channel
33+
import kotlinx.coroutines.Dispatchers
34+
import kotlinx.coroutines.Runnable
35+
import kotlinx.coroutines.launch
36+
import kotlinx.coroutines.withContext
3737
import net.sourceforge.ganttproject.*
3838
import net.sourceforge.ganttproject.action.GPAction
3939
import net.sourceforge.ganttproject.action.OkAction
@@ -55,7 +55,6 @@ import org.xml.sax.SAXException
5555
import java.awt.BorderLayout
5656
import java.awt.event.ActionEvent
5757
import java.io.File
58-
import java.util.concurrent.Executors
5958
import java.util.function.Consumer
6059
import java.util.regex.Pattern
6160
import javax.swing.*
@@ -355,25 +354,7 @@ internal class ProjectOpenStrategy(
355354
}
356355
}
357356

358-
internal inner class Step4 {
359-
fun onFetchResultChange(document: Document, callback: () -> Unit) {
360-
val onlineDocument = document.asOnlineDocument()
361-
if (onlineDocument != null) {
362-
val changeListener = object : ChangeListener<FetchResult?> {
363-
override fun changed(observable: ObservableValue<out FetchResult?>?, oldFetch: FetchResult?, newFetch: FetchResult?) {
364-
println("oldFetch=${oldFetch?.actualChecksum} newFetch=${newFetch?.actualChecksum}")
365-
if (oldFetch != null && newFetch != null) {
366-
if (oldFetch.actualVersion != newFetch.actualVersion) {
367-
observable?.removeListener(this)
368-
callback()
369-
}
370-
}
371-
}
372-
}
373-
onlineDocument.fetchResultProperty.addListener(changeListener)
374-
}
375-
376-
}
357+
internal class Step4 {
377358
}
378359
companion object {
379360
val milestonesOption = DefaultEnumerationOption(
@@ -403,22 +384,6 @@ internal class CommandLineProjectOpenStrategy(
403384
private fun doOpenStartupDocument(path: String) {
404385
DOCUMENT_LOGGER.debug(">>> openStartupDocument($path)")
405386
val document: Document = documentManager.getDocument(path)
406-
// val finishChannel = Channel<Boolean>()
407-
// CoroutineScope(Executors.newSingleThreadExecutor().asCoroutineDispatcher()).launch {
408-
// try {
409-
// finishChannel.receive()
410-
// } catch (e: Document.DocumentException) {
411-
// if (!tryImportDocument(document)) {
412-
// uiFacade.showErrorDialog(e)
413-
// }
414-
// } catch (e: IOException) {
415-
// // TODO: shall we try to import a document here? when it may make sense? CSV/MPP ?
416-
// uiFacade.showErrorDialog(e)
417-
// } catch (e: Exception) {
418-
// uiFacade.showErrorDialog(e)
419-
// }
420-
//
421-
// }
422387
projectUiFacade.openProject(document, project, null).apply {
423388
stateCompleted.await {
424389
DOCUMENT_LOGGER.debug("<<< openStartupDocument($path)")

0 commit comments

Comments
 (0)