add busyanimation to dispute view

This commit is contained in:
Manfred Karrer 2016-06-28 00:19:50 +02:00
parent b3576e3d23
commit 41960d8b90

View file

@ -24,14 +24,15 @@ import io.bitsquare.arbitration.Dispute;
import io.bitsquare.arbitration.DisputeManager; import io.bitsquare.arbitration.DisputeManager;
import io.bitsquare.arbitration.messages.DisputeCommunicationMessage; import io.bitsquare.arbitration.messages.DisputeCommunicationMessage;
import io.bitsquare.arbitration.payload.Attachment; import io.bitsquare.arbitration.payload.Attachment;
import io.bitsquare.common.Timer;
import io.bitsquare.common.UserThread; import io.bitsquare.common.UserThread;
import io.bitsquare.common.crypto.KeyRing; import io.bitsquare.common.crypto.KeyRing;
import io.bitsquare.common.util.Utilities; import io.bitsquare.common.util.Utilities;
import io.bitsquare.gui.common.view.ActivatableView; import io.bitsquare.gui.common.view.ActivatableView;
import io.bitsquare.gui.common.view.FxmlView; import io.bitsquare.gui.common.view.FxmlView;
import io.bitsquare.gui.components.BusyAnimation;
import io.bitsquare.gui.components.HyperlinkWithIcon; import io.bitsquare.gui.components.HyperlinkWithIcon;
import io.bitsquare.gui.components.TableGroupHeadline; import io.bitsquare.gui.components.TableGroupHeadline;
import io.bitsquare.gui.components.indicator.TxConfidenceIndicator;
import io.bitsquare.gui.main.overlays.popups.Popup; import io.bitsquare.gui.main.overlays.popups.Popup;
import io.bitsquare.gui.main.overlays.windows.ContractWindow; import io.bitsquare.gui.main.overlays.windows.ContractWindow;
import io.bitsquare.gui.main.overlays.windows.DisputeSummaryWindow; import io.bitsquare.gui.main.overlays.windows.DisputeSummaryWindow;
@ -102,7 +103,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
private TextArea inputTextArea; private TextArea inputTextArea;
private AnchorPane messagesAnchorPane; private AnchorPane messagesAnchorPane;
private VBox messagesInputBox; private VBox messagesInputBox;
private TxConfidenceIndicator sendMsgProgressIndicator; private BusyAnimation sendMsgBusyAnimation;
private Label sendMsgInfoLabel; private Label sendMsgInfoLabel;
private ChangeListener<Boolean> arrivedPropertyListener; private ChangeListener<Boolean> arrivedPropertyListener;
private ChangeListener<Boolean> storedInMailboxPropertyListener; private ChangeListener<Boolean> storedInMailboxPropertyListener;
@ -307,14 +308,12 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
inputTextArea.setDisable(true); inputTextArea.setDisable(true);
inputTextArea.clear(); inputTextArea.clear();
io.bitsquare.common.Timer timer = UserThread.runAfter(() -> { Timer timer = UserThread.runAfter(() -> {
sendMsgInfoLabel.setVisible(true); sendMsgInfoLabel.setVisible(true);
sendMsgInfoLabel.setManaged(true); sendMsgInfoLabel.setManaged(true);
sendMsgInfoLabel.setText("Sending Message..."); sendMsgInfoLabel.setText("Sending Message...");
sendMsgProgressIndicator.setProgress(-1); sendMsgBusyAnimation.play();
sendMsgProgressIndicator.setVisible(true);
sendMsgProgressIndicator.setManaged(true);
}, 500, TimeUnit.MILLISECONDS); }, 500, TimeUnit.MILLISECONDS);
arrivedPropertyListener = (observable, oldValue, newValue) -> { arrivedPropertyListener = (observable, oldValue, newValue) -> {
@ -335,7 +334,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
disputeCommunicationMessage.storedInMailboxProperty().addListener(storedInMailboxPropertyListener); disputeCommunicationMessage.storedInMailboxProperty().addListener(storedInMailboxPropertyListener);
} }
private void hideSendMsgInfo(io.bitsquare.common.Timer timer) { private void hideSendMsgInfo(Timer timer) {
timer.stop(); timer.stop();
inputTextArea.setDisable(false); inputTextArea.setDisable(false);
@ -343,9 +342,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
sendMsgInfoLabel.setVisible(false); sendMsgInfoLabel.setVisible(false);
sendMsgInfoLabel.setManaged(false); sendMsgInfoLabel.setManaged(false);
}, 5); }, 5);
sendMsgProgressIndicator.setProgress(0); sendMsgBusyAnimation.stop();
sendMsgProgressIndicator.setVisible(false);
sendMsgProgressIndicator.setManaged(false);
} }
private void onCloseDispute(Dispute dispute) { private void onCloseDispute(Dispute dispute) {
@ -510,15 +507,12 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
sendMsgInfoLabel.setManaged(false); sendMsgInfoLabel.setManaged(false);
sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0)); sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0));
sendMsgProgressIndicator = new TxConfidenceIndicator(0); sendMsgBusyAnimation = new BusyAnimation(false);
sendMsgProgressIndicator.setPrefSize(24, 24);
sendMsgProgressIndicator.setVisible(false);
sendMsgProgressIndicator.setManaged(false);
if (!selectedDispute.isClosed()) { if (!selectedDispute.isClosed()) {
HBox buttonBox = new HBox(); HBox buttonBox = new HBox();
buttonBox.setSpacing(10); buttonBox.setSpacing(10);
buttonBox.getChildren().addAll(sendButton, uploadButton, sendMsgProgressIndicator, sendMsgInfoLabel); buttonBox.getChildren().addAll(sendButton, uploadButton, sendMsgBusyAnimation, sendMsgInfoLabel);
if (!isTrader) { if (!isTrader) {
Button closeDisputeButton = new Button("Close ticket"); Button closeDisputeButton = new Button("Close ticket");
@ -550,7 +544,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
@Override @Override
public ListCell<DisputeCommunicationMessage> call(ListView<DisputeCommunicationMessage> list) { public ListCell<DisputeCommunicationMessage> call(ListView<DisputeCommunicationMessage> list) {
return new ListCell<DisputeCommunicationMessage>() { return new ListCell<DisputeCommunicationMessage>() {
public ChangeListener<Number> sendMsgProgressIndicatorListener; public ChangeListener<Boolean> sendMsgBusyAnimationListener;
final Pane bg = new Pane(); final Pane bg = new Pane();
final ImageView arrow = new ImageView(); final ImageView arrow = new ImageView();
final Label headerLabel = new Label(); final Label headerLabel = new Label();
@ -618,18 +612,18 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
else else
arrow.setId("bubble_arrow_blue_right"); arrow.setId("bubble_arrow_blue_right");
if (sendMsgProgressIndicatorListener != null) if (sendMsgBusyAnimationListener != null)
sendMsgProgressIndicator.progressProperty().removeListener(sendMsgProgressIndicatorListener); sendMsgBusyAnimation.runningProperty().removeListener(sendMsgBusyAnimationListener);
sendMsgProgressIndicatorListener = (observable, oldValue, newValue) -> { sendMsgBusyAnimationListener = (observable, oldValue, newValue) -> {
if ((double) oldValue == -1 && (double) newValue == 0) { if (!newValue) {
if (item.arrivedProperty().get()) if (item.arrivedProperty().get())
showArrivedIcon(); showArrivedIcon();
else if (item.storedInMailboxProperty().get()) else if (item.storedInMailboxProperty().get())
showMailboxIcon(); showMailboxIcon();
} }
}; };
sendMsgProgressIndicator.progressProperty().addListener(sendMsgProgressIndicatorListener); sendMsgBusyAnimation.runningProperty().addListener(sendMsgBusyAnimationListener);
if (item.arrivedProperty().get()) if (item.arrivedProperty().get())
showArrivedIcon(); showArrivedIcon();
@ -722,8 +716,8 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
// TODO There are still some cell rendering issues on updates // TODO There are still some cell rendering issues on updates
setGraphic(messageAnchorPane); setGraphic(messageAnchorPane);
} else { } else {
if (sendMsgProgressIndicator != null && sendMsgProgressIndicatorListener != null) if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
sendMsgProgressIndicator.progressProperty().removeListener(sendMsgProgressIndicatorListener); sendMsgBusyAnimation.runningProperty().removeListener(sendMsgBusyAnimationListener);
messageAnchorPane.prefWidthProperty().unbind(); messageAnchorPane.prefWidthProperty().unbind();