use of name.abuchen.portfolio.ui.Images in project portfolio by buchen.
the class ReviewExtractedItemsPage method showContextMenu.
private void showContextMenu(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
boolean atLeastOneImported = false;
boolean atLeastOneNotImported = false;
for (Object element : selection.toList()) {
ExtractedEntry entry = (ExtractedEntry) element;
// an entry will be imported if it is marked as to be
// imported *and* not a duplicate
atLeastOneImported = atLeastOneImported || entry.isImported();
// an entry will not be imported if it marked as not to be
// imported *or* if it is marked as duplicate
atLeastOneNotImported = atLeastOneNotImported || !entry.isImported();
}
// provide a hint to the user why the entry is struck out
if (selection.size() == 1) {
ExtractedEntry entry = (ExtractedEntry) selection.getFirstElement();
//
entry.getStatus().filter(//
s -> s.getCode() != ImportAction.Status.Code.OK).forEach(s -> {
Images image = //
s.getCode() == ImportAction.Status.Code.WARNING ? Images.WARNING : Images.ERROR;
manager.add(new LabelOnly(s.getMessage(), image.descriptor()));
});
}
if (atLeastOneImported) {
manager.add(new Action(Messages.LabelDoNotImport) {
@Override
public void run() {
for (Object element : ((IStructuredSelection) tableViewer.getSelection()).toList()) ((ExtractedEntry) element).setImported(false);
tableViewer.refresh();
}
});
}
if (atLeastOneNotImported) {
manager.add(new Action(Messages.LabelDoImport) {
@Override
public void run() {
for (Object element : ((IStructuredSelection) tableViewer.getSelection()).toList()) ((ExtractedEntry) element).setImported(true);
tableViewer.refresh();
}
});
}
}
use of name.abuchen.portfolio.ui.Images in project portfolio by buchen.
the class ReviewExtractedItemsPage method addColumns.
private void addColumns(TableViewer viewer, TableColumnLayout layout) {
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnStatus);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public Image getImage(ExtractedEntry element) {
Images image = null;
switch(element.getMaxCode()) {
case WARNING:
image = Images.WARNING;
break;
case ERROR:
image = Images.ERROR;
break;
case OK:
default:
}
return image != null ? image.image() : null;
}
@Override
public String getText(ExtractedEntry entry) {
// $NON-NLS-1$
return "";
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(22, true));
column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnDate);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
LocalDateTime date = entry.getItem().getDate();
return date != null ? Values.DateTime.format(date) : null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnTransactionType);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
return entry.getItem().getTypeInformation();
}
@Override
public Image getImage(ExtractedEntry entry) {
Annotated subject = entry.getItem().getSubject();
if (subject instanceof AccountTransaction)
return Images.ACCOUNT.image();
else if (subject instanceof PortfolioTransaction)
return Images.PORTFOLIO.image();
else if (subject instanceof Security)
return Images.SECURITY.image();
else if (subject instanceof BuySellEntry)
return Images.PORTFOLIO.image();
else if (subject instanceof AccountTransferEntry)
return Images.ACCOUNT.image();
else if (subject instanceof PortfolioTransferEntry)
return Images.PORTFOLIO.image();
else
return null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(100, true));
column = new TableViewerColumn(viewer, SWT.RIGHT);
column.getColumn().setText(Messages.ColumnAmount);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
Money amount = entry.getItem().getAmount();
return amount != null ? Values.Money.format(amount) : null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
column = new TableViewerColumn(viewer, SWT.RIGHT);
column.getColumn().setText(Messages.ColumnShares);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
return Values.Share.formatNonZero(entry.getItem().getShares());
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnSecurity);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
Security security = entry.getItem().getSecurity();
return security != null ? security.getName() : null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(250, true));
}
Aggregations