Search in sources :

Example 1 with BooleanEditingSupport

use of name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport in project portfolio by buchen.

the class SecuritiesTable method addMasterDataColumns.

private void addMasterDataColumns() {
    // $NON-NLS-1$
    Column column = new Column("0", Messages.ColumnName, SWT.LEFT, 400);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            return ((Security) e).getName();
        }

        @Override
        public Image getImage(Object e) {
            return ((Security) e).isRetired() ? Images.SECURITY_RETIRED.image() : Images.SECURITY.image();
        }
    });
    // $NON-NLS-1$
    ColumnViewerSorter.create(Security.class, "name").attachTo(column, SWT.DOWN);
    // $NON-NLS-1$
    new StringEditingSupport(Security.class, "name").setMandatory(true).addListener(this).attachTo(column);
    support.addColumn(column);
    column = new NoteColumn();
    column.getEditingSupport().addListener(this);
    support.addColumn(column);
    // $NON-NLS-1$
    column = new IsinColumn("1");
    column.getEditingSupport().addListener(this);
    support.addColumn(column);
    // $NON-NLS-1$
    column = new Column("2", Messages.ColumnTicker, SWT.LEFT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            return ((Security) e).getTickerSymbol();
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(Security.class, "tickerSymbol"));
    // $NON-NLS-1$
    new StringEditingSupport(Security.class, "tickerSymbol").addListener(this).attachTo(column);
    support.addColumn(column);
    // $NON-NLS-1$
    column = new Column("7", Messages.ColumnWKN, SWT.LEFT, 60);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            return ((Security) e).getWkn();
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(Security.class, "wkn"));
    // $NON-NLS-1$
    new StringEditingSupport(Security.class, "wkn").addListener(this).attachTo(column);
    column.setVisible(false);
    support.addColumn(column);
    column = new CurrencyColumn();
    column.setVisible(false);
    support.addColumn(column);
    // $NON-NLS-1$
    column = new Column("8", Messages.ColumnRetired, SWT.LEFT, 40);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            // $NON-NLS-1$
            return "";
        }

        @Override
        public Image getImage(Object e) {
            return ((Security) e).isRetired() ? Images.CHECK.image() : null;
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(Security.class, "retired"));
    // $NON-NLS-1$
    new BooleanEditingSupport(Security.class, "retired").addListener(this).attachTo(column);
    column.setVisible(false);
    support.addColumn(column);
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) Image(org.eclipse.swt.graphics.Image) Security(name.abuchen.portfolio.model.Security) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn)

Example 2 with BooleanEditingSupport

use of name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport 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);
}
Also used : DateEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateEditingSupport) Account(name.abuchen.portfolio.model.Account) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) InvestmentPlan(name.abuchen.portfolio.model.InvestmentPlan) ArrayList(java.util.ArrayList) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) Image(org.eclipse.swt.graphics.Image) Security(name.abuchen.portfolio.model.Security) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) ListEditingSupport(name.abuchen.portfolio.ui.util.viewers.ListEditingSupport)

Aggregations

Security (name.abuchen.portfolio.model.Security)2 BooleanEditingSupport (name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport)2 Column (name.abuchen.portfolio.ui.util.viewers.Column)2 NoteColumn (name.abuchen.portfolio.ui.views.columns.NoteColumn)2 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)2 Image (org.eclipse.swt.graphics.Image)2 ArrayList (java.util.ArrayList)1 Account (name.abuchen.portfolio.model.Account)1 InvestmentPlan (name.abuchen.portfolio.model.InvestmentPlan)1 DateEditingSupport (name.abuchen.portfolio.ui.util.viewers.DateEditingSupport)1 ListEditingSupport (name.abuchen.portfolio.ui.util.viewers.ListEditingSupport)1 StringEditingSupport (name.abuchen.portfolio.ui.util.viewers.StringEditingSupport)1 ValueEditingSupport (name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport)1 AttributeColumn (name.abuchen.portfolio.ui.views.columns.AttributeColumn)1 CurrencyColumn (name.abuchen.portfolio.ui.views.columns.CurrencyColumn)1 IsinColumn (name.abuchen.portfolio.ui.views.columns.IsinColumn)1 NameColumn (name.abuchen.portfolio.ui.views.columns.NameColumn)1 TaxonomyColumn (name.abuchen.portfolio.ui.views.columns.TaxonomyColumn)1