Search in sources :

Example 1 with RepositoryNodeComparator

use of org.talend.dq.helper.RepositoryNodeComparator in project tdq-studio-se by Talend.

the class ExportWizardPage method createRepositoryTree.

/**
 * DOC bZhou Comment method "createRepositoryTree".
 *
 * @param top
 */
protected void createRepositoryTree(Composite top) {
    Composite treeComposite = new Composite(top, SWT.NONE);
    treeComposite.setLayout(new GridLayout(2, false));
    treeComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    repositoryTree = new ContainerCheckedTreeViewer(treeComposite);
    repositoryTree.setContentProvider(new FileTreeContentProvider());
    repositoryTree.setLabelProvider(new FileTreeLabelProvider());
    repositoryTree.setInput(writer.computeInput(specifiedPath));
    repositoryTree.expandAll();
    repositoryTree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    // ADD msjian TDQ-14573: automatically checked the initial selected items.
    if (intCheckedElements != null) {
        List<ItemRecord> selectedItemRecords = new ArrayList<ItemRecord>();
        for (Object intCheckedElement : intCheckedElements) {
            getFileFromNode(selectedItemRecords, (IRepositoryNode) intCheckedElement);
        }
        repositoryTree.setCheckedElements(selectedItemRecords.toArray());
    }
    // show the same order with repository tree
    repositoryTree.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer iviewer, Object o1, Object o2) {
            DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(((ItemRecord) o1).getElement());
            DQRepositoryNode recursiveFind2 = RepositoryNodeHelper.recursiveFind(((ItemRecord) o2).getElement());
            return new RepositoryNodeComparator().compare(recursiveFind, recursiveFind2);
        }
    });
    // TDQ-14573~
    createUtilityButtons(treeComposite);
}
Also used : RepositoryNodeComparator(org.talend.dq.helper.RepositoryNodeComparator) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ArrayList(java.util.ArrayList) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) GridData(org.eclipse.swt.layout.GridData) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)

Aggregations

ArrayList (java.util.ArrayList)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ContainerCheckedTreeViewer (org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)1 ItemRecord (org.talend.dataprofiler.core.ui.imex.model.ItemRecord)1 RepositoryNodeComparator (org.talend.dq.helper.RepositoryNodeComparator)1 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)1