Search in sources :

Example 11 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 12 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project ow by vtst.

the class LessProjectPropertyPage method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite composite = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH);
    Label label = SWTFactory.createLabel(composite, messages.getString("LessProjectPropertyPage_includePaths"), 1);
    label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    includePaths.createContents(IContainer.class, composite);
    label = SWTFactory.createLabel(composite, messages.getString("LessProjectPropertyPage_roots"), 1);
    label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    roots.createContents(IFile.class, composite);
    final IContentType lessContentType = Platform.getContentTypeManager().getContentType(LessRuntimeModule.CONTENT_TYPE_ID);
    final IProject project = this.getProject();
    roots.setAddFilter(new ViewerFilter() {

        public boolean select(Viewer viewer, Object parent, Object element) {
            if (element instanceof IProject)
                return project.equals(element);
            else if (element instanceof IContainer)
                return true;
            else if (element instanceof IFile) {
                IFile file = (IFile) element;
                try {
                    if (file.getContentDescription() == null)
                        return false;
                    IContentType fileContentType = file.getContentDescription().getContentType();
                    if (fileContentType != null && fileContentType.isKindOf(lessContentType))
                        return true;
                } catch (CoreException e) {
                }
            }
            return false;
        }
    });
    try {
        includePaths.setCurrentValue(ResourceListProperty.<IContainer>get(IContainer.class, getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.INCLUDE_PATHS)));
        roots.setCurrentValue(ResourceListProperty.<IFile>get(IFile.class, getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.ROOTS)));
    } catch (CoreException e) {
        this.setErrorMessage(e.getMessage());
    }
    return composite;
}
Also used : IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) CoreException(org.eclipse.core.runtime.CoreException) QualifiedName(org.eclipse.core.runtime.QualifiedName) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) IContentType(org.eclipse.core.runtime.content.IContentType) Viewer(org.eclipse.jface.viewers.Viewer) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject)

Example 13 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project bndtools by bndtools.

the class LocalRepositorySelectionPage method createControl.

public void createControl(Composite parent) {
    setTitle("Select Local Repository");
    setMessage("Bundle will be imported into the selected repository.");
    Table table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    final TableViewer viewer = new TableViewer(table);
    viewer.setContentProvider(new RepositoryTreeContentProvider());
    viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
    viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return (element instanceof RepositoryPlugin) && ((RepositoryPlugin) element).canWrite();
        }
    } });
    try {
        Workspace workspace = Central.getWorkspace();
        viewer.setInput(workspace);
        if (selectedRepository != null)
            viewer.setSelection(new StructuredSelection(selectedRepository));
        validate(workspace);
    } catch (Exception e) {
        logger.logError("Error querying local repositories", e);
        setErrorMessage("Error querying local repositories, see log for details.");
    }
    // LISTENERS
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
        }
    });
    viewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent evt) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
            IWizardPage nextPage = getNextPage();
            if (nextPage != null)
                getContainer().showPage(nextPage);
        }
    });
    setControl(table);
}
Also used : Table(org.eclipse.swt.widgets.Table) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) RepositoryTreeContentProvider(bndtools.model.repo.RepositoryTreeContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryTreeLabelProvider(bndtools.model.repo.RepositoryTreeLabelProvider) IOpenListener(org.eclipse.jface.viewers.IOpenListener) IWizardPage(org.eclipse.jface.wizard.IWizardPage) TableViewer(org.eclipse.jface.viewers.TableViewer) Workspace(aQute.bnd.build.Workspace) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 14 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project bndtools by bndtools.

the class MapValuesContentProvider method createAvailableBundlesPanel.

Control createAvailableBundlesPanel(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);
    new Label(panel, SWT.NONE).setText("Available Bundles:");
    selectionSearchTxt = new Text(panel, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    selectionSearchTxt.setMessage("filter bundle name");
    final Tree availableTree = new Tree(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    availableViewer = new TreeViewer(availableTree);
    availableViewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
    availableViewer.setContentProvider(new RepositoryTreeContentProvider());
    availableViewer.setAutoExpandLevel(2);
    availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
    // Load data
    try {
        refreshBundleList();
    } catch (Exception e) {
        setErrorMessage("Error querying repositories: " + e.getMessage());
        logger.logError("Error querying repository configuration.", e);
    }
    // Listeners
    selectionSearchTxt.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.ARROW_DOWN)
                availableTree.setFocus();
        }
    });
    selectionSearchTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
        }
    });
    availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        // Enable add button when a bundle or bundle version is selected on
        // the left
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) availableViewer.getSelection();
            for (Iterator<?> iter = sel.iterator(); iter.hasNext(); ) {
                Object element = iter.next();
                if (element instanceof RepositoryBundle || element instanceof RepositoryBundleVersion || element instanceof ProjectBundle) {
                    addButton.setEnabled(true);
                    return;
                }
            }
            addButton.setEnabled(false);
        }
    });
    availableViewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            doAdd();
        }
    });
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(1, false);
    panel.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    selectionSearchTxt.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 300;
    gd.widthHint = 250;
    availableTree.setLayoutData(gd);
    return panel;
}
Also used : RepositoryBundle(bndtools.model.repo.RepositoryBundle) RepositoryBundleVersion(bndtools.model.repo.RepositoryBundleVersion) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) RepositoryTreeContentProvider(bndtools.model.repo.RepositoryTreeContentProvider) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) ProjectBundle(bndtools.model.repo.ProjectBundle) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Iterator(java.util.Iterator) Tree(org.eclipse.swt.widgets.Tree) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) RepositoryTreeLabelProvider(bndtools.model.repo.RepositoryTreeLabelProvider) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridData(org.eclipse.swt.layout.GridData) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 15 with ViewerFilter

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

