Search in sources :

Example 1 with RepositoryViewerProvider

use of org.talend.repository.viewer.ui.provider.RepositoryViewerProvider in project tesb-studio-se by Talend.

the class RouteResourceSelectionDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);
    final RepositoryViewerProvider provider = new RepositoryViewerProvider() {

        @Override
        protected TreeViewer createTreeViewer(Composite parent, int style) {
            return new RepositoryTreeViewer(parent, style);
        }

        @Override
        protected ERepositoryObjectType getCheckingType() {
            return CamelRepositoryNodeType.repositoryRouteResourceType;
        }

        @Override
        protected int getStyle() {
            // http://jira.talendforge.org/browse/TESB-6582 Xiaopeng Li
            return SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL;
        }
    };
    repositoryTreeViewer = (RepositoryTreeViewer) provider.createViewer(container);
    repositoryTreeViewer.expandAll();
    repositoryTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            getButton(IDialogConstants.OK_ID).setEnabled(validateSelection((IStructuredSelection) event.getSelection()));
        }
    });
    repositoryTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            if (getButton(IDialogConstants.OK_ID).isEnabled()) {
                okPressed();
            }
        }
    });
    return container;
}
Also used : RepositoryViewerProvider(org.talend.repository.viewer.ui.provider.RepositoryViewerProvider) RepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.RepositoryTreeViewer) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent)

Example 2 with RepositoryViewerProvider

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

Composite (org.eclipse.swt.widgets.Composite)2 RepositoryViewerProvider (org.talend.repository.viewer.ui.provider.RepositoryViewerProvider)2 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 FilteredCheckboxTree (org.talend.core.ui.advanced.composite.FilteredCheckboxTree)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 RepositoryTreeViewer (org.talend.repository.viewer.ui.viewer.RepositoryTreeViewer)1