use of bisq.desktop.components.TableGroupHeadline in project bisq-desktop by bisq-network.
the class BaseProposalView method createProposalsTableView.
protected void createProposalsTableView(String header, double top) {
TableGroupHeadline proposalsHeadline = new TableGroupHeadline(header);
GridPane.setRowIndex(proposalsHeadline, ++gridRow);
GridPane.setMargin(proposalsHeadline, new Insets(top, -10, -10, -10));
GridPane.setColumnSpan(proposalsHeadline, 2);
root.getChildren().add(proposalsHeadline);
proposalTableView = new TableView<>();
proposalTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
proposalTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
createProposalColumns(proposalTableView);
GridPane.setRowIndex(proposalTableView, gridRow);
GridPane.setMargin(proposalTableView, new Insets(top + 20, -10, 5, -10));
GridPane.setColumnSpan(proposalTableView, 2);
GridPane.setHgrow(proposalTableView, Priority.ALWAYS);
root.getChildren().add(proposalTableView);
proposalTableView.setItems(sortedList);
proposalViewItems.add(proposalsHeadline);
proposalViewItems.add(proposalTableView);
}
use of bisq.desktop.components.TableGroupHeadline in project bisq-desktop by bisq-network.
the class MyVotesView method createVoteTableView.
// /////////////////////////////////////////////////////////////////////////////////////////
// Create views
// /////////////////////////////////////////////////////////////////////////////////////////
private void createVoteTableView() {
TableGroupHeadline proposalsHeadline = new TableGroupHeadline(Res.get("dao.proposal.myVotes.header"));
GridPane.setRowIndex(proposalsHeadline, ++gridRow);
GridPane.setMargin(proposalsHeadline, new Insets(-10, -10, -10, -10));
GridPane.setColumnSpan(proposalsHeadline, 2);
root.getChildren().add(proposalsHeadline);
votesTableView = new TableView<>();
votesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
votesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
createVoteColumns(votesTableView);
GridPane.setRowIndex(votesTableView, gridRow);
GridPane.setMargin(votesTableView, new Insets(10, -10, 5, -10));
GridPane.setColumnSpan(votesTableView, 2);
GridPane.setHgrow(votesTableView, Priority.ALWAYS);
root.getChildren().add(votesTableView);
votesTableView.setItems(sortedList);
}
use of bisq.desktop.components.TableGroupHeadline in project bisq-desktop by bisq-network.
the class TraderDisputeView method onSelectDispute.
private void onSelectDispute(Dispute dispute) {
removeListenersOnSelectDispute();
if (dispute == null) {
if (root.getChildren().size() > 2)
root.getChildren().remove(2);
selectedDispute = null;
} else if (selectedDispute != dispute) {
this.selectedDispute = dispute;
boolean isTrader = disputeManager.isTrader(selectedDispute);
tableGroupHeadline = new TableGroupHeadline();
tableGroupHeadline.setText(Res.get("support.messages"));
AnchorPane.setTopAnchor(tableGroupHeadline, 10d);
AnchorPane.setRightAnchor(tableGroupHeadline, 0d);
AnchorPane.setBottomAnchor(tableGroupHeadline, 0d);
AnchorPane.setLeftAnchor(tableGroupHeadline, 0d);
disputeCommunicationMessages = selectedDispute.getDisputeCommunicationMessages();
SortedList<DisputeCommunicationMessage> sortedList = new SortedList<>(disputeCommunicationMessages);
sortedList.setComparator((o1, o2) -> new Date(o1.getDate()).compareTo(new Date(o2.getDate())));
messageListView = new ListView<>(sortedList);
messageListView.setId("message-list-view");
messageListView.setMinHeight(150);
AnchorPane.setTopAnchor(messageListView, 30d);
AnchorPane.setRightAnchor(messageListView, 0d);
AnchorPane.setLeftAnchor(messageListView, 0d);
messagesAnchorPane = new AnchorPane();
VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS);
inputTextArea = new TextArea();
inputTextArea.setPrefHeight(70);
inputTextArea.setWrapText(true);
if (!(this instanceof ArbitratorDisputeView))
inputTextArea.setPromptText(Res.get("support.input.prompt"));
sendButton = new AutoTooltipButton(Res.get("support.send"));
sendButton.setDefaultButton(true);
sendButton.setOnAction(e -> onTrySendMessage());
inputTextAreaTextSubscription = EasyBind.subscribe(inputTextArea.textProperty(), t -> sendButton.setDisable(t.isEmpty()));
Button uploadButton = new AutoTooltipButton(Res.get("support.addAttachments"));
uploadButton.setOnAction(e -> onRequestUpload());
sendMsgInfoLabel = new AutoTooltipLabel();
sendMsgInfoLabel.setVisible(false);
sendMsgInfoLabel.setManaged(false);
sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0));
sendMsgBusyAnimation = new BusyAnimation(false);
if (!selectedDispute.isClosed()) {
HBox buttonBox = new HBox();
buttonBox.setSpacing(10);
buttonBox.getChildren().addAll(sendButton, uploadButton, sendMsgBusyAnimation, sendMsgInfoLabel);
if (!isTrader) {
Button closeDisputeButton = new AutoTooltipButton(Res.get("support.closeTicket"));
closeDisputeButton.setOnAction(e -> onCloseDispute(selectedDispute));
closeDisputeButton.setDefaultButton(true);
Pane spacer = new Pane();
HBox.setHgrow(spacer, Priority.ALWAYS);
buttonBox.getChildren().addAll(spacer, closeDisputeButton);
}
messagesInputBox = new VBox();
messagesInputBox.setSpacing(10);
messagesInputBox.getChildren().addAll(inputTextArea, buttonBox);
VBox.setVgrow(buttonBox, Priority.ALWAYS);
AnchorPane.setRightAnchor(messagesInputBox, 0d);
AnchorPane.setBottomAnchor(messagesInputBox, 5d);
AnchorPane.setLeftAnchor(messagesInputBox, 0d);
AnchorPane.setBottomAnchor(messageListView, 120d);
messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView, messagesInputBox);
} else {
AnchorPane.setBottomAnchor(messageListView, 0d);
messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView);
}
messageListView.setCellFactory(new Callback<ListView<DisputeCommunicationMessage>, ListCell<DisputeCommunicationMessage>>() {
@Override
public ListCell<DisputeCommunicationMessage> call(ListView<DisputeCommunicationMessage> list) {
return new ListCell<DisputeCommunicationMessage>() {
public ChangeListener<Boolean> sendMsgBusyAnimationListener;
final Pane bg = new Pane();
final ImageView arrow = new ImageView();
final Label headerLabel = new AutoTooltipLabel();
final Label messageLabel = new AutoTooltipLabel();
final Label copyIcon = new Label();
final HBox attachmentsBox = new HBox();
final AnchorPane messageAnchorPane = new AnchorPane();
final Label statusIcon = new Label();
final double arrowWidth = 15d;
final double attachmentsBoxHeight = 20d;
final double border = 10d;
final double bottomBorder = 25d;
final double padding = border + 10d;
final double msgLabelPaddingRight = padding + 20d;
{
bg.setMinHeight(30);
messageLabel.setWrapText(true);
headerLabel.setTextAlignment(TextAlignment.CENTER);
attachmentsBox.setSpacing(5);
statusIcon.getStyleClass().add("small-text");
copyIcon.setTooltip(new Tooltip(Res.get("shared.copyToClipboard")));
messageAnchorPane.getChildren().addAll(bg, arrow, headerLabel, messageLabel, copyIcon, attachmentsBox, statusIcon);
messageLabel.setOnMouseClicked(event -> {
if (2 > event.getClickCount()) {
return;
}
GUIUtil.showSelectableTextModal(headerLabel.getText(), messageLabel.getText());
});
}
@Override
public void updateItem(final DisputeCommunicationMessage item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(messageLabel.getText()));
/* messageAnchorPane.prefWidthProperty().bind(EasyBind.map(messageListView.widthProperty(),
w -> (double) w - padding - GUIUtil.getScrollbarWidth(messageListView)));*/
if (!messageAnchorPane.prefWidthProperty().isBound())
messageAnchorPane.prefWidthProperty().bind(messageListView.widthProperty().subtract(padding + GUIUtil.getScrollbarWidth(messageListView)));
AnchorPane.setTopAnchor(bg, 15d);
AnchorPane.setBottomAnchor(bg, bottomBorder);
AnchorPane.setTopAnchor(headerLabel, 0d);
AnchorPane.setBottomAnchor(arrow, bottomBorder + 5d);
AnchorPane.setTopAnchor(messageLabel, 25d);
AnchorPane.setTopAnchor(copyIcon, 25d);
AnchorPane.setBottomAnchor(attachmentsBox, bottomBorder + 10);
boolean senderIsTrader = item.isSenderIsTrader();
boolean isMyMsg = isTrader ? senderIsTrader : !senderIsTrader;
arrow.setVisible(!item.isSystemMessage());
arrow.setManaged(!item.isSystemMessage());
statusIcon.setVisible(false);
headerLabel.getStyleClass().removeAll("message-header", "success-text", "highlight-static");
messageLabel.getStyleClass().removeAll("my-message", "message");
copyIcon.getStyleClass().removeAll("my-message", "message");
if (item.isSystemMessage()) {
headerLabel.getStyleClass().addAll("message-header", "success-text");
bg.setId("message-bubble-green");
messageLabel.getStyleClass().add("my-message");
copyIcon.getStyleClass().add("my-message");
} else if (isMyMsg) {
headerLabel.getStyleClass().add("highlight-static");
bg.setId("message-bubble-blue");
messageLabel.getStyleClass().add("my-message");
copyIcon.getStyleClass().add("my-message");
if (isTrader)
arrow.setId("bubble_arrow_blue_left");
else
arrow.setId("bubble_arrow_blue_right");
if (sendMsgBusyAnimationListener != null)
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
sendMsgBusyAnimationListener = (observable, oldValue, newValue) -> {
if (!newValue) {
if (item.arrivedProperty().get())
showArrivedIcon();
else if (item.storedInMailboxProperty().get())
showMailboxIcon();
}
};
sendMsgBusyAnimation.isRunningProperty().addListener(sendMsgBusyAnimationListener);
if (item.arrivedProperty().get())
showArrivedIcon();
else if (item.storedInMailboxProperty().get())
showMailboxIcon();
// TODO show that icon on error
/*else if (sendMsgProgressIndicator.getProgress() == 0)
showNotArrivedIcon();*/
} else {
headerLabel.getStyleClass().add("message-header");
bg.setId("message-bubble-grey");
messageLabel.getStyleClass().add("message");
copyIcon.getStyleClass().add("message");
if (isTrader)
arrow.setId("bubble_arrow_grey_right");
else
arrow.setId("bubble_arrow_grey_left");
}
if (item.isSystemMessage()) {
AnchorPane.setLeftAnchor(headerLabel, padding);
AnchorPane.setRightAnchor(headerLabel, padding);
AnchorPane.setLeftAnchor(bg, border);
AnchorPane.setRightAnchor(bg, border);
AnchorPane.setLeftAnchor(messageLabel, padding);
AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight);
AnchorPane.setRightAnchor(copyIcon, padding);
AnchorPane.setLeftAnchor(attachmentsBox, padding);
AnchorPane.setRightAnchor(attachmentsBox, padding);
} else if (senderIsTrader) {
AnchorPane.setLeftAnchor(headerLabel, padding + arrowWidth);
AnchorPane.setLeftAnchor(bg, border + arrowWidth);
AnchorPane.setRightAnchor(bg, border);
AnchorPane.setLeftAnchor(arrow, border);
AnchorPane.setLeftAnchor(messageLabel, padding + arrowWidth);
AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight);
AnchorPane.setRightAnchor(copyIcon, padding);
AnchorPane.setLeftAnchor(attachmentsBox, padding + arrowWidth);
AnchorPane.setRightAnchor(attachmentsBox, padding);
AnchorPane.setRightAnchor(statusIcon, padding);
} else {
AnchorPane.setRightAnchor(headerLabel, padding + arrowWidth);
AnchorPane.setLeftAnchor(bg, border);
AnchorPane.setRightAnchor(bg, border + arrowWidth);
AnchorPane.setRightAnchor(arrow, border);
AnchorPane.setLeftAnchor(messageLabel, padding);
AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight + arrowWidth);
AnchorPane.setRightAnchor(copyIcon, padding + arrowWidth);
AnchorPane.setLeftAnchor(attachmentsBox, padding);
AnchorPane.setRightAnchor(attachmentsBox, padding + arrowWidth);
AnchorPane.setLeftAnchor(statusIcon, padding);
}
AnchorPane.setBottomAnchor(statusIcon, 7d);
headerLabel.setText(formatter.formatDateTime(new Date(item.getDate())));
messageLabel.setText(item.getMessage());
attachmentsBox.getChildren().clear();
if (item.getAttachments() != null && item.getAttachments().size() > 0) {
AnchorPane.setBottomAnchor(messageLabel, bottomBorder + attachmentsBoxHeight + 10);
attachmentsBox.getChildren().add(new AutoTooltipLabel(Res.get("support.attachments") + " ") {
{
setPadding(new Insets(0, 0, 3, 0));
if (isMyMsg)
getStyleClass().add("my-message");
else
getStyleClass().add("message");
}
});
item.getAttachments().stream().forEach(attachment -> {
final Label icon = new Label();
setPadding(new Insets(0, 0, 3, 0));
if (isMyMsg)
icon.getStyleClass().add("attachment-icon");
else
icon.getStyleClass().add("attachment-icon-black");
AwesomeDude.setIcon(icon, AwesomeIcon.FILE_TEXT);
icon.setPadding(new Insets(-2, 0, 0, 0));
icon.setTooltip(new Tooltip(attachment.getFileName()));
icon.setOnMouseClicked(event -> onOpenAttachment(attachment));
attachmentsBox.getChildren().add(icon);
});
} else {
AnchorPane.setBottomAnchor(messageLabel, bottomBorder + 10);
}
// Need to set it here otherwise style is not correct
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY, "16.0");
copyIcon.getStyleClass().addAll("icon", "copy-icon-disputes");
// TODO There are still some cell rendering issues on updates
setGraphic(messageAnchorPane);
} else {
if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
messageAnchorPane.prefWidthProperty().unbind();
AnchorPane.clearConstraints(bg);
AnchorPane.clearConstraints(headerLabel);
AnchorPane.clearConstraints(arrow);
AnchorPane.clearConstraints(messageLabel);
AnchorPane.clearConstraints(copyIcon);
AnchorPane.clearConstraints(statusIcon);
AnchorPane.clearConstraints(attachmentsBox);
copyIcon.setOnMouseClicked(null);
setGraphic(null);
}
}
/* private void showNotArrivedIcon() {
statusIcon.setVisible(true);
AwesomeDude.setIcon(statusIcon, AwesomeIcon.WARNING_SIGN, "14");
Tooltip.install(statusIcon, new Tooltip("Message did not arrive. Please try to send again."));
statusIcon.setTextFill(Paint.valueOf("#dd0000"));
}*/
private void showMailboxIcon() {
statusIcon.setVisible(true);
AwesomeDude.setIcon(statusIcon, AwesomeIcon.ENVELOPE_ALT, "14");
statusIcon.setTooltip(new Tooltip(Res.get("support.savedInMailbox")));
statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
}
private void showArrivedIcon() {
statusIcon.setVisible(true);
AwesomeDude.setIcon(statusIcon, AwesomeIcon.OK, "14");
statusIcon.setTooltip(new Tooltip(Res.get("support.arrived")));
statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
}
};
}
});
if (root.getChildren().size() > 2)
root.getChildren().remove(2);
root.getChildren().add(2, messagesAnchorPane);
scrollToBottom();
}
addListenersOnSelectDispute();
}
use of bisq.desktop.components.TableGroupHeadline in project bisq-desktop by bisq-network.
the class ArbitratorSelectionView method addArbitratorsGroup.
private void addArbitratorsGroup() {
TableGroupHeadline tableGroupHeadline = new TableGroupHeadline(Res.get("account.arbitratorSelection.whichDoYouAccept"));
GridPane.setRowIndex(tableGroupHeadline, ++gridRow);
GridPane.setColumnSpan(tableGroupHeadline, 2);
GridPane.setMargin(tableGroupHeadline, new Insets(40, -10, -10, -10));
root.getChildren().add(tableGroupHeadline);
tableView = new TableView<>();
GridPane.setRowIndex(tableView, gridRow);
GridPane.setColumnSpan(tableView, 2);
GridPane.setMargin(tableView, new Insets(60, -10, 5, -10));
root.getChildren().add(tableView);
autoSelectAllMatchingCheckBox = addCheckBox(root, ++gridRow, Res.get("account.arbitratorSelection.autoSelect"));
GridPane.setColumnSpan(autoSelectAllMatchingCheckBox, 2);
GridPane.setHalignment(autoSelectAllMatchingCheckBox, HPos.LEFT);
GridPane.setColumnIndex(autoSelectAllMatchingCheckBox, 0);
GridPane.setMargin(autoSelectAllMatchingCheckBox, new Insets(0, -10, 0, -10));
autoSelectAllMatchingCheckBox.setOnAction(event -> model.setAutoSelectArbitrators(autoSelectAllMatchingCheckBox.isSelected()));
TableColumn<ArbitratorListItem, String> dateColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.regDate"));
dateColumn.setSortable(false);
dateColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getRegistrationDate()));
dateColumn.setMinWidth(140);
dateColumn.setMaxWidth(140);
TableColumn<ArbitratorListItem, String> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.onionAddress"));
nameColumn.setSortable(false);
nameColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getAddressString()));
nameColumn.setMinWidth(90);
TableColumn<ArbitratorListItem, String> languagesColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.languages"));
languagesColumn.setSortable(false);
languagesColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getLanguageCodes()));
languagesColumn.setMinWidth(130);
TableColumn<ArbitratorListItem, ArbitratorListItem> selectionColumn = new AutoTooltipTableColumn<ArbitratorListItem, ArbitratorListItem>(Res.get("shared.accept")) {
{
setMinWidth(60);
setMaxWidth(60);
setSortable(false);
}
};
selectionColumn.setCellValueFactory((arbitrator) -> new ReadOnlyObjectWrapper<>(arbitrator.getValue()));
selectionColumn.setCellFactory(new Callback<TableColumn<ArbitratorListItem, ArbitratorListItem>, TableCell<ArbitratorListItem, ArbitratorListItem>>() {
@Override
public TableCell<ArbitratorListItem, ArbitratorListItem> call(TableColumn<ArbitratorListItem, ArbitratorListItem> column) {
return new TableCell<ArbitratorListItem, ArbitratorListItem>() {
private final CheckBox checkBox = new AutoTooltipCheckBox();
private TableRow tableRow;
private BooleanProperty selectedProperty;
private void updateDisableState(final ArbitratorListItem item) {
boolean selected = model.isAcceptedArbitrator(item.arbitrator);
item.setIsSelected(selected);
boolean hasMatchingLanguage = model.hasMatchingLanguage(item.arbitrator);
if (!hasMatchingLanguage) {
model.onRemoveArbitrator(item.arbitrator);
if (selected)
item.setIsSelected(false);
}
boolean isMyOwnRegisteredArbitrator = model.isMyOwnRegisteredArbitrator(item.arbitrator);
checkBox.setDisable(!hasMatchingLanguage || isMyOwnRegisteredArbitrator);
tableRow = getTableRow();
if (tableRow != null) {
tableRow.setOpacity(hasMatchingLanguage && !isMyOwnRegisteredArbitrator ? 1 : 0.4);
if (isMyOwnRegisteredArbitrator) {
String text = Res.get("account.arbitratorSelection.cannotSelectHimself");
tableRow.setTooltip(new Tooltip(text));
tableRow.setOnMouseClicked(e -> new Popup<>().warning(text).show());
} else if (!hasMatchingLanguage) {
tableRow.setTooltip(new Tooltip(Res.get("account.arbitratorSelection.noMatchingLang")));
tableRow.setOnMouseClicked(e -> new Popup<>().warning(Res.get("account.arbitratorSelection.noLang")).show());
} else {
tableRow.setOnMouseClicked(null);
tableRow.setTooltip(null);
}
}
}
@Override
public void updateItem(final ArbitratorListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
selectedProperty = item.isSelectedProperty();
languageCodesListChangeListener = c -> updateDisableState(item);
model.languageCodes.addListener(languageCodesListChangeListener);
isSelectedChangeListener = (observable, oldValue, newValue) -> checkBox.setSelected(newValue);
selectedProperty.addListener(isSelectedChangeListener);
checkBox.setSelected(model.isAcceptedArbitrator(item.arbitrator));
checkBox.setOnAction(e -> {
if (checkBox.isSelected()) {
onAddArbitrator(item);
} else if (model.isDeselectAllowed(item)) {
onRemoveArbitrator(item);
} else {
new Popup<>().warning(Res.get("account.arbitratorSelection.minOne")).show();
checkBox.setSelected(true);
}
item.setIsSelected(checkBox.isSelected());
});
updateDisableState(item);
setGraphic(checkBox);
} else {
model.languageCodes.removeListener(languageCodesListChangeListener);
if (selectedProperty != null)
selectedProperty.removeListener(isSelectedChangeListener);
setGraphic(null);
if (checkBox != null)
checkBox.setOnAction(null);
if (tableRow != null)
tableRow.setOnMouseClicked(null);
}
}
};
}
});
// noinspection unchecked
tableView.getColumns().addAll(dateColumn, nameColumn, languagesColumn, selectionColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
}
Aggregations