diff --git a/G-Earth/pom.xml b/G-Earth/pom.xml
index 7a5099e..4d6acdd 100644
--- a/G-Earth/pom.xml
+++ b/G-Earth/pom.xml
@@ -84,5 +84,22 @@
jsoup
1.11.2
+
+ com.github.tulskiy
+ jkeymaster
+ 1.2
+
+
+ org.slf4j
+ slf4j-jdk14
+ 1.7.13
+
+
+
+
+ snapshots-repo
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
\ No newline at end of file
diff --git a/G-Earth/src/main/java/gearth/ui/buttons/PauseResumeButton.java b/G-Earth/src/main/java/gearth/ui/buttons/PauseResumeButton.java
index 4416aed..c107334 100644
--- a/G-Earth/src/main/java/gearth/ui/buttons/PauseResumeButton.java
+++ b/G-Earth/src/main/java/gearth/ui/buttons/PauseResumeButton.java
@@ -26,6 +26,8 @@ public class PauseResumeButton extends StackPane{
private Image imageResume;
private Image imageResumeOnHover;
+ private volatile boolean isHovering = false;
+
private List clickListeners = new ArrayList<>();
public PauseResumeButton(boolean isPaused) {
@@ -44,15 +46,7 @@ public class PauseResumeButton extends StackPane{
imageView.setImage(isPaused() ? imageResume : imagePause);
- PauseResumeButton thiss = this;
- setEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
- thiss.isPaused[0] = !thiss.isPaused[0];
- imageView.setImage(isPaused() ? imageResumeOnHover : imagePauseOnHover);
-
- for (int i = clickListeners.size() - 1; i >= 0; i--) {
- clickListeners.get(i).invalidated(null);
- }
- });
+ setEventHandler(MouseEvent.MOUSE_CLICKED, event -> click());
}
public boolean isPaused() {
@@ -65,12 +59,34 @@ public class PauseResumeButton extends StackPane{
private EventHandler onMouseHover =
- t -> imageView.setImage(isPaused() ? imageResumeOnHover : imagePauseOnHover);
+ t -> {
+ imageView.setImage(isPaused() ? imageResumeOnHover : imagePauseOnHover);
+ isHovering = true;
+ };
private EventHandler onMouseHoverDone =
- t -> imageView.setImage(isPaused() ? imageResume : imagePause);
+ t -> {
+ imageView.setImage(isPaused() ? imageResume : imagePause);
+ isHovering = false;
+ };
+ public void setPaused(boolean paused) {
+ isPaused[0] = paused;
+
+
+ imageView.setImage(isPaused() ?
+ (isHovering ? imageResumeOnHover : imageResume) :
+ (isHovering ? imagePauseOnHover : imagePause)
+ );
+ }
+
+ private void click() {
+ for (int i = clickListeners.size() - 1; i >= 0; i--) {
+ clickListeners.get(i).invalidated(null);
+ }
+ }
+
// private ImageView imageView;
// private Image image;
// private Image imageOnHover;
diff --git a/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItem.java b/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItem.java
index 4fd1321..1fc5aba 100644
--- a/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItem.java
+++ b/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItem.java
@@ -1,6 +1,7 @@
package gearth.ui.scheduler;
import javafx.beans.InvalidationListener;
+import javafx.beans.Observable;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
diff --git a/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItemContainer.java b/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItemContainer.java
index 9e8b5fa..d9f2ceb 100644
--- a/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItemContainer.java
+++ b/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItemContainer.java
@@ -1,5 +1,7 @@
package gearth.ui.scheduler;
+import javafx.beans.InvalidationListener;
+import javafx.beans.Observable;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
@@ -69,11 +71,12 @@ public class ScheduleItemContainer extends GridPane {
EditButton editButton = new EditButton();
DeleteButton deleteButton = new DeleteButton();
PauseResumeButton pauseResumeButton = new PauseResumeButton(item.getPausedProperty().get());
+ item.getPausedProperty().addListener(observable -> pauseResumeButton.setPaused(item.getPausedProperty().get()));
editButton.show();
deleteButton.show();
editButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.edit());
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.delete());
- pauseResumeButton.onClick(observable -> item.getPausedProperty().set(pauseResumeButton.isPaused()));
+ pauseResumeButton.onClick(observable -> item.getPausedProperty().set(!pauseResumeButton.isPaused()));
HBox buttonsBox = new HBox(pauseResumeButton, editButton, deleteButton);
buttonsBox.setSpacing(10);
buttonsBox.setAlignment(Pos.CENTER);
diff --git a/G-Earth/src/main/java/gearth/ui/scheduler/Scheduler.java b/G-Earth/src/main/java/gearth/ui/scheduler/Scheduler.java
index 246b2ef..f646366 100644
--- a/G-Earth/src/main/java/gearth/ui/scheduler/Scheduler.java
+++ b/G-Earth/src/main/java/gearth/ui/scheduler/Scheduler.java
@@ -1,5 +1,6 @@
package gearth.ui.scheduler;
+import com.tulskiy.keymaster.common.Provider;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.scene.control.*;
@@ -10,6 +11,7 @@ import gearth.protocol.HMessage;
import gearth.protocol.HPacket;
import gearth.ui.SubForm;
+import javax.swing.*;
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
@@ -101,6 +103,28 @@ public class Scheduler extends SubForm {
}
}).start();
+
+
+ //register hotkeys
+ //disable some output things
+ PrintStream err = System.err;
+ System.setErr(new PrintStream(new OutputStream() {
+ public void write(int b) {
+ }
+ }));
+
+ Provider provider = Provider.getCurrentProvider(false);
+ for (int i = 0; i < 10; i++) {
+ int[] ii = {i};
+ provider.register(KeyStroke.getKeyStroke("control shift " + ii[0]), hotKey -> switchPauseHotkey(ii[0]));
+ }
+ System.setErr(err);
+ }
+
+ private void switchPauseHotkey(int index) {
+ if (cbx_hotkeys.isSelected() && index < scheduleItemList.size()) {
+ scheduleItemList.get(index).getPausedProperty().set(!scheduleItemList.get(index).getPausedProperty().get());
+ }
}
public static boolean stringIsNumber(String str) {