Search in sources :

Example 1 with IHCatalogNode

use of org.talend.repository.hcatalog.model.IHCatalogNode in project tbd-studio-se by Talend.

the class HCatalogTableSelectorForm 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;
    }
    IHCatalogNode node = (IHCatalogNode) treeItem.getData();
    if (node == null) {
        return;
    }
    refreshItem(treeItem);
    checkedItems.remove(node.getTable().getName());
}
Also used : IHCatalogNode(org.talend.repository.hcatalog.model.IHCatalogNode)

Example 2 with IHCatalogNode

use of org.talend.repository.hcatalog.model.IHCatalogNode 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)

Example 3 with IHCatalogNode

use of org.talend.repository.hcatalog.model.IHCatalogNode in project tbd-studio-se by Talend.

the class HCatalogTableSelectorForm method refreshItem.

private void refreshItem(TreeItem item) {
    if (item != null && item.getData() != null) {
        item.setChecked(false);
        if (item.getData() != null) {
            IHCatalogNode node = (IHCatalogNode) item.getData();
            if (isExistTable(node)) {
                item.setChecked(true);
                Integer num = tableColumnNums.get(item.getText(0));
                if (num != null) {
                    // get column num from previous result
                    item.setText(1, num.toString());
                    // $NON-NLS-1$
                    item.setText(2, Messages.getString("HCatalogTableSelectorForm.title.success"));
                } else {
                    // retrieve column num again
                    refreshTable(item, -1);
                }
            }
        }
    }
}
Also used : IHCatalogNode(org.talend.repository.hcatalog.model.IHCatalogNode)

Example 4 with IHCatalogNode

use of org.talend.repository.hcatalog.model.IHCatalogNode in project tbd-studio-se by Talend.

the class HCatalogTableSelectorForm method updateItem.

private void updateItem(final TreeItem item, boolean checked, boolean isEvent) {
    IHCatalogNode node = (IHCatalogNode) item.getData();
    String pattern = getNameFilter();
    SearchPattern matcher = new SearchPattern();
    matcher.setPattern(pattern);
    if (!matcher.matches(node.getValue())) {
        return;
    }
    // if from click event, should set the table item original status.
    if (isEvent) {
        Set<MetadataTable> tables = ConnectionHelper.getTables(getConnection());
        for (MetadataTable table : tables) {
            if (table.getLabel().equals(node.getTable().getName())) {
                item.setChecked(true);
            }
        }
        item.setChecked(!checked);
    }
    if (checked) {
        if (!item.getChecked()) {
            MetadataTable existTable = HCatalogSchemaUtil.getTableByName(getConnection(), item.getText(0));
            if (existTable != null) {
                refreshExistItem(existTable, item);
            } else {
                // $NON-NLS-1$
                item.setText(2, Messages.getString("HCatalogTableSelectorForm.Pending"));
                countPending++;
                parentWizardPage.setPageComplete(false);
                refreshTable(item, -1);
            }
        } else {
            updateStatus(IStatus.OK, null);
        }
        item.setChecked(true);
    } else {
        if (item.getChecked()) {
            clearTreeItem(item);
            item.setChecked(false);
        }
    }
}
Also used : SearchPattern(org.eclipse.ui.dialogs.SearchPattern) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IHCatalogNode(org.talend.repository.hcatalog.model.IHCatalogNode)

Example 5 with IHCatalogNode

use of org.talend.repository.hcatalog.model.IHCatalogNode in project tbd-studio-se by Talend.

the class HCatalogTableSelectorForm method refreshTable.

private void refreshTable(final TreeItem treeItem, final int size) {
    if (threadExecutor == null) {
        return;
    }
    if (!threadExecutor.isThreadRunning(treeItem)) {
        IHCatalogNode node = (IHCatalogNode) treeItem.getData();
        RetrieveColumnRunnable runnable = new RetrieveColumnRunnable(treeItem);
        String value = node.getTable().getName();
        if (!(isExistingNames(value))) {
            threadExecutor.execute(runnable);
        }
    } else {
        RetrieveColumnRunnable runnable = threadExecutor.getRunnable(treeItem);
        runnable.setCanceled(false);
    }
}
Also used : IHCatalogNode(org.talend.repository.hcatalog.model.IHCatalogNode)

Aggregations

IHCatalogNode (org.talend.repository.hcatalog.model.IHCatalogNode)6 ArrayList (java.util.ArrayList)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 GridData (org.eclipse.swt.layout.GridData)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 ContainerCheckedTreeViewer (org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)1 SearchPattern (org.eclipse.ui.dialogs.SearchPattern)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 AbstractMetadataExtractorViewProvider (org.talend.core.repository.model.provider.AbstractMetadataExtractorViewProvider)1 TdTable (org.talend.cwm.relational.TdTable)1 HCatalogNode (org.talend.repository.hcatalog.model.HCatalogNode)1 HCatalogConnection (org.talend.repository.model.hcatalog.HCatalogConnection)1