Search in sources :

Example 11 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination in project bitsquare by bitsquare.

the class AccountView method initialize.

@Override
public void initialize() {
    navigationListener = viewPath -> {
        if (viewPath.size() == 3 && viewPath.indexOf(AccountView.class) == 1) {
            if (arbitratorRegistrationTab == null && viewPath.get(2).equals(ArbitratorRegistrationView.class))
                navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, FiatAccountsView.class);
            else
                loadView(viewPath.tip());
        }
    };
    keyEventEventHandler = event -> {
        if (new KeyCodeCombination(KeyCode.R, KeyCombination.ALT_DOWN).match(event) && arbitratorRegistrationTab == null) {
            arbitratorRegistrationTab = new Tab("Arbitrator registration");
            arbitratorRegistrationTab.setClosable(false);
            root.getTabs().add(arbitratorRegistrationTab);
        }
    };
    tabChangeListener = (ov, oldValue, newValue) -> {
        if (newValue == accountSettingsTab) {
            Class<? extends View> selectedViewClass = accountSettingsView.getSelectedViewClass();
            if (selectedViewClass == null)
                navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, FiatAccountsView.class);
            else
                navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, selectedViewClass);
        } else if (arbitratorRegistrationTab != null) {
            navigation.navigateTo(MainView.class, AccountView.class, ArbitratorRegistrationView.class);
        } else {
            navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class);
        }
    };
}
Also used : AccountSettingsView(io.bitsquare.gui.main.account.settings.AccountSettingsView) MainView(io.bitsquare.gui.main.MainView) Tab(javafx.scene.control.Tab) ArbitratorRegistrationView(io.bitsquare.gui.main.account.arbitratorregistration.ArbitratorRegistrationView) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) FiatAccountsView(io.bitsquare.gui.main.account.content.fiataccounts.FiatAccountsView)

Example 12 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination in project bitsquare by bitsquare.

the class TraderDisputeView method initialize.

