Skip to content

Commit 0d8a8a8

Browse files
committed
Improve UI and increase tolerance for timer tests
1 parent eed8a26 commit 0d8a8a8

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

core/src/test/java/edu/wpi/grip/core/metrics/TimerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testTiming() throws InterruptedException {
5454
timer.started();
5555
Thread.sleep(1000);
5656
timer.stopped();
57-
assertEquals("Elapsed time was out of tolerance", 1_000_000, timer.getElapsedTime(), 1000);
57+
assertEquals("Elapsed time was out of tolerance", 1_000_000, timer.getElapsedTime(), 10_000);
5858
}
5959

6060
@Test
@@ -73,7 +73,7 @@ private void onTimerEvent(TimerEvent event) {
7373
assertNotNull("No TimerEvent received", timerEvent.get());
7474
TimerEvent event = timerEvent.get();
7575
assertEquals("Event had an unexpected source", this, event.getSource());
76-
assertEquals("Elapsed time was out of tolerance", 1_000_000, event.getElapsedTime(), 1000);
76+
assertEquals("Elapsed time was out of tolerance", 1_000_000, event.getElapsedTime(), 10_000);
7777
Analysis analysis = event.getData();
7878
Statistics statistics = analysis.getStatistics();
7979
assertEquals("Analysis did not have 1 element", 1, analysis.getN());

ui/src/main/java/edu/wpi/grip/ui/MainWindowController.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
import edu.wpi.grip.ui.components.StartStoppableButton;
1717
import edu.wpi.grip.ui.util.DPIUtility;
1818

19-
import com.google.common.base.CaseFormat;
2019
import com.google.common.eventbus.EventBus;
2120
import com.google.common.eventbus.Subscribe;
2221
import com.google.common.util.concurrent.Service;
2322

24-
import org.controlsfx.control.StatusBar;
25-
2623
import java.io.File;
2724
import java.io.IOException;
2825
import java.util.Optional;
@@ -35,12 +32,13 @@
3532
import javafx.scene.control.ButtonType;
3633
import javafx.scene.control.Dialog;
3734
import javafx.scene.control.Label;
35+
import javafx.scene.control.MenuItem;
3836
import javafx.scene.control.SplitPane;
3937
import javafx.scene.image.Image;
4038
import javafx.scene.image.ImageView;
39+
import javafx.scene.layout.HBox;
4140
import javafx.scene.layout.Pane;
4241
import javafx.scene.layout.Region;
43-
import javafx.scene.text.TextAlignment;
4442
import javafx.stage.FileChooser;
4543
import javafx.stage.FileChooser.ExtensionFilter;
4644
import javafx.stage.Modality;
@@ -53,7 +51,6 @@
5351
* The Controller for the application window.
5452
*/
5553
public class MainWindowController {
56-
5754
@FXML
5855
private Parent root;
5956
@FXML
@@ -67,8 +64,13 @@ public class MainWindowController {
6764
@FXML
6865
private Pane aboutPane;
6966
@FXML
70-
private StatusBar statusBar;
71-
private Label elapsedTimeLabel; // TODO improve the layout of this label
67+
private MenuItem analyzeMenuItem;
68+
@FXML
69+
private HBox statusBar;
70+
@FXML
71+
private Label statusLabel;
72+
@FXML
73+
private Label elapsedTimeLabel;
7274
@Inject
7375
private EventBus eventBus;
7476
@Inject
@@ -90,20 +92,16 @@ public class MainWindowController {
9092

9193
@FXML
9294
protected void initialize() {
93-
elapsedTimeLabel = new Label();
94-
updateElapsedTimeLabel(0);
95-
elapsedTimeLabel.setTextAlignment(TextAlignment.CENTER);
9695
pipelineView.prefHeightProperty().bind(bottomPane.heightProperty());
97-
statusBar.getLeftItems().add(startStoppableButtonFactory.create(pipelineRunner));
98-
statusBar.getLeftItems().add(elapsedTimeLabel);
96+
statusBar.getChildren().add(0, startStoppableButtonFactory.create(pipelineRunner));
9997
pipelineRunner.addListener(new SingleActionListener(() -> {
10098
final Service.State state = pipelineRunner.state();
10199
final String stateMessage =
102100
state.equals(Service.State.TERMINATED)
103-
? "Stopped"
104-
: CaseFormat.UPPER_UNDERSCORE.converterTo(CaseFormat.UPPER_CAMEL).convert(state
105-
.toString());
106-
statusBar.setText(" Pipeline " + stateMessage);
101+
? "disabled "
102+
: "enabled ";
103+
statusLabel.setText("Pipeline " + stateMessage);
104+
analyzeMenuItem.setDisable(state.equals(Service.State.TERMINATED));
107105
}), Platform::runLater);
108106
}
109107

ui/src/main/resources/edu/wpi/grip/ui/MainWindow.fxml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
<?import javafx.scene.image.ImageView?>
1515
<?import javafx.scene.input.KeyCodeCombination?>
1616
<?import javafx.scene.layout.VBox?>
17-
<?import org.controlsfx.control.StatusBar?>
17+
<?import javafx.scene.layout.HBox?>
18+
<?import javafx.scene.control.Label?>
19+
<?import javafx.geometry.Insets?>
20+
<?import javafx.scene.control.Separator?>
1821
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
1922
minWidth="-Infinity" styleClass="main-window"
2023
fx:controller="edu.wpi.grip.ui.MainWindowController"
@@ -135,7 +138,7 @@
135138
</ImageView>
136139
</graphic>
137140
</MenuItem>
138-
<MenuItem text="Analyze" onAction="#showAnalysis">
141+
<MenuItem fx:id="analyzeMenuItem" text="Analyze" onAction="#showAnalysis">
139142
<graphic>
140143
<ImageView styleClass="menu-graphic">
141144
<fitWidth>
@@ -180,7 +183,17 @@
180183
</ScrollPane>
181184
</items>
182185
</SplitPane>
183-
<StatusBar fx:id="statusBar" />
186+
<HBox fx:id="statusBar" alignment="CENTER_LEFT" spacing="2">
187+
<padding>
188+
<Insets top="2" right="2" bottom="2" left="2" />
189+
</padding>
190+
<children>
191+
<!-- Start/Stop button goes here (created programmatically and inserted) -->
192+
<Label fx:id="statusLabel" text="Pipeline stopped" />
193+
<Separator orientation="VERTICAL" />
194+
<Label fx:id="elapsedTimeLabel" text="Did not run" />
195+
</children>
196+
</HBox>
184197
</children>
185198
<fx:define>
186199
<fx:include source="Deploy.fxml" fx:id="deployPane" />

0 commit comments

Comments
 (0)