org.eclipse.jface.viewers.ViewerFilter Java Examples

The following examples show how to use org.eclipse.jface.viewers.ViewerFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OutlineHideCommentsAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return the filter used to hide comments
 */
@Override
protected ViewerFilter createFilter() {
    return new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof ParsedItem) {
                ParsedItem item = (ParsedItem) element;
                if (item == null || item.getAstThis() == null || !(item.getAstThis().node instanceof commentType)) {
                    return true;
                }

            }
            return false;
        }

    };
}
 
Example #2
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Removes filters for the given parent and element
 *
 * @param parent the parent of the element
 * @param element the element
 * @param contentProvider the content provider of the viewer from which
 *  the filters will be removed
 *
 * @return the array of new filter ids
 */
public String[] removeFiltersFor(Object parent, Object element, IContentProvider contentProvider) {
	ArrayList<String> newFilters= new ArrayList<String>();
	for (Iterator<FilterItem> iterator= fFilterItems.values().iterator(); iterator.hasNext();) {
		FilterItem item= iterator.next();
		if (item.enabled) {
			ViewerFilter filter= item.getFilterInstance();
            if (filter != null && isSelected(parent, element, contentProvider, filter))
                newFilters.add(item.id);
		}
	}
	if (fUserDefinedPatternsEnabled && isSelected(parent, element, contentProvider, fPatternFilter))
		newFilters.add(fPatternFilter.getClass().getName());

    return newFilters.toArray(new String[newFilters.size()]);
}
 
Example #3
Source File: OutlineHideImportsAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return the filter used to hide comments
 */
@Override
protected ViewerFilter createFilter() {
    return new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof ParsedItem) {
                ParsedItem item = (ParsedItem) element;
                ASTEntryWithChildren astThis = item.getAstThis();
                if (astThis != null) {
                    SimpleNode n = astThis.node;
                    if (n instanceof ImportFrom || n instanceof Import) {
                        return false;
                    }
                }
            }
            return true;
        }

    };
}
 
Example #4
Source File: ExportRepositoryWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected Control createViewer(final Composite composite) {
    final Composite treeComposite = new Composite(composite, SWT.NONE);
    treeComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    treeComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    treeViewer = new CheckboxRepositoryTreeViewer(treeComposite);
    for (final ViewerFilter filter : filters) {
        treeViewer.addFilter(filter);
    }
    treeViewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(400, SWT.DEFAULT).create());
    treeViewer.bindTree(dbc, stores);
    treeViewer.setCheckedElements(defaultSelectedFiles.toArray());

    createButtonsComposite(treeComposite, treeViewer.checkedElementsObservable());

    return treeComposite;
}
 
Example #5
Source File: OperationViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public OperationViewer(final Composite parent, final TabbedPropertySheetWidgetFactory widgetFactory,
        final EditingDomain editingDomain,
        final ViewerFilter actionExpressionFilter,
        final ViewerFilter storageExpressionFilter, final boolean isPageFlowContext) {
    super(parent, SWT.NONE);
    this.isPageFlowContext = isPageFlowContext;
    this.editingDomain = editingDomain;
    this.widgetFactory = widgetFactory;
    if (widgetFactory != null) {
        widgetFactory.adapt(this);
    }
    this.actionExpressionFilter = actionExpressionFilter;
    this.storageExpressionFilter = storageExpressionFilter;
    setLayout(GridLayoutFactory.fillDefaults().numColumns(4).margins(0, 0).create());
    operationObervable = new WritableValue(Realm.getDefault());
    eObjectObervable = new WritableValue(Realm.getDefault());
    doCreateControls();
}
 
