use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class NewPortfolioAccountPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
GridLayoutFactory.fillDefaults().numColumns(5).applyTo(container);
Label lblPort = new Label(container, SWT.NULL);
lblPort.setText(Messages.ColumnPortfolio);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblPort);
final Text portfolioName = new Text(container, SWT.BORDER | SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(portfolioName);
Label lblAcc = new Label(container, SWT.NULL);
lblAcc.setText(Messages.ColumnReferenceAccount);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblAcc);
final Text accountName = new Text(container, SWT.BORDER | SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(accountName);
final List<Pair> data = new ArrayList<Pair>();
Button button = new Button(container, SWT.PUSH);
button.setText(Messages.NewFileWizardButtonAdd);
GridDataFactory.fillDefaults().applyTo(button);
Composite tableContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().span(5, 1).grab(true, true).applyTo(tableContainer);
TableColumnLayout layout = new TableColumnLayout();
tableContainer.setLayout(layout);
final TableViewer tViewer = new TableViewer(tableContainer);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String portName = portfolioName.getText();
String acnName = accountName.getText();
if (portName.length() > 0 && acnName.length() > 0) {
Account account = new Account();
account.setName(acnName);
account.setCurrencyCode(client.getBaseCurrency());
Portfolio portfolio = new Portfolio();
portfolio.setName(portName);
portfolio.setReferenceAccount(account);
client.addAccount(account);
client.addPortfolio(portfolio);
data.add(new Pair(portName, acnName));
tViewer.refresh();
// delete previous input
// $NON-NLS-1$
accountName.setText("");
// $NON-NLS-1$
portfolioName.setText("");
// focus first input field
portfolioName.setFocus();
setPageComplete(true);
}
}
});
Table table = tViewer.getTable();
table.setEnabled(false);
table.setHeaderVisible(true);
table.setLinesVisible(false);
tViewer.setContentProvider(ArrayContentProvider.getInstance());
tViewer.setInput(data);
TableViewerColumn pCol = new TableViewerColumn(tViewer, SWT.NONE);
layout.setColumnData(pCol.getColumn(), new ColumnWeightData(50));
pCol.getColumn().setText(Messages.ColumnPortfolio);
pCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Pair) element).portfolio;
}
@Override
public Image getImage(Object element) {
return Images.PORTFOLIO.image();
}
});
TableViewerColumn aCol = new TableViewerColumn(tViewer, SWT.NONE);
layout.setColumnData(aCol.getColumn(), new ColumnWeightData(50));
aCol.getColumn().setText(Messages.ColumnReferenceAccount);
aCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Pair) element).account;
}
@Override
public Image getImage(Object element) {
return Images.ACCOUNT.image();
}
});
container.pack();
setPageComplete(false);
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class CSVImportDefinitionPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new FormLayout());
Label lblTarget = new Label(container, SWT.RIGHT);
lblTarget.setText(Messages.CSVImportLabelTarget);
Combo cmbTarget = new Combo(container, SWT.READ_ONLY);
ComboViewer target = new ComboViewer(cmbTarget);
target.setContentProvider(ArrayContentProvider.getInstance());
target.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Extractor) element).getLabel();
}
});
target.getCombo().setEnabled(!onlySecurityPrices);
target.addSelectionChangedListener(this);
Label lblDelimiter = new Label(container, SWT.NONE);
lblDelimiter.setText(Messages.CSVImportLabelDelimiter);
Combo cmbDelimiter = new Combo(container, SWT.READ_ONLY);
ComboViewer delimiter = new ComboViewer(cmbDelimiter);
delimiter.setContentProvider(ArrayContentProvider.getInstance());
delimiter.setInput(new Delimiter[] { //
new Delimiter(',', Messages.CSVImportSeparatorComma), //
new Delimiter(';', Messages.CSVImportSeparatorSemicolon), new Delimiter('\t', Messages.CSVImportSeparatorTab) });
cmbDelimiter.select(1);
delimiter.addSelectionChangedListener(this);
Label lblSkipLines = new Label(container, SWT.NONE);
lblSkipLines.setText(Messages.CSVImportLabelSkipLines);
final Spinner skipLines = new Spinner(container, SWT.BORDER);
skipLines.setMinimum(0);
skipLines.addModifyListener(event -> onSkipLinesChanged(skipLines.getSelection()));
Label lblEncoding = new Label(container, SWT.NONE);
lblEncoding.setText(Messages.CSVImportLabelEncoding);
Combo cmbEncoding = new Combo(container, SWT.READ_ONLY);
ComboViewer encoding = new ComboViewer(cmbEncoding);
encoding.setContentProvider(ArrayContentProvider.getInstance());
encoding.setInput(Charset.availableCharsets().values().toArray());
encoding.setSelection(new StructuredSelection(Charset.defaultCharset()));
encoding.addSelectionChangedListener(this);
final Button firstLineIsHeader = new Button(container, SWT.CHECK);
firstLineIsHeader.setText(Messages.CSVImportLabelFirstLineIsHeader);
firstLineIsHeader.setSelection(true);
firstLineIsHeader.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
onFirstLineIsHeaderChanged(firstLineIsHeader.getSelection());
}
});
Composite compositeTable = new Composite(container, SWT.NONE);
//
// form layout
//
int width = widest(lblTarget, lblDelimiter, lblEncoding);
FormDataFactory.startingWith(lblTarget).width(width).top(new FormAttachment(0, 5)).thenRight(cmbTarget).right(new FormAttachment(50, -5)).thenBelow(cmbDelimiter).label(lblDelimiter).right(new FormAttachment(50, -5)).thenBelow(cmbEncoding).label(lblEncoding).right(new FormAttachment(50, -5));
FormDataFactory.startingWith(cmbDelimiter).thenRight(lblSkipLines).suffix(skipLines);
FormDataFactory.startingWith(cmbEncoding).thenRight(firstLineIsHeader);
FormData data = new FormData();
data.top = new FormAttachment(cmbEncoding, 10);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(100, 0);
data.width = 100;
data.height = 100;
compositeTable.setLayoutData(data);
//
// table & columns
//
TableColumnLayout layout = new TableColumnLayout();
compositeTable.setLayout(layout);
tableViewer = new TableViewer(compositeTable, SWT.BORDER | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
tableViewer.setLabelProvider(new ImportLabelProvider(importer));
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
table.addMouseListener(new MouseListener() {
@Override
public // NOSONAR
void mouseUp(// NOSONAR
MouseEvent e) {
}
@Override
public // NOSONAR
void mouseDown(// NOSONAR
MouseEvent e) {
}
@Override
public void mouseDoubleClick(MouseEvent e) {
TableItem item = table.getItem(0);
if (item == null)
return;
int columnIndex = -1;
for (int ii = 0; ii < table.getColumnCount(); ii++) {
Rectangle bounds = item.getBounds(ii);
int width = table.getColumn(ii).getWidth();
if (e.x >= bounds.x && e.x <= bounds.x + width)
columnIndex = ii;
}
if (columnIndex >= 0)
onColumnSelected(columnIndex);
}
});
//
// setup form elements
//
target.setInput(importer.getExtractors());
target.getCombo().select(importer.getExtractors().indexOf(importer.getExtractor()));
doProcessFile();
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class TransactionsTab method createControl.
@Override
public Control createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
tableViewer = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
TransactionsTab.class.getSimpleName() + "@v2", preferences, tableViewer, layout);
addColumns(support);
support.createColumns();
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.addSelectionChangedListener(event -> {
TransactionPair<?> tx = ((TransactionPair<?>) ((IStructuredSelection) event.getSelection()).getFirstElement());
if (tx != null && tx.getTransaction().getSecurity() != null)
selectionService.setSelection(new SecuritySelection(model.getClient(), tx.getTransaction().getSecurity()));
});
tableViewer.setInput(model.getTransactions());
model.addUpdateListener(() -> tableViewer.setInput(model.getTransactions()));
return container;
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class BookmarksListTab method createTab.
@Override
public CTabItem createTab(CTabFolder folder) {
Composite container = new Composite(folder, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
bookmarks = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnEditingSupport.prepare(bookmarks);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
BookmarksListTab.class.getSimpleName() + "@bottom", preferences, bookmarks, layout);
// Create Column for Bookmark
Column column = new Column(Messages.BookmarksListView_bookmark, SWT.None, 150);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Bookmark) element).getLabel();
}
@Override
public Image getImage(Object element) {
return Images.TEXT.image();
}
});
// $NON-NLS-1$
new StringEditingSupport(Bookmark.class, "label").addListener(this).attachTo(column);
support.addColumn(column);
// Create Column for URL
column = new Column(Messages.BookmarksListView_url, SWT.None, 500);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Bookmark) element).getPattern();
}
});
// $NON-NLS-1$
new StringEditingSupport(Bookmark.class, "pattern").addListener(this).attachTo(column);
support.addColumn(column);
support.createColumns();
bookmarks.getTable().setHeaderVisible(true);
bookmarks.getTable().setLinesVisible(true);
bookmarks.setContentProvider(ArrayContentProvider.getInstance());
bookmarks.setInput(client.getSettings().getBookmarks());
bookmarks.refresh();
new ContextMenu(bookmarks.getTable(), this::fillContextMenu).hook();
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.BookmarksListView_title);
item.setControl(container);
return item;
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class ReviewExtractedItemsPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new FormLayout());
Composite targetContainer = new Composite(container, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(4).applyTo(targetContainer);
lblPrimaryAccount = new Label(targetContainer, SWT.NONE);
lblPrimaryAccount.setText(Messages.ColumnAccount);
Combo cmbAccount = new Combo(targetContainer, SWT.READ_ONLY);
primaryAccount = new ComboViewer(cmbAccount);
primaryAccount.setContentProvider(ArrayContentProvider.getInstance());
primaryAccount.setInput(client.getActiveAccounts());
primaryAccount.addSelectionChangedListener(e -> checkEntriesAndRefresh(allEntries));
lblSecondaryAccount = new Label(targetContainer, SWT.NONE);
lblSecondaryAccount.setText(Messages.LabelTransferTo);
lblSecondaryAccount.setVisible(false);
Combo cmbAccountTarget = new Combo(targetContainer, SWT.READ_ONLY);
secondaryAccount = new ComboViewer(cmbAccountTarget);
secondaryAccount.setContentProvider(ArrayContentProvider.getInstance());
secondaryAccount.setInput(client.getActiveAccounts());
secondaryAccount.getControl().setVisible(false);
lblPrimaryPortfolio = new Label(targetContainer, SWT.NONE);
lblPrimaryPortfolio.setText(Messages.ColumnPortfolio);
Combo cmbPortfolio = new Combo(targetContainer, SWT.READ_ONLY);
primaryPortfolio = new ComboViewer(cmbPortfolio);
primaryPortfolio.setContentProvider(ArrayContentProvider.getInstance());
primaryPortfolio.setInput(client.getActivePortfolios());
primaryPortfolio.addSelectionChangedListener(e -> checkEntriesAndRefresh(allEntries));
lblSecondaryPortfolio = new Label(targetContainer, SWT.NONE);
lblSecondaryPortfolio.setText(Messages.LabelTransferTo);
lblSecondaryPortfolio.setVisible(false);
Combo cmbPortfolioTarget = new Combo(targetContainer, SWT.READ_ONLY);
secondaryPortfolio = new ComboViewer(cmbPortfolioTarget);
secondaryPortfolio.setContentProvider(ArrayContentProvider.getInstance());
secondaryPortfolio.setInput(client.getActivePortfolios());
secondaryPortfolio.getControl().setVisible(false);
lblImportAssistantExtractor = new Label(targetContainer, SWT.NONE);
lblImportAssistantExtractor.setText(Messages.PDFImportWizardExtractor);
Combo cmbImportAssistantExtractor = new Combo(targetContainer, SWT.READ_ONLY);
comboExtractors = new ComboViewer(cmbImportAssistantExtractor);
comboExtractors.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Extractor) element).getLabel();
}
});
comboExtractors.addSelectionChangedListener(e -> runExtractionJob());
if (extractor instanceof AssistantPDFExtractor) {
List<Extractor> extractors = ((AssistantPDFExtractor) extractor).getAvailableExtractors();
comboExtractors.add(extractors.toArray());
} else {
lblImportAssistantExtractor.setVisible(false);
comboExtractors.getCombo().setVisible(false);
}
preselectDropDowns();
cbConvertToDelivery = new Button(container, SWT.CHECK);
cbConvertToDelivery.setText(Messages.LabelConvertBuySellIntoDeliveryTransactions);
Composite compositeTable = new Composite(container, SWT.NONE);
Composite errorTable = new Composite(container, SWT.NONE);
//
// form layout
//
//
FormDataFactory.startingWith(targetContainer).top(new FormAttachment(0, 0)).left(new FormAttachment(0, 0)).right(new FormAttachment(100, 0)).thenBelow(//
cbConvertToDelivery).thenBelow(compositeTable).right(targetContainer).bottom(//
new FormAttachment(80, 0)).thenBelow(errorTable).right(targetContainer).bottom(new FormAttachment(100, 0));
//
// table & columns
//
TableColumnLayout layout = new TableColumnLayout();
compositeTable.setLayout(layout);
tableViewer = new TableViewer(compositeTable, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
addColumns(tableViewer, layout);
attachContextMenu(table);
layout = new TableColumnLayout();
errorTable.setLayout(layout);
errorTableViewer = new TableViewer(errorTable, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
errorTableViewer.setContentProvider(ArrayContentProvider.getInstance());
table = errorTableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
addColumnsExceptionTable(errorTableViewer, layout);
}
Aggregations