Skip to content

Commit 9fff323

Browse files
committed
Merge pull request #455 from ThomasJClark/warning-icon
Fix warning icon
2 parents 39f1158 + 66d9fff commit 9fff323

4 files changed

Lines changed: 35 additions & 31 deletions

File tree

ui/src/main/java/edu/wpi/grip/ui/components/ExceptionWitnessResponderButton.java

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
import edu.wpi.grip.core.events.ExceptionClearedEvent;
99
import edu.wpi.grip.core.events.ExceptionEvent;
1010
import edu.wpi.grip.ui.util.DPIUtility;
11-
import javafx.animation.FadeTransition;
12-
import javafx.animation.Timeline;
11+
import javafx.animation.*;
1312
import javafx.application.Platform;
1413
import javafx.geometry.HPos;
1514
import javafx.geometry.Insets;
1615
import javafx.geometry.VPos;
17-
import javafx.scene.Node;
1816
import javafx.scene.Parent;
1917
import javafx.scene.control.*;
18+
import javafx.scene.image.ImageView;
2019
import javafx.scene.layout.GridPane;
2120
import javafx.scene.layout.Priority;
2221
import javafx.scene.paint.Color;
@@ -25,16 +24,13 @@
2524
import javafx.util.Duration;
2625
import org.apache.commons.lang3.text.WordUtils;
2726
import org.controlsfx.control.PopOver;
28-
import org.controlsfx.glyphfont.FontAwesome;
29-
import org.controlsfx.glyphfont.Glyph;
3027

3128
import java.util.Optional;
3229

3330
import static com.google.common.base.Preconditions.checkNotNull;
3431

