Search in sources :

Example 1 with SashLayoutData

use of name.abuchen.portfolio.ui.util.swt.SashLayoutData in project portfolio by buchen.

the class SecuritiesPerformanceView method createBottomTable.

@Override
protected // NOSONAR
void createBottomTable(// NOSONAR
Composite parent) {
    Composite sash = new Composite(parent, SWT.NONE);
    sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
    // folder
    CTabFolder folder = new CTabFolder(sash, SWT.BORDER);
    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabChart);
    Composite chartComposite = new Composite(folder, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(chartComposite);
    item.setControl(chartComposite);
    chart = new SecuritiesChart(chartComposite, getClient(), new CurrencyConverterImpl(factory, getClient().getBaseCurrency()));
    latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
    latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabTransactions);
    Composite container = new Composite(folder, SWT.NONE);
    item.setControl(container);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    folder.setSelection(0);
    transactions = new TableViewer(container, SWT.FULL_SELECTION);
    ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
    SecuritiesPerformanceView.class.getSimpleName() + "@bottom4", // $NON-NLS-1$
    getPreferenceStore(), transactions, layout);
    // date
    Column column = new Column(Messages.ColumnDate, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            Transaction t = (Transaction) e;
            return Values.DateTime.format(t.getDateTime());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(Transaction.class, "dateTime"), SWT.DOWN);
    support.addColumn(column);
    // transaction type
    column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof PortfolioTransaction)
                return ((PortfolioTransaction) t).getType().toString();
            else if (t instanceof AccountTransaction)
                return ((AccountTransaction) t).getType().toString();
            else if (t instanceof DividendTransaction)
                return AccountTransaction.Type.DIVIDENDS.toString();
            else
                return Messages.LabelQuote;
        }
    });
    support.addColumn(column);
    // shares
    column = new Column(Messages.ColumnShares, SWT.None, 80);
    column.setLabelProvider(new // NOSONAR
    SharesLabelProvider() {

        @Override
        public // NOSONAR
        Long getValue(// NOSONAR
        Object t) {
            if (t instanceof PortfolioTransaction)
                return ((PortfolioTransaction) t).getShares();
            else if (t instanceof DividendInitialTransaction)
                return ((DividendInitialTransaction) t).getPosition().getShares();
            else if (t instanceof DividendFinalTransaction)
                return ((DividendFinalTransaction) t).getPosition().getShares();
            else if (t instanceof DividendTransaction)
                return ((DividendTransaction) t).getShares() != 0L ? ((DividendTransaction) t).getShares() : null;
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend amount
    column = new Column(Messages.ColumnDividendPayment, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnGrossDividend);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.Money.format(((DividendTransaction) t).getGrossValue(), getClient().getBaseCurrency());
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend per share
    column = new Column(Messages.ColumnDividendPerShare, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.AmountFraction.formatNonZero(((DividendTransaction) t).getDividendPerShare());
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend per share
    column = new Column(Messages.ColumnPersonalDividendYield, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnPersonalDividendYield_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYield());
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend per share (moving average)
    column = new Column(Messages.ColumnPersonalDividendYieldMovingAverage, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnPersonalDividendYieldMovingAverage_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYieldMovingAverage());
            else
                return null;
        }
    });
    support.addColumn(column);
    // einstandskurs / bewertung
    column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return null;
            else
                return Values.Money.format(((Transaction) t).getMonetaryAmount(), getClient().getBaseCurrency());
        }
    });
    support.addColumn(column);
    // purchase quote
    column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof PortfolioTransaction) {
                PortfolioTransaction p = (PortfolioTransaction) t;
                return Values.Quote.format(p.getGrossPricePerShare(), getClient().getBaseCurrency());
            } else
                return null;
        }
    });
    support.addColumn(column);
    // gegenkonto
    column = new Column(Messages.ColumnAccount, SWT.None, 120);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof PortfolioTransaction) {
                PortfolioTransaction p = (PortfolioTransaction) t;
                return p.getCrossEntry() != null ? p.getCrossEntry().getCrossOwner(p).toString() : null;
            } else if (t instanceof DividendTransaction) {
                return ((DividendTransaction) t).getAccount().getName();
            } else {
                return null;
            }
        }
    });
    support.addColumn(column);
    // note
    // $NON-NLS-1$
    column = new Column("note", Messages.ColumnNote, SWT.LEFT, 22);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return ((Transaction) r).getNote();
        }

        @Override
        public Image getImage(Object r) {
            String note = ((Transaction) r).getNote();
            return note != null && note.length() > 0 ? Images.NOTE.image() : null;
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(Transaction.class, "note"));
    support.addColumn(column);
    support.createColumns();
    transactions.getTable().setHeaderVisible(true);
    transactions.getTable().setLinesVisible(true);
    transactions.setContentProvider(ArrayContentProvider.getInstance());
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Image(org.eclipse.swt.graphics.Image) CTabItem(org.eclipse.swt.custom.CTabItem) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) 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) DividendFinalTransaction(name.abuchen.portfolio.snapshot.security.DividendFinalTransaction) DividendInitialTransaction(name.abuchen.portfolio.snapshot.security.DividendInitialTransaction) SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Composite(org.eclipse.swt.widgets.Composite) DividendTransaction(name.abuchen.portfolio.snapshot.security.DividendTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) Transaction(name.abuchen.portfolio.model.Transaction) DividendInitialTransaction(name.abuchen.portfolio.snapshot.security.DividendInitialTransaction) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) DividendTransaction(name.abuchen.portfolio.snapshot.security.DividendTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) DividendFinalTransaction(name.abuchen.portfolio.snapshot.security.DividendFinalTransaction) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with SashLayoutData

