Search in sources :

Example 11 with IHDFSNode

use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.

the class FileSelectorTreeViewerProvider method getColumnText.

public String getColumnText(Object element, int columnIndex) {
    IHDFSNode content = (IHDFSNode) element;
    EHadoopFileTypes type = content.getType();
    switch(columnIndex) {
        case 0:
            return StringUtils.trimToEmpty(content.getValue());
        case 1:
            return StringUtils.trimToEmpty(type.getValue());
        case 2:
            if (content instanceof HDFSFile) {
                HDFSFile file = (HDFSFile) content;
                return StringUtils.trimToEmpty(file.getSize());
            } else {
                return EMPTY_STRING;
            }
        default:
            return EMPTY_STRING;
    }
}
Also used : EHadoopFileTypes(org.talend.designer.hdfsbrowse.model.EHadoopFileTypes) HDFSFile(org.talend.designer.hdfsbrowse.model.HDFSFile) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Example 12 with IHDFSNode

use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.

the class HDFSFileSelectorForm method restoreCheckItems.

protected void restoreCheckItems(TreeItem treeItem, List<String> checkedItems) {
    // If all the checked items are updated then no need to restore.
    if (checkedItems.size() == 0) {
        return;
    }
    IHDFSNode node = (IHDFSNode) treeItem.getData();
    if (node == null) {
        return;
    }
    EHadoopFileTypes type = node.getType();
    if (type == EHadoopFileTypes.FOLDER) {
        for (TreeItem item : treeItem.getItems()) {
            IHDFSNode childNode = (IHDFSNode) item.getData();
            if (childNode == null) {
                node.getChildren();
            }
            restoreCheckItems(item, checkedItems);
        }
    } else if (type == EHadoopFileTypes.FILE) {
        refreshItem(treeItem);
        checkedItems.remove(node.getTable().getName());
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) EHadoopFileTypes(org.talend.designer.hdfsbrowse.model.EHadoopFileTypes) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Example 13 with IHDFSNode

use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.

the class HDFSFileSelectorForm method fetchChildren.

private long fetchChildren(IHDFSNode node, IProgressMonitor monitor) {
    if (monitor != null && monitor.isCanceled()) {
        return 0;
    }
    node.forceFetchChildren();
    long nodeSize = 0;
    EHadoopFileTypes type = node.getType();
    if (type == EHadoopFileTypes.FILE) {
        nodeSize++;
    }
    List<IHDFSNode> children = node.getChildren();
    if (monitor != null && monitor.isCanceled()) {
        return 0;
    }
    if (children != null) {
        for (IHDFSNode child : children) {
            nodeSize += fetchChildren(child, monitor);
        }
    }
    return nodeSize;
}
Also used : EHadoopFileTypes(org.talend.designer.hdfsbrowse.model.EHadoopFileTypes) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Aggregations

IHDFSNode (org.talend.designer.hdfsbrowse.model.IHDFSNode)13 TreeItem (org.eclipse.swt.widgets.TreeItem)6 EHadoopFileTypes (org.talend.designer.hdfsbrowse.model.EHadoopFileTypes)6 TreeEditor (org.eclipse.swt.custom.TreeEditor)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 Point (org.eclipse.swt.graphics.Point)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 Text (org.eclipse.swt.widgets.Text)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 ContainerCheckedTreeViewer (org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)1