use of org.eclipse.wb.internal.core.utils.ui.TableFactory in project windowbuilder by eclipse.
the class StringPropertyKeyDialog method createValuesGroup.
private void createValuesGroup(Composite parent) {
Group valuesGroup = new Group(parent, SWT.NONE);
GridDataFactory.create(valuesGroup).hintC(105, 20).grab().fill();
GridLayoutFactory.create(valuesGroup);
valuesGroup.setText(ModelMessages.StringPropertyKeyDialog_valuesGroup);
// pattern
{
new Label(valuesGroup, SWT.NONE).setText(ModelMessages.StringPropertyKeyDialog_valuesFilterLabel);
//
m_filterPatternText = new Text(valuesGroup, SWT.BORDER);
GridDataFactory.create(m_filterPatternText).grabH().fill();
m_filterPatternText.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
refreshValuesViewer();
}
});
}
// viewer
{
new Label(valuesGroup, SWT.NONE).setText(ModelMessages.StringPropertyKeyDialog_matchedGroup);
//
m_valuesViewer = new TableViewer(valuesGroup, SWT.BORDER | SWT.FULL_SELECTION);
GridDataFactory.create(m_valuesViewer.getTable()).grab().fill();
// columns
{
TableFactory tableFactory = TableFactory.modify(m_valuesViewer).standard();
tableFactory.newColumn().widthC(40).text(ModelMessages.StringPropertyKeyDialog_keyColumn);
tableFactory.newColumn().widthC(57).image(LocaleUtils.getImage(m_locale)).text(ModelMessages.StringPropertyKeyDialog_valueColumn);
}
// content
setValuesFilter();
m_valuesViewer.setContentProvider(new ArrayContentProvider());
m_valuesViewer.setLabelProvider(new ValuesLabelProvider());
m_valuesViewer.setComparator(new ViewerComparator());
// listeners
m_valuesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
m_selectedKey = (String) selection.getFirstElement();
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
});
m_valuesViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
}
// pattern options
{
Composite optionsComposite = new Composite(valuesGroup, SWT.NONE);
GridDataFactory.create(optionsComposite).fill();
GridLayoutFactory.create(optionsComposite).noMargins().columns(4);
//
new Label(optionsComposite, SWT.NONE).setText(ModelMessages.StringPropertyKeyDialog_filterLabel);
// create buttons
m_filterKeyButton = createFilterOptionButton(optionsComposite, ModelMessages.StringPropertyKeyDialog_filterKeyButton);
m_filterValueButton = createFilterOptionButton(optionsComposite, ModelMessages.StringPropertyKeyDialog_filterValueButton);
m_filterBothButton = createFilterOptionButton(optionsComposite, ModelMessages.StringPropertyKeyDialog_filterBothButton);
// by default select "key"
if (!m_filterKeyButton.getSelection() && !m_filterValueButton.getSelection() && !m_filterBothButton.getSelection()) {
m_filterKeyButton.setSelection(true);
}
}
}
use of org.eclipse.wb.internal.core.utils.ui.TableFactory in project windowbuilder by eclipse.
the class ViewerColumnsUiContentProvider method createContent.
@Override
public void createContent(final Composite parent, int columns) {
// create expandable composite
m_expandableComposite = new ExpandableComposite(parent, SWT.NONE);
m_expandableComposite.setText(Messages.ViewerColumnsUiContentProvider_viewerColumns);
m_expandableComposite.setExpanded(true);
GridDataFactory.create(m_expandableComposite).fillH().grabH().spanH(columns);
m_expandableComposite.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
m_settings.put(SETTING_KEY, !m_expandableComposite.isExpanded());
if (m_expandableComposite.isExpanded()) {
m_expandableComposite.setText(Messages.ViewerColumnsUiContentProvider_viewerColumnsDots);
} else {
m_expandableComposite.setText(Messages.ViewerColumnsUiContentProvider_viewerColumns);
}
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
parent.layout();
}
});
// create sub content providers
Composite clientComposite = new Composite(m_expandableComposite, SWT.NONE);
GridLayoutFactory.create(clientComposite).columns(2).noMargins();
m_expandableComposite.setClient(clientComposite);
// buttons
Composite toolbar = new Composite(clientComposite, SWT.NONE);
GridLayoutFactory.create(toolbar).noMargins();
// edit
m_editButton = new Button(toolbar, SWT.NONE);
GridDataFactory.create(m_editButton).fillH().grabH();
m_editButton.setText(Messages.ViewerColumnsUiContentProvider_editButton);
m_editButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
configureEditingSupport();
}
});
// delete
m_deleteButton = new Button(toolbar, SWT.NONE);
GridDataFactory.create(m_deleteButton).fillH().grabH();
m_deleteButton.setText(Messages.ViewerColumnsUiContentProvider_deleteButton);
m_deleteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteEditingSupport();
}
});
// viewer for supports
m_tableViewer = new TableViewer(clientComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
GridDataFactory.create(m_tableViewer.getTable()).fillH().grabH().hintVC(7);
m_tableViewer.setContentProvider(new ArrayContentProvider());
m_tableViewer.setLabelProvider(new EditingSupportLabelProvider());
m_tableViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
calculateButtons();
}
});
m_tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (!event.getSelection().isEmpty()) {
configureEditingSupport();
}
}
});
//
TableFactory factory = TableFactory.modify(m_tableViewer).headerVisible(true).linesVisible(true);
factory.newColumn().text(Messages.ViewerColumnsUiContentProvider_viewerColumn).width(250);
factory.newColumn().text(Messages.ViewerColumnsUiContentProvider_cellEditorColumn).width(300);
factory.newColumn().text(Messages.ViewerColumnsUiContentProvider_elementPropertyColumn).width(300);
}
Aggregations