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());
}
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));
}
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);
}
}
}
}
}
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);
}
}
}
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);
}
}
Aggregations