Search in sources :

Example 1 with CheckboxRepositoryTreeViewer

use of org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer in project tdi-studio-se by Talend.

the class StatLogsAndImplicitcontextTreeViewPage method createStatTree.

private void createStatTree(Composite composite) {
    //$NON-NLS-1$
    Group g = widgetFactory.createGroup(composite, Messages.getString("StatsAndLogsComposite.StatsLogsSettings"));
    GridData gd = new GridData(GridData.FILL_BOTH);
    g.setLayoutData(gd);
    g.setLayout(new FillLayout());
    statViewer = new CheckboxRepositoryTreeViewer(g, SWT.MULTI | SWT.V_SCROLL);
    statContentProvider = new AllJobContentProvider(repositoryView);
    statViewer.setContentProvider(statContentProvider);
    statViewer.setLabelProvider(new RepositoryLabelProvider(repositoryView));
    statViewer.setSorter(repositoryView.getViewer().getSorter());
    IViewSite viewSite = repositoryView.getViewSite();
    statViewer.setInput(viewSite);
    // This only tree listener aim is to change open/close icons on folders :
    statViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(statViewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON));
                }
            }
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(statViewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_OPEN_ICON));
                }
            }
        }
    });
    statViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
            processItems(objects, node);
            if (event.getChecked()) {
                statAddedObjects.addAll(objects);
                statRemovedObjects.removeAll(objects);
                statCheckedObjects.addAll(objects);
            } else {
                statAddedObjects.removeAll(objects);
                statRemovedObjects.addAll(objects);
                statCheckedObjects.removeAll(objects);
            }
            // set checked
            statViewer.setCheckedElements(statCheckedObjects.toArray());
        // viewer.refresh();
        }
    });
    RepositoryNode[] nodes = statContentProvider.getContents();
    List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
    if (nodes != null) {
        for (RepositoryNode n : nodes) {
            processItems(objects, n);
            for (RepositoryNode node : objects) {
                if (isStatUseProjectSetting(node)) {
                    if (!statCheckedObjects.contains(node)) {
                        statCheckedObjects.add(node);
                    }
                }
            }
        }
    }
    statViewer.setCheckedElements(statCheckedObjects.toArray());
    if (nodes != null) {
        statViewer.setExpandedElements(nodes);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) ArrayList(java.util.ArrayList) FillLayout(org.eclipse.swt.layout.FillLayout) RepositoryLabelProvider(org.talend.core.repository.ui.view.RepositoryLabelProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IViewSite(org.eclipse.ui.IViewSite) CheckboxRepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 2 with CheckboxRepositoryTreeViewer

use of org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method addRepositoryTreeViewer.

/**
     * repository tree viewer.
     */
private void addRepositoryTreeViewer(Composite leftComposite) {
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = 210;
    gridData.heightHint = 400;
    leftComposite.setLayoutData(gridData);
    RepoCommonViewerProvider provider = RepoCommonViewerProvider.CHECKBOX;
    treeViewer = (CheckboxRepositoryTreeViewer) provider.createViewer(leftComposite);
    IProjectRepositoryNode projectRepositoryNode = provider.getProjectRepositoryNode();
    processItems(versionObjects, (RepositoryNode) projectRepositoryNode);
    addMenuAction(treeViewer.getTree());
    // filter
    treeViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            RepositoryNode node = (RepositoryNode) element;
            return filterRepositoryNode(node);
        }
    });
    // event
    treeViewer.addCheckStateListener(checkStateListener);
    treeViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        //
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
        // refreshCheckedTreeView();
        }
    });
    expandSomeNodes(projectRepositoryNode);
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) GridData(org.eclipse.swt.layout.GridData) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) CheckboxRepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) 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) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 3 with CheckboxRepositoryTreeViewer

use of org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer in project tdi-studio-se by Talend.

the class StatLogsAndImplicitcontextTreeViewPage method createImplicitcontextTree.

