Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add context menu for expandable items in PerformanceView #2967

Merged
merged 1 commit into from Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -572,6 +572,7 @@ public class Messages extends NLS
public static String FilterOnlyClosedTrades;
public static String LabelCoinGeckoCoinId;
public static String LabelCoinGeckoCoinIdHint;
public static String LabelCollapse;
public static String LabelCollapseAll;
public static String LabelColorSchema;
public static String LabelColumns;
Expand All @@ -597,6 +598,7 @@ public class Messages extends NLS
public static String LabelDoImport;
public static String LabelDoNotImport;
public static String LabelEarnings;
public static String LabelExpand;
public static String LabelExpandAll;
public static String LabelExpenses;
public static String LabelError;
Expand Down
Expand Up @@ -1156,6 +1156,8 @@ LabelCoinGeckoCoinId = CoinGecko Coin ID

LabelCoinGeckoCoinIdHint = This field can be used to specify the internal CoinGecko Coin ID for cryptocurrencies having a non-unique ticker symbol. The ID can be retrieved via https://www.coingecko.com.\n\nIf no ID is given the ticker symbol will be used for data access.

LabelCollapse = Collapse

LabelCollapseAll = Collapse all

LabelColorSchema = Color scheme
Expand Down Expand Up @@ -1228,6 +1230,8 @@ LabelExchangeRate = Exchange Rate

LabelExchangeRates = Exchange Rates

LabelExpand = Expand

LabelExpandAll = Expand all

LabelExpenses = Expenses
Expand Down
Expand Up @@ -1142,6 +1142,8 @@ LabelCoinGeckoCoinId = CoinGecko Coin ID

LabelCoinGeckoCoinIdHint = Toto pole lze pou\u017E\u00EDt k zad\u00E1n\u00ED intern\u00EDho ID mince CoinGecko pro kryptom\u011Bny s jin\u00FDm ne\u017E jedine\u010Dn\u00FDm symbolem. ID lze z\u00EDskat prost\u0159ednictv\u00EDm adresy https://www.coingecko.com.\n\nPokud nen\u00ED ID uvedeno, bude pro p\u0159\u00EDstup k dat\u016Fm pou\u017Eit ticker symbol.

LabelCollapse = Sbalit

LabelCollapseAll = Sbalit v\u0161e

LabelColorSchema = Barevn\u00E9 sch\u00E9ma
Expand Down Expand Up @@ -1214,6 +1216,8 @@ LabelExchangeRate = Sm\u011Bnn\u00FD kurz

LabelExchangeRates = Sm\u011Bnn\u00E9 kurzy

LabelExpand = Rozbalit

LabelExpandAll = Rozbalit v\u0161e

LabelExpenses = N\u00E1klady
Expand Down
Expand Up @@ -1141,6 +1141,8 @@ LabelClose = Schlie\u00DFen

LabelCoinGeckoCoinIdHint = Angabe der internen CoinGecko Coin ID f\u00FCr Kryptow\u00E4hrungen, die kein eindeutiges Tickersymbol haben. Die ID kann \u00FCber https://www.coingecko.com ermittelt werden.\n\nWenn die ID nicht angeben wird, wird das Tickersymbol f\u00FCr den Datenzugriff verwendet.

LabelCollapse = Einklappen

LabelCollapseAll = Alle einklappen

LabelColorSchema = Farbschema
Expand Down Expand Up @@ -1213,6 +1215,8 @@ LabelExchangeRate = Wechselkurs

LabelExchangeRates = Wechselkurse

LabelExpand = Aufklappen

LabelExpandAll = Alle aufklappen

LabelExpenses = Ausgaben
Expand Down
Expand Up @@ -1139,6 +1139,8 @@ LabelClientFilterNoCustomFilterExisting = No hay filtro existente.\nCree un nuev

LabelClose = Cerrar

LabelCollapse = Desplegar

LabelCollapseAll = Desplegar todo

LabelColorSchema = Esquema de colores
Expand Down Expand Up @@ -1211,6 +1213,8 @@ LabelExchangeRate = Tipo de cambio

LabelExchangeRates = Cambios de Divisa

