Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

65 change jfoenix to controlsfx #70

Merged
merged 3 commits into from
Jun 18, 2024
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
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>9.0.10</version>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.2.0</version>
</dependency>

<dependency>
<groupId>eu.mihosoft.monacofx</groupId>
<artifactId>monacofx</artifactId>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package com.JayPi4c.RobbiSimulator.controller;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.List;

import com.JayPi4c.RobbiSimulator.model.RobbiException;
import com.JayPi4c.RobbiSimulator.model.Territory;
import com.JayPi4c.RobbiSimulator.utils.AlertHelper;
import com.JayPi4c.RobbiSimulator.utils.I18nUtils;
import com.JayPi4c.RobbiSimulator.utils.annotations.Default;
import com.JayPi4c.RobbiSimulator.view.MainStage;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Alert.AlertType;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.List;

/**
* MethodHandler to handle a methods invocation
*
Expand Down Expand Up @@ -71,7 +70,7 @@ public void handle(ActionEvent event) {
e.printStackTrace();
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RobbiException) {
parent.getSnackbarController().showMessage(e.getCause().getLocalizedMessage());
parent.getNotificationController().showMessage(3000, e.getCause().getLocalizedMessage());
} else {
AlertHelper.showAlertAndWait(AlertType.ERROR, e.getCause().getMessage(), parent);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.JayPi4c.RobbiSimulator.controller;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.util.Duration;
import lombok.extern.slf4j.Slf4j;
import org.controlsfx.control.NotificationPane;

import static com.JayPi4c.RobbiSimulator.utils.I18nUtils.i18n;

@Slf4j
public class NotificationController {

private final NotificationPane notificationPane;
private final Timeline hideTimeline = new Timeline();

public NotificationController(Node node) {
notificationPane = new NotificationPane(node);
notificationPane.setShowFromTop(false);
notificationPane.getStyleClass().add(NotificationPane.STYLE_CLASS_DARK);
hideTimeline.setCycleCount(1);
}

public Parent getScene() {
return notificationPane;
}

/**
* Shows a message in a notification pane. The message will be shown for the given timeout in milliseconds.
* If a message is already shown, it will be replaced by the new message and the timeout will be reset.
*
* @param timeout in milliseconds
* @param key the key of the message
* @param args the arguments for the message
*/
public void showMessage(int timeout, String key, Object... args) {
hideTimeline.stop();
notificationPane.show(i18n(key, args));
KeyFrame kf = new KeyFrame(Duration.millis(timeout), e -> {
if (notificationPane.isShowing())
notificationPane.hide();
});
hideTimeline.getKeyFrames().setAll(kf);
hideTimeline.play();
}

}

This file was deleted.

Loading