use of org.eclipse.jface.layout.TableColumnLayout in project org.csstudio.display.builder by kasemir.
the class SearchView method createSearchSash.
/**
* Create the 'lower' sash for searching archives
* @param sashform
*/
private void createSearchSash(final SashForm sashform) {
final Composite parent = new Composite(sashform, SWT.BORDER);
final GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// Pattern: ___pattern___ [x] [search]
Label l = new Label(parent, 0);
l.setText(Messages.SearchPattern);
l.setLayoutData(new GridData());
// On OS X, a 'search' box might look a little better:
// pattern = new Text(parent, SWT.SEARCH | SWT.ICON_CANCEL);
// ... except:
// a) only takes effect on OS X
// b) doesn't support drop-down for recent searches
pattern = new Text(parent, SWT.BORDER);
pattern.setToolTipText(Messages.SearchPatternTT);
pattern.setLayoutData(new GridData(SWT.FILL, 0, true, false));
pattern.setEnabled(false);
pattern.addListener(SWT.DefaultSelection, new Listener() {
@Override
public void handleEvent(Event e) {
searchForChannels();
}
});
AutoCompleteWidget acw = new AutoCompleteWidget(pattern, AutoCompleteTypes.PV);
search = new Button(parent, SWT.PUSH);
search.setText(Messages.Search);
search.setToolTipText(Messages.SearchTT);
search.setLayoutData(new GridData());
search.setEnabled(false);
AutoCompleteUIHelper.handleSelectEvent(search, acw);
// ( ) Add (*) Replace [ ] Reg.Exp.
final Button result_append = new Button(parent, SWT.RADIO);
result_append.setText(Messages.AppendSearchResults);
result_append.setToolTipText(Messages.AppendSearchResultsTT);
result_append.setLayoutData(new GridData());
result_replace = new Button(parent, SWT.RADIO);
result_replace.setText(Messages.ReplaceSearchResults);
result_replace.setToolTipText(Messages.ReplaceSearchResultsTT);
result_replace.setLayoutData(new GridData(SWT.LEFT, 0, true, false));
result_replace.setSelection(true);
regex = new Button(parent, SWT.CHECK);
regex.setText(Messages.RegularExpression);
regex.setToolTipText(Messages.RegularExpressionTT);
regex.setLayoutData(new GridData());
// Table for channel names, displaying array of ChannelInfo entries
// TableColumnLayout requires table in its own composite
final Composite table_parent = new Composite(parent, 0);
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
table_parent.setLayout(table_layout);
table_parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
channel_table = new TableViewer(table_parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
channel_table.setContentProvider(new ArrayContentProvider());
TableViewerColumn col = TableHelper.createColumn(table_layout, channel_table, Messages.PVName, 200, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ChannelInfo channel = (ChannelInfo) cell.getElement();
cell.setText(channel.getProcessVariable().getName());
}
});
new TableColumnSortHelper<ChannelInfo>(channel_table, col) {
@Override
public int compare(final ChannelInfo item1, final ChannelInfo item2) {
return item1.getProcessVariable().getName().compareTo(item2.getProcessVariable().getName());
}
};
col = TableHelper.createColumn(table_layout, channel_table, Messages.ArchiveName, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ChannelInfo channel = (ChannelInfo) cell.getElement();
cell.setText(channel.getArchiveDataSource().getName());
}
});
new TableColumnSortHelper<ChannelInfo>(channel_table, col) {
@Override
public int compare(final ChannelInfo item1, final ChannelInfo item2) {
return item1.getArchiveDataSource().getName().compareTo(item2.getArchiveDataSource().getName());
}
};
final Table table = channel_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// searchForChannels() relies on non-null content
channel_table.setInput(new ChannelInfo[0]);
// Restore settings from memento
if (memento != null) {
if (memento.getBoolean(TAG_REGEX) != null)
regex.setSelection(memento.getBoolean(TAG_REGEX));
if (memento.getBoolean(TAG_REPLACE) != null) {
final boolean replace = memento.getBoolean(TAG_REPLACE);
result_append.setSelection(!replace);
result_replace.setSelection(replace);
}
}
}
use of org.eclipse.jface.layout.TableColumnLayout in project egit by eclipse.
the class RefSpecPanel method createTableColumns.
private void createTableColumns(final Composite tablePanel) {
final TableColumnLayout columnLayout = new TableColumnLayout();
tablePanel.setLayout(columnLayout);
createDummyColumn(columnLayout);
if (pushSpecs)
createModeColumn(columnLayout);
createSrcColumn(columnLayout);
createDstColumn(columnLayout);
createForceColumn(columnLayout);
createRemoveColumn(columnLayout);
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class ListSelectionDialog 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(this.message);
GridDataFactory.fillDefaults().grab(true, false).applyTo(label);
searchText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(searchText);
searchText.setFocus();
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);
elementFilter = new ElementFilter();
int style = SWT.BORDER | SWT.FULL_SELECTION;
if (isMultiSelection)
style |= SWT.MULTI;
tableViewer = new TableViewer(tableArea, style);
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(labelProvider);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.addFilter(elementFilter);
tableViewer.setInput(elements);
tableViewer.setComparator(new ViewerComparator());
hookListener();
return composite;
}
use of org.eclipse.jface.layout.TableColumnLayout 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());
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class SecuritiesPerformanceView method createTopTable.
@Override
protected void createTopTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
records = new TableViewer(container, SWT.FULL_SELECTION);
recordColumns = new ShowHideColumnHelper(SecuritiesPerformanceView.class.getName(), getClient(), getPreferenceStore(), records, layout);
updateTitle(getDefaultTitle());
recordColumns.addListener(() -> updateTitle(getDefaultTitle()));
ColumnViewerToolTipSupport.enableFor(records, ToolTip.NO_RECREATE);
ColumnEditingSupport.prepare(records);
createCommonColumns();
createDividendColumns();
addPerformanceColumns();
createRiskColumns();
createAdditionalColumns();
recordColumns.createColumns();
records.getTable().setHeaderVisible(true);
records.getTable().setLinesVisible(true);
records.setContentProvider(ArrayContentProvider.getInstance());
//
records.addDragSupport(//
DND.DROP_MOVE, //
new Transfer[] { SecurityTransfer.getTransfer() }, new SecurityDragListener(records));
hookContextMenu(records.getTable(), this::fillContextMenu);
records.addSelectionChangedListener(new // NOSONAR
ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) ((IStructuredSelection) event.getSelection()).getFirstElement();
Security security = null;
List<Transaction> transactionList = null;
if (record != null) {
transactionList = record.getTransactions();
security = record.getSecurity();
}
transactions.setInput(transactionList);
transactions.refresh();
chart.updateChart(security);
latest.setInput(security);
}
});
records.addSelectionChangedListener(event -> {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (record != null)
selectionService.setSelection(new SecuritySelection(getClient(), record.getSecurity()));
});
records.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (recordFilter.isEmpty())
return true;
for (Predicate<SecurityPerformanceRecord> predicate : recordFilter) {
if (!predicate.test((SecurityPerformanceRecord) element))
return false;
}
return true;
}
});
reportingPeriodUpdated();
}
Aggregations