LabelExpand = Expandir

LabelExpandAll = Expandir todo

LabelExpenses = Gastos
Expand Down
Expand Up @@ -1144,6 +1144,8 @@ LabelCoinGeckoCoinId = CoinGecko Coin ID

LabelCoinGeckoCoinIdHint = Ce champ peut \u00EAtre utilis\u00E9 pour sp\u00E9cifier l'ID interne de la monnaie CoinGecko pour les crypto-monnaies ayant un symbole de ticker non unique. L'ID peut \u00EAtre r\u00E9cup\u00E9r\u00E9 via https://www.coingecko.com.\n\nSi aucun ID n'est donn\u00E9, le symbole du ticker sera utilis\u00E9 pour l'acc\u00E8s aux donn\u00E9es.

LabelCollapse = R\u00E9duire

LabelCollapseAll = Tout r\u00E9duire

LabelColorSchema = Palette de couleurs
Expand Down Expand Up @@ -1216,6 +1218,8 @@ LabelExchangeRate = Taux de change

LabelExchangeRates = Taux de change

LabelExpand = D\u00E9velopper

LabelExpandAll = D\u00E9velopper tout

LabelExpenses = D\u00E9penses
Expand Down
Expand Up @@ -1143,6 +1143,8 @@ LabelCoinGeckoCoinId = ID Coin CoinGecko

LabelCoinGeckoCoinIdHint = Questo campo pu\u00F2 essere utilizzato per specificare l'ID Coin CoinGecko interno per le criptovalute con un simbolo ticker non univoco. L'ID pu\u00F2 essere recuperato dal sito https://www.coingecko.com.\n\nIn assenza dell'ID per l'accesso ai dati verr\u00E0 utilizzato il simbolo del ticker.

LabelCollapse = Comprimi

LabelCollapseAll = Comprimi tutto

LabelColorSchema = Schema colori
Expand Down Expand Up @@ -1215,6 +1217,8 @@ LabelExchangeRate = Tasso di cambio

LabelExchangeRates = Tassi di cambio

LabelExpand = Espandi

LabelExpandAll = Espandi tutto

LabelExpenses = Spese
Expand Down
Expand Up @@ -1139,6 +1139,8 @@ LabelClientFilterNoCustomFilterExisting = Geen bestaand filter.\nMaak een nieuw

LabelClose = Sluiten

LabelCollapse = Inklappen

LabelCollapseAll = Alles inklappen

LabelColorSchema = Kleurenschema
Expand Down Expand Up @@ -1211,6 +1213,8 @@ LabelExchangeRate = Wisselkoers

LabelExchangeRates = Wisselkoersen

LabelExpand = Uitvouwen

LabelExpandAll = Alles uitvouwen

LabelExpenses = Uitgaven
Expand Down
Expand Up @@ -1141,6 +1141,8 @@ LabelClose = Fecho

LabelCoinGeckoCoinId = ID CoinGecko Coin

LabelCollapse = Recolher

LabelCollapseAll = Recolher todos

LabelColorSchema = Esquema de Cores
Expand Down Expand Up @@ -1213,6 +1215,8 @@ LabelExchangeRate = Taxa de C\u00E2mbio

LabelExchangeRates = Taxas de C\u00E2mbio

LabelExpand = Expandir

LabelExpandAll = Expandir todos

LabelExpenses = Despesas
Expand Down
Expand Up @@ -1143,6 +1143,8 @@ LabelCoinGeckoCoinId = CoinGecko Coin ID

LabelCoinGeckoCoinIdHint = \u042D\u0442\u043E \u043F\u043E\u043B\u0435 \u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0434\u043B\u044F \u0443\u043A\u0430\u0437\u0430\u043D\u0438\u044F \u0432\u043D\u0443\u0442\u0440\u0435\u043D\u043D\u0435\u0433\u043E \u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u0430 CoinGecko Coin ID \u0434\u043B\u044F \u043A\u0440\u0438\u043F\u0442\u043E\u0432\u0430\u043B\u044E\u0442, \u0438\u043C\u0435\u044E\u0449\u0438\u0445 \u043D\u0435\u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u0442\u0438\u043A\u0435\u0440. \u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440 \u043C\u043E\u0436\u043D\u043E \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0447\u0435\u0440\u0435\u0437 https://www.coingecko.com.\n\n\u0415\u0441\u043B\u0438 \u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440 \u043D\u0435 \u0443\u043A\u0430\u0437\u0430\u043D, \u0434\u043B\u044F \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A \u0434\u0430\u043D\u043D\u044B\u043C \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C\u0441\u044F \u0441\u0438\u043C\u0432\u043E\u043B \u0442\u0438\u043A\u0435\u0440\u0430.

