Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions biz.ganttproject.core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.+'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.10.+'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.10.+'
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
api "com.google.guava:guava:31.+"
api "com.michael-bull.kotlin-result:kotlin-result:2.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import net.fortuna.ical4j.data.ParserException;
import net.sourceforge.ganttproject.GPLogger;
import net.sourceforge.ganttproject.calendar.CalendarEditorPanel;
import net.sourceforge.ganttproject.gui.UIFacade;
import net.sourceforge.ganttproject.gui.projectwizard.WizardPage;
import net.sourceforge.ganttproject.importer.ImporterBase;
import net.sourceforge.ganttproject.wizard.AbstractWizard;
import net.sourceforge.ganttproject.wizard.WizardPage;

import javax.swing.*;
import java.io.*;
Expand All @@ -43,11 +43,11 @@
public class IcsFileImporter extends ImporterBase {
private static final LoggerApi LOGGER = GPLogger.create("Import.Ics");
private static final DefaultLocalizer ourLocalizer = InternationalizationKt.getRootLocalizer();
private final CalendarEditorPage myEditorPage;
private CalendarEditorPage myEditorPage;

public IcsFileImporter() {
super("impex.ics");
myEditorPage = new CalendarEditorPage();
myEditorPage = null;
}

@Override
Expand All @@ -57,20 +57,23 @@ public String getFileNamePattern() {

@Override
public void run() {
getUiFacade().getUndoManager().undoableEdit(ourLocalizer.formatText("importCalendar"), new Runnable() {
@Override
public void run() {
// getUiFacade().getUndoManager().undoableEdit(ourLocalizer.formatText("importCalendar"), new Runnable() {
// @Override
// public void run() {
List<CalendarEvent> events = myEditorPage.getEvents();
if (events != null) {
getProject().getActiveCalendar().setPublicHolidays(events);
}
}
});
// }
// });
}


@Override
public WizardPage getCustomPage() {
if (myEditorPage == null) {
myEditorPage = new CalendarEditorPage(getUiFacade());
}
return myEditorPage;
}

Expand All @@ -92,9 +95,15 @@ public void setFile(File file) {
* Calendar editor page which wraps a {@link CalendarEditorPanel} instance
*/
static class CalendarEditorPage implements WizardPage {
private final UIFacade myUiFacade;
private File myFile;
private final JPanel myPanel = new JPanel();
private List<CalendarEvent> myEvents;

public CalendarEditorPage(UIFacade uiFacade) {
myUiFacade = uiFacade;
}

private void setFile(File f) {
myFile = f;
}
Expand All @@ -112,12 +121,13 @@ public JComponent getComponent() {
return myPanel;
}

public void setActive(AbstractWizard wizard) {
if (wizard != null) {
@Override
public void setActive(boolean b) {
if (b) {
myPanel.removeAll();
if (myFile != null && myFile.exists() && myFile.canRead()) {
if (myEvents != null) {
myPanel.add(new CalendarEditorPanel(wizard.getUIFacade(), myEvents, null).createComponent());
myPanel.add(new CalendarEditorPanel(myUiFacade, myEvents, null).createComponent());
return;
} else {
LOGGER.error("No events found in file {}", new Object[]{myFile}, Collections.emptyMap(), null);
Expand Down
4 changes: 2 additions & 2 deletions cloud.ganttproject.colloboque/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ repositories {
}

dependencies {
implementation("biz.ganttproject:biz.ganttproject.core:25.+")
implementation("biz.ganttproject:ganttproject:25.+")
implementation("biz.ganttproject:biz.ganttproject.core:26.+")
implementation("biz.ganttproject:ganttproject:26.+")
implementation("org.slf4j:slf4j-api:2.0.16")
implementation("ch.qos.logback:logback-classic:1.5.6")
implementation("org.slf4j:jul-to-slf4j:2.0.13")
Expand Down
43 changes: 23 additions & 20 deletions ganttproject/src/main/java/biz/ganttproject/FXUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,34 +245,37 @@ object FXUtil {
}
}
*/
fun transitionNode(node: Node, replacePane: ()->Unit, resizer: ()->Unit) {
val fadeIn = FadeTransition(Duration.seconds(0.5), node)
fadeIn.fromValue = 0.0
fadeIn.toValue = 1.0

val fadeOut = FadeTransition(Duration.seconds(0.5), node)
fadeOut.fromValue = 1.0
fadeOut.toValue = 0.1
fadeOut.play()
//Exception("Fade out! ").printStackTrace()
fadeOut.setOnFinished {
//Exception("Fade in!").printStackTrace()
replacePane()
fadeIn.setOnFinished {
//borderPane.requestLayout()
resizer()
}
fadeIn.play()
}
}
fun transitionCenterPane(borderPane: BorderPane, newCenter: javafx.scene.Node?, resizer: () -> Unit) {
if (newCenter == null) { return }
val replacePane = Runnable {
val replacePane = {
borderPane.center = newCenter
//resizer()
}
if (borderPane.center == null) {
replacePane.run()
replacePane()
resizer()
} else {
val fadeIn = FadeTransition(Duration.seconds(0.5), borderPane)
fadeIn.fromValue = 0.0
fadeIn.toValue = 1.0

val fadeOut = FadeTransition(Duration.seconds(0.5), borderPane)
fadeOut.fromValue = 1.0
fadeOut.toValue = 0.1
fadeOut.play()
//Exception("Fade out! ").printStackTrace()
fadeOut.setOnFinished {
//Exception("Fade in!").printStackTrace()
replacePane.run()
fadeIn.setOnFinished {
borderPane.requestLayout()
resizer()
}
fadeIn.play()
}
transitionNode(borderPane, replacePane, resizer)
}
}
}
Expand Down
85 changes: 81 additions & 4 deletions ganttproject/src/main/java/biz/ganttproject/app/Dialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ package biz.ganttproject.app

import biz.ganttproject.FXUtil
import biz.ganttproject.centerOnOwner
import biz.ganttproject.colorFromUiManager
import biz.ganttproject.lib.fx.VBoxBuilder
import biz.ganttproject.printCss
import biz.ganttproject.walkTree
import com.sandec.mdfx.MDFXNode
import javafx.animation.FadeTransition
import javafx.animation.ParallelTransition
import javafx.animation.Transition
import javafx.application.Platform
import javafx.embed.swing.SwingNode
import javafx.event.ActionEvent
import javafx.event.EventHandler
import javafx.geometry.Insets
import javafx.scene.Node
import javafx.scene.Parent
import javafx.scene.control.*
Expand All @@ -51,6 +55,7 @@ import net.sourceforge.ganttproject.gui.UIFacade
import java.util.Stack
import java.util.concurrent.CountDownLatch
import javax.swing.SwingUtilities
import kotlin.math.max

/**
* Some utility code for building nice dialogs. Provides the following features:
Expand Down Expand Up @@ -88,6 +93,7 @@ fun dialogFxBuild(owner: Window? = null, id: String? = null, contentBuilder: (Di
dialogPane.stylesheets.addAll(DIALOG_STYLESHEET)
dialogBuildApi.setEscCloseEnabled(true)
contentBuilder(dialogBuildApi)

when (dialogBuildApi.frameStyle) {
FrameStyle.NATIVE_FRAME -> initStyle(StageStyle.DECORATED)
FrameStyle.NO_FRAME -> initStyle(StageStyle.UNDECORATED)
Expand Down Expand Up @@ -127,6 +133,7 @@ fun dialogFxBuild(owner: Window? = null, id: String? = null, contentBuilder: (Di
}

class DialogPaneExt : DialogPane() {
lateinit var buttonBar: HBox
private lateinit var errorPaneWrapper: StackPane

fun setButtonBarNode(node: Node) {
Expand All @@ -137,16 +144,21 @@ class DialogPaneExt : DialogPane() {
errorPaneWrapper.isManaged = true
}
override fun createButtonBar(): Node {
val buttonBar = StackPane(super.createButtonBar())
val buttonBar = StackPane(super.createButtonBar()).also {
it.minWidth = Region.USE_PREF_SIZE
}
errorPaneWrapper = StackPane().also {
it.styleClass.addAll("swing-background", "hide")
it.styleClass.addAll("hide")
it.isManaged = false
}
return HBox().apply {
styleClass.addAll("button-pane", "swing-background")
styleClass.addAll("button-pane")
minWidth = Region.USE_PREF_SIZE
HBox.setHgrow(buttonBar, Priority.ALWAYS)
HBox.setHgrow(errorPaneWrapper, Priority.SOMETIMES)
children.addAll(errorPaneWrapper, buttonBar)
}.also {
this.buttonBar = it
}
}
}
Expand Down Expand Up @@ -431,7 +443,9 @@ class DialogControllerFx(private val dialogPane: DialogPaneExt, private val dial
}
}
override var onClosed: () -> Unit = {}
private val stackPane = StackPane().also { it.styleClass.add("layers") }
private val stackPane = StackPane().also {
it.styleClass.add("layers")
}
private var content: Node = Region()
private var cancelAction: CancelAction? = null

Expand Down Expand Up @@ -497,6 +511,8 @@ class DialogControllerFx(private val dialogPane: DialogPaneExt, private val dial
}

override fun resize() {
dialogPane.minWidth = dialogPane.width
dialogPane.buttonBar.minWidth = max(dialogPane.buttonBar.minWidth, dialogPane.width)
dialogPane.layout()
dialogPane.scene?.window?.sizeToScene()
}
Expand Down Expand Up @@ -746,4 +762,65 @@ object DialogPlacement {
}

const val DIALOG_STYLESHEET = "/biz/ganttproject/app/Dialog.css"
private val SWING_BACKGROUND_STYLES = setOf("tab-header-background", "tab-contents", "swing-background")
fun DialogController.setSwingBackground() {
val background = Background(
BackgroundFill(
"Panel.background".colorFromUiManager(), CornerRadii.EMPTY, Insets.EMPTY
)
)

walkTree {
if (it is Region && it.styleClass.intersect(SWING_BACKGROUND_STYLES).isNotEmpty()) {
it.background = background
}
}
}

fun main() {
class PureFxTestApp : javafx.application.Application() {
override fun start(primaryStage: javafx.stage.Stage) {
val btnOpen = Button("Open Pure JavaFX Dialog")
btnOpen.onAction = EventHandler {
val dialog = Dialog<Unit>()
dialog.title = "Pure JavaFX Layout Test"

val pane = object : DialogPane() {
override fun createButtonBar(): Node {
// This mimics the structure in DialogPaneExt
val buttonBar = super.createButtonBar()
val errorPaneWrapper = StackPane().apply {
isManaged = false
isVisible = false
}
return HBox(10.0).apply {
styleClass.add("button-pane")
HBox.setHgrow(buttonBar, Priority.ALWAYS)
children.addAll(errorPaneWrapper, buttonBar)
}
}
}

// pane.content = Label("This dialog uses pure JavaFX components.\nCheck if the buttons below are clipped.").apply {
// padding = Insets(20.0)
//// minWidth = 200.0
// }
pane.content = StackPane()//SwingNode()

pane.buttonTypes.addAll(
ButtonType.OK,
ButtonType.APPLY,
ButtonType.CANCEL,
ButtonType("Very Long Button Label")
)

dialog.dialogPane = pane
dialog.showAndWait()
}

primaryStage.scene = javafx.scene.Scene(StackPane(btnOpen), 300.0, 200.0)
primaryStage.show()
}
}
javafx.application.Application.launch(PureFxTestApp::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ class StorageDialogBuilder(
}

fun build(mode: Mode) {
dialogBuildApi.addStyleClass("dlg-storage")
dialogBuildApi.addStyleClass("dlg", "dlg-storage")
dialogBuildApi.addStyleSheet("/biz/ganttproject/app/Dialog.css")
dialogBuildApi.addStyleSheet("/biz/ganttproject/storage/StorageDialog.css")
dialogBuildApi.addStyleSheet("/biz/ganttproject/storage/StorageDialog2.css")
dialogBuildApi.removeButtonBar()
dialogBuildApi.setEscCloseEnabled(true)
dialogBuildApi.onShown = {
dialogBuildApi.resize()
}

val contentPane = BorderPane()
contentPane.styleClass.addAll("body", "pane-storage")
Expand Down
Loading