Search in sources :

Example 1 with FilteredCheckboxTree

use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.

the class ExportItemWizardPage method createTreeViewer.

private void createTreeViewer(Composite itemComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI) {

        @Override
        protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
            RepoCommonViewerProvider provider = RepoCommonViewerProvider.CHECKBOX;
            if (baseViewId != null) {
                provider.setViewId(baseViewId);
            }
            CheckboxTreeViewer viwer = (CheckboxTreeViewer) provider.createViewer(parent);
            // FIXME this is temp fix for 5.4.2
            INavigatorContentService navigatorContentService = ((INavigatorContentServiceProvider) viwer).getNavigatorContentService();
            if (navigatorContentService != null) {
                IExtensionStateModel findStateModel = navigatorContentService.findStateModel(//$NON-NLS-1$
                "com.oaklandsw.transform.navigatorContent");
                if (findStateModel != null) {
                    //$NON-NLS-1$
                    findStateModel.setBooleanProperty("org.talend.repository.ui.actions.importexport", true);
                }
            }
            return viwer;
        }

        @Override
        protected void refreshCompleted() {
            getViewer().expandToLevel(3);
            restoreCheckedElements();
        }

        @Override
        protected boolean isNodeCollectable(TreeItem item) {
            Object obj = item.getData();
            if (obj instanceof RepositoryNode) {
                RepositoryNode node = (RepositoryNode) obj;
                if (node.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
                    return true;
                }
            }
            return false;
        }
    };
    filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            boolean select = true;
            if (element instanceof RepositoryNode) {
                select = selectRepositoryNode(viewer, (RepositoryNode) element);
            }
            if (select) {
                for (IRepositoryReviewFilter nodeHandler : RepositoryContentManager.getRepositoryReviewFilters()) {
                    //$NON-NLS-1$
                    boolean exportFilter = nodeHandler.filter(viewer, parentElement, element, "repository_review");
                    if (!exportFilter) {
                        return exportFilter;
                    }
                }
            }
            return select;
        }
    });
}
Also used : IExtensionStateModel(org.eclipse.ui.navigator.IExtensionStateModel) FilteredCheckboxTree(org.talend.core.ui.advanced.composite.FilteredCheckboxTree) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepoCommonViewerProvider(org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) IRepositoryReviewFilter(org.talend.core.model.repository.IRepositoryReviewFilter) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService)

Example 2 with FilteredCheckboxTree

use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.

the class ImportItemWizardPage method createTreeViewer.

private TreeViewer createTreeViewer(Composite listComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(listComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    CheckboxTreeViewer viewer = filteredCheckboxTree.getViewer();
    viewer.setContentProvider(new ITreeContentProvider() {

        @Override
        public Object[] getChildren(Object parentElement) {
            if (parentElement instanceof IContainerNode) {
                return ((IContainerNode) parentElement).getChildren().toArray();
            }
            return null;
        }

        @Override
        public Object[] getElements(Object inputElement) {
            // return getValidItems();
            return repositoryUtil.getTreeViewInput().toArray();
        }

        @Override
        public boolean hasChildren(Object element) {
            if (element instanceof IContainerNode) {
                return ((IContainerNode) element).hasChildren();
            }
            return false;
        }

        @Override
        public Object getParent(Object element) {
            return null;
        }

        @Override
        public void dispose() {
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IContainerNode) {
                if (element instanceof ProjectNode) {
                    Project project = ((ProjectNode) element).getProject();
                    return ProjectManager.getProjectDisplayLabel(project);
                }
                return ((IContainerNode) element).getLabel();
            } else if (element instanceof ItemRecord) {
                return ((ItemRecord) element).getLabel();
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof IContainerNode) {
                return ((IContainerNode) element).getImage();
            } else if (element instanceof ItemRecord) {
                return ((ItemRecord) element).getImage();
            }
            return super.getImage(element);
        }
    });
    viewer.setSorter(TreeBuilder.createSorter());
    viewer.setInput(this);
    viewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            filteredCheckboxTree.calculateCheckedLeafNodes();
            updateFinishStatus();
        }
    });
    filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return selectRepositoryNode(viewer, element);
        }
    });
    return viewer;
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) FilteredCheckboxTree(org.talend.core.ui.advanced.composite.FilteredCheckboxTree) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TableViewer(org.eclipse.jface.viewers.TableViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Image(org.eclipse.swt.graphics.Image) IContainerNode(org.talend.repository.imports.TreeBuilder.IContainerNode) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Project(org.talend.core.model.properties.Project) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) ProjectNode(org.talend.repository.imports.TreeBuilder.ProjectNode) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 3 with FilteredCheckboxTree

