diff options
| author | Kostya <mail@sartin.in> | 2026-10-13 13:14:50 +0300 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-10-13 13:15:15 +0300 |
| commit | c0e134981cb494f12c72fbbd3e5c4de513327520 (patch) | |
| tree | 8b073a9bbca4c975a1eb0bc1237b49e6b98fdc77 | |
| parent | a8bc9dce528abb6340315f7daa61ad76be4a8739 (diff) | |
| download | guess-market-c0e134981cb494f12c72fbbd3e5c4de513327520.tar.gz guess-market-c0e134981cb494f12c72fbbd3e5c4de513327520.tar.xz guess-market-c0e134981cb494f12c72fbbd3e5c4de513327520.zip | |
ui-fx: support running as one logged-in user of a server
The shared UI assumed the whole market was local: it showed nothing
until a file was loaded, let the user act as anyone in the list and
offered to create events by hand. None of that holds for a client of a
shared server.
AppState and AppView now take an optional session user. When it is set:
- the tabs show from the start, since other users' events are there
whether or not we loaded a file ourselves;
- the acting user is fixed, and the user list becomes a directory of
the other users with their balance and role;
- the buttons that create events are hidden, and the Users tab gets a
Deposit Funds button with a small dialog;
- loading a file skips the two-second pause Ex2 asked for.
Without a session user everything behaves as before.
Also keep the event's Trade and Close buttons from collapsing to an
ellipsis when the description is long.
12 files changed, 216 insertions, 12 deletions
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java b/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java index 728d4e8..b116833 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java | |||
| @@ -45,6 +45,7 @@ public final class AppState { | |||
| 45 | private final CatalogContext catalogContext; | 45 | private final CatalogContext catalogContext; |
| 46 | private final GuessMarketContext marketContext; | 46 | private final GuessMarketContext marketContext; |
| 47 | private final AccountContext accountContext; | 47 | private final AccountContext accountContext; |
| 48 | private final String sessionUser; | ||
| 48 | 49 | ||
| 49 | private final StringProperty loadedFile = new SimpleStringProperty(null); | 50 | private final StringProperty loadedFile = new SimpleStringProperty(null); |
| 50 | 51 | ||
| @@ -88,9 +89,19 @@ public final class AppState { | |||
| 88 | CatalogContext catalogContext, | 89 | CatalogContext catalogContext, |
| 89 | GuessMarketContext marketContext, | 90 | GuessMarketContext marketContext, |
| 90 | AccountContext accountContext) { | 91 | AccountContext accountContext) { |
| 92 | this(catalogContext, marketContext, accountContext, null); | ||
| 93 | } | ||
| 94 | |||
| 95 | public AppState( | ||
| 96 | CatalogContext catalogContext, | ||
| 97 | GuessMarketContext marketContext, | ||
| 98 | AccountContext accountContext, | ||
| 99 | String sessionUser) { | ||
| 91 | this.catalogContext = catalogContext; | 100 | this.catalogContext = catalogContext; |
| 92 | this.marketContext = marketContext; | 101 | this.marketContext = marketContext; |
| 93 | this.accountContext = accountContext; | 102 | this.accountContext = accountContext; |
| 103 | this.sessionUser = sessionUser; | ||
| 104 | actingUserName.set(sessionUser); | ||
| 94 | 105 | ||
| 95 | selectedEventId.addListener((obs, oldVal, newVal) -> updateSelectedEvent()); | 106 | selectedEventId.addListener((obs, oldVal, newVal) -> updateSelectedEvent()); |
| 96 | events.addListener((ListChangeListener<EventData>) c -> updateSelectedEvent()); | 107 | events.addListener((ListChangeListener<EventData>) c -> updateSelectedEvent()); |
| @@ -302,6 +313,9 @@ public final class AppState { | |||
| 302 | boolean isMm = | 313 | boolean isMm = |
| 303 | allEvents.stream().anyMatch(e -> e.mm != null && acc.owner().equalsIgnoreCase(e.mm)); | 314 | allEvents.stream().anyMatch(e -> e.mm != null && acc.owner().equalsIgnoreCase(e.mm)); |
| 304 | String role = isMm ? "Market Maker" : "Trader"; | 315 | String role = isMm ? "Market Maker" : "Trader"; |
| 316 | if (acc.owner().equalsIgnoreCase(sessionUser)) { | ||
| 317 | role += " (you)"; | ||
| 318 | } | ||
| 305 | 319 | ||
| 306 | UserData u = new UserData(acc.owner(), role, bal, acc.blocked(), isMm); | 320 | UserData u = new UserData(acc.owner(), role, bal, acc.blocked(), isMm); |
| 307 | 321 | ||
| @@ -442,6 +456,10 @@ public final class AppState { | |||
| 442 | actingUser.set(u); | 456 | actingUser.set(u); |
| 443 | } | 457 | } |
| 444 | 458 | ||
| 459 | public boolean isRemote() { | ||
| 460 | return sessionUser != null; | ||
| 461 | } | ||
| 462 | |||
| 445 | public CatalogContext getCatalogContext() { | 463 | public CatalogContext getCatalogContext() { |
| 446 | return catalogContext; | 464 | return catalogContext; |
| 447 | } | 465 | } |
| @@ -514,6 +532,7 @@ public final class AppState { | |||
| 514 | } | 532 | } |
| 515 | 533 | ||
| 516 | public void setActingUserName(String name) { | 534 | public void setActingUserName(String name) { |
| 535 | if (isRemote()) return; | ||
| 517 | this.actingUserName.set(name); | 536 | this.actingUserName.set(name); |
| 518 | } | 537 | } |
| 519 | 538 | ||
| @@ -530,6 +549,7 @@ public final class AppState { | |||
| 530 | } | 549 | } |
| 531 | 550 | ||
| 532 | public void setActingUser(UserData u) { | 551 | public void setActingUser(UserData u) { |
| 552 | if (isRemote()) return; | ||
| 533 | this.actingUser.set(u); | 553 | this.actingUser.set(u); |
| 534 | if (u != null) { | 554 | if (u != null) { |
| 535 | this.actingUserName.set(u.name); | 555 | this.actingUserName.set(u.name); |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/AppView.java b/ui-fx/src/main/java/market/guess/ui/desktop/AppView.java index b17d3a8..665c9ef 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/AppView.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/AppView.java | |||
| @@ -34,11 +34,20 @@ public final class AppView { | |||
| 34 | CatalogContext catalogContext, | 34 | CatalogContext catalogContext, |
| 35 | GuessMarketContext marketContext, | 35 | GuessMarketContext marketContext, |
| 36 | AccountContext accountContext) { | 36 | AccountContext accountContext) { |
| 37 | this(stage, catalogContext, marketContext, accountContext, null); | ||
| 38 | } | ||
| 39 | |||
| 40 | public AppView( | ||
| 41 | Stage stage, | ||
| 42 | CatalogContext catalogContext, | ||
| 43 | GuessMarketContext marketContext, | ||
| 44 | AccountContext accountContext, | ||
| 45 | String sessionUser) { | ||
| 37 | this.stage = stage; | 46 | this.stage = stage; |
| 38 | this.catalogContext = catalogContext; | 47 | this.catalogContext = catalogContext; |
| 39 | this.marketContext = marketContext; | 48 | this.marketContext = marketContext; |
| 40 | this.accountContext = accountContext; | 49 | this.accountContext = accountContext; |
| 41 | this.state = new AppState(catalogContext, marketContext, accountContext); | 50 | this.state = new AppState(catalogContext, marketContext, accountContext, sessionUser); |
| 42 | stage.initStyle(StageStyle.TRANSPARENT); | 51 | stage.initStyle(StageStyle.TRANSPARENT); |
| 43 | initScene(); | 52 | initScene(); |
| 44 | } | 53 | } |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/components/ModalDialog.java b/ui-fx/src/main/java/market/guess/ui/desktop/components/ModalDialog.java index 21865a5..e2ed363 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/components/ModalDialog.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/components/ModalDialog.java | |||
| @@ -4,5 +4,6 @@ public enum ModalDialog { | |||
| 4 | NONE, | 4 | NONE, |
| 5 | LOAD, | 5 | LOAD, |
| 6 | CREATE_EVENT, | 6 | CREATE_EVENT, |
| 7 | RESOLVE | 7 | RESOLVE, |
| 8 | DEPOSIT | ||
| 8 | } | 9 | } |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java index 416770e..e544200 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java | |||
| @@ -85,6 +85,8 @@ public class AppController { | |||
| 85 | @FXML private CreateEventDialogController createEventDialogController; | 85 | @FXML private CreateEventDialogController createEventDialogController; |
| 86 | @FXML private Node resolveDialog; | 86 | @FXML private Node resolveDialog; |
| 87 | @FXML private ResolveDialogController resolveDialogController; | 87 | @FXML private ResolveDialogController resolveDialogController; |
| 88 | @FXML private Node depositDialog; | ||
| 89 | @FXML private DepositDialogController depositDialogController; | ||
| 88 | 90 | ||
| 89 | private Node currentlyActiveContent; | 91 | private Node currentlyActiveContent; |
| 90 | 92 | ||
| @@ -95,6 +97,8 @@ public class AppController { | |||
| 95 | createEventDialogController.setOnCreate((CreateEventRequest req) -> createEvent(req)); | 97 | createEventDialogController.setOnCreate((CreateEventRequest req) -> createEvent(req)); |
| 96 | resolveDialogController.setOnCancel(this::closeDialog); | 98 | resolveDialogController.setOnCancel(this::closeDialog); |
| 97 | resolveDialogController.setOnConfirm(this::resolveEvent); | 99 | resolveDialogController.setOnConfirm(this::resolveEvent); |
| 100 | depositDialogController.setOnCancel(this::closeDialog); | ||
| 101 | depositDialogController.setOnConfirm(this::deposit); | ||
| 98 | } | 102 | } |
| 99 | 103 | ||
| 100 | public void init(AppView appView) { | 104 | public void init(AppView appView) { |
| @@ -150,6 +154,7 @@ public class AppController { | |||
| 150 | usersTabController.setOnCreateNewEvent(this::openCreateEventDialog); | 154 | usersTabController.setOnCreateNewEvent(this::openCreateEventDialog); |
| 151 | usersTabController.setOnToast(this::toast); | 155 | usersTabController.setOnToast(this::toast); |
| 152 | usersTabController.setOnPlaceOrder(this::placeOrder); | 156 | usersTabController.setOnPlaceOrder(this::placeOrder); |
| 157 | usersTabController.setOnDeposit(this::openDepositDialog); | ||
| 153 | } | 158 | } |
| 154 | 159 | ||
| 155 | private void setupStateBindings() { | 160 | private void setupStateBindings() { |
| @@ -273,7 +278,7 @@ public class AppController { | |||
| 273 | var state = getState(); | 278 | var state = getState(); |
| 274 | if (state == null) return; | 279 | if (state == null) return; |
| 275 | 280 | ||
| 276 | boolean showEmpty = (state.getLoadedFile() == null); | 281 | boolean showEmpty = (state.getLoadedFile() == null) && !state.isRemote(); |
| 277 | boolean showEvents = !showEmpty && (state.getActiveTab() == AppTab.EVENTS); | 282 | boolean showEvents = !showEmpty && (state.getActiveTab() == AppTab.EVENTS); |
| 278 | boolean showUsers = !showEmpty && (state.getActiveTab() == AppTab.USERS); | 283 | boolean showUsers = !showEmpty && (state.getActiveTab() == AppTab.USERS); |
| 279 | 284 | ||
| @@ -308,10 +313,13 @@ public class AppController { | |||
| 308 | var state = getState(); | 313 | var state = getState(); |
| 309 | if (state == null || statusBarLabel == null) return; | 314 | if (state == null || statusBarLabel == null) return; |
| 310 | 315 | ||
| 311 | if (state.getLoadedFile() == null) { | 316 | if (state.getLoadedFile() == null && !state.isRemote()) { |
| 312 | statusBarLabel.setText(" IDLE ī± "); | 317 | statusBarLabel.setText(" IDLE ī± "); |
| 313 | } else { | 318 | } else { |
| 314 | String fileName = Paths.get(state.getLoadedFile()).getFileName().toString(); | 319 | String fileName = |
| 320 | state.isRemote() | ||
| 321 | ? state.getActingUserName() | ||
| 322 | : Paths.get(state.getLoadedFile()).getFileName().toString(); | ||
| 315 | statusBarLabel.setText( | 323 | statusBarLabel.setText( |
| 316 | " ļ " | 324 | " ļ " |
| 317 | + fileName | 325 | + fileName |
| @@ -342,6 +350,10 @@ public class AppController { | |||
| 342 | boolean isResolve = (state.getDialog() == ModalDialog.RESOLVE); | 350 | boolean isResolve = (state.getDialog() == ModalDialog.RESOLVE); |
| 343 | resolveDialog.setVisible(isResolve); | 351 | resolveDialog.setVisible(isResolve); |
| 344 | resolveDialog.setManaged(isResolve); | 352 | resolveDialog.setManaged(isResolve); |
| 353 | |||
| 354 | boolean isDeposit = (state.getDialog() == ModalDialog.DEPOSIT); | ||
| 355 | depositDialog.setVisible(isDeposit); | ||
| 356 | depositDialog.setManaged(isDeposit); | ||
| 345 | } | 357 | } |
| 346 | 358 | ||
| 347 | private void updateToastOverlay() { | 359 | private void updateToastOverlay() { |
| @@ -427,7 +439,8 @@ public class AppController { | |||
| 427 | state.setPendingFile(picked.getAbsolutePath()); | 439 | state.setPendingFile(picked.getAbsolutePath()); |
| 428 | 440 | ||
| 429 | var loadTask = | 441 | var loadTask = |
| 430 | new InitialLoadTask(appView.getCatalogContext(), Paths.get(state.getPendingFile())); | 442 | new InitialLoadTask( |
| 443 | appView.getCatalogContext(), Paths.get(state.getPendingFile()), !state.isRemote()); | ||
| 431 | this.currentLoadTask = loadTask; | 444 | this.currentLoadTask = loadTask; |
| 432 | 445 | ||
| 433 | loadTask.setOnRunning( | 446 | loadTask.setOnRunning( |
| @@ -505,6 +518,27 @@ public class AppController { | |||
| 505 | state.setDialog(ModalDialog.RESOLVE); | 518 | state.setDialog(ModalDialog.RESOLVE); |
| 506 | } | 519 | } |
| 507 | 520 | ||
| 521 | public void openDepositDialog() { | ||
| 522 | depositDialogController.reset(); | ||
| 523 | appView.getState().setDialog(ModalDialog.DEPOSIT); | ||
| 524 | } | ||
| 525 | |||
| 526 | public void deposit(String amount) { | ||
| 527 | var state = appView.getState(); | ||
| 528 | var user = state.getActingUserName(); | ||
| 529 | async( | ||
| 530 | () -> appView.getAccountContext().deposit(user, amount), | ||
| 531 | res -> { | ||
| 532 | if (res.isSuccess()) { | ||
| 533 | state.refreshData(); | ||
| 534 | state.setDialog(ModalDialog.NONE); | ||
| 535 | toast("Deposited " + Format.money(new BigDecimal(amount))); | ||
| 536 | } else { | ||
| 537 | toast("Deposit failed: " + res.getDetails()); | ||
| 538 | } | ||
| 539 | }); | ||
| 540 | } | ||
| 541 | |||
| 508 | public void createEvent(CreateEventRequest req) { | 542 | public void createEvent(CreateEventRequest req) { |
| 509 | var state = appView.getState(); | 543 | var state = appView.getState(); |
| 510 | state.setCreateType(req.mechanism()); | 544 | state.setCreateType(req.mechanism()); |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/DepositDialogController.java b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/DepositDialogController.java new file mode 100644 index 0000000..8cd531f --- /dev/null +++ b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/DepositDialogController.java | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | package market.guess.ui.desktop.controllers; | ||
| 2 | |||
| 3 | import java.math.BigDecimal; | ||
| 4 | import java.util.function.Consumer; | ||
| 5 | import javafx.css.PseudoClass; | ||
| 6 | import javafx.fxml.FXML; | ||
| 7 | import javafx.scene.control.Button; | ||
| 8 | import javafx.scene.control.TextField; | ||
| 9 | |||
| 10 | public class DepositDialogController { | ||
| 11 | private static final PseudoClass ERROR = PseudoClass.getPseudoClass("error"); | ||
| 12 | |||
| 13 | private Runnable onCancel; | ||
| 14 | private Consumer<String> onConfirm; | ||
| 15 | |||
| 16 | @FXML private TextField amountField; | ||
| 17 | @FXML private Button confirmBtn; | ||
| 18 | |||
| 19 | @FXML | ||
| 20 | private void initialize() { | ||
| 21 | amountField | ||
| 22 | .textProperty() | ||
| 23 | .addListener( | ||
| 24 | (obs, o, n) -> { | ||
| 25 | confirmBtn.setDisable(!isValid(n)); | ||
| 26 | amountField.pseudoClassStateChanged(ERROR, !n.isBlank() && !isValid(n)); | ||
| 27 | }); | ||
| 28 | } | ||
| 29 | |||
| 30 | static boolean isValid(String amount) { | ||
| 31 | try { | ||
| 32 | return new BigDecimal(amount.trim()).signum() > 0; | ||
| 33 | } catch (NumberFormatException e) { | ||
| 34 | return false; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | public void setOnCancel(Runnable onCancel) { | ||
| 39 | this.onCancel = onCancel; | ||
| 40 | } | ||
| 41 | |||
| 42 | public void setOnConfirm(Consumer<String> onConfirm) { | ||
| 43 | this.onConfirm = onConfirm; | ||
| 44 | } | ||
| 45 | |||
| 46 | public void reset() { | ||
| 47 | amountField.clear(); | ||
| 48 | amountField.requestFocus(); | ||
| 49 | } | ||
| 50 | |||
| 51 | @FXML | ||
| 52 | private void handleCancel() { | ||
| 53 | if (onCancel != null) { | ||
| 54 | onCancel.run(); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | @FXML | ||
| 59 | private void handleConfirm() { | ||
| 60 | if (onConfirm != null && isValid(amountField.getText())) { | ||
| 61 | onConfirm.accept(amountField.getText().trim()); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } | ||
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/EventsTabController.java b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/EventsTabController.java index e71be40..06e6780 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/EventsTabController.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/EventsTabController.java | |||
| @@ -47,6 +47,7 @@ public class EventsTabController { | |||
| 47 | private Graphic equalizer; | 47 | private Graphic equalizer; |
| 48 | private boolean updatingSelection = false; | 48 | private boolean updatingSelection = false; |
| 49 | 49 | ||
| 50 | @FXML private Button newEventBtn; | ||
| 50 | @FXML private Button methodFilterAllBtn; | 51 | @FXML private Button methodFilterAllBtn; |
| 51 | @FXML private Button methodFilterLmsrBtn; | 52 | @FXML private Button methodFilterLmsrBtn; |
| 52 | @FXML private Button methodFilterObBtn; | 53 | @FXML private Button methodFilterObBtn; |
| @@ -113,6 +114,8 @@ public class EventsTabController { | |||
| 113 | 114 | ||
| 114 | public void init(AppState state) { | 115 | public void init(AppState state) { |
| 115 | this.state = state; | 116 | this.state = state; |
| 117 | newEventBtn.setVisible(!state.isRemote()); | ||
| 118 | newEventBtn.setManaged(!state.isRemote()); | ||
| 116 | equalizer = EqualizerGraphic.create(); | 119 | equalizer = EqualizerGraphic.create(); |
| 117 | liveBarsBox.getChildren().setAll(equalizer.getNode()); | 120 | liveBarsBox.getChildren().setAll(equalizer.getNode()); |
| 118 | 121 | ||
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/UsersTabController.java b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/UsersTabController.java index 6211337..f5c787b 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/UsersTabController.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/UsersTabController.java | |||
| @@ -3,6 +3,7 @@ package market.guess.ui.desktop.controllers; | |||
| 3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
| 4 | import java.util.ArrayList; | 4 | import java.util.ArrayList; |
| 5 | import java.util.function.Consumer; | 5 | import java.util.function.Consumer; |
| 6 | import javafx.application.Platform; | ||
| 6 | import javafx.collections.ListChangeListener; | 7 | import javafx.collections.ListChangeListener; |
| 7 | import javafx.css.PseudoClass; | 8 | import javafx.css.PseudoClass; |
| 8 | import javafx.fxml.FXML; | 9 | import javafx.fxml.FXML; |
| @@ -47,11 +48,14 @@ public class UsersTabController { | |||
| 47 | private Runnable onCreateNewEvent; | 48 | private Runnable onCreateNewEvent; |
| 48 | private Consumer<String> onToast; | 49 | private Consumer<String> onToast; |
| 49 | private OrderPlacer onPlaceOrder; | 50 | private OrderPlacer onPlaceOrder; |
| 51 | private Runnable onDeposit; | ||
| 50 | private Graphic sparkline; | 52 | private Graphic sparkline; |
| 51 | private boolean updatingSelection = false; | 53 | private boolean updatingSelection = false; |
| 52 | 54 | ||
| 53 | @FXML private StackPane sparklineBox; | 55 | @FXML private StackPane sparklineBox; |
| 54 | @FXML private ListView<UserData> userListContainer; | 56 | @FXML private ListView<UserData> userListContainer; |
| 57 | @FXML private Button createEventBtn; | ||
| 58 | @FXML private Button depositBtn; | ||
| 55 | @FXML private VBox userDetailCard; | 59 | @FXML private VBox userDetailCard; |
| 56 | @FXML private Label userNameLabel; | 60 | @FXML private Label userNameLabel; |
| 57 | @FXML private Label userRolePill; | 61 | @FXML private Label userRolePill; |
| @@ -86,6 +90,11 @@ public class UsersTabController { | |||
| 86 | sparkline = SparklineGraphic.create(); | 90 | sparkline = SparklineGraphic.create(); |
| 87 | sparklineBox.getChildren().setAll(sparkline.node); | 91 | sparklineBox.getChildren().setAll(sparkline.node); |
| 88 | 92 | ||
| 93 | createEventBtn.setVisible(!state.isRemote()); | ||
| 94 | createEventBtn.setManaged(!state.isRemote()); | ||
| 95 | depositBtn.setVisible(state.isRemote()); | ||
| 96 | depositBtn.setManaged(state.isRemote()); | ||
| 97 | |||
| 89 | userListContainer.setCellFactory(lv -> new UserListCell()); | 98 | userListContainer.setCellFactory(lv -> new UserListCell()); |
| 90 | userListContainer | 99 | userListContainer |
| 91 | .getSelectionModel() | 100 | .getSelectionModel() |
| @@ -95,6 +104,9 @@ public class UsersTabController { | |||
| 95 | if (updatingSelection) return; | 104 | if (updatingSelection) return; |
| 96 | if (newVal != null && state != null) { | 105 | if (newVal != null && state != null) { |
| 97 | state.setActingUser(newVal); | 106 | state.setActingUser(newVal); |
| 107 | if (state.isRemote() && !newVal.equals(state.actingUser())) { | ||
| 108 | Platform.runLater(this::refreshUserList); | ||
| 109 | } | ||
| 98 | } | 110 | } |
| 99 | }); | 111 | }); |
| 100 | 112 | ||
| @@ -165,6 +177,10 @@ public class UsersTabController { | |||
| 165 | this.onToast = onToast; | 177 | this.onToast = onToast; |
| 166 | } | 178 | } |
| 167 | 179 | ||
| 180 | public void setOnDeposit(Runnable onDeposit) { | ||
| 181 | this.onDeposit = onDeposit; | ||
| 182 | } | ||
| 183 | |||
| 168 | public void setOnPlaceOrder(OrderPlacer onPlaceOrder) { | 184 | public void setOnPlaceOrder(OrderPlacer onPlaceOrder) { |
| 169 | this.onPlaceOrder = onPlaceOrder; | 185 | this.onPlaceOrder = onPlaceOrder; |
| 170 | } | 186 | } |
| @@ -431,6 +447,13 @@ public class UsersTabController { | |||
| 431 | } | 447 | } |
| 432 | 448 | ||
| 433 | @FXML | 449 | @FXML |
| 450 | private void handleDeposit() { | ||
| 451 | if (onDeposit != null) { | ||
| 452 | onDeposit.run(); | ||
| 453 | } | ||
| 454 | } | ||
| 455 | |||
| 456 | @FXML | ||
| 434 | private void handleSelectTradeYes() { | 457 | private void handleSelectTradeYes() { |
| 435 | if (state != null) state.setTradeOptionYes(true); | 458 | if (state != null) state.setTradeOptionYes(true); |
| 436 | } | 459 | } |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/task/InitialLoadTask.java b/ui-fx/src/main/java/market/guess/ui/desktop/task/InitialLoadTask.java index e49b0c4..a5149b8 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/task/InitialLoadTask.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/task/InitialLoadTask.java | |||
| @@ -8,10 +8,12 @@ import market.guess.api.LoadResult; | |||
| 8 | public final class InitialLoadTask extends Task<LoadResult> { | 8 | public final class InitialLoadTask extends Task<LoadResult> { |
| 9 | private final CatalogContext catalog; | 9 | private final CatalogContext catalog; |
| 10 | private final Path path; | 10 | private final Path path; |
| 11 | private final boolean slow; | ||
| 11 | 12 | ||
| 12 | public InitialLoadTask(CatalogContext catalog, Path path) { | 13 | public InitialLoadTask(CatalogContext catalog, Path path, boolean slow) { |
| 13 | this.catalog = catalog; | 14 | this.catalog = catalog; |
| 14 | this.path = path; | 15 | this.path = path; |
| 16 | this.slow = slow; | ||
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | @Override | 19 | @Override |
| @@ -21,7 +23,7 @@ public final class InitialLoadTask extends Task<LoadResult> { | |||
| 21 | return null; | 23 | return null; |
| 22 | } | 24 | } |
| 23 | 25 | ||
| 24 | for (int i = 0; i < 20; i++) { | 26 | for (int i = 0; slow && i < 20; i++) { |
| 25 | if (isCancelled()) { | 27 | if (isCancelled()) { |
| 26 | return null; | 28 | return null; |
| 27 | } | 29 | } |
diff --git a/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml b/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml index 855b787..3a34a7e 100644 --- a/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml +++ b/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml | |||
| @@ -143,6 +143,7 @@ | |||
| 143 | <fx:include fx:id="loadDialog" managed="false" source="controllers/dialog_load.fxml" visible="false" /> | 143 | <fx:include fx:id="loadDialog" managed="false" source="controllers/dialog_load.fxml" visible="false" /> |
| 144 | <fx:include fx:id="createEventDialog" managed="false" source="controllers/dialog_create_event.fxml" visible="false" /> | 144 | <fx:include fx:id="createEventDialog" managed="false" source="controllers/dialog_create_event.fxml" visible="false" /> |
| 145 | <fx:include fx:id="resolveDialog" managed="false" source="controllers/dialog_resolve.fxml" visible="false" /> | 145 | <fx:include fx:id="resolveDialog" managed="false" source="controllers/dialog_resolve.fxml" visible="false" /> |
| 146 | <fx:include fx:id="depositDialog" managed="false" source="controllers/dialog_deposit.fxml" visible="false" /> | ||
| 146 | </children> | 147 | </children> |
| 147 | </StackPane> | 148 | </StackPane> |
| 148 | <StackPane fx:id="toastContainer" mouseTransparent="true" pickOnBounds="false"> | 149 | <StackPane fx:id="toastContainer" mouseTransparent="true" pickOnBounds="false"> |
diff --git a/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/dialog_deposit.fxml b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/dialog_deposit.fxml new file mode 100644 index 0000000..8f7076d --- /dev/null +++ b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/dialog_deposit.fxml | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | |||
| 3 | <?import javafx.geometry.Insets?> | ||
| 4 | <?import javafx.scene.control.Button?> | ||
| 5 | <?import javafx.scene.control.Label?> | ||
| 6 | <?import javafx.scene.control.TextField?> | ||
| 7 | <?import javafx.scene.layout.HBox?> | ||
| 8 | <?import javafx.scene.layout.Region?> | ||
| 9 | <?import javafx.scene.layout.StackPane?> | ||
| 10 | <?import javafx.scene.layout.VBox?> | ||
| 11 | |||
| 12 | <StackPane styleClass="gm-modal-scrim" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="market.guess.ui.desktop.controllers.DepositDialogController"> | ||
| 13 | <children> | ||
| 14 | <VBox maxHeight="-Infinity" maxWidth="-Infinity" prefWidth="400.0" styleClass="gm-card" StackPane.alignment="CENTER"> | ||
| 15 | <children> | ||
| 16 | <HBox alignment="CENTER_LEFT" styleClass="gm-divider-bottom"> | ||
| 17 | <padding> | ||
| 18 | <Insets bottom="16.0" left="20.0" right="20.0" top="16.0" /> | ||
| 19 | </padding> | ||
| 20 | <children> | ||
| 21 | <Label styleClass="gm-text-lg, gm-font-bold, gm-text-ink" text="Deposit funds" /> | ||
| 22 | </children> | ||
| 23 | </HBox> | ||
| 24 | <VBox spacing="8.0"> | ||
| 25 | <padding> | ||
| 26 | <Insets bottom="18.0" left="20.0" right="20.0" top="18.0" /> | ||
| 27 | </padding> | ||
| 28 | <children> | ||
| 29 | <Label styleClass="gm-text-base, gm-font-medium, gm-text-ink2" text="Amount to add to your account" /> | ||
| 30 | <TextField fx:id="amountField" onAction="#handleConfirm" promptText="100.00" styleClass="gm-textfield, gm-textfield-mono" /> | ||
| 31 | </children> | ||
| 32 | </VBox> | ||
| 33 | <HBox alignment="CENTER_LEFT" spacing="9.0" styleClass="gm-divider-top"> | ||
| 34 | <padding> | ||
| 35 | <Insets bottom="14.0" left="20.0" right="20.0" top="14.0" /> | ||
| 36 | </padding> | ||
| 37 | <children> | ||
| 38 | <Region HBox.hgrow="ALWAYS" /> | ||
| 39 | <Button onAction="#handleCancel" styleClass="gm-btn, gm-btn-secondary" text="Cancel" /> | ||
| 40 | <Button fx:id="confirmBtn" disable="true" onAction="#handleConfirm" styleClass="gm-btn, gm-btn-primary" text="Deposit" /> | ||
| 41 | </children> | ||
| 42 | </HBox> | ||
| 43 | </children> | ||
| 44 | </VBox> | ||
| 45 | </children> | ||
| 46 | </StackPane> | ||
diff --git a/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/events_tab.fxml b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/events_tab.fxml index 4e2c1d4..19b5e61 100644 --- a/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/events_tab.fxml +++ b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/events_tab.fxml | |||
| @@ -61,7 +61,7 @@ | |||
| 61 | <children> | 61 | <children> |
| 62 | <Label fx:id="eventCountLabel" styleClass="gm-text-sm, gm-font-regular, gm-text-ink2" text="0 of 0 events shown" /> | 62 | <Label fx:id="eventCountLabel" styleClass="gm-text-sm, gm-font-regular, gm-text-ink2" text="0 of 0 events shown" /> |
| 63 | <Region HBox.hgrow="ALWAYS" /> | 63 | <Region HBox.hgrow="ALWAYS" /> |
| 64 | <Button onAction="#handleNewEvent" styleClass="gm-btn, gm-btn-secondary" text="+ New Event" /> | 64 | <Button fx:id="newEventBtn" onAction="#handleNewEvent" styleClass="gm-btn, gm-btn-secondary" text="+ New Event" /> |
| 65 | </children> | 65 | </children> |
| 66 | </HBox> | 66 | </HBox> |
| 67 | </children> | 67 | </children> |
| @@ -85,8 +85,8 @@ | |||
| 85 | </VBox> | 85 | </VBox> |
| 86 | <HBox spacing="7.0"> | 86 | <HBox spacing="7.0"> |
| 87 | <children> | 87 | <children> |
| 88 | <Button fx:id="openEventBtn" onAction="#handleOpenEvent" styleClass="gm-btn, gm-btn-primary" text="Open Event" /> | 88 | <Button fx:id="openEventBtn" minWidth="-Infinity" onAction="#handleOpenEvent" styleClass="gm-btn, gm-btn-primary" text="Open Event" /> |
| 89 | <Button fx:id="closeEventBtn" onAction="#handleCloseEvent" styleClass="gm-btn, gm-btn-secondary" text="Close & Resolveā¦" /> | 89 | <Button fx:id="closeEventBtn" minWidth="-Infinity" onAction="#handleCloseEvent" styleClass="gm-btn, gm-btn-secondary" text="Close & Resolveā¦" /> |
| 90 | </children> | 90 | </children> |
| 91 | </HBox> | 91 | </HBox> |
| 92 | </children> | 92 | </children> |
diff --git a/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/users_tab.fxml b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/users_tab.fxml index 0a8ee3b..abc03e5 100644 --- a/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/users_tab.fxml +++ b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/users_tab.fxml | |||
| @@ -36,7 +36,8 @@ | |||
| 36 | <!-- Virtualized Users List --> | 36 | <!-- Virtualized Users List --> |
| 37 | <ListView fx:id="userListContainer" styleClass="gm-scroll-transparent, gm-list-view" VBox.vgrow="ALWAYS" /> | 37 | <ListView fx:id="userListContainer" styleClass="gm-scroll-transparent, gm-list-view" VBox.vgrow="ALWAYS" /> |
| 38 | <!-- Create Event Button --> | 38 | <!-- Create Event Button --> |
| 39 | <Button maxWidth="1.7976931348623157E308" onAction="#handleCreateNewEvent" styleClass="gm-btn, gm-btn-primary" text="+ Create New Event" /> | 39 | <Button fx:id="createEventBtn" maxWidth="1.7976931348623157E308" onAction="#handleCreateNewEvent" styleClass="gm-btn, gm-btn-primary" text="+ Create New Event" /> |
| 40 | <Button fx:id="depositBtn" maxWidth="1.7976931348623157E308" onAction="#handleDeposit" styleClass="gm-btn, gm-btn-primary" text="Deposit Funds" /> | ||
| 40 | </children> | 41 | </children> |
| 41 | </VBox> | 42 | </VBox> |
| 42 | <!-- Right Card: User Details --> | 43 | <!-- Right Card: User Details --> |