Skip to content

Commit 8d62a9f

Browse files
committed
Remove bond from planning in planner
1 parent e34a80e commit 8d62a9f

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

src/main/java/ru/shemplo/tbs/gfx/TBBSPlannerTool.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.panemu.tiwulfx.control.NumberField;
1616

1717
import javafx.beans.property.DoubleProperty;
18+
import javafx.beans.property.SimpleObjectProperty;
1819
import javafx.collections.ListChangeListener;
1920
import javafx.geometry.Insets;
2021
import javafx.geometry.Pos;
@@ -50,6 +51,7 @@
5051
import ru.shemplo.tbs.entity.IPlanningBond;
5152
import ru.shemplo.tbs.entity.ITBSProfile;
5253
import ru.shemplo.tbs.gfx.table.TBSEditTableCell;
54+
import ru.tinkoff.invest.openapi.model.rest.Currency;
5355

5456

5557
public class TBBSPlannerTool extends HBox {
@@ -261,6 +263,7 @@ private TableView <IPlanningBond> makeTable () {
261263

262264
final var grThreshold = TBSStyles.<IPlanningBond, Number> threshold (0.0, 1e-6);
263265
final var sameMonth = TBSStyles.<IPlanningBond> sameMonth (NOW);
266+
final var linkIcon = TBSStyles.<IPlanningBond> linkIcon ();
264267

265268
table.getColumns ().add (TBSUIUtils.<IPlanningBond, Integer> buildTBSTableColumn ()
266269
.name ("#").tooltip (null)
@@ -283,6 +286,15 @@ private TableView <IPlanningBond> makeTable () {
283286
.propertyFetcher (bond -> bond.getRWProperty ("code", () -> "")).converter ((r, v) -> v)
284287
.highlighter (null)
285288
.build ());
289+
table.getColumns ().add (TBSUIUtils.<IPlanningBond, Currency> buildTBSTableColumn ()
290+
.name ("Currency").tooltip (null)
291+
.alignment (Pos.BASELINE_LEFT).minWidth (80.0).sortable (false)
292+
.propertyFetcher (bond -> new MappingROProperty <> (
293+
bond.getRWProperty ("code", () -> ""),
294+
TBSBondManager::getBondCurrency
295+
))
296+
.highlighter (null).converter ((r, v) -> String.valueOf (v))
297+
.build ());
286298
table.getColumns ().add (TBSUIUtils.<IPlanningBond, Number> buildTBSTableColumn ()
287299
.name ("👝").tooltip ("Number of lots in your portfolio (sum by all your accounts)")
288300
.alignment (Pos.BASELINE_LEFT).minWidth (50.0).sortable (false)
@@ -335,6 +347,12 @@ bond.<Integer> getRWProperty ("customValue", () -> null),
335347
.fieldSupplier (this::makeCustomLotsValueField)
336348
.converter (null).highlighter (null)
337349
.build ());
350+
table.getColumns ().add (TBSUIUtils.<IPlanningBond, LinkedSymbolOrImage> buildTBSIconTableColumn ()
351+
.name ("🗑").tooltip (null).minWidth (30.0).sortable (false)
352+
.propertyFetcher (b -> new SimpleObjectProperty <> (LinkedSymbolOrImage.symbol ("⌫", b.getCode ())))
353+
.onClick ((me, cell) -> TBSPlanner.getInstance ().removeBond (cell.getItem ().getLink ()))
354+
.highlighter (linkIcon)
355+
.build ());
338356

339357
return table;
340358
}

src/main/java/ru/shemplo/tbs/gfx/TBSUIUtils.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,6 @@
2121

2222
public class TBSUIUtils {
2323

24-
/*
25-
public static <F, S> TableColumn <F, F> makeTBSTableColumn (
26-
String name, String tooltip, BiFunction <TableRow <F>, F, S> converter, boolean sortable,
27-
double minWidth, Pos alignment, BiConsumer <TBSTableCell <F, S>, S> highlighter
28-
) {
29-
final var column = new TableColumn <F, F> (name);
30-
column.setCellFactory (__ -> {
31-
final var cell = new TBSTableCell <> (converter, highlighter, alignment);
32-
TBSUtils.doIfNN (tooltip, t -> cell.setTooltip (new Tooltip (t)));
33-
return cell;
34-
});
35-
column.setCellValueFactory (cell -> {
36-
return new SimpleObjectProperty <> (cell.getValue ());
37-
});
38-
column.setPrefWidth (minWidth);
39-
column.setSortable (sortable);
40-
column.setMinWidth (minWidth);
41-
42-
return column;
43-
}
44-
45-
public static <F, S> TableColumn <F, F> makeTBSTableColumn (
46-
String name, String tooltip, Function <F, S> converter, boolean sortable,
47-
double minWidth, Pos alignment, BiConsumer <TBSTableCell <F, S>, S> highlighter
48-
) {
49-
return makeTBSTableColumn (name, tooltip,
50-
(r, f) -> TBSUtils.mapIfNN (converter, c -> c.apply (f), null),
51-
sortable, minWidth, alignment, highlighter
52-
);
53-
}
54-
*/
55-
5624
@Builder (builderMethodName = "buildTBSTableColumn")
5725
public static <F, S> TableColumn <F, S> makeTBSTableColumn (
5826
String name, String tooltip, boolean sortable, double minWidth, Pos alignment,

0 commit comments

Comments
 (0)