@Override
public void initialize() {
    Label label = new Label("Filter list:");
    HBox.setMargin(label, new Insets(5, 0, 0, 0));
    filterTextField = new InputTextField();
    filterTextField.setText("open");
    filterTextFieldListener = (observable, oldValue, newValue) -> applyFilteredListPredicate(filterTextField.getText());
    filterBox = new HBox();
    filterBox.setSpacing(5);
    filterBox.getChildren().addAll(label, filterTextField);
    VBox.setVgrow(filterBox, Priority.NEVER);
    filterBox.setVisible(false);
    filterBox.setManaged(false);
    tableView = new TableView<>();
    VBox.setVgrow(tableView, Priority.SOMETIMES);
    tableView.setMinHeight(150);
    root.getChildren().addAll(filterBox, tableView);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("There are no open tickets");
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);
    tableView.getSelectionModel().clearSelection();
    tableView.getColumns().add(getSelectColumn());
    TableColumn<Dispute, Dispute> contractColumn = getContractColumn();
    tableView.getColumns().add(contractColumn);
    TableColumn<Dispute, Dispute> dateColumn = getDateColumn();
    tableView.getColumns().add(dateColumn);
    TableColumn<Dispute, Dispute> tradeIdColumn = getTradeIdColumn();
    tableView.getColumns().add(tradeIdColumn);
    TableColumn<Dispute, Dispute> buyerOnionAddressColumn = getBuyerOnionAddressColumn();
    tableView.getColumns().add(buyerOnionAddressColumn);
    TableColumn<Dispute, Dispute> sellerOnionAddressColumn = getSellerOnionAddressColumn();
    tableView.getColumns().add(sellerOnionAddressColumn);
    TableColumn<Dispute, Dispute> marketColumn = getMarketColumn();
    tableView.getColumns().add(marketColumn);
    TableColumn<Dispute, Dispute> roleColumn = getRoleColumn();
    tableView.getColumns().add(roleColumn);
    TableColumn<Dispute, Dispute> stateColumn = getStateColumn();
    tableView.getColumns().add(stateColumn);
    tradeIdColumn.setComparator((o1, o2) -> o1.getTradeId().compareTo(o2.getTradeId()));
    dateColumn.setComparator((o1, o2) -> o1.getOpeningDate().compareTo(o2.getOpeningDate()));
    buyerOnionAddressColumn.setComparator((o1, o2) -> getBuyerOnionAddressColumnLabel(o1).compareTo(getBuyerOnionAddressColumnLabel(o2)));
    sellerOnionAddressColumn.setComparator((o1, o2) -> getSellerOnionAddressColumnLabel(o1).compareTo(getSellerOnionAddressColumnLabel(o2)));
    marketColumn.setComparator((o1, o2) -> formatter.getCurrencyPair(o1.getContract().offer.getCurrencyCode()).compareTo(o2.getContract().offer.getCurrencyCode()));
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(dateColumn);
    /*inputTextAreaListener = (observable, oldValue, newValue) ->
                sendButton.setDisable(newValue.length() == 0
                        && tempAttachments.size() == 0 &&
                        selectedDispute.disputeResultProperty().get() == null);*/
    selectedDisputeClosedPropertyListener = (observable, oldValue, newValue) -> {
        messagesInputBox.setVisible(!newValue);
        messagesInputBox.setManaged(!newValue);
        AnchorPane.setBottomAnchor(messageListView, newValue ? 0d : 120d);
    };
    disputeDirectMessageListListener = c -> scrollToBottom();
    keyEventEventHandler = event -> {
        if (new KeyCodeCombination(KeyCode.L, KeyCombination.ALT_DOWN).match(event)) {
            Map<String, List<Dispute>> map = new HashMap<>();
            disputeManager.getDisputesAsObservableList().stream().forEach(dispute -> {
                String tradeId = dispute.getTradeId();
                List<Dispute> list;
                if (!map.containsKey(tradeId))
                    map.put(tradeId, new ArrayList<>());
                list = map.get(tradeId);
                list.add(dispute);
            });
            List<List<Dispute>> disputeGroups = new ArrayList<>();
            map.entrySet().stream().forEach(entry -> {
                disputeGroups.add(entry.getValue());
            });
            disputeGroups.sort((o1, o2) -> !o1.isEmpty() && !o2.isEmpty() ? o1.get(0).getOpeningDate().compareTo(o2.get(0).getOpeningDate()) : 0);
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("Summary of all disputes (No. of disputes: " + disputeGroups.size() + ")\n\n");
            disputeGroups.stream().forEach(disputeGroup -> {
                Dispute dispute0 = disputeGroup.get(0);
                stringBuilder.append("##########################################################################################/\n").append("## Trade ID: ").append(dispute0.getTradeId()).append("\n").append("## Date: ").append(formatter.formatDateTime(dispute0.getOpeningDate())).append("\n").append("## Is support ticket: ").append(dispute0.isSupportTicket()).append("\n");
                if (dispute0.disputeResultProperty().get() != null && dispute0.disputeResultProperty().get().getReason() != null) {
                    stringBuilder.append("## Reason: ").append(dispute0.disputeResultProperty().get().getReason()).append("\n");
                }
                stringBuilder.append("##########################################################################################/\n").append("\n");
                disputeGroup.stream().forEach(dispute -> {
                    stringBuilder.append("*******************************************************************************************\n").append("** Trader's ID: ").append(dispute.getTraderId()).append("\n*******************************************************************************************\n").append("\n");
                    dispute.getDisputeCommunicationMessagesAsObservableList().stream().forEach(m -> {
                        String role = m.isSenderIsTrader() ? ">> Trader's msg: " : "<< Arbitrator's msg: ";
                        stringBuilder.append(role).append(m.getMessage()).append("\n");
                    });
                    stringBuilder.append("\n");
                });
                stringBuilder.append("\n");
            });
            String message = stringBuilder.toString();
            new Popup().headLine("All disputes (" + disputeGroups.size() + ")").information(message).width(1000).actionButtonText("Copy").onAction(() -> Utilities.copyToClipboard(message)).show();
        } else if (new KeyCodeCombination(KeyCode.U, KeyCombination.ALT_DOWN).match(event)) {
            if (selectedDispute != null) {
                if (selectedDisputeClosedPropertyListener != null)
                    selectedDispute.isClosedProperty().removeListener(selectedDisputeClosedPropertyListener);
                selectedDispute.setIsClosed(false);
            }
        } else if (new KeyCodeCombination(KeyCode.R, KeyCombination.ALT_DOWN).match(event)) {
            if (selectedDispute != null) {
                PubKeyRing pubKeyRing = selectedDispute.getTraderPubKeyRing();
                NodeAddress nodeAddress;
                if (pubKeyRing.equals(selectedDispute.getContract().getBuyerPubKeyRing()))
                    nodeAddress = selectedDispute.getContract().getBuyerNodeAddress();
                else
                    nodeAddress = selectedDispute.getContract().getSellerNodeAddress();
                new SendPrivateNotificationWindow(pubKeyRing, nodeAddress).onAddAlertMessage(privateNotificationManager::sendPrivateNotificationMessageIfKeyIsValid).show();
            }
        }
    };
}
Also used : Insets(javafx.geometry.Insets) InputTextField(io.bitsquare.gui.components.InputTextField) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SendPrivateNotificationWindow(io.bitsquare.gui.main.overlays.windows.SendPrivateNotificationWindow) Popup(io.bitsquare.gui.main.overlays.popups.Popup) PubKeyRing(io.bitsquare.common.crypto.PubKeyRing) Dispute(io.bitsquare.arbitration.Dispute) SortedList(javafx.collections.transformation.SortedList) FilteredList(javafx.collections.transformation.FilteredList) ObservableList(javafx.collections.ObservableList) NodeAddress(io.bitsquare.p2p.NodeAddress)

