Search in sources :

Example 1 with AbstractMetadataExtractorViewProvider

use of org.talend.core.repository.model.provider.AbstractMetadataExtractorViewProvider 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 AbstractMetadataExtractorViewProvider

use of org.talend.core.repository.model.provider.AbstractMetadataExtractorViewProvider in project tbd-studio-se by Talend.

the class HCatalogTableSelectorForm 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 TableSelectorViewerFilter());
    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) {
                    IHCatalogNode node = (IHCatalogNode) item.getData();
                    if (isExistTable(node)) {
                        item.setChecked(true);
                    } else {
                        item.setChecked(false);
                    }
                }
            }
        }
    });
    int columnWidth1 = 300;
    int columnWidth2 = 125;
    int columnWidth3 = 140;
    TreeColumn tableName = new TreeColumn(schemaTree, SWT.NONE);
    // $NON-NLS-1$
    tableName.setText(Messages.getString("HCatalogTableSelectorForm.schemaTree.nameColumn"));
    tableName.setWidth(columnWidth1);
    TreeColumn nbColumns = new TreeColumn(schemaTree, SWT.RIGHT);
    // $NON-NLS-1$
    nbColumns.setText(Messages.getString("HCatalogTableSelectorForm.schemaTree.numberColumn"));
    nbColumns.setWidth(columnWidth2);
    TreeColumn creationStatus = new TreeColumn(schemaTree, SWT.RIGHT);
    // $NON-NLS-1$
    creationStatus.setText(Messages.getString("HCatalogTableSelectorForm.schemaTree.statusColumn"));
    creationStatus.setWidth(columnWidth3);
    AbstractMetadataExtractorViewProvider viewProvider = new TableSelectorTreeViewerProvider();
    schemaTreeViewer.setLabelProvider(viewProvider);
    schemaTreeViewer.setContentProvider(viewProvider);
    // schemaTreeViewer.setInput(getConnection());
    scrolledCompositeFileViewer.setContent(schemaTree);
    scrolledCompositeFileViewer.setMinSize(schemaTree.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : AbstractMetadataExtractorViewProvider(org.talend.core.repository.model.provider.AbstractMetadataExtractorViewProvider) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeItem(org.eclipse.swt.widgets.TreeItem) 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) IHCatalogNode(org.talend.repository.hcatalog.model.IHCatalogNode) Point(org.eclipse.swt.graphics.Point)

Aggregations

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