the class AttributeEditPage method createPageContents.

@Override
protected Control createPageContents(Composite parent) {
    Composite propsGroup = new Composite(parent, SWT.NONE);
    propsGroup.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    propsGroup.setLayoutData(gd);
    //$NON-NLS-2$
    final Text nameText = UIUtils.createLabelText(propsGroup, "Name", attribute.getName());
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (attribute instanceof DBPNamedObject2) {
                ((DBPNamedObject2) attribute).setName(nameText.getText());
            }
        }
    });
    UIUtils.createControlLabel(propsGroup, "Properties").setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    final PropertyTreeViewer propertyViewer = new PropertyTreeViewer(propsGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 400;
    propertyViewer.getControl().setLayoutData(gd);
    propertyViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return true;
        }
    });
    PropertySourceAbstract pc = new PropertySourceEditable(commandContext, attribute, attribute) {

        @Override
        public void setPropertyValue(@Nullable DBRProgressMonitor monitor, Object editableValue, ObjectPropertyDescriptor prop, Object newValue) throws IllegalArgumentException {
            super.setPropertyValue(monitor, editableValue, prop, newValue);
        /*
                if (prop.getId().equals("dataType")) {
                    newValue = getPropertyValue(monitor, editableValue, prop);
                    if (newValue instanceof DBSDataType) {
                        DBPPropertyDescriptor lengthProp = getProperty("maxLength");
                        if (lengthProp instanceof ObjectPropertyDescriptor) {
                            DBPDataKind dataKind = ((DBSDataType) newValue).getDataKind();
                            if (dataKind == DBPDataKind.STRING) {
                                setPropertyValue(monitor, editableValue, (ObjectPropertyDescriptor) lengthProp, 100);
                            } else {
                                setPropertyValue(monitor, editableValue, (ObjectPropertyDescriptor) lengthProp, null);
                            }
                            propertyViewer.update(lengthProp, null);
                        }
                    }
                }
*/
        }
    };
    pc.collectProperties();
    for (DBPPropertyDescriptor prop : pc.getProperties()) {
        if (prop instanceof ObjectPropertyDescriptor) {
            if (((ObjectPropertyDescriptor) prop).isEditPossible() && !((ObjectPropertyDescriptor) prop).isNameProperty()) {
                continue;
            }
        }
        pc.removeProperty(prop);
    }
    propertyViewer.loadProperties(pc);
    return propsGroup;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer) Text(org.eclipse.swt.widgets.Text) Viewer(org.eclipse.jface.viewers.Viewer) PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) PropertySourceEditable(org.jkiss.dbeaver.runtime.properties.PropertySourceEditable) GridData(org.eclipse.swt.layout.GridData) PropertySourceAbstract(org.jkiss.dbeaver.runtime.properties.PropertySourceAbstract) ObjectPropertyDescriptor(org.jkiss.dbeaver.runtime.properties.ObjectPropertyDescriptor) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) Nullable(org.jkiss.code.Nullable)

Aggregations

ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)29 Viewer (org.eclipse.jface.viewers.Viewer)22 Composite (org.eclipse.swt.widgets.Composite)16 GridData (org.eclipse.swt.layout.GridData)14 IFile (org.eclipse.core.resources.IFile)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 CoreException (org.eclipse.core.runtime.CoreException)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 TableViewer (org.eclipse.jface.viewers.TableViewer)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)5 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 FileFolderSelectionDialog (net.heartsome.cat.common.ui.dialog.FileFolderSelectionDialog)4 LocalFile (org.eclipse.core.internal.filesystem.local.LocalFile)4 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)4 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)4 IOpenListener (org.eclipse.jface.viewers.IOpenListener)4