Search in sources :

Example 1 with FileSelectorTreeViewerProvider

use of org.talend.designer.hdfsbrowse.ui.provider.FileSelectorTreeViewerProvider in project tbd-studio-se by Talend.

the class HDFSFileSelectorForm method addSchemaFields.

private void addSchemaFields() {
    schemaTreeViewer = new ContainerCheckedTreeViewer(scrolledCompositeFileViewer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    schemaTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    schemaTreeViewer.setUseHashlookup(true);
    schemaTreeViewer.addFilter(new FileSelectorViewerFilter());
    schemaTree = schemaTreeViewer.getTree();
    schemaTree.setHeaderVisible(true);
    schemaTree.setLinesVisible(true);
    schemaTree.addListener(SWT.Expand, new Listener() {

        @Override
        public void handleEvent(Event event) {
            TreeItem treeItem = (TreeItem) event.item;
            for (TreeItem item : treeItem.getItems()) {
                if (item.getData() != null) {
                    IHDFSNode node = (IHDFSNode) item.getData();
                    if (node.getType() == EHadoopFileTypes.FILE) {
                        if (isExistTable(node)) {
                            item.setChecked(true);
                            updateParentItemCheckStatus(item);
                        } else {
                            TreeEditor treeEditor = treeEditorMap.get(item);
                            if (treeEditor == null) {
                                item.setChecked(false);
                            }
                        }
                    } else {
                    // item.setGrayed(item.getChecked());
                    }
                }
            }
        }
    });
    int columnWidth1 = 250;
    int columnWidth2 = 100;
    int columnWidth3 = 110;
    int columnWidth4 = 130;
    int columnWidth5 = 140;
    TreeColumn fileName = new TreeColumn(schemaTree, SWT.LEFT);
    // $NON-NLS-1$
    fileName.setText(Messages.getString("HDFSFileSelectorForm.schemaTree.nameColumn"));
    fileName.setWidth(columnWidth1);
    TreeColumn fileType = new TreeColumn(schemaTree, SWT.LEFT);
    // $NON-NLS-1$
    fileType.setText(Messages.getString("HDFSFileSelectorForm.schemaTree.typeColumn"));
    fileType.setWidth(columnWidth2);
    TreeColumn fileSize = new TreeColumn(schemaTree, SWT.LEFT);
    // $NON-NLS-1$
    fileSize.setText(Messages.getString("HDFSFileSelectorForm.schemaTree.sizeColumn"));
    fileSize.setWidth(columnWidth3);
    TreeColumn nbColumns = new TreeColumn(schemaTree, SWT.LEFT);
    // $NON-NLS-1$
    nbColumns.setText(Messages.getString("HDFSFileSelectorForm.schemaTree.numberColumn"));
    nbColumns.setWidth(columnWidth4);
    TreeColumn creationStatus = new TreeColumn(schemaTree, SWT.LEFT);
    // $NON-NLS-1$
    creationStatus.setText(Messages.getString("HDFSFileSelectorForm.schemaTree.statusColumn"));
    creationStatus.setWidth(columnWidth5);
    AbstractMetadataExtractorViewProvider viewProvider = new FileSelectorTreeViewerProvider();
    schemaTreeViewer.setLabelProvider(viewProvider);
    schemaTreeViewer.setContentProvider(viewProvider);
    schemaTreeViewer.setInput(connectionBean = getConnectionBean());
    scrolledCompositeFileViewer.setContent(schemaTree);
    scrolledCompositeFileViewer.setMinSize(schemaTree.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) Point(org.eclipse.swt.graphics.Point) AbstractMetadataExtractorViewProvider(org.talend.core.repository.model.provider.AbstractMetadataExtractorViewProvider) FileSelectorTreeViewerProvider(org.talend.designer.hdfsbrowse.ui.provider.FileSelectorTreeViewerProvider) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Example 2 with FileSelectorTreeViewerProvider

use of org.talend.designer.hdfsbrowse.ui.provider.FileSelectorTreeViewerProvider in project tbd-studio-se by Talend.

the class HDFSBrowseDialog method createHDFSTreeField.

private void createHDFSTreeField(Composite composite) {
    viewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer.setUseHashlookup(true);
    tree = viewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    // $NON-NLS-1$
    column1.setText(Messages.getString("HDFSBrowseDialog.column.name"));
    column1.setWidth(300);
    column1.setResizable(true);
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    // $NON-NLS-1$
    column2.setText(Messages.getString("HDFSBrowseDialog.column.type"));
    column2.setWidth(120);
    column2.setResizable(true);
    TreeColumn column3 = new TreeColumn(tree, SWT.LEFT);
    // $NON-NLS-1$
    column3.setText(Messages.getString("HDFSBrowseDialog.column.size"));
    column3.setWidth(150);
    column3.setResizable(true);
    FileSelectorTreeViewerProvider provider = new FileSelectorTreeViewerProvider();
    viewer.setContentProvider(provider);
    viewer.setLabelProvider(provider);
    viewer.setInput(connectionBean);
    viewer.expandToLevel(2);
}
Also used : FileSelectorTreeViewerProvider(org.talend.designer.hdfsbrowse.ui.provider.FileSelectorTreeViewerProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData)

Aggregations

GridData (org.eclipse.swt.layout.GridData)2 TreeColumn (org.eclipse.swt.widgets.TreeColumn)2 FileSelectorTreeViewerProvider (org.talend.designer.hdfsbrowse.ui.provider.FileSelectorTreeViewerProvider)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 TreeEditor (org.eclipse.swt.custom.TreeEditor)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Point (org.eclipse.swt.graphics.Point)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 ContainerCheckedTreeViewer (org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)1 AbstractMetadataExtractorViewProvider (org.talend.core.repository.model.provider.AbstractMetadataExtractorViewProvider)1 IHDFSNode (org.talend.designer.hdfsbrowse.model.IHDFSNode)1