Example #6
Source File: MessageIdExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void bindExpression(EMFDataBindingContext dataBindingContext, EObject context, Expression inputExpression, ViewerFilter[] filters,
        ExpressionViewer expressionViewer) {
    this.inputExpression = inputExpression;
    IObservableValue nameModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__NAME);
    IObservableValue contentModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__CONTENT);

    Set<String> input = new HashSet<String>();
    IExpressionProvider provider = ExpressionProviderService.getInstance().getExpressionProvider(ExpressionConstants.MESSAGE_ID_TYPE);
    for (Expression e : provider.getExpressions(context)) {
        input.add(e.getName());
    }
    viewer.setInput(input);

    dataBindingContext.bindValue(SWTObservables.observeText(valueText, SWT.Modify), nameModelObservable);
    dataBindingContext.bindValue(SWTObservables.observeText(valueText, SWT.Modify), contentModelObservable);
    dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), nameModelObservable);
    dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), contentModelObservable);
}
 
Example #7
Source File: CheckboxTreeAndListGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the result of running the given elements through the filters.
 * @param filters
 *
 * @param elements the elements to filter
 * @return only the elements which all filters accept
 */
protected Object[] filter(ViewerFilter[] filters, Object[] elements) {
	if (filters != null) {
		ArrayList<Object> filtered = new ArrayList<Object>(elements.length);
		for (int i = 0; i < elements.length; i++) {
			boolean add = true;
			for (int j = 0; j < filters.length; j++) {
				add = filters[j].select(null, null, elements[i]);
				if (!add)
					break;
			}
			if (add)
				filtered.add(elements[i]);
		}
		return filtered.toArray();
	}
	return elements;
}
 
Example #8
Source File: FilterDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a new <code>ViewerFilter</code>.
 * This method is only valid for viewer filters.
 * @return a new <code>ViewerFilter</code>
 */
public ViewerFilter createViewerFilter() {
	if (!isCustomFilter())
		return null;

	final ViewerFilter[] result= new ViewerFilter[1];
	String message= Messages.format(FilterMessages.FilterDescriptor_filterCreationError_message, getId());
	ISafeRunnable code= new SafeRunnable(message) {
		/*
		 * @see org.eclipse.core.runtime.ISafeRunnable#run()
		 */
		public void run() throws Exception {
			result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
		}

	};
	SafeRunner.run(code);
	return result[0];
}
 
Example #9
Source File: FileStoreSelectDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createFilter(final Composite listComposite) {
    final Text fileStoreListFilter = new Text(listComposite,
            SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    fileStoreListFilter.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    fileStoreListFilter.setMessage(WorkbenchMessages.FilteredTree_FilterMessage);
    fileStoreListFilter.addModifyListener(new ModifyListener() {

        private ViewerFilter filter;

        @Override
        public void modifyText(final ModifyEvent e) {
            final String textForFiltering = fileStoreListFilter.getText();
            if (filter != null) {
                fileStoreListViewer.removeFilter(filter);
            }
            if (textForFiltering != null
                    && !textForFiltering.isEmpty()) {
                filter = new ViewerFilterOnFileStoreName(textForFiltering);
                fileStoreListViewer.addFilter(filter);
            }

        }
    });
}
 
Example #10
Source File: AbstractDataSectionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldHideBusinessObjectData_ReturnAViewerFilterThatHideBusinessData() throws Exception {
    doCallRealMethod().when(sectionUnderTest).hideBusinessObjectData();

    final ViewerFilter filter = sectionUnderTest.hideBusinessObjectData();
    assertThat(filter.select(null, null, ProcessFactory.eINSTANCE.createData())).isTrue();
    assertThat(filter.select(null, null, ProcessFactory.eINSTANCE.createBusinessObjectData())).isFalse();
}
 
Example #11
Source File: AbstractDataSection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected ViewerFilter hideBusinessObjectData() {
    return new ViewerFilter() {

        @Override
        public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
            return !(element instanceof BusinessObjectData);
        }
    };
}
 