use of name.abuchen.portfolio.ui.util.swt.SashLayoutData in project portfolio by buchen.

the class AbstractListView method createBody.

@Override
protected final Control createBody(Composite parent) {
    Composite sash = new Composite(parent, SWT.NONE);
    int style = getSashStyle();
    SashLayout sashLayout = new SashLayout(sash, style);
    sash.setLayout(sashLayout);
    createTopTable(sash);
    createBottomTable(sash);
    List<Control> children = sashLayout.getChildren();
    int childIndex = (style & SWT.BEGINNING) == SWT.BEGINNING ? 0 : 1;
    if (children.size() > childIndex) {
        Control control = children.get(childIndex);
        int size = getPreferenceStore().getInt(identifier);
        control.setLayoutData(new SashLayoutData(size != 0 ? size : 250));
        sash.addDisposeListener(e -> getPreferenceStore().setValue(identifier, ((SashLayoutData) control.getLayoutData()).getSize()));
    }
    return sash;
}
Also used : SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData)

Example 3 with SashLayoutData

use of name.abuchen.portfolio.ui.util.swt.SashLayoutData in project portfolio by buchen.

the class PortfolioPart method createContainerWithViews.

private void createContainerWithViews(Composite parent) {
    container = new Composite(parent, SWT.NONE);
    container.setLayout(new FillLayout());
    Composite sash = new Composite(container, SWT.NONE);
    SashLayout sashLayout = new SashLayout(sash, SWT.HORIZONTAL | SWT.BEGINNING);
    sash.setLayout(sashLayout);
    Composite navigationBar = new Composite(sash, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).margins(0, 0).applyTo(navigationBar);
    ClientEditorSidebar sidebar = new ClientEditorSidebar(this);
    Control control = sidebar.createSidebarControl(navigationBar);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(control);
    sashLayout.addQuickNavigation(sidebar::menuAboutToShow);
    Composite divider = new Composite(navigationBar, SWT.NONE);
    divider.setBackground(Colors.SIDEBAR_BORDER);
    GridDataFactory.fillDefaults().span(0, 2).hint(1, SWT.DEFAULT).applyTo(divider);
    ClientProgressProvider provider = make(ClientProgressProvider.class, client, navigationBar);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(provider.getControl());
    book = new PageBook(sash, SWT.NONE);
    // restore & save size of navigation bar
    // $NON-NLS-1$
    final String sashIdentifier = PortfolioPart.class.getSimpleName() + "-newsash";
    int size = getPreferenceStore().getInt(sashIdentifier);
    navigationBar.setLayoutData(new SashLayoutData(size != 0 ? size : 180));
    sash.addDisposeListener(e -> getPreferenceStore().setValue(sashIdentifier, ((SashLayoutData) navigationBar.getLayoutData()).getSize()));
    sidebar.selectDefaultView();
    focus = book;
}
Also used : SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) FillLayout(org.eclipse.swt.layout.FillLayout) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData)

Example 4 with SashLayoutData

use of name.abuchen.portfolio.ui.util.swt.SashLayoutData in project portfolio by buchen.

