Search in sources :

Example 1 with ProjectNode

use of org.talend.repository.imports.TreeBuilder.ProjectNode 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)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 Image (org.eclipse.swt.graphics.Image)1 Project (org.talend.core.model.properties.Project)1 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)1 FilteredCheckboxTree (org.talend.core.ui.advanced.composite.FilteredCheckboxTree)1 IContainerNode (org.talend.repository.imports.TreeBuilder.IContainerNode)1 ProjectNode (org.talend.repository.imports.TreeBuilder.ProjectNode)1