Search in sources :

Example 16 with CheckboxTreeViewer

use of org.eclipse.jface.viewers.CheckboxTreeViewer in project tdi-studio-se by Talend.

the class ExportTreeViewer method createItemList.

/**
     *
     * @param workArea
     */
public Composite createItemList(Composite workArea) {
    Group itemComposite = new Group(workArea, 0);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(itemComposite);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(400, 200).applyTo(itemComposite);
    Label label = new Label(itemComposite, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("ExportTreeViewer.selectItems"));
    GridDataFactory.swtDefaults().grab(true, false).span(2, 1).applyTo(label);
    createTreeViewer(itemComposite);
    createSelectionButton(itemComposite);
    CheckboxTreeViewer exportItemsTreeViewer = getExportItemsTreeViewer();
    exportItemsTreeViewer.refresh();
    // force loading all nodes
    exportItemsTreeViewer.expandAll();
    exportItemsTreeViewer.collapseAll();
    // expand to level of metadata connection
    exportItemsTreeViewer.expandToLevel(4);
    // if user has select some items in repository view, mark them as checked
    if (!repositoryNodes.isEmpty()) {
        exportItemsTreeViewer.setCheckedElements(repositoryNodes.toArray());
        for (RepositoryNode node : repositoryNodes) {
            expandParent(exportItemsTreeViewer, node);
            exportItemsTreeViewer.refresh(node);
        }
        selectItems(exportItemsTreeViewer.getTree().getItems());
    }
    return itemComposite;
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Group(org.eclipse.swt.widgets.Group) Label(org.eclipse.swt.widgets.Label) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 17 with CheckboxTreeViewer

use of org.eclipse.jface.viewers.CheckboxTreeViewer in project tdi-studio-se by Talend.

the class ExportTreeViewer method getCheckNodes.

public RepositoryNode[] getCheckNodes() {
    List<RepositoryNode> ret = new ArrayList<RepositoryNode>();
    CheckboxTreeViewer exportItemsTreeViewer = getExportItemsTreeViewer();
    for (int i = 0; i < exportItemsTreeViewer.getCheckedElements().length; i++) {
        RepositoryNode node = (RepositoryNode) exportItemsTreeViewer.getCheckedElements()[i];
        if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
            ret.add(node);
        }
    }
    return ret.toArray(new RepositoryNode[0]);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 18 with CheckboxTreeViewer

use of org.eclipse.jface.viewers.CheckboxTreeViewer 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)

Example 19 with CheckboxTreeViewer

use of org.eclipse.jface.viewers.CheckboxTreeViewer 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 20 with CheckboxTreeViewer

use of org.eclipse.jface.viewers.CheckboxTreeViewer in project tdi-studio-se by Talend.

the class ExportItemWizardPage method refreshExportDependNodes.

private void refreshExportDependNodes() {
    CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
    Object[] checkedObj = exportItemsTreeViewer.getCheckedElements();
    for (Object element : checkedObj) {
        if (element instanceof RepositoryNode) {
            RepositoryNode checkedNode = (RepositoryNode) element;
            if (checkedNode != null && !RepositoryNode.NO_ID.equals(checkedNode.getId())) {
                if (ENodeType.REPOSITORY_ELEMENT.equals(checkedNode.getType())) {
                    checkedDependency.add(checkedNode);
                }
            }
        }
    }
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) 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)

Aggregations

CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)25 Composite (org.eclipse.swt.widgets.Composite)14 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)8 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)8 GridData (org.eclipse.swt.layout.GridData)8 GridLayout (org.eclipse.swt.layout.GridLayout)7 Label (org.eclipse.swt.widgets.Label)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 Button (org.eclipse.swt.widgets.Button)6 Viewer (org.eclipse.jface.viewers.Viewer)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 ArrayList (java.util.ArrayList)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)4 ModifyListener (org.eclipse.swt.events.ModifyListener)4 Text (org.eclipse.swt.widgets.Text)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4