Example #12
Source File: PackageViewerWrapper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void transferFilters(StructuredViewer oldViewer) {
	//set filters
	if (oldViewer != null) {
		ViewerFilter[] filters= oldViewer.getFilters();
		for (int i= 0; i < filters.length; i++) {
			ViewerFilter filter= filters[i];
			fViewer.addFilter(filter);
		}
	}
}
 
Example #13
Source File: NonEssentialElementsFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean hasFilteredChildren(StructuredViewer viewer, IPackageFragment fragment) {
	Object[] children= getRawChildren(viewer, fragment);
	ViewerFilter[] filters= viewer.getFilters();
	for (int i= 0; i < filters.length; i++) {
		children= filters[i].filter(viewer, fragment, children);
		if (children.length == 0)
			return false;
	}
	return true;
}
 
Example #14
Source File: TimeGraphFilterDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Adds a filter to the tree viewer.
 *
 * @param filter
 *            a filter.
 */
public void addFilter(ViewerFilter filter) {
    if (fFilters == null) {
        fFilters = new ArrayList<>();
    }
    fFilters.add(filter);
}
 
Example #15
Source File: ElementTreeSelectionDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #16
Source File: ShowFilterDialogAction.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void run() {
    ITimeGraphEntry[] topInput = fTimeGraphViewer.getTimeGraphContentProvider().getElements(fTimeGraphViewer.getInput());
    if (topInput != null) {
        List<? extends ITimeGraphEntry> allElements = listAllInputs(Arrays.asList(topInput));
        fFilterDialog.setInput(fTimeGraphViewer.getInput());
        fFilterDialog.setTitle(Messages.TmfTimeFilterDialog_WINDOW_TITLE);
        fFilterDialog.setMessage(Messages.TmfTimeFilterDialog_MESSAGE);
        fFilterDialog.setExpandedElements(allElements.toArray());
        RawViewerFilter rawViewerFilter = null;
        for (ViewerFilter filter : fTimeGraphViewer.getFilters()) {
            if (filter instanceof RawViewerFilter) {
                rawViewerFilter = (RawViewerFilter) filter;
            }
        }
        if (rawViewerFilter != null && rawViewerFilter.getFiltered() != null) {
            ArrayList<? extends ITimeGraphEntry> nonFilteredElements = new ArrayList<>(allElements);
            nonFilteredElements.removeAll(rawViewerFilter.getFiltered());
            fFilterDialog.setInitialElementSelections(nonFilteredElements);
        } else {
            fFilterDialog.setInitialElementSelections(allElements);
        }
        fFilterDialog.open();
        if (fFilterDialog.getResult() != null) {
            if (fFilterDialog.getResult().length != allElements.size()) {
                List<? extends ITimeGraphEntry> filteredElements = new ArrayList<>(allElements);
                filteredElements.removeAll(Arrays.asList(fFilterDialog.getResult()));
                if (rawViewerFilter == null) {
                    rawViewerFilter = new RawViewerFilter(filteredElements);
                    addFilter(rawViewerFilter);
                } else {
                    rawViewerFilter.setFiltered(filteredElements);
                    changeFilter(rawViewerFilter);
                }
            } else if (rawViewerFilter != null) {
                removeFilter(rawViewerFilter);
            }
        }
    }
}
 
Example #17
Source File: OutlineHideNonPublicMembersAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @return the filter used to hide comments
 */
@Override
protected ViewerFilter createFilter() {
    return new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof ParsedItem) {
                ParsedItem item = (ParsedItem) element;
                if (item == null) {
                    return true;
                }

                ASTEntryWithChildren astThis = item.getAstThis();
                if (astThis == null) {
                    return true;
                }

                SimpleNode token = astThis.node;
                if (token == null) {
                    return true;
                }

                String name = NodeUtils.getRepresentationString(token);

                if (name != null) {
                    return (!name.startsWith("_")) || (name.startsWith("__") && name.endsWith("__"));
                }
            }
            return true;
        }

    };
}
 
