Search in sources :

Example 76 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project egit by eclipse.

the class MultiPullResultDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(main);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
    tv = new TableViewer(main, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    tv.setContentProvider(ArrayContentProvider.getInstance());
    TableColumnLayout layout = new TableColumnLayout();
    main.setLayout(layout);
    tv.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            boolean enabled = false;
            for (Object obj : sel.toList()) {
                @SuppressWarnings("unchecked") Entry<Repository, Object> entry = (Entry<Repository, Object>) obj;
                enabled |= entry.getValue() instanceof PullResult;
            }
            getButton(DETAIL_BUTTON).setEnabled(enabled);
        }
    });
    tv.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            buttonPressed(DETAIL_BUTTON);
        }
    });
    Table table = tv.getTable();
    int linesToShow = Math.min(Math.max(results.size(), 5), 15);
    int heightHint = table.getItemHeight() * linesToShow;
    GridDataFactory.fillDefaults().grab(true, true).hint(800, heightHint).applyTo(table);
    // repository
    TableViewerColumn tc = new TableViewerColumn(tv, SWT.NONE);
    TableColumn col = tc.getColumn();
    tc.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            @SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
            return utils.getRepositoryName(item.getKey());
        }
    });
    col.setText(UIText.MultiPullResultDialog_RepositoryColumnHeader);
    layout.setColumnData(col, new ColumnWeightData(200, 200));
    createComparator(col, 0);
    // fetch status
    tc = new TableViewerColumn(tv, SWT.NONE);
    col = tc.getColumn();
    tc.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            @SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
            if (item.getValue() instanceof IStatus)
                return UIText.MultiPullResultDialog_UnknownStatus;
            PullResult pullRes = (PullResult) item.getValue();
            if (pullRes.getFetchResult() == null) {
                return UIText.MultiPullResultDialog_NothingFetchedStatus;
            } else if (pullRes.getFetchResult().getTrackingRefUpdates().isEmpty()) {
                return UIText.MultiPullResultDialog_NothingUpdatedStatus;
            } else {
                int updated = pullRes.getFetchResult().getTrackingRefUpdates().size();
                if (updated == 1) {
                    return UIText.MultiPullResultDialog_UpdatedOneMessage;
                }
                return NLS.bind(UIText.MultiPullResultDialog_UpdatedMessage, Integer.valueOf(updated));
            }
        }
    });
    col.setText(UIText.MultiPullResultDialog_FetchStatusColumnHeader);
    layout.setColumnData(col, new ColumnWeightData(200, 200));
    createComparator(col, 1);
    // update status
    tc = new TableViewerColumn(tv, SWT.NONE);
    col = tc.getColumn();
    tc.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            @SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
            if (item.getValue() instanceof IStatus) {
                return UIText.MultiPullResultDialog_UnknownStatus;
            }
            PullResult pullRes = (PullResult) item.getValue();
            if (pullRes.getMergeResult() != null) {
                return NLS.bind(UIText.MultiPullResultDialog_MergeResultMessage, MergeResultDialog.getStatusText(pullRes.getMergeResult().getMergeStatus()));
            } else if (pullRes.getRebaseResult() != null) {
                RebaseResult res = pullRes.getRebaseResult();
                return NLS.bind(UIText.MultiPullResultDialog_RebaseResultMessage, RebaseResultDialog.getStatusText(res.getStatus()));
            } else {
                return UIText.MultiPullResultDialog_NothingUpdatedStatus;
            }
        }
    });
    col.setText(UIText.MultiPullResultDialog_UpdateStatusColumnHeader);
    layout.setColumnData(col, new ColumnWeightData(200, 200));
    createComparator(col, 2);
    // overall status
    tc = new TableViewerColumn(tv, SWT.NONE);
    col = tc.getColumn();
    tc.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public Image getImage(Object element) {
            @SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
            Object resultOrError = item.getValue();
            if (resultOrError instanceof IStatus) {
                return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_STOP);
            }
            PullResult res = (PullResult) item.getValue();
            boolean success = res.isSuccessful();
            if (!success) {
                return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_STOP);
            }
            return null;
        }

        @Override
        public String getText(Object element) {
            @SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
            if (item.getValue() instanceof IStatus) {
                IStatus status = (IStatus) item.getValue();
                return status.getMessage();
            }
            PullResult res = (PullResult) item.getValue();
            if (res.isSuccessful()) {
                return UIText.MultiPullResultDialog_OkStatus;
            } else {
                return UIText.MultiPullResultDialog_FailedStatus;
            }
        }
    });
    col.setText(UIText.MultiPullResultDialog_OverallStatusColumnHeader);
    layout.setColumnData(col, new ColumnWeightData(200, 200));
    createComparator(col, 3);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    tv.setInput(results.entrySet());
    return main;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn) PullResult(org.eclipse.jgit.api.PullResult) Point(org.eclipse.swt.graphics.Point) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Entry(java.util.Map.Entry) Repository(org.eclipse.jgit.lib.Repository) IOpenListener(org.eclipse.jface.viewers.IOpenListener) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) TableViewer(org.eclipse.jface.viewers.TableViewer) RebaseResult(org.eclipse.jgit.api.RebaseResult) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 77 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout 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);
}
Also used : NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Type(name.abuchen.portfolio.model.AccountTransaction.Type) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AccountSnapshot(name.abuchen.portfolio.snapshot.AccountSnapshot) ToolBar(org.eclipse.swt.widgets.ToolBar) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) KeyEvent(org.eclipse.swt.events.KeyEvent) LocalTime(java.time.LocalTime) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) Account(name.abuchen.portfolio.model.Account) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) MenuManager(org.eclipse.jface.action.MenuManager) CurrencyEditingSupport(name.abuchen.portfolio.ui.views.columns.CurrencyColumn.CurrencyEditingSupport) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) DateTimeEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateTimeEditingSupport) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) Colors(name.abuchen.portfolio.ui.util.Colors) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Quote(name.abuchen.portfolio.money.Quote) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) LocalDateTime(java.time.LocalDateTime) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) ISeries(org.swtchart.ISeries) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Messages(name.abuchen.portfolio.ui.Messages) AccountTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransferDialog) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) AccountTransferEntry(name.abuchen.portfolio.model.AccountTransferEntry) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) MutableMoney(name.abuchen.portfolio.money.MutableMoney) TimelineChart(name.abuchen.portfolio.ui.util.chart.TimelineChart) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) ChronoUnit(java.time.temporal.ChronoUnit) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolTip(org.eclipse.jface.window.ToolTip) Collections(java.util.Collections) Control(org.eclipse.swt.widgets.Control) Account(name.abuchen.portfolio.model.Account) Composite(org.eclipse.swt.widgets.Composite) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList) CurrencyEditingSupport(name.abuchen.portfolio.ui.views.columns.CurrencyColumn.CurrencyEditingSupport) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 78 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.

