use of name.abuchen.portfolio.ui.util.ClientFilterMenu in project portfolio by buchen.
the class DataSeriesSet method buildCommonDataSeries.
private void buildCommonDataSeries(Client client, IPreferenceStore preferences, ColorWheel wheel) {
int index = client.getSecurities().size();
for (Security security : client.getSecurities()) {
// as equity data series (only as benchmark)
if (security.getCurrencyCode() == null)
continue;
availableSeries.add(new //
DataSeries(//
DataSeries.Type.SECURITY, //
security, //
security.getName(), wheel.getRGB(index++)));
}
for (Portfolio portfolio : client.getPortfolios()) availableSeries.add(new //
DataSeries(//
DataSeries.Type.PORTFOLIO, //
portfolio, //
portfolio.getName(), wheel.getRGB(index++)));
// portfolio + reference account
for (Portfolio portfolio : client.getPortfolios()) {
DataSeries series = new DataSeries(DataSeries.Type.PORTFOLIO_PLUS_ACCOUNT, portfolio, // $NON-NLS-1$
portfolio.getName() + " + " + portfolio.getReferenceAccount().getName(), wheel.getRGB(index++));
availableSeries.add(series);
}
// custom client filters
ClientFilterMenu menu = new ClientFilterMenu(client, preferences);
// quick fix: users can create duplicate client filters that end up to
// have the same UUID. Avoid adding both violates the precondition that
// every data series must have a unique id
Set<String> addedSeries = new HashSet<>();
for (ClientFilterMenu.Item item : menu.getCustomItems()) {
DataSeries series = new DataSeries(DataSeries.Type.CLIENT_FILTER, item, item.getLabel(), wheel.getRGB(index++));
if (addedSeries.add(series.getUUID()))
availableSeries.add(series);
}
for (Account account : client.getAccounts()) availableSeries.add(new DataSeries(DataSeries.Type.ACCOUNT, account, account.getName(), wheel.getRGB(index++)));
for (Taxonomy taxonomy : client.getTaxonomies()) {
taxonomy.foreach(new Taxonomy.Visitor() {
@Override
public void visit(Classification classification) {
if (classification.getParent() == null)
return;
availableSeries.add(new DataSeries(DataSeries.Type.CLASSIFICATION, classification, classification.getName(), Colors.toRGB(classification.getColor())));
}
});
}
}
Aggregations