Skip to content

Commit

Permalink
Added option to filter events by type to event list widget
Browse files Browse the repository at this point in the history
Issue: #4431
  • Loading branch information
buchen committed Jan 25, 2025
1 parent 8258564 commit afa9f35
Show file tree
Hide file tree
Showing 18 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public class Messages extends NLS
public static String ColumnEntity;
public static String ColumnEntryValue;
public static String ColumnErrorMessages;
public static String ColumnEventType;
public static String ColumnExchangeRate;
public static String ColumnExDate;
public static String ColumnExitValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ ColumnEntryValue = Entry value

ColumnErrorMessages = Error Messages

ColumnEventType = Event type

ColumnExDate = Ex-Date

ColumnExchangeRate = Exchange Rate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ ColumnEntryValue = Hodnota vstupu

ColumnErrorMessages = Chybov\u00E9 hl\u00E1\u0161ky

ColumnEventType = Typ ud\u00E1losti

ColumnExDate = Ex-Datum

ColumnExchangeRate = Sm\u011Bnn\u00FD kurz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Startv\u00E6rdi

ColumnErrorMessages = Fejlbeskeder

ColumnEventType = Type begivenhed

ColumnExDate = Ex-Dato

ColumnExchangeRate = Vekselkurs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Einstiegspreis

ColumnErrorMessages = Fehlermeldungen

ColumnEventType = Ereignistyp

ColumnExDate = Ex-Tag

ColumnExchangeRate = Wechselkurs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Valor de entrada

ColumnErrorMessages = Mensajes de error

ColumnEventType = Tipo de acontecimiento

ColumnExDate = Fecha valor

ColumnExchangeRate = Tipo de cambio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ ColumnEntryValue = Prix d'entr\u00E9e

ColumnErrorMessages = Messages d'erreur

ColumnEventType = Type d'\u00E9v\u00E9nement

ColumnExDate = Date de fractionnement

ColumnExchangeRate = Taux de change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Val. ingresso

ColumnErrorMessages = Messaggi errore

ColumnEventType = Tipo di evento

ColumnExDate = Ex-Date

ColumnExchangeRate = Tasso di Cambio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Beginwaarde
ColumnErrorMessages = Foutmeldingen
ColumnEventType = Type evenement
ColumnExDate = Ex-datum
ColumnExchangeRate = Wisselkoers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Warto\u015B\u0107 wej\u015Bciowa

ColumnErrorMessages = Komunikaty o b\u0142\u0119dach

ColumnEventType = Typ zdarzenia

ColumnExDate = Ex-Date

ColumnExchangeRate = Kurs wymiany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Valor da entrada

ColumnErrorMessages = Mensagens de erro

ColumnEventType = Tipo de evento

ColumnExDate = Data EX

ColumnExchangeRate = Taxa de C\u00E2mbio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Valor da entrada

ColumnErrorMessages = Mensagens de erro

ColumnEventType = Tipo de evento

ColumnExDate = Data EX

ColumnExchangeRate = Taxa de C\u00E2mbio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = \u041D\u0430\u0447\u0430\u043B\u044C\u043D\u0430\u044F \u0441

ColumnErrorMessages = \u0421\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u044F \u043E\u0431 \u043E\u0448\u0438\u0431\u043A\u0430\u0445

ColumnEventType = \u0422\u0438\u043F \u0441\u043E\u0431\u044B\u0442\u0438\u044F

ColumnExDate = \u042D\u043A\u0441-\u0434\u0430\u0442\u0430

ColumnExchangeRate = \u041A\u0443\u0440\u0441 \u043E\u0431\u043C\u0435\u043D\u0430
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = Vstupn\u00E1 hodnota
ColumnErrorMessages = Chybov\u00E9 spr\u00E1vy
ColumnEventType = Typ podujatia
ColumnExDate = D\u00E1tum ex
ColumnExchangeRate = V\u00FDmenn\u00FD kurz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = \u5165\u573A\u4EF7\u683C

