Search in sources :

Example 1 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project tdi-studio-se by Talend.

the class PerlScdDialog method createScdContents.

/**
     * DOC hcw Comment method "createContents".
     * 
     * @param composite
     */
@Override
Control createScdContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).spacing(20, 10).applyTo(composite);
    GridDataFactory.fillDefaults().applyTo(composite);
    Composite filterUnusedComposite = new Composite(composite, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(0, 0).spacing(0, 0).applyTo(filterUnusedComposite);
    GridDataFactory.swtDefaults().grab(true, true).applyTo(filterUnusedComposite);
    ViewerFilter filter = createFilter(filterUnusedComposite);
    unusedFields = new FieldSection(filterUnusedComposite, scdManager, false, false);
    //$NON-NLS-1$
    unusedFields.setTitle("Unused", SWTResourceManager.getColor(198, 195, 198));
    unusedFields.setTableInput(scdManager.getUnusedFields());
    unusedFields.getTableViewer().addFilter(filter);
    GridDataFactory.swtDefaults().grab(true, true).applyTo(unusedFields.getControl());
    //$NON-NLS-1$
    addContextHelp(unusedFields.getTableViewer().getTable(), "org.talend.designer.scd.unused");
    type1Fields = new FieldSection(composite, scdManager, false, false);
    //$NON-NLS-1$
    type1Fields.setTitle("Type 1 fields", SWTResourceManager.getColor(255, 203, 0));
    GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(type1Fields.getControl());
    type1Fields.setTableInput(scdManager.getType1Table());
    //$NON-NLS-1$
    addContextHelp(type1Fields.getTableViewer().getTable(), "org.talend.designer.scd.type1");
    sourceKeys = new FieldSection(composite, scdManager, false, false);
    //$NON-NLS-1$
    sourceKeys.setTitle(Messages.getString("PerlScdDialog.sourceKey"), SWTResourceManager.getColor(156, 0, 255));
    GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(sourceKeys.getControl());
    sourceKeys.setTableInput(scdManager.getSourceKeys());
    //$NON-NLS-1$
    addContextHelp(sourceKeys.getTableViewer().getTable(), "org.talend.designer.scd.sourceKey");
    type2Fields = new Type2Section(composite, scdManager);
    //$NON-NLS-1$
    type2Fields.setTitle(Messages.getString("PerlScdDialog.typeField"), SWTResourceManager.getColor(255, 255, 0));
    GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(type2Fields.getControl());
    type2Fields.setTableInput(scdManager.getType2Table());
    type2Fields.setSupportCreationType(false);
    if (scdManager.getVersionData() != null) {
        type2Fields.setVersionInput(scdManager.getVersionData());
    } else {
        type2Fields.setVersionInput(new Versioning());
    }
    //$NON-NLS-1$
    addContextHelp(type2Fields.getTableViewer().getTable(), "org.talend.designer.scd.type2");
    scdManager.setUnusedFieldsSource(unusedFields);
    ScdSection[] sections = { sourceKeys, type1Fields, type2Fields };
    for (ScdSection scd : sections) {
        scdManager.addUnusedFieldsTarget(scd);
    }
    return composite;
}
Also used : Versioning(org.talend.designer.scd.model.Versioning) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter)

Example 2 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project tdi-studio-se by Talend.

the class DatabaseTypeFilter method createDialogArea.

protected Control createDialogArea(Composite parent, String specifiedPId) {
    Composite container = (Composite) super.createDialogArea(parent);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "before createDialogArea...");
    GridData data = (GridData) container.getLayoutData();
    data.minimumHeight = 400;
    data.heightHint = 400;
    data.minimumWidth = 500;
    data.widthHint = 500;
    container.setLayoutData(data);
    createFilterField(container);
    Composite viewContainer = new Composite(container, SWT.BORDER);
    viewContainer.setLayout(new GridLayout());
    viewContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    repositoryTreeViewer = RepoCommonViewerProvider.NORMAL.createViewer(viewContainer, specifiedPId);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed createViewer");
    repositoryTreeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    addFilter(textFilter);
    if (dbSupportFilter != null) {
        addFilter(dbSupportFilter);
    }
    if (additionalFilters != null) {
        addFilter(additionalFilters);
    }
    ViewerFilter filter = typeProcessor.makeFilter();
    addFilter(filter);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed add Filters");
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "set input");
    repositoryTreeViewer.expandToLevel(2);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "expandAll");
    final Label label = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("RepositoryReviewDialog.label"));
    label.setForeground(new Color(null, 250, 0, 0));
    label.setVisible(false);
    // see feature 0003664: tRunJob: When opening the tree dialog to select the job target, it could be useful to
    // open it on previous selected job if exists
    selectNode();
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "selectNode");
    repositoryTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            boolean highlightOKButton = isSelectionValid(event);
            getButton(IDialogConstants.OK_ID).setEnabled(highlightOKButton);
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null && !selection.isEmpty()) {
                RepositoryNode node = (RepositoryNode) selection.getFirstElement();
                if (!highlightOKButton && node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObjectType().equals(ERepositoryObjectType.METADATA_VALIDATION_RULES)) {
                    label.setVisible(true);
                } else {
                    label.setVisible(false);
                }
            }
        }
    });
    repositoryTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (getButton(IDialogConstants.OK_ID).isEnabled()) {
                okPressed();
            }
        }
    });
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finished createDialogArea...");
    TimeMeasure.end(RepositoryReviewDialog.class.getSimpleName());
    TimeMeasure.display = false;
    TimeMeasure.displaySteps = false;
    TimeMeasure.measureActive = false;
    return container;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Color(org.eclipse.swt.graphics.Color) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData)