Example #18
Source File: TreeSelectionDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    Control composite = super.createDialogArea(parent);

    if (composite instanceof Composite) {
        updateCompositeLayout((Composite) composite);
    }

    TreeViewer treeViewer = getTreeViewer();
    treeViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return matchItemToShowInTree(element);
        }
    });
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    treeViewer.expandAll();

    if (this.initialFilter.length() > 0) {
        this.text.setText(this.initialFilter);
        this.text.setSelection(this.initialFilter.length());
        this.setFilter(this.initialFilter, new NullProgressMonitor(), true);
    }

    notifyViewCreated();
    onControlCreated.call(this.text);
    onControlCreated.call(this.getTreeViewer());

    return composite;
}
 
Example #19
Source File: SGenWizardPage2.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private void createObjectTree(Composite container) {
	lblNewLabel = new Label(container, SWT.NONE);
	lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	lblNewLabel.setText("Choose: " + getSelectedGenerator().getContentType());

	resourceTree = new CheckboxTreeViewer(container, SWT.BORDER);
	resourceTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	resourceTree.setContentProvider(new WorkspaceTreeContentProvider());
	resourceTree.setLabelProvider(new SGenWorkspaceLabelProvider());

	TreePropagatingCheckStateListener checkStateListener = new TreePropagatingCheckStateListener(resourceTree) {
		@Override
		public void checkStateChanged(CheckStateChangedEvent event) {
			super.checkStateChanged(event);
		}
	};
	resourceTree.addCheckStateListener(checkStateListener);
	resourceTree.addDoubleClickListener(new TreeExpandingDoubleClickListener(resourceTree, checkStateListener));
	resourceTree.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
	resourceTree.setFilters(new ViewerFilter[] { new ViewerFilter() {
		@Override
		public boolean select(Viewer viewer, Object parentElement, Object element) {
			// TODO: Filter by common navigator filter instead of supressing
			// '.' prefixed folder
			if (element instanceof IFolder) {
				return !((IFolder) element).getName().startsWith(".");
			}
			return true;
		}
	} });
}
 
Example #20
Source File: DocumentExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void fillViewerDocument(final EObject context, final ViewerFilter[] filters) {
    final Set<Document> simpleDocuments = new HashSet<Document>();
    final Set<Document> multipleDocuments = new HashSet<Document>();
    retrieveAndFillDocumentSet(context, simpleDocuments, multipleDocuments);
    final Set<Document> input = computeInput(simpleDocuments, multipleDocuments);
    viewer.setInput(input);
}
 
Example #21
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void fillContextMenu(IMenuManager mgr) {
    super.fillContextMenu(mgr);
    fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
    fActionGroup.fillContextMenu(mgr);
    AbstractSearchIndexQuery query = (AbstractSearchIndexQuery) getInput().getQuery();
    if (query.getSearchString().length() > 0) {
        IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
        if (!selection.isEmpty()) {
            ReplaceAction replaceSelection = new ReplaceAction(getSite().getShell(), getInput(),
                    selection.toArray(), true);
            replaceSelection.setText(SearchMessages.ReplaceAction_label_selected);
            mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceSelection);

        }
        ICallback<Boolean, Match> skipMatch = new ICallback<Boolean, Match>() {

            @Override
            public Boolean call(Match match) {
                StructuredViewer viewer = getViewer();
                ViewerFilter[] filters = viewer.getFilters();
                if (filters == null || filters.length == 0) {
                    return false;
                }
                for (ViewerFilter viewerFilter : filters) {
                    if (viewerFilter instanceof AbstractSearchResultsViewerFilter) {
                        AbstractSearchResultsViewerFilter searchResultsViewerFilter = (AbstractSearchResultsViewerFilter) viewerFilter;
                        if (searchResultsViewerFilter.isLeafMatch(viewer, match)) {
                            return false;
                        }
                    }
                }
                return true;
            }
        };
        ReplaceAction replaceAll = new ReplaceAction(getSite().getShell(), getInput(), null, true, skipMatch);
        replaceAll.setText(SearchMessages.ReplaceAction_label_all);
        mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll);
    }
}
 