the class AccountListView method createTransactionTable.

protected Control createTransactionTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    transactions = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
    ColumnViewerToolTipSupport.enableFor(transactions, ToolTip.NO_RECREATE);
    ColumnEditingSupport.prepare(transactions);
    transactionsColumns = new // $NON-NLS-1$
    ShowHideColumnHelper(// $NON-NLS-1$
    AccountListView.class.getSimpleName() + "@bottom5", getPreferenceStore(), transactions, layout);
    Column column = new Column(Messages.ColumnDate, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            return Values.DateTime.format(((AccountTransaction) e).getDateTime());
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }
    });
    ColumnViewerSorter.create(new AccountTransaction.ByDateAmountTypeAndHashCode()).attachTo(column, SWT.DOWN);
    // $NON-NLS-1$
    new DateTimeEditingSupport(AccountTransaction.class, "dateTime").addListener(this).attachTo(column);
    transactionsColumns.addColumn(column);
    column = new Column(Messages.ColumnTransactionType, SWT.None, 100);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            AccountTransaction t = (AccountTransaction) e;
            return t.getType().toString();
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "type"));
    transactionsColumns.addColumn(column);
    column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            AccountTransaction t = (AccountTransaction) e;
            long v = t.getAmount();
            if (t.getType().isDebit())
                v = -v;
            return Values.Money.format(Money.of(t.getCurrencyCode(), v), getClient().getBaseCurrency());
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "amount"));
    transactionsColumns.addColumn(column);
    column = new Column(Messages.Balance, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            Money balance = transaction2balance.get(e);
            return balance != null ? Values.Money.format(balance, getClient().getBaseCurrency()) : null;
        }
    });
    column.setSorter(ColumnViewerSorter.create(new AccountTransaction.ByDateAmountTypeAndHashCode()));
    transactionsColumns.addColumn(column);
    column = new Column(Messages.ColumnSecurity, SWT.None, 250);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            AccountTransaction t = (AccountTransaction) e;
            return t.getSecurity() != null ? String.valueOf(t.getSecurity()) : null;
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "security"));
    transactionsColumns.addColumn(column);
    column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
    column.setLabelProvider(new SharesLabelProvider() {

        @Override
        public Long getValue(Object e) {
            AccountTransaction t = (AccountTransaction) e;
            if (t.getCrossEntry() instanceof BuySellEntry) {
                return ((BuySellEntry) t.getCrossEntry()).getPortfolioTransaction().getShares();
            } else if (t.getType() == Type.DIVIDENDS && t.getShares() != 0) {
                return t.getShares();
            } else {
                return null;
            }
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }
    });
    new // $NON-NLS-1$
    ValueEditingSupport(// $NON-NLS-1$
    AccountTransaction.class, // $NON-NLS-1$
    "shares", // $NON-NLS-1$
    Values.Share) {

        @Override
        public boolean canEdit(Object element) {
            AccountTransaction t = (AccountTransaction) element;
            return t.getType() == AccountTransaction.Type.DIVIDENDS;
        }
    }.addListener(this).attachTo(column);
    transactionsColumns.addColumn(column);
    column = new Column(Messages.ColumnPerShare, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnPerShare_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            AccountTransaction t = (AccountTransaction) e;
            if (t.getCrossEntry() instanceof BuySellEntry) {
                PortfolioTransaction pt = ((BuySellEntry) t.getCrossEntry()).getPortfolioTransaction();
                return Values.Quote.format(pt.getGrossPricePerShare(), getClient().getBaseCurrency());
            } else if (t.getType() == Type.DIVIDENDS && t.getShares() != 0) {
                long dividendPerShare = Math.round(t.getAmount() * Values.Share.divider() * Values.Quote.factorToMoney() / t.getShares());
                return Values.Quote.format(Quote.of(t.getCurrencyCode(), dividendPerShare), getClient().getBaseCurrency());
            } else {
                return null;
            }
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }
    });
    transactionsColumns.addColumn(column);
    column = new Column(Messages.ColumnOffsetAccount, SWT.None, 120);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            AccountTransaction t = (AccountTransaction) e;
            return t.getCrossEntry() != null ? t.getCrossEntry().getCrossOwner(t).toString() : null;
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }
    });
    transactionsColumns.addColumn(column);
    column = new Column(Messages.ColumnNote, SWT.None, 200);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            return ((AccountTransaction) e).getNote();
        }

        @Override
        public Color getForeground(Object element) {
            return colorFor((AccountTransaction) element);
        }

        @Override
        public Image getImage(Object e) {
            String note = ((AccountTransaction) e).getNote();
            return note != null && note.length() > 0 ? Images.NOTE.image() : null;
        }
    });
    // $NON-NLS-1$
    ColumnViewerSorter.create(AccountTransaction.class, "note").attachTo(column);
    // $NON-NLS-1$
    new StringEditingSupport(AccountTransaction.class, "note").addListener(this).attachTo(column);
    transactionsColumns.addColumn(column);
    transactionsColumns.createColumns();
    transactions.getTable().setHeaderVisible(true);
    transactions.getTable().setLinesVisible(true);
    transactions.setContentProvider(ArrayContentProvider.getInstance());
    hookContextMenu(transactions.getTable(), this::fillTransactionsContextMenu);
    hookKeyListener();
    return container;
}
Also used : BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Image(org.eclipse.swt.graphics.Image) DateTimeEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateTimeEditingSupport) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) Money(name.abuchen.portfolio.money.Money) MutableMoney(name.abuchen.portfolio.money.MutableMoney) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 79 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.