3532
/**
3633
* Listens and responds to events posted by the {@link edu.wpi.grip.core.util.ExceptionWitness}
37-
*
3834
*/
3935
public final class ExceptionWitnessResponderButton extends Button {
4036
@VisibleForTesting
@@ -64,11 +60,13 @@ protected static class ExceptionPopOver extends PopOver {
6460

6561
private ExceptionPopOver(String title) {
6662
super();
63+
6764
setTitle(title);
6865
stackTrace.setEditable(false);
6966

7067
getStyleClass().add(this.STYLE_CLASS);
7168
setHeaderAlwaysVisible(true);
69+
setDetachable(false);
7270

7371
GridPane.setHalignment(errorMessage, HPos.CENTER);
7472
GridPane.setValignment(errorMessage, VPos.CENTER);
@@ -98,6 +96,7 @@ private ExceptionPopOver(String title) {
9896

9997
/**
10098
* Assigns the contents of the popover using the data from the exception event.
99+
*
101100
* @param event The event that this popover should display.
102101
*/
103102
private void assignFromExceptionEvent(ExceptionEvent event) {
@@ -127,22 +126,33 @@ private void assignFromExceptionEvent(ExceptionEvent event) {
127126
*/
128127
@Inject
129128
ExceptionWitnessResponderButton(@Assisted Object origin, @Assisted String popOverTitle) {
130-
super(null, addFadeTransition(
131-
new Glyph("FontAwesome", FontAwesome.Glyph.EXCLAMATION_TRIANGLE)
132-
.color(Color.RED).size(DPIUtility.MINI_ICON_SIZE)));
129+
super();
130+
133131
this.origin = checkNotNull(origin, "The origin can not be null");
134132
this.popOverTitle = checkNotNull(popOverTitle, "The pop over title can not be null");
135133
this.tooltip = new Tooltip();
136134
this.getStyleClass().add(STYLE_CLASS);
137135

138-
this.setOnAction(event -> getPopover().show(this));
136+
ImageView icon = new ImageView("/edu/wpi/grip/ui/icons/warning.png");
139137

140-
this.setVisible(false);
138+
setOnMouseClicked(event -> getPopover().show(this));
139+
setVisible(false);
140+
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
141+
setGraphic(icon);
142+
icon.setFitWidth(DPIUtility.SMALL_ICON_SIZE);
143+
icon.setFitHeight(DPIUtility.SMALL_ICON_SIZE);
144+
145+
FadeTransition ft = new FadeTransition(Duration.millis(750), icon);
146+
ft.setToValue(0.1);
147+
ft.setCycleCount(Transition.INDEFINITE);
148+
ft.setAutoReverse(true);
149+
ft.play();
141150
}
142151

143152
/**
144153
* If the popover hasn't been created before then this creates the popover.
145154
* Otherwise it returns the popover that was constructed the first time this method was run.
155+
*
146156
* @return The popover for this button
147157
*/
148158
private synchronized ExceptionPopOver getPopover() {
@@ -165,8 +175,6 @@ public void onExceptionEvent(ExceptionEvent event) {
165175
Platform.runLater(() -> {
166176
// Update the text of the tooltip to this event
167177
tooltip.setText(WordUtils.wrap(event.getMessage(), 90, null, true));
168-
// The tooltip is removed when the exception is cleared
169-
setTooltip(tooltip);
170178

171179
getPopover().assignFromExceptionEvent(event);
172180
this.setVisible(true);
@@ -181,23 +189,7 @@ public void onExceptionClearedEvent(ExceptionClearedEvent event) {
181189
Platform.runLater(() -> {
182190
getPopover().hide();
183191
setVisible(false);
184-
setTooltip(null);
185192
});
186193
}
187194
}
188-
189-
/**
190-
* Creates a fade transition on a node.
191-
* @param node The node to add the transition too.
192-
* @return The node that the transition is now applied to.
193-
*/
194-
private static Node addFadeTransition(Node node) {
195-
FadeTransition ft = new FadeTransition(Duration.millis(750), node);
196-
ft.setFromValue(1.0);
197-
ft.setToValue(0.1);
198-
ft.setCycleCount(Timeline.INDEFINITE);
199-
ft.setAutoReverse(true);
200-
ft.play();
201-
return node;
202-
}
203195
}

ui/src/main/resources/edu/wpi/grip/ui/GRIP.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ Button.add-source {
106106
-fx-spacing: 0.5em;
107107
}
108108

109-
Button.delete, Button.move-left, Button.move-right, start-stoppable-button {
109+
Button.delete, Button.move-left, Button.move-right, .start-stoppable-button, .exception-witness-responder-button {
110110
-fx-padding: 0.2em 0.8em;
111111
-fx-font-weight: bold;
112112
-fx-text-fill: -fx-dark-color;
113+
-fx-pref-height: 2em;
114+
-fx-pref-width: 2em;
113115
}
114116

115117
VBox.sockets {
@@ -177,6 +179,10 @@ VBox.sockets {
177179
-fx-fill: none;
178180
}
179181

182+
.error-pop-over {
183+
-fx-padding: 0.5em;
184+
}
185+
180186
.error-pop-over .titled-pane > .title {
181187
-fx-border-color: lightgrey;
182188
-fx-border-insets: 5 5 5 5;
607 Bytes
Loading

ui/src/main/resources/edu/wpi/grip/ui/pipeline/Step.fxml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515
</tooltip>
1616
</Button>
1717
<Pane HBox.hgrow="ALWAYS"/>
18-
<HBox fx:id="buttons" >
18+
<HBox fx:id="buttons">
1919
<Button fx:id="moveLeftButton" onMouseClicked="#moveStepLeft" styleClass="move-left"
2020
text="" HBox.hgrow="NEVER">
21+
<minHeight>
22+
<DPIUtility fx:constant="SMALL_ICON_SIZE"/>
23+
</minHeight>
2124
<tooltip>
2225
<Tooltip text="Move Step Left"/>
2326
</tooltip>
2427
</Button>
2528
<Button fx:id="moveRightButton" onMouseClicked="#moveStepRight" styleClass="move-right"
2629
text="" HBox.hgrow="NEVER">
30+
<minHeight>
31+
<DPIUtility fx:constant="SMALL_ICON_SIZE"/>
32+
</minHeight>
2733
<tooltip>
2834
<Tooltip text="Move Step Right"/>
2935
</tooltip>

0 commit comments

Comments
 (0)