Search in sources :

Example 1 with SearchPattern

use of org.eclipse.ui.dialogs.SearchPattern in project tesb-studio-se by Talend.

the class XmlTableForm method addFieldsListeners.

private void addFieldsListeners() {
    nameFilter.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String pattern = nameFilter.getText();
            SearchPattern matcher = new SearchPattern();
            matcher.setPattern(pattern);
            final List<Item> newList = new ArrayList<Item>();
            for (Item item : items) {
                if (matcher.matches(item.getLabel())) {
                    newList.add(item);
                }
            }
            reftesTableContent(newList);
            completeListener.setComplete(!getSelectionItems().isEmpty());
        }
    });
    // Event checkBox action
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (e.detail == SWT.CHECK) {
                ((Item) e.item.getData()).setCheck(((TableItem) e.item).getChecked());
                if (null != completeListener) {
                    completeListener.setComplete(!getSelectionItems().isEmpty());
                }
            }
        }
    });
    table.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            table.getColumns()[0].setWidth(table.getClientArea().width - 2 * table.getBorderWidth());
        }
    });
    selectAllTablesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            setChecked(true);
        }
    });
    selectNoneTablesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            setChecked(false);
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) TableItem(org.eclipse.swt.widgets.TableItem) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SearchPattern(org.eclipse.ui.dialogs.SearchPattern) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 2 with SearchPattern

use of org.eclipse.ui.dialogs.SearchPattern in project tdi-studio-se by Talend.

the class AbstractScdDialog method createFilter.

/**
     * DOC hcw Comment method "createFilter".
     * 
     * @param container
     * @return
     */
protected ViewerFilter createFilter(Composite container) {
    Composite composite = new Composite(container, SWT.NONE);
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(composite);
    composite.setLayout(new FormLayout());
    final Button filterButton = new Button(composite, SWT.PUSH);
    filterText = new Text(composite, SWT.BORDER);
    filterText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            Shell dialogShell = AbstractScdDialog.this.getShell();
            if (dialogShell != null) {
                dialogShell.setDefaultButton(filterButton);
            }
        }
    });
    filterText.setFocus();
    FormData formData = new FormData();
    formData.right = new FormAttachment(100);
    formData.top = new FormAttachment(0);
    filterButton.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(filterButton, 0, SWT.CENTER);
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(filterButton, 0, SWT.LEFT);
    filterText.setLayoutData(formData);
    //$NON-NLS-1$
    filterButton.setText(Messages.getString("AbstractScdDialog.filter"));
    filterButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            filterText.setFocus();
            applyFilter();
        }
    });
    ViewerFilter filter = new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            String pattern = filterText.getText();
            SearchPattern matcher = new SearchPattern();
            matcher.setPattern(pattern);
            return matcher.matches(element.toString());
        }
    };
    return filter;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Text(org.eclipse.swt.widgets.Text) Viewer(org.eclipse.jface.viewers.Viewer) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SearchPattern(org.eclipse.ui.dialogs.SearchPattern) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SearchPattern (org.eclipse.ui.dialogs.SearchPattern)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Shell (org.eclipse.swt.widgets.Shell)1 TableItem (org.eclipse.swt.widgets.TableItem)1 Text (org.eclipse.swt.widgets.Text)1