mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
hotkeys in scheduler
This commit is contained in:
parent
f461573a99
commit
d18d815571
@ -84,5 +84,22 @@
|
|||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
<version>1.11.2</version>
|
<version>1.11.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tulskiy</groupId>
|
||||||
|
<artifactId>jkeymaster</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
|
<version>1.7.13</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>snapshots-repo</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
</project>
|
</project>
|
@ -26,6 +26,8 @@ public class PauseResumeButton extends StackPane{
|
|||||||
private Image imageResume;
|
private Image imageResume;
|
||||||
private Image imageResumeOnHover;
|
private Image imageResumeOnHover;
|
||||||
|
|
||||||
|
private volatile boolean isHovering = false;
|
||||||
|
|
||||||
private List<InvalidationListener> clickListeners = new ArrayList<>();
|
private List<InvalidationListener> clickListeners = new ArrayList<>();
|
||||||
|
|
||||||
public PauseResumeButton(boolean isPaused) {
|
public PauseResumeButton(boolean isPaused) {
|
||||||
@ -44,15 +46,7 @@ public class PauseResumeButton extends StackPane{
|
|||||||
|
|
||||||
imageView.setImage(isPaused() ? imageResume : imagePause);
|
imageView.setImage(isPaused() ? imageResume : imagePause);
|
||||||
|
|
||||||
PauseResumeButton thiss = this;
|
setEventHandler(MouseEvent.MOUSE_CLICKED, event -> click());
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPaused() {
|
public boolean isPaused() {
|
||||||
@ -65,12 +59,34 @@ public class PauseResumeButton extends StackPane{
|
|||||||
|
|
||||||
|
|
||||||
private EventHandler<MouseEvent> onMouseHover =
|
private EventHandler<MouseEvent> onMouseHover =
|
||||||
t -> imageView.setImage(isPaused() ? imageResumeOnHover : imagePauseOnHover);
|
t -> {
|
||||||
|
imageView.setImage(isPaused() ? imageResumeOnHover : imagePauseOnHover);
|
||||||
|
isHovering = true;
|
||||||
|
};
|
||||||
|
|
||||||
private EventHandler<MouseEvent> onMouseHoverDone =
|
private EventHandler<MouseEvent> 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 ImageView imageView;
|
||||||
// private Image image;
|
// private Image image;
|
||||||
// private Image imageOnHover;
|
// private Image imageOnHover;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package gearth.ui.scheduler;
|
package gearth.ui.scheduler;
|
||||||
|
|
||||||
import javafx.beans.InvalidationListener;
|
import javafx.beans.InvalidationListener;
|
||||||
|
import javafx.beans.Observable;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package gearth.ui.scheduler;
|
package gearth.ui.scheduler;
|
||||||
|
|
||||||
|
import javafx.beans.InvalidationListener;
|
||||||
|
import javafx.beans.Observable;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
@ -69,11 +71,12 @@ public class ScheduleItemContainer extends GridPane {
|
|||||||
EditButton editButton = new EditButton();
|
EditButton editButton = new EditButton();
|
||||||
DeleteButton deleteButton = new DeleteButton();
|
DeleteButton deleteButton = new DeleteButton();
|
||||||
PauseResumeButton pauseResumeButton = new PauseResumeButton(item.getPausedProperty().get());
|
PauseResumeButton pauseResumeButton = new PauseResumeButton(item.getPausedProperty().get());
|
||||||
|
item.getPausedProperty().addListener(observable -> pauseResumeButton.setPaused(item.getPausedProperty().get()));
|
||||||
editButton.show();
|
editButton.show();
|
||||||
deleteButton.show();
|
deleteButton.show();
|
||||||
editButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.edit());
|
editButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.edit());
|
||||||
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.delete());
|
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);
|
HBox buttonsBox = new HBox(pauseResumeButton, editButton, deleteButton);
|
||||||
buttonsBox.setSpacing(10);
|
buttonsBox.setSpacing(10);
|
||||||
buttonsBox.setAlignment(Pos.CENTER);
|
buttonsBox.setAlignment(Pos.CENTER);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.ui.scheduler;
|
package gearth.ui.scheduler;
|
||||||
|
|
||||||
|
import com.tulskiy.keymaster.common.Provider;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
@ -10,6 +11,7 @@ import gearth.protocol.HMessage;
|
|||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
import gearth.ui.SubForm;
|
import gearth.ui.SubForm;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -101,6 +103,28 @@ public class Scheduler extends SubForm {
|
|||||||
}
|
}
|
||||||
}).start();
|
}).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) {
|
public static boolean stringIsNumber(String str) {
|
||||||
|
Loading…
Reference in New Issue
Block a user