ColumnErrorMessages = \u9519\u8BEF\u4FE1\u606F

ColumnEventType = \u4E8B\u4EF6\u7C7B\u578B

ColumnExDate = \u9664\u6743\u65E5

ColumnExchangeRate = \u6C47\u7387
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ ColumnEntryValue = \u671F\u521D\u50F9\u503C

ColumnErrorMessages = \u932F\u8AA4\u8A0A\u606F

ColumnEventType = \u6D3B\u52D5\u985E\u578B

ColumnExDate = \u9664\u606F\u65E5

ColumnExchangeRate = \u532F\u7387
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.Supplier;

Expand All @@ -12,6 +13,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import name.abuchen.portfolio.model.Dashboard;
import name.abuchen.portfolio.model.Dashboard.Widget;
import name.abuchen.portfolio.model.Security;
import name.abuchen.portfolio.model.SecurityEvent;
Expand All @@ -23,7 +25,9 @@
import name.abuchen.portfolio.ui.util.swt.StyledLabel;
import name.abuchen.portfolio.ui.views.dashboard.ChartHeightConfig;
import name.abuchen.portfolio.ui.views.dashboard.DashboardData;
import name.abuchen.portfolio.ui.views.dashboard.EnumBasedConfig;
import name.abuchen.portfolio.ui.views.dashboard.ReportingPeriodConfig;
import name.abuchen.portfolio.ui.views.dashboard.WidgetDelegate;
import name.abuchen.portfolio.util.TextUtil;

public class EventListWidget extends AbstractSecurityListWidget<EventListWidget.EventItem>
Expand All @@ -39,11 +43,21 @@ public EventItem(Security security, SecurityEvent event)
}
}

public class EventTypeConfig extends EnumBasedConfig<SecurityEvent.Type>
{
public EventTypeConfig(WidgetDelegate<?> delegate)
{
super(delegate, Messages.ColumnEventType, SecurityEvent.Type.class, Dashboard.Config.EVENT_TYPE,
EnumBasedConfig.Policy.MULTIPLE);
}
}

public EventListWidget(Widget widget, DashboardData data)
{
super(widget, data);

addConfig(new ReportingPeriodConfig(this));
addConfig(new EventTypeConfig(this));
addConfig(new SortingConfig(this));
addConfig(new ChartHeightConfig(this));
}
Expand All @@ -55,15 +69,22 @@ public Supplier<List<EventItem>> getUpdateTask()

var interval = get(ReportingPeriodConfig.class).getReportingPeriod().toInterval(LocalDate.now());

var types = get(EventTypeConfig.class).getValues();
if (types.isEmpty())
types = EnumSet.allOf(SecurityEvent.Type.class);

List<EventItem> items = new ArrayList<>();
for (Security security : getClient().getSecurities())
{
for (var event : security.getEvents())
{
if (interval.contains(event.getDate()))
{
items.add(new EventItem(security, event));
}
if (!interval.contains(event.getDate()))
continue;

if (!types.contains(event.getType()))
continue;

items.add(new EventItem(security, event));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum Config
REPORTING_PERIOD, DATA_SERIES, SECONDARY_DATA_SERIES, CONFIG_UUID, AGGREGATION, EXCHANGE_RATE_SERIES, //
COLOR_SCHEMA, LAYOUT, HEIGHT, EARNING_TYPE, NET_GROSS, CLIENT_FILTER, CALCULATION_METHOD, METRIC, //
ATTRIBUTE_UUID, URL, SHOW_Y_AXIS, TAXONOMY, FLAG_INCLUDE_UNASSIGNED, SORT_DIRECTION, START_YEAR, //
TRANSACTION_FILTER, CLIENT_DATA_SERIES;
TRANSACTION_FILTER, CLIENT_DATA_SERIES, EVENT_TYPE;
}

public static final class Column
Expand Down

0 comments on commit afa9f35

Please sign in to comment.