use of name.abuchen.portfolio.ui.views.columns.NameColumn in project portfolio by buchen.
the class SecuritiesPerformanceView method createCommonColumns.
private void createCommonColumns() {
// shares held
// $NON-NLS-1$
Column column = new Column("shares", Messages.ColumnSharesOwned, SWT.RIGHT, 80);
column.setLabelProvider(new // NOSONAR
SharesLabelProvider() {
@Override
public Long getValue(Object e) {
return ((SecurityPerformanceRecord) e).getSharesHeld();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "sharesHeld"));
recordColumns.addColumn(column);
// security name
column = new NameColumn();
recordColumns.addColumn(column);
// cost value - fifo
// $NON-NLS-1$
column = new Column("pv", Messages.ColumnPurchaseValue, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnPurchaseValue_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getFifoCost(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCost"));
recordColumns.addColumn(column);
// cost value - moving average
// $NON-NLS-1$
column = new Column("pvmvavg", Messages.ColumnPurchaseValueMovingAverage, SWT.RIGHT, 75);
column.setMenuLabel(Messages.ColumnPurchaseValueMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnPurchaseValueMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getMovingAverageCost(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCost"));
column.setVisible(false);
recordColumns.addColumn(column);
// cost value per share - fifo
// $NON-NLS-1$
column = new Column("pp", Messages.ColumnPurchasePrice, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnPurchasePrice_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Quote.format(((SecurityPerformanceRecord) r).getFifoCostPerSharesHeld(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
recordColumns.addColumn(column);
// cost value per share - moving average
// $NON-NLS-1$
column = new Column("ppmvavg", Messages.ColumnPurchasePriceMovingAverage, SWT.RIGHT, 75);
column.setMenuLabel(Messages.ColumnPurchasePriceMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnPurchasePriceMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Quote.format(((SecurityPerformanceRecord) r).getMovingAverageCostPerSharesHeld(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCostPerSharesHeld"));
column.setVisible(false);
recordColumns.addColumn(column);
// latest / current quote
// $NON-NLS-1$
column = new Column("quote", Messages.ColumnQuote, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnQuote_DescriptionEndOfReportingPeriod);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
return Values.Quote.format(record.getQuote(), getClient().getBaseCurrency());
}
@Override
public String getToolTipText(Object element) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
return MessageFormat.format(Messages.TooltipQuoteAtDate, getText(element), Values.Date.format(record.getLatestSecurityPrice().getDate()));
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
recordColumns.addColumn(column);
// market value
// $NON-NLS-1$
column = new Column("mv", Messages.ColumnMarketValue, SWT.RIGHT, 75);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getMarketValue(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "marketValue"));
recordColumns.addColumn(column);
// fees paid
// $NON-NLS-1$
column = new Column("fees", Messages.ColumnFees, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnFees_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getFees(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fees"));
column.setVisible(false);
recordColumns.addColumn(column);
// taxes paid
// $NON-NLS-1$
column = new Column("taxes", Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getTaxes(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "taxes"));
column.setVisible(false);
recordColumns.addColumn(column);
// isin
column = new IsinColumn();
column.getEditingSupport().addListener(new MarkDirtyListener(this));
column.setVisible(false);
recordColumns.addColumn(column);
// note
column = new NoteColumn();
column.getEditingSupport().addListener(new MarkDirtyListener(this));
column.setVisible(false);
recordColumns.addColumn(column);
}
use of name.abuchen.portfolio.ui.views.columns.NameColumn in project portfolio by buchen.
the class InvestmentPlanListView method addColumns.
private void addColumns(ShowHideColumnHelper support) {
// $NON-NLS-1$
Column column = new NameColumn("0", Messages.ColumnName, SWT.None, 100);
column.getEditingSupport().addListener(this);
support.addColumn(column);
column = new Column(Messages.ColumnSecurity, SWT.NONE, 250);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return ((InvestmentPlan) e).getSecurity().getName();
}
@Override
public Image getImage(Object element) {
return Images.SECURITY.image();
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(Security.class, "name").attachTo(column);
List<Security> securities = new ArrayList<>(getClient().getSecurities());
Collections.sort(securities, new Security.ByName());
// $NON-NLS-1$
new ListEditingSupport(InvestmentPlan.class, "security", securities).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnPortfolio, SWT.None, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return ((InvestmentPlan) e).getPortfolio().getName();
}
@Override
public Image getImage(Object element) {
return Images.PORTFOLIO.image();
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(InvestmentPlan.class, "portfolio").attachTo(column);
// $NON-NLS-1$
new ListEditingSupport(InvestmentPlan.class, "portfolio", getClient().getActivePortfolios()).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnAccount, SWT.None, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
InvestmentPlan plan = (InvestmentPlan) e;
return plan.getAccount() != null ? plan.getAccount().getName() : Messages.InvestmentPlanOptionDelivery;
}
@Override
public Image getImage(Object e) {
InvestmentPlan plan = (InvestmentPlan) e;
return plan.getAccount() != null ? Images.ACCOUNT.image() : null;
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(Account.class, "name").attachTo(column);
List<Account> accounts = new ArrayList<>();
accounts.add(InvestmentPlanModel.DELIVERY);
accounts.addAll(getClient().getAccounts());
// $NON-NLS-1$
new ListEditingSupport(InvestmentPlan.class, "account", accounts).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnStartDate, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return Values.Date.format(((InvestmentPlan) e).getStart());
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(InvestmentPlan.class, "start").attachTo(column);
// $NON-NLS-1$
new DateEditingSupport(InvestmentPlan.class, "start").addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnInterval, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return MessageFormat.format(Messages.InvestmentPlanIntervalLabel, ((InvestmentPlan) e).getInterval());
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(InvestmentPlan.class, "interval").attachTo(column);
List<Integer> available = new ArrayList<>();
for (int ii = 1; ii <= 12; ii++) available.add(ii);
// $NON-NLS-1$
new ListEditingSupport(InvestmentPlan.class, "interval", available).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
InvestmentPlan plan = (InvestmentPlan) e;
return Values.Money.format(Money.of(plan.getCurrencyCode(), plan.getAmount()));
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(InvestmentPlan.class, "amount").attachTo(column);
// $NON-NLS-1$
new ValueEditingSupport(InvestmentPlan.class, "amount", Values.Amount).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnFees, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
InvestmentPlan plan = (InvestmentPlan) e;
return Values.Money.format(Money.of(plan.getCurrencyCode(), plan.getFees()));
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(InvestmentPlan.class, "fees").attachTo(column);
// $NON-NLS-1$
new ValueEditingSupport(InvestmentPlan.class, "fees", Values.Amount).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnAutoGenerate, SWT.LEFT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
// $NON-NLS-1$
return "";
}
@Override
public Image getImage(Object e) {
return ((InvestmentPlan) e).isAutoGenerate() ? Images.CHECK.image() : null;
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(InvestmentPlan.class, "autoGenerate").attachTo(column);
// $NON-NLS-1$
new BooleanEditingSupport(InvestmentPlan.class, "autoGenerate").addListener(this).attachTo(column);
support.addColumn(column);
column = new NoteColumn();
column.getEditingSupport().addListener(this);
column.setVisible(false);
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.views.columns.NameColumn in project portfolio by buchen.
the class StatementOfAssetsViewer method createColumns.
private // NOSONAR
Control createColumns(// NOSONAR
Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
assets = new TableViewer(container, SWT.FULL_SELECTION);
ColumnViewerToolTipSupport.enableFor(assets, ToolTip.NO_RECREATE);
ColumnEditingSupport.prepare(assets);
assets.addSelectionChangedListener(event -> {
Element element = (Element) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (element != null && element.isSecurity())
selectionService.setSelection(new SecuritySelection(client, element.getSecurity()));
});
support = new ShowHideColumnHelper(StatementOfAssetsViewer.class.getName(), client, preference, assets, layout);
// $NON-NLS-1$
Column column = new Column("0", Messages.ColumnSharesOwned, SWT.RIGHT, 80);
column.setLabelProvider(new // NOSONAR
SharesLabelProvider() {
@Override
public Long getValue(Object e) {
Element element = (Element) e;
return element.isSecurity() ? element.getSecurityPosition().getShares() : null;
}
});
column.setComparator(new ElementComparator(new AttributeComparator(e -> ((Element) e).isSecurity() ? ((Element) e).getSecurityPosition().getShares() : null)));
support.addColumn(column);
// $NON-NLS-1$
column = new NameColumn("1");
column.setLabelProvider(new // NOSONAR
NameColumnLabelProvider() {
@Override
public String getText(Object e) {
if (((Element) e).isGroupByTaxonomy())
return Messages.LabelTotalSum;
return super.getText(e);
}
@Override
public Font getFont(Object e) {
return ((Element) e).isGroupByTaxonomy() || ((Element) e).isCategory() ? boldFont : null;
}
@Override
public Image getImage(Object e) {
if (((Element) e).isCategory())
return null;
return super.getImage(e);
}
});
column.setEditingSupport(new // $NON-NLS-1$
StringEditingSupport(// $NON-NLS-1$
Named.class, // $NON-NLS-1$
"name") {
@Override
public boolean canEdit(Object element) {
boolean isCategory = ((Element) element).isCategory();
boolean isUnassignedCategory = isCategory && Classification.UNASSIGNED_ID.equals(((Element) element).getCategory().getClassification().getId());
return !isUnassignedCategory ? super.canEdit(element) : false;
}
}.setMandatory(true).addListener(new MarkDirtyListener(this.owner)));
column.getSorter().wrap(ElementComparator::new);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("2", Messages.ColumnTicker, SWT.None, 60);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
return element.isSecurity() ? element.getSecurity().getTickerSymbol() : null;
}
});
column.setComparator(new ElementComparator(new AttributeComparator(e -> ((Element) e).isSecurity() ? ((Element) e).getSecurity().getTickerSymbol() : null)));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("12", Messages.ColumnWKN, SWT.None, 60);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
return element.isSecurity() ? element.getSecurity().getWkn() : null;
}
});
column.setComparator(new ElementComparator(new AttributeComparator(e -> ((Element) e).isSecurity() ? ((Element) e).getSecurity().getWkn() : null)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new IsinColumn("3");
column.getEditingSupport().addListener(new MarkDirtyListener(this.owner));
column.getSorter().wrap(ElementComparator::new);
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("4", Messages.ColumnQuote, SWT.RIGHT, 60);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
if (!element.isSecurity())
return null;
Security security = element.getSecurity();
return Values.Quote.format(security.getCurrencyCode(), element.getSecurityPosition().getPrice().getValue(), client.getBaseCurrency());
}
});
column.setComparator(new ElementComparator(new AttributeComparator(e -> {
Element element = (Element) e;
if (!element.isSecurity())
return null;
return Money.of(element.getSecurity().getCurrencyCode(), element.getSecurityPosition().getPrice().getValue());
})));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("qdate", Messages.ColumnDateOfQuote, SWT.LEFT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
return element.isSecurity() ? Values.Date.format(element.getSecurityPosition().getPrice().getDate()) : null;
}
});
column.setComparator(new ElementComparator(new AttributeComparator(e -> ((Element) e).isSecurity() ? ((Element) e).getSecurityPosition().getPrice().getDate() : null)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("5", Messages.ColumnMarketValue, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
return Values.Money.format(element.getValuation(), client.getBaseCurrency());
}
@Override
public Font getFont(Object e) {
return ((Element) e).isGroupByTaxonomy() || ((Element) e).isCategory() ? boldFont : null;
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Element.class, "valuation").wrap(ElementComparator::new));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("6", Messages.ColumnShareInPercent, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
if (element.isGroupByTaxonomy())
return Values.Percent.format(1d);
if (element.isCategory())
return Values.Percent.format(element.getCategory().getShare());
else
return Values.Percent.format(element.getPosition().getShare());
}
@Override
public Font getFont(Object e) {
return ((Element) e).isGroupByTaxonomy() || ((Element) e).isCategory() ? boldFont : null;
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Element.class, "valuation").wrap(ElementComparator::new));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("7", Messages.ColumnPurchasePrice, SWT.RIGHT, 60);
column.setDescription(Messages.ColumnPurchasePrice_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
if (element.isSecurity()) {
Money purchasePrice = element.getSecurityPosition().getFIFOPurchasePrice();
return Values.Money.formatNonZero(purchasePrice, client.getBaseCurrency());
}
return null;
}
});
column.setComparator(new ElementComparator(new AttributeComparator(e -> ((Element) e).isSecurity() ? ((Element) e).getSecurityPosition().getFIFOPurchasePrice() : null)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("ppmvavg", Messages.ColumnPurchasePriceMovingAverage, SWT.RIGHT, 60);
column.setDescription(Messages.ColumnPurchasePriceMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
if (element.isSecurity()) {
Money purchasePrice = element.getSecurityPosition().getMovingAveragePurchasePrice();
return Values.Money.formatNonZero(purchasePrice, client.getBaseCurrency());
}
return null;
}
});
column.setComparator(new ElementComparator(new AttributeComparator(e -> ((Element) e).isSecurity() ? ((Element) e).getSecurityPosition().getMovingAveragePurchasePrice() : null)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("8", Messages.ColumnPurchaseValue, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPurchaseValue_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
Money purchaseValue = element.getFIFOPurchaseValue();
return Values.Money.formatNonZero(purchaseValue, client.getBaseCurrency());
}
@Override
public Font getFont(Object e) {
return ((Element) e).isGroupByTaxonomy() || ((Element) e).isCategory() ? boldFont : null;
}
});
column.setVisible(false);
column.setSorter(// $NON-NLS-1$
ColumnViewerSorter.create(Element.class, "FIFOPurchaseValue").wrap(ElementComparator::new));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("pvmvavg", Messages.ColumnPurchaseValueMovingAverage, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPurchaseValueMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Element element = (Element) e;
Money purchaseValue = element.getMovingAveragePurchaseValue();
return Values.Money.formatNonZero(purchaseValue, client.getBaseCurrency());
}
@Override
public Font getFont(Object e) {
return ((Element) e).isGroupByTaxonomy() || ((Element) e).isCategory() ? boldFont : null;
}
});
column.setVisible(false);
column.setSorter(// $NON-NLS-1$
ColumnViewerSorter.create(Element.class, "MovingAveragePurchaseValue").wrap(ElementComparator::new));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("9", Messages.ColumnProfitLoss, SWT.RIGHT, 80);
column.setLabelProvider(new // NOSONAR
ColumnLabelProvider() {
@Override
public String getText(Object e) {
Money profitLoss = ((Element) e).getProfitLoss();
return Values.Money.formatNonZero(profitLoss, client.getBaseCurrency());
}
@Override
public Color getForeground(Object e) {
Money profitLoss = ((Element) e).getProfitLoss();
return Display.getCurrent().getSystemColor(profitLoss.isNegative() ? SWT.COLOR_DARK_RED : SWT.COLOR_DARK_GREEN);
}
@Override
public Image getImage(Object e) {
Money profitLoss = ((Element) e).getProfitLoss();
if (profitLoss.isZero())
return null;
return profitLoss.isNegative() ? Images.RED_ARROW.image() : Images.GREEN_ARROW.image();
}
@Override
public Font getFont(Object e) {
return ((Element) e).isGroupByTaxonomy() || ((Element) e).isCategory() ? boldFont : null;
}
});
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Element.class, "profitLoss").wrap(ElementComparator::new));
support.addColumn(column);
column = new NoteColumn();
column.getEditingSupport().addListener(new MarkDirtyListener(this.owner));
column.getSorter().wrap(ElementComparator::new);
support.addColumn(column);
// create a modifiable copy as all menus share the same list of
// reporting periods
List<ReportingPeriod> options = new ArrayList<>(owner.getPart().loadReportingPeriods());
addPerformanceColumns(options);
addDividendColumns(options);
addTaxonomyColumns();
addAttributeColumns();
addCurrencyColumns();
support.createColumns();
assets.getTable().setHeaderVisible(true);
assets.getTable().setLinesVisible(true);
assets.setContentProvider(new StatementOfAssetsContentProvider());
//
assets.addDragSupport(//
DND.DROP_MOVE, //
new Transfer[] { SecurityTransfer.getTransfer() }, new SecurityDragListener(assets));
LocalResourceManager resources = new LocalResourceManager(JFaceResources.getResources(), assets.getTable());
boldFont = resources.createFont(FontDescriptor.createFrom(assets.getTable().getFont()).setStyle(SWT.BOLD));
return container;
}
use of name.abuchen.portfolio.ui.views.columns.NameColumn in project portfolio by buchen.
the class AbstractNodeTreeViewer method addDimensionColumn.
protected void addDimensionColumn(ShowHideColumnHelper support) {
// $NON-NLS-1$
Column column = new NameColumn("txname", Messages.ColumnLevels, SWT.NONE, 400);
column.setLabelProvider(new // NOSONAR
NameColumnLabelProvider() {
@Override
public Image getImage(Object e) {
if (((TaxonomyNode) e).isUnassignedCategory())
return Images.UNASSIGNED_CATEGORY.image();
return super.getImage(e);
}
});
new // $NON-NLS-1$
StringEditingSupport(// $NON-NLS-1$
Named.class, // $NON-NLS-1$
"name") {
@Override
public boolean canEdit(Object element) {
if (((TaxonomyNode) element).isUnassignedCategory())
return false;
else
return super.canEdit(element);
}
}.setMandatory(true).addListener(this).attachTo(column);
column.setRemovable(false);
// drag & drop sorting does not work well with auto sorting
column.setSorter(null);
support.addColumn(column);
column = new IsinColumn();
column.getEditingSupport().addListener(this);
column.setSorter(null);
column.setVisible(false);
support.addColumn(column);
column = new NoteColumn();
column.getEditingSupport().addListener(this);
column.setSorter(null);
column.setVisible(false);
support.addColumn(column);
addWeightColumn(support);
}
use of name.abuchen.portfolio.ui.views.columns.NameColumn in project portfolio by buchen.
the class AccountListView method createTopTable.
// //////////////////////////////////////////////////////////////
// top table: accounts
// //////////////////////////////////////////////////////////////
@Override
protected void createTopTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
accounts = new TableViewer(container, SWT.FULL_SELECTION);
ColumnEditingSupport.prepare(accounts);
accountColumns = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
AccountListView.class.getSimpleName() + "@top2", getPreferenceStore(), accounts, layout);
// $NON-NLS-1$
Column column = new NameColumn("0", Messages.ColumnAccount, SWT.None, 150);
column.setLabelProvider(new // NOSONAR
NameColumnLabelProvider() {
@Override
public Color getForeground(Object e) {
boolean isRetired = ((Account) e).isRetired();
return isRetired ? Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY) : null;
}
});
column.getEditingSupport().addListener(this);
accountColumns.addColumn(column);
column = new Column(Messages.ColumnBalance, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnBalance_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return Values.Amount.format(((Account) e).getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX)));
}
});
ColumnViewerSorter.create(o -> ((Account) o).getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX))).attachTo(column);
accountColumns.addColumn(column);
column = new CurrencyColumn();
column.setEditingSupport(new CurrencyEditingSupport() {
@Override
public boolean canEdit(Object element) {
return ((Account) element).getTransactions().isEmpty();
}
});
accountColumns.addColumn(column);
column = new NoteColumn();
column.getEditingSupport().addListener(this);
accountColumns.addColumn(column);
accountColumns.createColumns();
accounts.getTable().setHeaderVisible(true);
accounts.getTable().setLinesVisible(true);
accounts.setContentProvider(ArrayContentProvider.getInstance());
resetInput();
accounts.refresh();
accounts.addSelectionChangedListener(event -> {
Account account = (Account) ((IStructuredSelection) event.getSelection()).getFirstElement();
updateOnAccountSelected(account);
transactions.setData(Account.class.toString(), account);
transactions.setInput(account != null ? account.getTransactions() : new ArrayList<AccountTransaction>(0));
transactions.refresh();
});
hookContextMenu(accounts.getTable(), this::fillAccountsContextMenu);
}
Aggregations