From 7e353d001c44b5a3dcc18dd7f83385fa611947e5 Mon Sep 17 00:00:00 2001 From: iMoHax Date: Sat, 30 Aug 2014 14:47:16 +0400 Subject: [PATCH] add reset offer button on edit vendor --- .../view/support/cells/EditOfferCell.java | 28 ++++++++++++++++++- client/src/main/resources/view/style.css | 13 +++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/ru/trader/view/support/cells/EditOfferCell.java b/client/src/main/java/ru/trader/view/support/cells/EditOfferCell.java index 0a1d6d7..4ac7e57 100644 --- a/client/src/main/java/ru/trader/view/support/cells/EditOfferCell.java +++ b/client/src/main/java/ru/trader/view/support/cells/EditOfferCell.java @@ -1,18 +1,28 @@ package ru.trader.view.support.cells; +import javafx.application.Platform; +import javafx.geometry.Pos; +import javafx.scene.Node; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableRow; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.Border; +import javafx.scene.layout.BorderStroke; import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; import javafx.scene.text.Text; import javafx.util.Callback; import javafx.util.StringConverter; +import org.controlsfx.glyphfont.Glyph; +import org.controlsfx.glyphfont.GlyphFontRegistry; import ru.trader.controllers.VendorEditorController; public class EditOfferCell extends TextFieldCell { private final static String CSS_CHANGE = "change"; private final static String CSS_ADD = "add"; private final static String CSS_REMOVE = "remove"; + private final static String CSS_RESET_ICON = "reset"; private boolean isSell; public EditOfferCell(StringConverter converter, boolean isSell) { @@ -31,8 +41,8 @@ public class EditOfferCell extends TextFieldCell { + Platform.runLater(() -> { + if (isSell) { + offer.setSprice(offer.getOldSprice()); + } else { + offer.setBprice(offer.getOldBprice()); + } + }); + e.consume(); + }); + HBox icon = new HBox(glyph); + icon.getStyleClass().add(CSS_RESET_ICON); + HBox.setHgrow(icon, Priority.ALWAYS); + hBox.getChildren().add(icon); setText(null); setGraphic(hBox); } else { diff --git a/client/src/main/resources/view/style.css b/client/src/main/resources/view/style.css index a4cf9d3..4615c22 100644 --- a/client/src/main/resources/view/style.css +++ b/client/src/main/resources/view/style.css @@ -100,4 +100,17 @@ HBox.fields-group hbox-margin{ #items .add { -fx-background-color: lightblue; +} + +#items HBox.reset { + -fx-padding: 0 4; + -fx-alignment: top-right; +} + +#items HBox.reset Glyph { + -fx-opacity: 0.3; +} + +#items HBox.reset Glyph:hover { + -fx-opacity: 1; } \ No newline at end of file