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