Java Code Examples for org.eclipse.jface.viewers.ComboViewer#addFilter()

The following examples show how to use org.eclipse.jface.viewers.ComboViewer#addFilter() . 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: OperatorSelectionDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(final Composite parent) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, SWT.DEFAULT).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create());
    final Label operatorType = new Label(mainComposite, SWT.NONE);
    operatorType.setText(Messages.operatorType);

    final ComboViewer operatorViewer = new ComboViewer(mainComposite, SWT.READ_ONLY | SWT.BORDER);
    operatorViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    operatorViewer.setContentProvider(ArrayContentProvider.getInstance());
    operatorViewer.setLabelProvider(new OperatorLabelProvider());
    operatorViewer.addFilter(new OperatorViewerFilter(operation));

    operatorViewer.setInput(operatorTypeList);

    section = new Section(mainComposite, Section.NO_TITLE);
    section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());

    final Expression exp = operation.getLeftOperand();
    for (final IOperatorEditor opEditor : operatorEditors) {
        if (!opEditor.appliesTo(exp) && opEditor.appliesTo(operator.getType())) {
            operator.setType(ExpressionConstants.ASSIGNMENT_OPERATOR);
        }
    }
    createOperatorEditorFor(section, operator.getType(), operator, exp);

    context.bindValue(ViewersObservables.observeSingleSelection(operatorViewer),
            EMFObservables.observeValue(operator, ExpressionPackage.Literals.OPERATOR__TYPE));
    operatorViewer.addSelectionChangedListener(this);

    return mainComposite;
}
 
Example 2
Source File: DataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createTypeChooser(final Composite parent) {
    final Label typeLabel = new Label(parent, SWT.NONE);
    typeLabel.setText(Messages.datatypeLabel);
    typeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());

    typeCombo = new ComboViewer(parent, SWT.BORDER | SWT.READ_ONLY);
    typeCombo.setContentProvider(new ArrayContentProvider());
    typeCombo.setLabelProvider(new DataTypeLabelProvider());
    typeCombo.addFilter(typeViewerFilter);
    typeCombo.setSorter(new ViewerSorter());
    typeCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(10, 0).create());

    typeDescriptionDecorator = new ControlDecoration(typeCombo.getCombo(), SWT.LEFT);
    typeDescriptionDecorator.setImage(Pics.getImage(PicsConstants.hint));

    if (allowEnum) {
        final Button createOptionButton = new Button(parent, SWT.PUSH);
        createOptionButton.setText(Messages.listOfOptions);
        createOptionButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                final EnumDataTypeDialog dialog = new EnumDataTypeDialog(Display.getDefault().getActiveShell(),
                        ModelHelper.getMainProcess(container));
                if (dialog.open() == Window.OK) {
                    final EnumType type = dialog.getSelectedEnum();
                    updateDatabinding();
                    typeCombo.setSelection(new StructuredSelection(type));
                }
            }
        });
    } else {
        typeCombo.getCombo()
                .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).indent(10, 0).create());
    }
}
 
Example 3
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();
        }
    });
}
 
Example 4
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createInputForDataGroup(final TabbedPropertySheetWidgetFactory widgetFactory,
        final Composite dataContent) {
    final Group inputGroup = widgetFactory.createGroup(dataContent, Messages.input);
    inputGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    inputGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).spacing(5, 3).create());

    final Label inputListlabel = widgetFactory.createLabel(inputGroup, Messages.inputList + " *");
    inputListlabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create());

    final ControlDecoration inputListlabelDecoration = new ControlDecoration(inputListlabel, SWT.RIGHT);
    inputListlabelDecoration.setMarginWidth(-3);
    inputListlabelDecoration.setDescriptionText(Messages.inputListHint);
    inputListlabelDecoration.setImage(Pics.getImage(PicsConstants.hint));

    final ComboViewer inputListComboViewer = createComboViewer(widgetFactory, inputGroup,
            new ObservableListContentProviderWithProposalListenersForPool());
    inputListComboViewer.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).indent(5, 0).create());
    inputListComboViewer.addFilter(new ListDataFilter());
    inputListComboViewer.setSorter(new DataViewerSorter());
    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(inputListComboViewer);
    final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider);
    final IObservableValue observeInputCollectionValue = CustomEMFEditObservables.observeDetailValue(
            Realm.getDefault(), selectionObservable,
            ProcessPackage.Literals.MULTI_INSTANTIABLE__COLLECTION_DATA_TO_MULTI_INSTANTIATE);

    selectionObservable.addValueChangeListener(createInputValueChanged(inputListComboViewer, observeSingleSelection,
            observeInputCollectionValue, false));

    inputListComboViewer.addSelectionChangedListener(createComboSelectionListener(inputListComboViewer, false));
    inputListComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            updateReturnTypeFromSelectedInputCollection(inputListComboViewer);
        }

    });
    context.bindValue(observeSingleSelection, observeInputCollectionValue);

    final Label label = widgetFactory.createLabel(inputGroup, "");
    label.setImage(Pics.getImage("icon-arrow-down.png"));
    label.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).align(SWT.CENTER, SWT.CENTER).create());

    createIteratorControl(widgetFactory, inputGroup);
}