private void createImplicitcontextTree(Composite composite) {
    //$NON-NLS-1$
    Group g = widgetFactory.createGroup(composite, Messages.getString("ExtraComposite.ImplicitContextSettings"));
    GridData gd = new GridData(GridData.FILL_BOTH);
    g.setLayoutData(gd);
    g.setLayout(new FillLayout());
    viewer = new CheckboxRepositoryTreeViewer(g, SWT.MULTI | SWT.V_SCROLL);
    contentProvider = new AllJobContentProvider(repositoryView);
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(new RepositoryLabelProvider(repositoryView));
    viewer.setSorter(repositoryView.getViewer().getSorter());
    IViewSite viewSite = repositoryView.getViewSite();
    viewer.setInput(viewSite);
    // This only tree listener aim is to change open/close icons on folders :
    viewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(viewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON));
                }
            }
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(viewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_OPEN_ICON));
                }
            }
        }
    });
    viewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
            processItems(objects, node);
            if (event.getChecked()) {
                addedObjects.addAll(objects);
                removedObjects.removeAll(objects);
                checkedObjects.addAll(addedObjects);
            } else {
                addedObjects.removeAll(objects);
                removedObjects.addAll(objects);
                checkedObjects.removeAll(objects);
            }
            // set checked
            viewer.setCheckedElements(checkedObjects.toArray());
        // viewer.refresh();
        }
    });
    RepositoryNode[] nodes = contentProvider.getContents();
    List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
    if (nodes != null) {
        for (RepositoryNode n : nodes) {
            processItems(objects, n);
            for (RepositoryNode node : objects) {
                if (isUseProjectSetting(node)) {
                    if (!checkedObjects.contains(node)) {
                        checkedObjects.add(node);
                    }
                }
            }
        }
    }
    viewer.setCheckedElements(checkedObjects.toArray());
    if (nodes != null) {
        viewer.setExpandedElements(nodes);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) ArrayList(java.util.ArrayList) FillLayout(org.eclipse.swt.layout.FillLayout) RepositoryLabelProvider(org.talend.core.repository.ui.view.RepositoryLabelProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IViewSite(org.eclipse.ui.IViewSite) CheckboxRepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 4 with CheckboxRepositoryTreeViewer

use of org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method addRepositoryTreeViewer.

/**
     * repository tree viewer.
     */
private void addRepositoryTreeViewer(Composite leftComposite) {
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = 210;
    gridData.heightHint = 400;
    leftComposite.setLayoutData(gridData);
    RepoCommonViewerProvider provider = RepoCommonViewerProvider.CHECKBOX;
    treeViewer = (CheckboxRepositoryTreeViewer) provider.createViewer(leftComposite);
    // filter
    treeViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            RepositoryNode node = (RepositoryNode) element;
            return filterRepositoryNode(node);
        }
    });
    // event
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            List<RepositoryObject> objects = new ArrayList<RepositoryObject>();
            processItems(objects, node);
            if (!objects.isEmpty()) {
                if (event.getChecked()) {
                    checkedObjects.addAll(objects);
                } else {
                    checkedObjects.removeAll(objects);
                    removeItemElements(objects);
                }
                // researchMaxVersion();
                refreshTableItems();
            }
        }
    });
    treeViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        //
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
        // refreshCheckedTreeView();
        }
    });
    expandSomeNodes(provider.getProjectRepositoryNode());
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) CheckboxRepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) 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) GridData(org.eclipse.swt.layout.GridData) RepositoryObject(org.talend.core.model.repository.RepositoryObject) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Aggregations

ITreeViewerListener (org.eclipse.jface.viewers.ITreeViewerListener)4 TreeExpansionEvent (org.eclipse.jface.viewers.TreeExpansionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 CheckboxRepositoryTreeViewer (org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)3 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)3 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Group (org.eclipse.swt.widgets.Group)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 IViewSite (org.eclipse.ui.IViewSite)2 RepositoryLabelProvider (org.talend.core.repository.ui.view.RepositoryLabelProvider)2 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)2 RepoCommonViewerProvider (org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider)2