Example 13 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination in project bitsquare by bitsquare.

the class PendingTradesView method initialize.

@Override
public void initialize() {
    setTradeIdColumnCellFactory();
    setDateColumnCellFactory();
    setAmountColumnCellFactory();
    setPriceColumnCellFactory();
    setVolumeColumnCellFactory();
    setPaymentMethodColumnCellFactory();
    setMarketColumnCellFactory();
    setRoleColumnCellFactory();
    setAvatarColumnCellFactory();
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new Label("No pending trades available"));
    tableView.setMinHeight(100);
    idColumn.setComparator((o1, o2) -> o1.getTrade().getId().compareTo(o2.getTrade().getId()));
    dateColumn.setComparator((o1, o2) -> o1.getTrade().getDate().compareTo(o2.getTrade().getDate()));
    tradeVolumeColumn.setComparator((o1, o2) -> {
        if (o1.getTrade().getTradeVolume() != null && o2.getTrade().getTradeVolume() != null)
            return o1.getTrade().getTradeVolume().compareTo(o2.getTrade().getTradeVolume());
        else
            return 0;
    });
    tradeAmountColumn.setComparator((o1, o2) -> {
        if (o1.getTrade().getTradeAmount() != null && o2.getTrade().getTradeAmount() != null)
            return o1.getTrade().getTradeAmount().compareTo(o2.getTrade().getTradeAmount());
        else
            return 0;
    });
    priceColumn.setComparator((o1, o2) -> o1.getPrice().compareTo(o2.getPrice()));
    paymentMethodColumn.setComparator((o1, o2) -> o1.getTrade().getOffer().getPaymentMethod().getId().compareTo(o2.getTrade().getOffer().getPaymentMethod().getId()));
    avatarColumn.setComparator((o1, o2) -> {
        if (o1.getTrade().getTradingPeerNodeAddress() != null && o2.getTrade().getTradingPeerNodeAddress() != null)
            return o1.getTrade().getTradingPeerNodeAddress().hostName.compareTo(o2.getTrade().getTradingPeerNodeAddress().hostName);
        else
            return 0;
    });
    roleColumn.setComparator((o1, o2) -> model.getMyRole(o1).compareTo(model.getMyRole(o2)));
    marketColumn.setComparator((o1, o2) -> model.getMarketLabel(o1).compareTo(model.getMarketLabel(o2)));
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(dateColumn);
    // we use a hidden emergency shortcut to open support ticket
    keyEventEventHandler = event -> {
        if (new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN).match(event) || new KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN).match(event)) {
            Popup popup = new Popup();
            popup.headLine("Open support ticket").message("Please use that only in emergency case if you don't get displayed a \"Open support\" or \"Open dispute\" button.\n\n" + "When you open a support ticket the trade will be interrupted and handled by the arbitrator\n\n" + "Unjustified support tickets (e.g. caused by usability problems or questions) will " + "cause a loss of the security deposit by the trader who opened the ticket.").actionButtonText("Open support ticket").onAction(model.dataModel::onOpenSupportTicket).closeButtonText("Cancel").onClose(() -> popup.hide()).show();
        }
    };
}
Also used : Popup(io.bitsquare.gui.main.overlays.popups.Popup) KeyCodeCombination(javafx.scene.input.KeyCodeCombination)