use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.

the class UseDynamicJobSelectionDialog method createTreeViewer.

private void createTreeViewer(Composite itemComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI) {

        @Override
        protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
            return (CheckboxTreeViewer) RepoCommonViewerProvider.CHECKBOX.createViewer(parent);
        }

        @Override
        protected void refreshCompleted() {
            restoreCheckedElements();
        }
    };
    CheckboxTreeViewer viewer = filteredCheckboxTree.getViewer();
    viewer.setComparer(new IElementComparer() {

        private String getElementUniqueString(Object element) {
            if (element instanceof RepositoryNode && getSupportType() != null && getSupportType().equals(((RepositoryNode) element).getContentType())) {
                final RepositoryNode node = (RepositoryNode) element;
                StringBuffer sb = new StringBuffer();
                boolean validElem = false;
                ENodeType type = node.getType();
                if (ENodeType.REPOSITORY_ELEMENT.equals(type)) {
                    sb.append(node.getId());
                    validElem = true;
                } else if (ENodeType.SIMPLE_FOLDER.equals(type)) {
                    final IRepositoryViewObject object = node.getObject();
                    // path
                    if (object instanceof Folder) {
                        sb.append(((Folder) object).getPath());
                        sb.append('/');
                    }
                    sb.append(node.getLabel());
                    validElem = true;
                }
                if (validElem) {
                    sb.append('|');
                    // add project
                    if (node.getRoot() != null && node.getRoot().getProject() != null) {
                        sb.append(node.getRoot().getProject().getTechnicalLabel());
                    }
                    sb.append('|');
                    sb.append(node.getContentType().getType());
                    sb.append('|');
                    sb.append(type);
                    return sb.toString();
                }
            }
            return null;
        }

        @Override
        public int hashCode(Object element) {
            final String elementUniqueString = getElementUniqueString(element);
            if (elementUniqueString != null) {
                return elementUniqueString.hashCode();
            }
            return element.hashCode();
        }

        @Override
        public boolean equals(Object a, Object b) {
            String aStr = getElementUniqueString(a);
            String bStr = getElementUniqueString(b);
            return aStr != null && bStr != null ? aStr.equals(bStr) : a.equals(b);
        }
    });
    viewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            RepositoryNode node = (RepositoryNode) element;
            return filterRepositoryNode(node);
        }
    });
}
Also used : FilteredCheckboxTree(org.talend.core.ui.advanced.composite.FilteredCheckboxTree) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) IElementComparer(org.eclipse.jface.viewers.IElementComparer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Folder(org.talend.core.model.repository.Folder) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType)

Example 4 with FilteredCheckboxTree

use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.

the class ExportTreeViewer method createTreeViewer.

private void createTreeViewer(Composite itemComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI) {

        @Override
        protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
            RepositoryViewerProvider provider = new RepositoryViewerProvider() {

                @Override
                protected ERepositoryObjectType getCheckingType() {
                    return ExportTreeViewer.this.getCheckingType();
                }
            };
            return (CheckboxTreeViewer) provider.createViewer(parent);
        }

        @Override
        protected void refreshCompleted() {
            getViewer().expandToLevel(3);
            restoreCheckedElements();
        }

        @Override
        protected boolean isNodeCollectable(TreeItem item) {
            Object obj = item.getData();
            if (obj instanceof RepositoryNode) {
                RepositoryNode node = (RepositoryNode) obj;
                if (node.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
                    return true;
                }
            }
            return false;
        }
    };
    getExportItemsTreeViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            RepositoryNode node = (RepositoryNode) element;
            return filterRepositoryNode(node);
        }
    });
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) RepositoryViewerProvider(org.talend.repository.viewer.ui.provider.RepositoryViewerProvider) FilteredCheckboxTree(org.talend.core.ui.advanced.composite.FilteredCheckboxTree) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)4 Viewer (org.eclipse.jface.viewers.Viewer)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 FilteredCheckboxTree (org.talend.core.ui.advanced.composite.FilteredCheckboxTree)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 Composite (org.eclipse.swt.widgets.Composite)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 TreeItem (org.eclipse.swt.widgets.TreeItem)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 IElementComparer (org.eclipse.jface.viewers.IElementComparer)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Image (org.eclipse.swt.graphics.Image)1 IExtensionStateModel (org.eclipse.ui.navigator.IExtensionStateModel)1 INavigatorContentService (org.eclipse.ui.navigator.INavigatorContentService)1