add other tabs & implementation Scheduler

This commit is contained in:
sirjonasxx 2018-04-11 22:58:54 +02:00
parent 5c62c1d188
commit 663d759207
27 changed files with 818 additions and 10 deletions

View File

@ -758,7 +758,7 @@ public class HPacket {
if (resultTest[i] != null) expression.append(resultTest[i]);
}
return expression.toString();
return expression.toString().replace("{i:0}{b:false}{b:true}", "{s:}{i:1}");
}
public static void main(String[] args) {

View File

@ -29,10 +29,26 @@
<fx:include fx:id="tools" source="tools/Tools.fxml" />
</content>
</Tab>
<Tab disable="true" text="Scheduler" />
<Tab disable="true" text="Settings" />
<Tab disable="true" text="Extensions" />
<Tab disable="true" text="Info" />
<Tab text="Scheduler">
<content>
<fx:include fx:id="scheduler" source="scheduler/Scheduler.fxml" />
</content>
</Tab>
<Tab text="Settings">
<content>
<fx:include fx:id="settings" source="settings/Settings.fxml" />
</content>
</Tab>
<Tab text="Extensions">
<content>
<fx:include fx:id="extensions" source="extensions/Extensions.fxml" />
</content>
</Tab>
<Tab text="Info">
<content>
<fx:include fx:id="info" source="info/Info.fxml" />
</content>
</Tab>
</tabs>
</TabPane>

View File

@ -4,8 +4,12 @@ import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import main.protocol.HConnection;
import main.ui.connection.Connection;
import main.ui.extensions.Extensions;
import main.ui.info.Info;
import main.ui.injection.Injection;
import main.ui.logger.Logger;
import main.ui.scheduler.Scheduler;
import main.ui.settings.Settings;
import main.ui.tools.Tools;
public class GEarthController {
@ -17,6 +21,11 @@ public class GEarthController {
public Injection injectionController;
public Logger loggerController;
public Tools toolsController;
public Scheduler schedulerController;
public Settings settingsController;
public Info infoController;
public Extensions extensionsController;
public Pane mover;
public GEarthController() {
@ -28,6 +37,12 @@ public class GEarthController {
injectionController.setParentController(this);
loggerController.setParentController(this);
toolsController.setParentController(this);
schedulerController.setParentController(this);
settingsController.setParentController(this);
infoController.setParentController(this);
extensionsController.setParentController(this);
//custom header bar
// final Point[] startpos = {null};
// final Double[] xx = {0.0};

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.ui.extensions.Extensions">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="303.0" minWidth="10.0" prefWidth="277.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="288.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>

View File

@ -0,0 +1,9 @@
package main.ui.extensions;
import main.ui.SubForm;
/**
* Created by Jonas on 06/04/18.
*/
public class Extensions extends SubForm {
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.ui.info.Info">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="303.0" minWidth="10.0" prefWidth="277.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="288.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>

View File

@ -0,0 +1,9 @@
package main.ui.info;
import main.ui.SubForm;
/**
* Created by Jonas on 06/04/18.
*/
public class Info extends SubForm {
}

View File

@ -19,12 +19,9 @@ public class Injection extends SubForm {
public Button btn_sendToClient;
protected void onParentSet() {
getHConnection().addStateChangeListener((oldState, newState) -> Platform.runLater(() ->
updateUI()));
getHConnection().addStateChangeListener((oldState, newState) -> Platform.runLater(this::updateUI));
inputPacket.textProperty().addListener(event -> { Platform.runLater(() ->
updateUI());
});
inputPacket.textProperty().addListener(event -> Platform.runLater(this::updateUI));
}
private void updateUI() {

View File

@ -0,0 +1,56 @@
package main.ui.scheduler;
/**
* Created by Jonas on 11/04/18.
*/
public class Interval {
private int offset;
private int delay;
public Interval(int offset, int delay) {
this.offset = offset;
this.delay = delay;
}
public Interval(String interval) {
String[] split = interval.split("\\+");
if (split.length == 0 || split.length > 2) {
delay = -1;
offset = -1;
return;
}
if (!Scheduler.stringIsNumber(split[0]) || (split.length == 2 && !Scheduler.stringIsNumber(split[1]))) {
delay = -1;
offset = -1;
return;
}
delay = Integer.parseInt(split[0]);
offset = split.length == 2 ? Integer.parseInt(split[1]) : 0;
if (delay <= 0 || offset < 0 || offset > delay) {
delay = -1;
offset = -1;
}
}
public int getDelay() {
return delay;
}
public int getOffset() {
return offset;
}
public String toString() {
return delay + "+" + offset;
}
public static boolean isValid(String s) {
Interval test = new Interval(s);
return (test.delay != -1);
}
}

View File

@ -0,0 +1,93 @@
package main.ui.scheduler;
import javafx.beans.InvalidationListener;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import main.protocol.HMessage;
import main.protocol.HPacket;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Jonas on 07/04/18.
*/
public class ScheduleItem {
private SimpleIntegerProperty indexProperty;
private SimpleBooleanProperty pausedProperty;
private SimpleObjectProperty<Interval> delayProperty;
private SimpleObjectProperty<HPacket> packetProperty;
private SimpleObjectProperty<HMessage.Side> destinationProperty;
ScheduleItem (int index, boolean paused, Interval delay, HPacket packet, HMessage.Side destination) {
this.indexProperty = new SimpleIntegerProperty(index);
this.pausedProperty = new SimpleBooleanProperty(paused);
this.delayProperty = new SimpleObjectProperty<>(delay);
this.packetProperty = new SimpleObjectProperty<>(packet);
this.destinationProperty = new SimpleObjectProperty<>(destination);
}
public SimpleIntegerProperty getIndexProperty() {
return indexProperty;
}
public SimpleBooleanProperty getPausedProperty() {
return pausedProperty;
}
public SimpleObjectProperty<Interval> getDelayProperty() {
return delayProperty;
}
public SimpleObjectProperty<HPacket> getPacketProperty() {
return packetProperty;
}
public SimpleObjectProperty<HMessage.Side> getDestinationProperty() {
return destinationProperty;
}
private List<InvalidationListener> onDeleteListeners = new ArrayList<>();
public void onDelete(InvalidationListener listener) {
onDeleteListeners.add(listener);
}
public void delete() {
for (int i = onDeleteListeners.size() - 1; i >= 0; i--) {
onDeleteListeners.get(i).invalidated(null);
}
}
private List<InvalidationListener> onEditListeners = new ArrayList<>();
public void onEdit(InvalidationListener listener) {
onEditListeners.add(listener);
}
public void edit() {
for (int i = onEditListeners.size() - 1; i >= 0; i--) {
onEditListeners.get(i).invalidated(null);
}
}
private List<InvalidationListener> onIsupdatedListeners = new ArrayList<>();
public void onIsupdated(InvalidationListener listener) {
onIsupdatedListeners.add(listener);
}
public void isUpdatedTrigger() {
for (int i = onIsupdatedListeners.size() - 1; i >= 0; i--) {
onIsupdatedListeners.get(i).invalidated(null);
}
}
private List<InvalidationListener> OnIsBeingUpdatedListeners = new ArrayList<>();
public void onIsBeingUpdated(InvalidationListener listener) {
OnIsBeingUpdatedListeners.add(listener);
}
public void onIsBeingUpdatedTrigger() {
for (int i = OnIsBeingUpdatedListeners.size() - 1; i >= 0; i--) {
OnIsBeingUpdatedListeners.get(i).invalidated(null);
}
}
}

View File

@ -0,0 +1,106 @@
package main.ui.scheduler;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import main.ui.scheduler.buttons.DeleteButton;
import main.ui.scheduler.buttons.EditButton;
import main.ui.scheduler.buttons.PauseResumeButton;
/**
* Created by Jonas on 07/04/18.
*/
public class ScheduleItemContainer extends GridPane {
public static final int[] columnWidths = {10, 39, 16, 18, 15};
ScheduleItem item;
Label indexLabel;
Label packetLabel;
Label delayLabel;
Label destinationLabel;
VBox parent;
ScheduleItemContainer(ScheduleItem item, VBox parent, ScrollPane scrollPane) {
super();
setGridLinesVisible(true);
VBox.setMargin(this, new Insets(2, -2, -2, -2));
setPrefWidth(scrollPane.getWidth());
setPrefHeight(23);
scrollPane.widthProperty().addListener(observable -> setPrefWidth(scrollPane.getWidth()));
this.parent = parent;
this.item = item;
initialize();
}
private void initialize() {
RowConstraints rowConstraints = new RowConstraints(23);
getRowConstraints().addAll(rowConstraints);
for (int i = 0; i < columnWidths.length; i++) {
ColumnConstraints columnConstraints = new ColumnConstraints(20);
columnConstraints.setPercentWidth(columnWidths[i]);
getColumnConstraints().add(columnConstraints);
}
indexLabel = initNewLabelColumn(item.getIndexProperty().get()+"");
packetLabel = initNewLabelColumn(item.getPacketProperty().get().toString());
delayLabel = initNewLabelColumn(item.getDelayProperty().get()+"");
destinationLabel = initNewLabelColumn(item.getDestinationProperty().get().name());
add(indexLabel, 0, 0);
add(packetLabel, 1, 0);
add(delayLabel, 2, 0);
add(destinationLabel, 3, 0);
// getChildren().addAll(indexLabel, packetLabel, delayLabel, destinationLabel);
item.getIndexProperty().addListener(observable -> indexLabel.setText(item.getIndexProperty().get()+""));
item.getPacketProperty().addListener(observable -> packetLabel.setText(item.getPacketProperty().get().toString()));
item.getDelayProperty().addListener(observable -> delayLabel.setText(item.getDelayProperty().get()+""));
item.getDestinationProperty().addListener(observable -> destinationLabel.setText(item.getDestinationProperty().get().name()));
EditButton editButton = new EditButton();
DeleteButton deleteButton = new DeleteButton();
PauseResumeButton pauseResumeButton = new PauseResumeButton(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()));
HBox buttonsBox = new HBox(pauseResumeButton, editButton, deleteButton);
buttonsBox.setSpacing(10);
buttonsBox.setAlignment(Pos.CENTER);
GridPane.setMargin(buttonsBox, new Insets(0, 5, 0, 5));
add(buttonsBox, 4, 0);
parent.getChildren().add(this);
GridPane this2 = this;
item.onDelete(observable -> parent.getChildren().remove(this2));
item.onIsBeingUpdated(observable -> setStyle("-fx-background-color: #faebcc;"));
item.onIsupdated(observable -> setStyle("-fx-background-color: #ffffff;"));
}
private Label initNewLabelColumn(String text) {
Label label = new Label();
// label.setMaxWidth(Double.MAX_VALUE);
// label.setMinHeight(Double.MAX_VALUE);
// label.setAlignment(Pos.CENTER);
label.setFont(new Font(12));
GridPane.setMargin(label, new Insets(0, 0, 0, 5));
label.setText(text);
return label;
}
}

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.ui.scheduler.Scheduler">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="220.0" minHeight="10.0" prefHeight="183.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="185.0" minHeight="10.0" prefHeight="79.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ScrollPane fx:id="scrollpane" hbarPolicy="NEVER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-border-color: #888888; -fx-background: #FFFFFF; -fx-border-radius: 4px;" vbarPolicy="ALWAYS">
<GridPane.margin>
<Insets bottom="8.0" left="17.0" right="17.0" top="17.0" />
</GridPane.margin>
<content>
<VBox fx:id="schedulecontainer" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<children>
<GridPane fx:id="header" gridLinesVisible="true">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="163.0" minWidth="10.0" percentWidth="10.0" prefWidth="57.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="190.0" minWidth="10.0" percentWidth="39.0" prefWidth="189.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="118.0" minWidth="10.0" percentWidth="16.0" prefWidth="66.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" percentWidth="18.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" percentWidth="15.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Index" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Packet" GridPane.columnIndex="1" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Interval" GridPane.columnIndex="2" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Destination" GridPane.columnIndex="3" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Edit" GridPane.columnIndex="4" />
</children>
<VBox.margin>
<Insets bottom="-2.0" left="-2.0" right="-2.0" top="-2.0" />
</VBox.margin>
</GridPane>
</children></VBox>
</content>
</ScrollPane>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" vgap="3.0" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="349.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<GridPane.margin>
<Insets bottom="10.0" left="17.0" right="17.0" />
</GridPane.margin>
<children>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="63.0" minWidth="10.0" prefWidth="63.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="468.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="txt_packet" text="[0][0][0][2][0][0]" GridPane.columnIndex="1">
<GridPane.margin>
<Insets />
</GridPane.margin>
</TextField>
<Label maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Packet:" textFill="#000000bb">
<GridPane.margin>
<Insets left="3.0" />
</GridPane.margin>
</Label>
</children>
</GridPane>
<GridPane prefHeight="33.0" prefWidth="502.0" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="63.0" minWidth="0.0" prefWidth="63.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="488.0" minWidth="10.0" prefWidth="80.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="102.0" minWidth="10.0" prefWidth="102.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="107.0" minWidth="10.0" prefWidth="107.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="488.0" minWidth="10.0" prefWidth="181.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="txt_delay" text="500+0" GridPane.columnIndex="1">
<GridPane.margin>
<Insets right="5.0" />
</GridPane.margin>
</TextField>
<Label maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Interval:" textFill="#000000bb">
<GridPane.margin>
<Insets left="3.0" />
</GridPane.margin>
</Label>
<Button fx:id="btn_addoredit" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#scheduleBtnClicked" text="Add to scheduler" GridPane.columnIndex="4">
<GridPane.margin>
<Insets bottom="2.0" left="5.0" top="2.0" />
</GridPane.margin>
</Button>
<RadioButton fx:id="rb_incoming" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Incoming" GridPane.columnIndex="2">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
<toggleGroup>
<ToggleGroup fx:id="scheduler_dest" />
</toggleGroup></RadioButton>
<RadioButton fx:id="rb_outgoing" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Outgoing" toggleGroup="$scheduler_dest" GridPane.columnIndex="3">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin></RadioButton>
</children>
<GridPane.margin>
<Insets />
</GridPane.margin>
</GridPane>
</children>
</GridPane>
</children>
</GridPane>

View File

@ -0,0 +1,161 @@
package main.ui.scheduler;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.event.ActionEvent;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import main.protocol.HMessage;
import main.protocol.HPacket;
import main.ui.SubForm;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Jonas on 06/04/18.
*/
public class Scheduler extends SubForm {
private static final Interval defaultInterval = new Interval(0, 500);
private static final HPacket defaultPacket = new HPacket(0);
public VBox schedulecontainer;
public GridPane header;
public ScrollPane scrollpane;
public Button btn_addoredit;
public TextField txt_delay;
public ToggleGroup scheduler_dest;
public TextField txt_packet;
public RadioButton rb_incoming;
public RadioButton rb_outgoing;
private ScheduleItem isBeingEdited = null;
private List<ScheduleItem> scheduleItemList = new ArrayList<>();
public void initialize() {
scrollpane.widthProperty().addListener(observable -> header.setPrefWidth(scrollpane.getWidth()));
scheduler_dest.selectToggle(scheduler_dest.getToggles().get(0));
txt_packet.textProperty().addListener(event -> Platform.runLater(this::updateUI));
txt_delay.textProperty().addListener(event -> Platform.runLater(this::updateUI));
updateUI();
new Thread(() -> {
long i = 0;
while (true) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
for (ScheduleItem item : scheduleItemList) {
if (!item.getPausedProperty().get()) {
Interval cur = item.getDelayProperty().get();
if (i % cur.getDelay() == cur.getOffset()) {
getHConnection().sendToServerAsync(item.getPacketProperty().get());
}
}
}
i++;
}
}).start();
}
public static boolean stringIsNumber(String str) {
try {
Integer.parseInt(str);
return true;
}
catch (Exception e){
return false;
}
}
private void updateUI() {
btn_addoredit.setDisable(!Interval.isValid(txt_delay.getText()) || new HPacket(txt_packet.getText()).isCorrupted());
}
public void scheduleBtnClicked(ActionEvent actionEvent) {
if (isBeingEdited == null) {
HPacket packet = new HPacket(txt_packet.getText());
if (packet.isCorrupted()) return;
ScheduleItem newItem = new ScheduleItem(
scheduleItemList.size(),
false,
new Interval(txt_delay.getText()),
new HPacket(txt_packet.getText()),
rb_incoming.isSelected() ? HMessage.Side.TOCLIENT : HMessage.Side.TOSERVER);
new ScheduleItemContainer(newItem, schedulecontainer, scrollpane);
scheduleItemList.add(newItem);
newItem.onDelete(observable -> {
if (isBeingEdited == newItem) {
setInputDefault();
isBeingEdited = null;
}
scheduleItemList.remove(newItem);
for (int i = 0; i < scheduleItemList.size(); i++) {
scheduleItemList.get(i).getIndexProperty().set(i);
}
});
newItem.onEdit(observable -> {
if (isBeingEdited != null) {
isBeingEdited.isUpdatedTrigger();
}
if (isBeingEdited != newItem) {
txt_packet.setText(newItem.getPacketProperty().get().toString());
txt_delay.setText(newItem.getDelayProperty().get().toString());
rb_incoming.setSelected(newItem.getDestinationProperty().get() == HMessage.Side.TOCLIENT);
rb_outgoing.setSelected(newItem.getDestinationProperty().get() == HMessage.Side.TOSERVER);
isBeingEdited = newItem;
btn_addoredit.setText("Edit schedule item"); //Add to scheduler
updateUI();
newItem.onIsBeingUpdatedTrigger();
}
else {
setInputDefault();
isBeingEdited.isUpdatedTrigger();
isBeingEdited = null;
}
});
}
else {
isBeingEdited.getPacketProperty().set(new HPacket(txt_packet.getText()));
isBeingEdited.getDelayProperty().set(new Interval(txt_delay.getText()));
isBeingEdited.getDestinationProperty().set(rb_incoming.isSelected() ? HMessage.Side.TOCLIENT : HMessage.Side.TOSERVER);
isBeingEdited.isUpdatedTrigger();
isBeingEdited = null;
setInputDefault();
}
}
private void setInputDefault() {
txt_delay.setText(defaultInterval.toString());
txt_packet.setText(defaultPacket.toString());
rb_incoming.setSelected(true);
rb_outgoing.setSelected(false);
btn_addoredit.setText("Add to scheduler");
updateUI();
}
}

View File

@ -0,0 +1,53 @@
package main.ui.scheduler.buttons;
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
public class BoxButton extends StackPane {
private ImageView imageView;
private Image image;
private Image imageOnHover;
private boolean isVisible;
//paths zijn relatief aan deze classpath
public BoxButton(String imagePath, String imageOnHoverPath) {
this.image = new Image(getClass().getResourceAsStream(imagePath));
this.imageOnHover = new Image(getClass().getResourceAsStream(imageOnHoverPath));
this.imageView = new ImageView();
setCursor(Cursor.DEFAULT);
getChildren().add(imageView);
setOnMouseEntered(onMouseHover);
setOnMouseExited(onMouseHoverDone);
}
public void show() {
imageView.setImage(image);
isVisible = true;
}
public void dispose() {
imageView.setImage(null);
isVisible = false;
}
private EventHandler<MouseEvent> onMouseHover =
t -> {
if (isVisible) {
imageView.setImage(imageOnHover);
}
};
private EventHandler<MouseEvent> onMouseHoverDone =
t -> {
if (isVisible) {
imageView.setImage(image);
}
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

View File

@ -0,0 +1,8 @@
package main.ui.scheduler.buttons;
public class DeleteButton extends BoxButton {
public DeleteButton() {
super("ButtonDelete.png", "ButtonDeleteHover.png");
}
}

View File

@ -0,0 +1,8 @@
package main.ui.scheduler.buttons;
public class EditButton extends BoxButton {
public EditButton() {
super("ButtonEdit.png", "ButtonEditHover.png");
}
}

View File

@ -0,0 +1,91 @@
package main.ui.scheduler.buttons;
import javafx.beans.InvalidationListener;
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Jonas on 11/04/18.
*/
public class PauseResumeButton extends StackPane{
private boolean isPaused[] = {false};
private ImageView imageView;
private Image imagePause;
private Image imagePauseOnHover;
private Image imageResume;
private Image imageResumeOnHover;
private List<InvalidationListener> clickListeners = new ArrayList<>();
public PauseResumeButton(boolean isPaused) {
this.isPaused[0] = isPaused;
this.imagePause = new Image(getClass().getResourceAsStream("ButtonPause.png"));
this.imagePauseOnHover = new Image(getClass().getResourceAsStream("ButtonPauseHover.png"));
this.imageResume = new Image(getClass().getResourceAsStream("ButtonResume.png"));
this.imageResumeOnHover = new Image(getClass().getResourceAsStream("ButtonResumeHover.png"));
this.imageView = new ImageView();
setCursor(Cursor.DEFAULT);
getChildren().add(imageView);
setOnMouseEntered(onMouseHover);
setOnMouseExited(onMouseHoverDone);
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);
}
});
}
public boolean isPaused() {
return isPaused[0];
}
public void onClick(InvalidationListener listener) {
clickListeners.add(listener);
}
private EventHandler<MouseEvent> onMouseHover =
t -> imageView.setImage(isPaused() ? imageResumeOnHover : imagePauseOnHover);
private EventHandler<MouseEvent> onMouseHoverDone =
t -> imageView.setImage(isPaused() ? imageResume : imagePause);
// private ImageView imageView;
// private Image image;
// private Image imageOnHover;
// private boolean isVisible;
//
// //paths zijn relatief aan deze classpath
// public BoxButton(String imagePath, String imageOnHoverPath) {
// this.image = new Image(getClass().getResourceAsStream(imagePath));
// this.imageOnHover = new Image(getClass().getResourceAsStream(imageOnHoverPath));
// this.imageView = new ImageView();
//
// setCursor(Cursor.DEFAULT);
// getChildren().add(imageView);
// setOnMouseEntered(onMouseHover);
// setOnMouseExited(onMouseHoverDone);
// }
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.ui.settings.Settings">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="303.0" minWidth="10.0" prefWidth="277.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="288.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>

View File

@ -0,0 +1,9 @@
package main.ui.settings;
import main.ui.SubForm;
/**
* Created by Jonas on 06/04/18.
*/
public class Settings extends SubForm {
}