Example #22
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void addColumnToViewer(final int index) {
    final TableViewerColumn column = new TableViewerColumn(viewer, SWT.FILL);

    if (captions != null && captions.size() > index
            && captions.get(index) != null) {
        column.getColumn().setText(captions.get(index));
    }

    final ExpressionCollectionEditingSupport editingSupport = new ExpressionCollectionEditingSupport(
            column.getViewer(), index, editingDomain, removeRowListener);
    if (context != null) {
        editingSupport.setInput(context);
    }
    if (viewerFilters != null && viewerFilters.size() > index) {
        final ViewerFilter filter = viewerFilters.get(index);
        if (filter != null) {
            editingSupport.addFilter(filter);
        }
        if (viewerExprProviders != null
                && viewerExprProviders.size() > index) {
            final IExpressionNatureProvider provider = viewerExprProviders
                    .get(index);
            if (provider != null) {
                editingSupport.setExpressionNatureProvider(provider);
            }
        }
    }
    editingSupports.add(index, editingSupport);
    column.setEditingSupport(editingSupport);
    column.setLabelProvider(new ExpressionColumnLabelProvider(index));
    viewer.getTable().setLayout(createTableLayout());
}
 
Example #23
Source File: InvocableEndpointPropertiesEditionPartImpl.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.InvocableEndpointPropertiesEditionPart#addFilterOwnedServiceInvocations(ViewerFilter filter)
 * 
 */
public void addFilterToOwnedServiceInvocations(ViewerFilter filter) {
	ownedServiceInvocationsFilters.add(filter);
	if (this.ownedServiceInvocations != null) {
		this.ownedServiceInvocations.addFilter(filter);
	}
}
 
Example #24
Source File: ConfigurationWizardDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createPageChooserComposite(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults().span(1, 2).create());
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 10).create());

    pageChooserViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
    pageChooserViewer.getTable().setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.FILL).grab(false, true).create());
    pageChooserViewer.setContentProvider(new WizardPageContentProvider());
    ILabelDecorator decorator = new WizardPageDecorator(this);
    pageChooserViewer.setLabelProvider(new DecoratingLabelProvider(new WizardPageLabelProvider(this), decorator));
    pageChooserViewer.setInput(getWizard().getPages());
    pageChooserViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            IProcessConfigurationWizardPage page = (IProcessConfigurationWizardPage) element;
            if (!isSimpleMode) {
                return true;
            }
            return page.isDefault() || page.isConfigurationPageValid(getConfiguration()) != null;
        }
    });
    pageChooserViewer.addSelectionChangedListener(this);
    pageChooserViewer.getTable().setEnabled(false);

    addPageChangedListener(this);
}
 
Example #25
Source File: GroovyOnlyExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected EditExpressionDialog createEditDialog(final EObject editInput) {
    final GroovyOnlyEditExpressionDialog groovyOnlyEditExpressionDialog = new GroovyOnlyEditExpressionDialog(control.getShell(), isPassword,
            getSelectedExpression(), editInput, getEditingDomain(),
            filters.toArray(new ViewerFilter[filters.size()]), this);
    return groovyOnlyEditExpressionDialog;
}
 