Example 14 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination in project Gargoyle by callakrsos.

the class SqlTabPanExample method start.

@Override
public void start(Stage primaryStage) throws NotYetSupportException, GargoyleConnectionFailException, InstantiationException, IllegalAccessException, ClassNotFoundException {
    primaryStage.setTitle("Database Exam");
    CommonsSqllPan sqlPane = CommonsSqllPan.getSqlPane();
    sqlPane.getStylesheets().add(SkinManager.getInstance().getSkin());
    BorderPane root = new BorderPane(sqlPane);
    Menu menu = new Menu("Exam");
    MenuItem e = new MenuItem("exam");
    e.setOnAction(System.out::println);
    e.setAccelerator(new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN));
    menu.getItems().add(e);
    root.setTop(new MenuBar(menu));
    primaryStage.setScene(new Scene(root, 1100, 700));
    primaryStage.show();
// Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
// DockPane.initializeDefaultUserAgentStylesheet();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) CommonsSqllPan(com.kyj.fx.voeditor.visual.component.sql.view.CommonsSqllPan) MenuBar(javafx.scene.control.MenuBar) MenuItem(javafx.scene.control.MenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) Menu(javafx.scene.control.Menu) Scene(javafx.scene.Scene)

Aggregations

KeyCodeCombination (javafx.scene.input.KeyCodeCombination)14 MenuItem (javafx.scene.control.MenuItem)8 Menu (javafx.scene.control.Menu)7 ContextMenu (javafx.scene.control.ContextMenu)5 Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 MainView (io.bitsquare.gui.main.MainView)2 SendPrivateNotificationWindow (io.bitsquare.gui.main.overlays.windows.SendPrivateNotificationWindow)2 IOException (java.io.IOException)2 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)2 Level (ch.qos.logback.classic.Level)1 Logger (ch.qos.logback.classic.Logger)1 Guice (com.google.inject.Guice)1 Injector (com.google.inject.Injector)1 FileWrapper (com.kyj.fx.voeditor.visual.component.FileWrapper)1 JavaProjectMemberFileTreeItem (com.kyj.fx.voeditor.visual.component.JavaProjectMemberFileTreeItem)1 CommonsSqllPan (com.kyj.fx.voeditor.visual.component.sql.view.CommonsSqllPan)1 GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)1 FxPostInitialize (com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)1 AlertManager (io.bitsquare.alert.AlertManager)1 APP_NAME_KEY (io.bitsquare.app.AppOptionKeys.APP_NAME_KEY)1