the class SecurityListView method createBottomTable.

// //////////////////////////////////////////////////////////////
// bottom table: folder
// //////////////////////////////////////////////////////////////
@Override
protected void createBottomTable(Composite parent) {
    Composite sash = new Composite(parent, SWT.NONE);
    sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
    // folder
    CTabFolder folder = new CTabFolder(sash, SWT.BORDER);
    // latest
    latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
    latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
    // tab 1: chart
    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabChart);
    Composite chartComposite = new Composite(folder, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(chartComposite);
    item.setControl(chartComposite);
    chart = new SecuritiesChart(chartComposite, getClient(), new CurrencyConverterImpl(factory, getClient().getBaseCurrency()));
    // tab 2: historical quotes
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabHistoricalQuotes);
    item.setControl(createPricesTable(folder));
    // tab 3: transactions
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabTransactions);
    item.setControl(createTransactionTable(folder));
    // tab 4: event
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabEvents);
    item.setControl(createEventsTable(folder));
    folder.setSelection(0);
}
Also used : SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) CTabItem(org.eclipse.swt.custom.CTabItem) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl)

Example 5 with SashLayoutData

use of name.abuchen.portfolio.ui.util.swt.SashLayoutData in project portfolio by buchen.

the class TreeMapViewer method createControl.

@Override
public Control createControl(Composite parent) {
    Composite sash = new Composite(parent, SWT.NONE);
    sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
    Composite container = new Composite(sash, SWT.NONE);
    container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    treeMap = new TreeMap<>(container);
    treeMap.setTreeMapLayout(new SquarifiedLayout<TaxonomyNode>(10));
    treeMap.setLabelProvider((model, rectangle) -> rectangle.getNode().getName());
    legend = new TreeMapLegend(container, treeMap, getModel(), getRenderer());
    final SecurityDetailsViewer details = new SecurityDetailsViewer(sash, SWT.NONE, getModel().getClient(), true);
    treeMap.addSelectionChangeListener((model, rectangle, label) -> {
        TaxonomyNode node = rectangle.getNode();
        details.setInput(node.getBackingSecurity());
    });
    // layout tree map + legend
    GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).applyTo(container);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(treeMap);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(legend);
    // layout sash
    details.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(details.getControl())));
    treeMap.setRectangleRenderer(new ClassificationRectangleRenderer(getModel(), getRenderer()));
    treeMap.setTreeModel(new Model(getModel()));
    legend.setRootItem(getModel().getChartRenderingRootNode());
    return sash;
}
Also used : SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Composite(org.eclipse.swt.widgets.Composite) ITreeModel(de.engehausen.treemap.ITreeModel) IWeightedTreeModel(de.engehausen.treemap.IWeightedTreeModel) SecurityDetailsViewer(name.abuchen.portfolio.ui.views.SecurityDetailsViewer) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData)

Aggregations

SashLayout (name.abuchen.portfolio.ui.util.swt.SashLayout)5 SashLayoutData (name.abuchen.portfolio.ui.util.swt.SashLayoutData)5 Composite (org.eclipse.swt.widgets.Composite)5 CurrencyConverterImpl (name.abuchen.portfolio.money.CurrencyConverterImpl)2 CTabFolder (org.eclipse.swt.custom.CTabFolder)2 CTabItem (org.eclipse.swt.custom.CTabItem)2 Control (org.eclipse.swt.widgets.Control)2 ITreeModel (de.engehausen.treemap.ITreeModel)1 IWeightedTreeModel (de.engehausen.treemap.IWeightedTreeModel)1 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)1 Transaction (name.abuchen.portfolio.model.Transaction)1 DividendFinalTransaction (name.abuchen.portfolio.snapshot.security.DividendFinalTransaction)1 DividendInitialTransaction (name.abuchen.portfolio.snapshot.security.DividendInitialTransaction)1 DividendTransaction (name.abuchen.portfolio.snapshot.security.DividendTransaction)1 Column (name.abuchen.portfolio.ui.util.viewers.Column)1 ShowHideColumnHelper (name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper)1 SecurityDetailsViewer (name.abuchen.portfolio.ui.views.SecurityDetailsViewer)1 AttributeColumn (name.abuchen.portfolio.ui.views.columns.AttributeColumn)1 IsinColumn (name.abuchen.portfolio.ui.views.columns.IsinColumn)1