Example #26
Source File: SelectConnectorConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
       composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(10, 10, 10, 0).create());
	filterTree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER, new PatternFilter(), true);
       filterTree.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ;
       filterTree.getViewer().setLabelProvider(new ConnectorConfigurationLabelProvider());
       filterTree.getViewer().setContentProvider(new ConnectorConfigurationContentProvider());
       filterTree.getViewer().addSelectionChangedListener(this) ;
       filterTree.getViewer().addDoubleClickListener(this) ;
       filterTree.getViewer().setInput(new Object());
       filterTree.getViewer().addFilter(new ViewerFilter() {

           @Override
           public boolean select(Viewer arg0, Object arg1, Object element) {
           	ITreeContentProvider contentProvider = (ITreeContentProvider)filterTree.getViewer().getContentProvider();
			if (element instanceof Category){
				
           		if(!contentProvider.hasChildren(element)){
           			return false;
           		}
           		boolean hasElements=false;
           		for(Object c : contentProvider.getChildren(element)){
           					hasElements=hasElements || select(arg0,element,c);
           				}
           		return hasElements;
           	}else if(element instanceof ConnectorDefinition){
           		return contentProvider.getChildren(element).length > 0;
   
   			}
               return element instanceof ConnectorConfiguration;
           }
       }) ;
       filterTree.getViewer().expandAll();
       filterTree.setFocus();
       setControl(composite);
}
 
Example #27
Source File: EditExpressionDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private ViewerFilter filterEditor() {
    return new ViewerFilter() {

        @Override
        public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
            return !(element instanceof IExpressionProvider
                    && filteredEditor.contains(((IExpressionProvider) element).getExpressionType()));
        }
    };
}
 
Example #28
Source File: CustomElementSelectionDialog.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	CustomElementSelectionForm form = new CustomElementSelectionForm(parent, SWT.FILL);
	form.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

	TreeViewer v = form.getTreeViewer();
	for (ViewerFilter filter : filters) {
		v.addFilter(filter);
	}
	this.treeViewer = v;

	WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
	ILabelProvider labelProvider = new WorkbenchLabelProvider();

	this.treeViewer.setContentProvider(contentProvider);
	this.treeViewer.setLabelProvider(labelProvider);

	this.treeViewer.setComparator(new ViewerComparator());

	this.treeViewer.setAutoExpandLevel(this.getAutoExpandLevel());

	form.setElementLabel(this.elementLabel);

	this.elementNameInput = form.getElementInput();

	form.getElementInput().addPropertyChangeListener(new PropertyChangeListener() {

		@Override
		public void propertyChange(PropertyChangeEvent evt) {
			if (evt.getPropertyName().equals(SuffixText.TEXT_PROPERTY) ||
					evt.getPropertyName().equals(SuffixText.SUFFIX_PROPERTY)) {
				validateElementInput();
				elementInputChanged();
			}

		}
	});
	return form;
}
 
Example #29
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public void setExpressionEditorFilter(ViewerFilter filter) {
    expressionEditor.getFilters().clear();
    expressionEditor.addFilter(filter);
}
 
Example #30
Source File: CatchEventEventSelectionContribution.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createControl(final Composite composite,
        final TabbedPropertySheetWidgetFactory widgetFactory,
        final ExtensibleGridPropertySection extensibleGridPropertySection) {
    combo = new ComboViewer(composite, SWT.NONE);
    combo.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    combo.setLabelProvider(new EventLabelProvider());
    combo.setContentProvider(ArrayContentProvider.getInstance());
    combo.addFilter(new ViewerFilter() {

        @Override
        public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
            if (element instanceof EventObject) {
                final ThrowMessageEvent source = ((Message) element).getSource();
                if (eObject != null) {
                    if (source != null) {
                        final AbstractProcess parentProcessOfSourceMessage = ModelHelper.getParentProcess(source);
                        if (parentProcessOfSourceMessage != null
                                && parentProcessOfSourceMessage.equals(ModelHelper.getParentProcess(eObject))) {
                            return false;
                        }
                    }
                }
            }
            return true;
        }
    });
    final List<Message> events = retrievePossibleMessageEvents();

    combo.setInput(events);
    if (eObject.getEvent() != null) {
        combo.getCombo().setText(eObject.getEvent());
        oldEventName = combo.getCombo().getText();
    }
    combo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent arg0) {
            handleSelectionChanged();
        }
    });

    combo.getCombo().addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            handleSelectionChanged();
        }
    });
}