Search in sources :

Example 1 with TableFactory

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);
        }
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableFactory(org.eclipse.wb.internal.core.utils.ui.TableFactory) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with TableFactory

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);
}
Also used : IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableFactory(org.eclipse.wb.internal.core.utils.ui.TableFactory) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Composite (org.eclipse.swt.widgets.Composite)2 TableFactory (org.eclipse.wb.internal.core.utils.ui.TableFactory)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Button (org.eclipse.swt.widgets.Button)1 Event (org.eclipse.swt.widgets.Event)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1 Listener (org.eclipse.swt.widgets.Listener)1 Text (org.eclipse.swt.widgets.Text)1 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)1 IExpansionListener (org.eclipse.ui.forms.events.IExpansionListener)1