Search in sources :

Example 1 with RepoCommonViewerProvider

use of org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider 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)

Example 2 with RepoCommonViewerProvider

use of org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider 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 3 with RepoCommonViewerProvider

use of org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider 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)

Aggregations

Viewer (org.eclipse.jface.viewers.Viewer)3 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)3 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)3 RepoCommonViewerProvider (org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider)3 ITreeViewerListener (org.eclipse.jface.viewers.ITreeViewerListener)2 TreeExpansionEvent (org.eclipse.jface.viewers.TreeExpansionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 CheckboxRepositoryTreeViewer (org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Composite (org.eclipse.swt.widgets.Composite)1