-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add query timer
- Loading branch information
Showing
21 changed files
with
235 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...wer/ui/controllers/MenuBarController.java → ...tviewer/ui/menubar/MenuBarController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ewer/ui/components/AddInstanceDialog.java → ...ui/projectexplorer/AddInstanceDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ui/components/SyntaxHighlightingUtil.java → ...r/ui/querybox/SyntaxHighlightingUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...er/ui/components/BigtableRowTreeItem.java → ...r/ui/queryresult/BigtableRowTreeItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...fo/btviewer/ui/components/RowKeyView.java → ...o/btviewer/ui/queryresult/RowKeyView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../ui/components/CredentialsPathDialog.java → ...ewer/ui/shared/CredentialsPathDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...er/ui/components/TableSettingsDialog.java → ...viewer/ui/shared/TableSettingsDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/main/java/com/erikmafo/btviewer/ui/timer/TimerView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.erikmafo.btviewer.ui.timer; | ||
|
||
import com.erikmafo.btviewer.util.FXMLLoaderUtil; | ||
import javafx.animation.Animation; | ||
import javafx.animation.KeyFrame; | ||
import javafx.animation.Timeline; | ||
import javafx.beans.property.Property; | ||
import javafx.beans.property.SimpleObjectProperty; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.Pane; | ||
import javafx.util.Duration; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static javafx.beans.binding.Bindings.createIntegerBinding; | ||
|
||
public class TimerView extends Pane { | ||
|
||
private static final double KEY_FRAME_DURATION_MILLIS = 1; | ||
private static final String TWO_DIGITS = "%02d"; | ||
private static final String TREE_DIGITS = "%03d"; | ||
|
||
private final Property<Duration> time = new SimpleObjectProperty<>(Duration.ZERO); | ||
private final Timeline timeline = new Timeline(); | ||
|
||
@FXML | ||
private Label hoursLabel; | ||
|
||
@FXML | ||
private Label minutesLabel; | ||
|
||
@FXML | ||
private Label secondsLabel; | ||
|
||
@FXML | ||
private Label millisLabel; | ||
|
||
public TimerView() { FXMLLoaderUtil.loadFxml("/fxml/timer_view.fxml", this); } | ||
|
||
@FXML | ||
public void initialize() { | ||
timeline.setCycleCount(Animation.INDEFINITE); | ||
hoursLabel.textProperty().bind(createIntegerBinding(this::getHoursPart, time).asString(TWO_DIGITS)); | ||
minutesLabel.textProperty().bind(createIntegerBinding(this::getMinutesPart, time).asString(TWO_DIGITS)); | ||
secondsLabel.textProperty().bind(createIntegerBinding(this::getSecondsPart, time).asString(TWO_DIGITS)); | ||
millisLabel.textProperty().bind(createIntegerBinding(this::getMillisPart, time).asString(TREE_DIGITS)); | ||
} | ||
|
||
public void setTime(Duration duration) { | ||
time.setValue(duration); | ||
} | ||
|
||
public void startFromZero() { | ||
reset(); | ||
start(); | ||
} | ||
|
||
public void start() { | ||
timeline.getKeyFrames() | ||
.setAll(new KeyFrame(Duration.millis(KEY_FRAME_DURATION_MILLIS), event -> increaseTime())); | ||
timeline.play(); | ||
} | ||
|
||
public void stop() { timeline.stop(); } | ||
|
||
public void reset() { | ||
stop(); | ||
setTime(Duration.ZERO); | ||
} | ||
|
||
private void increaseTime() { | ||
time.setValue(time.getValue().add(Duration.ONE)); | ||
} | ||
|
||
private int getMillisPart() { | ||
return toJavaDuration(time.getValue()).toMillisPart(); | ||
} | ||
|
||
private int getSecondsPart() { | ||
return toJavaDuration(time.getValue()).toSecondsPart(); | ||
} | ||
|
||
private int getMinutesPart() { | ||
return toJavaDuration(time.getValue()).toMinutesPart(); | ||
} | ||
|
||
private int getHoursPart() { | ||
return toJavaDuration(time.getValue()).toHoursPart(); | ||
} | ||
|
||
private java.time.Duration toJavaDuration(@NotNull Duration duration) { | ||
return java.time.Duration.ofMillis((long) duration.toMillis()); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import com.erikmafo.btviewer.ui.timer.TimerView?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.ProgressBar?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.Pane?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import org.fxmisc.richtext.CodeArea?> | ||
<VBox styleClass="queryBox, has-spacing" | ||
stylesheets="/css/query_box.css" | ||
xmlns:fx="http://javafx.com/fxml" | ||
fx:controller="com.erikmafo.btviewer.ui.components.QueryBoxController"> | ||
fx:controller="com.erikmafo.btviewer.ui.querybox.QueryBoxController"> | ||
|
||
<CodeArea fx:id="codeArea" onKeyPressed="#onKeyPressedInCodeArea"/> | ||
<HBox alignment="BASELINE_LEFT" styleClass="has-spacing"> | ||
<Button | ||
fx:id="executeQueryButton" | ||
<Button fx:id="executeQueryButton" | ||
text="Execute" | ||
styleClass="btn-success" | ||
onAction="#onExecuteQueryButtonPressed"/> | ||
<Button | ||
fx:id="cancelQueryButton" | ||
<Button fx:id="cancelQueryButton" | ||
text="Cancel" | ||
styleClass="btn-danger" | ||
onAction="#onCancelQueryButtonPressed"/> | ||
<ProgressBar | ||
fx:id="progressBar" | ||
styleClass="progress-bar-success"/> | ||
<ProgressBar fx:id="progressBar" styleClass="progress-bar-success"/> | ||
<Pane HBox.hgrow="ALWAYS" /> | ||
<TimerView fx:id="timer"/> | ||
</HBox> | ||
|
||
</VBox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.Pane?> | ||
<fx:root type="javafx.scene.layout.Pane" | ||
xmlns="http://javafx.com/javafx" | ||
xmlns:fx="http://javafx.com/fxml"> | ||
<GridPane> | ||
<children> | ||
<Label fx:id="hoursLabel" GridPane.rowIndex="0" GridPane.columnIndex="0" text="01"/> | ||
<Label GridPane.rowIndex="0" GridPane.columnIndex="1" text=":"/> | ||
<Label fx:id="minutesLabel" GridPane.rowIndex="0" GridPane.columnIndex="2" text="12"/> | ||
<Label GridPane.rowIndex="0" GridPane.columnIndex="3" text=":"/> | ||
<Label fx:id="secondsLabel" GridPane.rowIndex="0" GridPane.columnIndex="4" text="56"/> | ||
<Label GridPane.rowIndex="0" GridPane.columnIndex="5" text=":"/> | ||
<Label fx:id="millisLabel" GridPane.rowIndex="0" GridPane.columnIndex="6" text="999"/> | ||
</children> | ||
</GridPane> | ||
</fx:root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.