LabelCollapse = \u041A\u043E\u043B\u043B\u0430\u043F\u0441

LabelCollapseAll = \u0421\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u0441\u0435

LabelColorSchema = \u0426\u0432\u0435\u0442\u043E\u0432\u0430\u044F \u0441\u0445\u0435\u043C\u0430
Expand Down Expand Up @@ -1215,6 +1217,8 @@ LabelExchangeRate = \u041E\u0431\u043C\u0435\u043D\u043D\u044B\u0439 \u043A\u044

LabelExchangeRates = \u041E\u0431\u043C\u0435\u043D\u043D\u044B\u0435 \u043A\u0443\u0440\u0441\u044B

LabelExpand = \u0420\u0430\u0437\u0432\u0435\u0440\u043D\u0443\u0442\u044C

LabelExpandAll = \u0420\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044C \u0432\u0441\u0435

LabelExpenses = \u0417\u0430\u0442\u0440\u0430\u0442\u044B
Expand Down
Expand Up @@ -8,8 +8,10 @@
import javax.inject.Inject;

import org.eclipse.e4.ui.services.IStylingEngine;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.layout.TreeColumnLayout;
Expand Down Expand Up @@ -402,12 +404,68 @@ private void fillContextMenu(IMenuManager manager) // NOSONAR
{
Object selection = ((IStructuredSelection) calculation.getSelection()).getFirstElement();
if (!(selection instanceof ClientPerformanceSnapshot.Position))
{
addTreeActionsContextMenu(manager, selection);
return;
}

Security security = ((ClientPerformanceSnapshot.Position) selection).getSecurity();
new SecurityContextMenu(this).menuAboutToShow(manager, security);
}

private void addTreeActionsContextMenu(IMenuManager manager, Object obj)
{
manager.add(new Action(Messages.LabelExpand)
{
@Override
public void run()
{
calculation.setExpandedState(obj, true);
}

@Override
public boolean isEnabled()
{
return calculation.isExpandable(obj) && !calculation.getExpandedState(obj);
}
});

manager.add(new Action(Messages.LabelCollapse)
{
@Override
public void run()
{
calculation.setExpandedState(obj, false);
}

@Override
public boolean isEnabled()
{
return calculation.getExpandedState(obj);
}
});

manager.add(new Separator());

manager.add(new Action(Messages.LabelExpandAll)
{
@Override
public void run()
{
calculation.expandAll();
}
});

manager.add(new Action(Messages.LabelCollapseAll)
{
@Override
public void run()
{
calculation.collapseAll();
}
});
}

private TableViewer createTransactionViewer(CTabFolder folder, String title)
{
Composite container = new Composite(folder, SWT.NONE);
Expand All @@ -429,15 +487,14 @@ private TableViewer createTransactionViewer(CTabFolder folder, String title)
getPreferenceStore(), transactionViewer, layout);

Column column = new Column(Messages.ColumnDate, SWT.None, 100);
column.setLabelProvider(
new DateTimeLabelProvider(e -> ((TransactionPair<?>) e).getTransaction().getDateTime())
{
@Override
public Color getForeground(Object element)
{
return colorFor(element);
}
});
column.setLabelProvider(new DateTimeLabelProvider(e -> ((TransactionPair<?>) e).getTransaction().getDateTime())
{
@Override
public Color getForeground(Object element)
{
return colorFor(element);
}
});
column.setSorter(ColumnViewerSorter.create(TransactionPair.BY_DATE), SWT.DOWN);
support.addColumn(column);

Expand Down