the class EditReportingPeriodsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    Composite tableArea = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).minSize(SWT.DEFAULT, 200).applyTo(tableArea);
    TableColumnLayout layout = new TableColumnLayout();
    tableArea.setLayout(layout);
    tableViewer = new TableViewer(tableArea, SWT.BORDER | SWT.MULTI | SWT.MULTI);
    final Table table = tableViewer.getTable();
    table.setHeaderVisible(false);
    table.setLinesVisible(false);
    TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.None);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(100));
    tableViewer.setLabelProvider(new LabelProvider() {

        @Override
        public Image getImage(Object element) {
            return Images.TEXT.image();
        }
    });
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setInput(periods);
    new ContextMenu(tableViewer.getTable(), m -> fillContextMenu(m)).hook();
    return container;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) Shell(org.eclipse.swt.widgets.Shell) TableViewer(org.eclipse.jface.viewers.TableViewer) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) Action(org.eclipse.jface.action.Action) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Table(org.eclipse.swt.widgets.Table) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) ArrayList(java.util.ArrayList) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) SWT(org.eclipse.swt.SWT) ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Control(org.eclipse.swt.widgets.Control) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) Image(org.eclipse.swt.graphics.Image) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 80 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.

the class FilePickerDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(composite, SWT.None);
    GridDataFactory.fillDefaults().grab(true, true).hint(400, 300).applyTo(container);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
    Label label = new Label(container, SWT.None);
    label.setText(Messages.SaveHandlerTitle);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(label);
    Composite tableArea = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, true).applyTo(tableArea);
    tableArea.setLayout(new FillLayout());
    TableColumnLayout layout = new TableColumnLayout();
    tableArea.setLayout(layout);
    Table table = new Table(tableArea, SWT.BORDER | SWT.CHECK | SWT.MULTI);
    tableViewer = new CheckboxTableViewer(table);
    table.setHeaderVisible(false);
    table.setLinesVisible(false);
    TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.None);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(100));
    tableViewer.setLabelProvider(labelProvider);
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setInput(elements);
    tableViewer.setCheckedElements(elements);
    tableViewer.setComparator(new ViewerComparator());
    hookListener();
    return composite;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)105 Composite (org.eclipse.swt.widgets.Composite)94 TableViewer (org.eclipse.jface.viewers.TableViewer)78 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)62 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)51 GridData (org.eclipse.swt.layout.GridData)46 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)44 Table (org.eclipse.swt.widgets.Table)38 GridLayout (org.eclipse.swt.layout.GridLayout)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)31 Image (org.eclipse.swt.graphics.Image)28 Label (org.eclipse.swt.widgets.Label)27 Viewer (org.eclipse.jface.viewers.Viewer)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)23 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 Button (org.eclipse.swt.widgets.Button)21 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)18 TableColumn (org.eclipse.swt.widgets.TableColumn)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)17