Example 3 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project dbeaver by serge-rider.

the class CheckboxTreeManager method collectChildren.

private boolean collectChildren(DBRProgressMonitor monitor, final Object element, List<DBNDatabaseNode> targetChildren, List<DBNDatabaseNode> targetContainers, boolean onlyChecked) throws DBException {
    if (element instanceof DBNDatabaseNode) {
        for (ViewerFilter filter : filters) {
            if (!filter.select(viewer, ((DBNDatabaseNode) element).getParentNode(), element)) {
                return false;
            }
        }
        boolean isChecked = ArrayUtils.contains(checkedElements, element);
        for (Class<?> type : targetTypes) {
            if (type.isInstance(((DBNDatabaseNode) element).getObject())) {
                if (!onlyChecked || isChecked) {
                    targetChildren.add((DBNDatabaseNode) element);
                }
                return true;
            }
        }
        ((DBNDatabaseNode) element).initializeNode(monitor, null);
        DBNDatabaseNode[] children = ((DBNDatabaseNode) element).getChildren(monitor);
        if (!ArrayUtils.isEmpty(children)) {
            boolean foundChild = false;
            for (DBNDatabaseNode child : children) {
                if (collectChildren(monitor, child, targetChildren, targetContainers, onlyChecked)) {
                    foundChild = true;
                }
            }
            if (foundChild) {
                if (!onlyChecked || isChecked) {
                    targetContainers.add((DBNDatabaseNode) element);
                }
            }
            return foundChild;
        }
    }
    return false;
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)

Example 4 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project translationstudio8 by heartsome.

the class ElementTreeSelectionDialog method evaluateIfTreeEmpty.

private boolean evaluateIfTreeEmpty(Object input) {
    Object[] elements = fContentProvider.getElements(input);
    if (elements.length > 0) {
        if (fFilters != null) {
            for (int i = 0; i < fFilters.size(); i++) {
                ViewerFilter curr = (ViewerFilter) fFilters.get(i);
                elements = curr.filter(fViewer, input, elements);
            }
        }
    }
    return elements.length == 0;
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter)

Example 5 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project translationstudio8 by heartsome.

the class WorkingSetActionProvider method setWorkingSetFilter.

private void setWorkingSetFilter(IWorkingSet workingSet, boolean firstTime) {
    ResourceWorkingSetFilter workingSetFilter = null;
    ViewerFilter[] filters = viewer.getFilters();
    for (int i = 0; i < filters.length; i++) {
        if (filters[i] instanceof ResourceWorkingSetFilter) {
            workingSetFilter = (ResourceWorkingSetFilter) filters[i];
            break;
        }
    }
    if (workingSetFilter == null) {
        if (firstTime) {
            filterService.addActiveFilterIds(new String[] { WORKING_SET_FILTER_ID });
            filterService.updateViewer();
            setWorkingSetFilter(workingSet, !FIRST_TIME);
            return;
        }
        WorkbenchNavigatorPlugin.log(//$NON-NLS-1$
        "Required filter " + WORKING_SET_FILTER_ID + //$NON-NLS-1$
        " is not present. Working set support will not function correctly.", //$NON-NLS-1$
        new Status(IStatus.ERROR, WorkbenchNavigatorPlugin.PLUGIN_ID, ""));
        return;
    }
    workingSetFilter.setWorkingSet(emptyWorkingSet ? null : workingSet);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ResourceWorkingSetFilter(org.eclipse.ui.ResourceWorkingSetFilter)

Aggregations

ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)266 EObject (org.eclipse.emf.ecore.EObject)144 Viewer (org.eclipse.jface.viewers.Viewer)130 GridData (org.eclipse.swt.layout.GridData)124 SelectionEvent (org.eclipse.swt.events.SelectionEvent)107 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)101 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)86 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)86 ReferencesTable (org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable)84 ReferencesTableListener (org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable.ReferencesTableListener)84 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)38 Composite (org.eclipse.swt.widgets.Composite)38 GridLayout (org.eclipse.swt.layout.GridLayout)33 TreeViewer (org.eclipse.jface.viewers.TreeViewer)28 IFile (org.eclipse.core.resources.IFile)24 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)22 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)21 Label (org.eclipse.swt.widgets.Label)21 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)20 TableViewer (org.eclipse.jface.viewers.TableViewer)20