use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm method refreshTable.
protected void refreshTable(final TreeItem treeItem, final int size) {
IHDFSNode node = (IHDFSNode) treeItem.getData();
if (!threadExecutor.isThreadRunning(treeItem)) {
if (node.getType() == EHadoopFileTypes.FILE) {
RetrieveColumnRunnable runnable = new RetrieveColumnRunnable(treeItem);
threadExecutor.execute(runnable);
}
} else {
RetrieveColumnRunnable runnable = threadExecutor.getRunnable(node.getPath());
runnable.setCanceled(false);
}
}
use of org.talend.designer.hdfsbrowse.model.IHDFSNode 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));
}
use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm method updateParentItemCheckStatus.
private static void updateParentItemCheckStatus(TreeItem item) {
TreeItem parentItem = item.getParentItem();
if (parentItem == null) {
return;
}
boolean hasCheckedItem = false;
boolean hasUncheckedItem = false;
for (TreeItem i : parentItem.getItems()) {
if (hasCheckedItem && hasUncheckedItem) {
break;
}
IHDFSNode node = (IHDFSNode) i.getData();
if (node.getType() == EHadoopFileTypes.FOLDER && i.getGrayed() == true) {
hasCheckedItem = true;
hasUncheckedItem = true;
}
if (i.getChecked()) {
hasCheckedItem = true;
} else {
hasUncheckedItem = true;
}
}
if (!hasCheckedItem) {
parentItem.setChecked(false);
} else if (hasCheckedItem && hasUncheckedItem) {
parentItem.setChecked(true);
parentItem.setGrayed(true);
} else {
parentItem.setChecked(true);
parentItem.setGrayed(false);
}
updateParentItemCheckStatus(parentItem);
}
use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm method fetchAllChildren.
protected long fetchAllChildren(final TreeItem[] treeItems) {
long childSize = 0;
try {
final StringBuffer fetchNumber = new StringBuffer();
parentWizardPage.getWizard().getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
// $NON-NLS-1$
monitor.beginTask(Messages.getString("HDFSFileSelectorForm.fetchChildren"), IProgressMonitor.UNKNOWN);
long checkedSize = 0;
for (TreeItem tItem : treeItems) {
if (monitor != null && monitor.isCanceled()) {
break;
}
checkedSize += fetchAllChildren((IHDFSNode) tItem.getData(), monitor);
}
fetchNumber.append(checkedSize);
monitor.done();
}
});
// System.out.println("monitor:" + monitor.isCanceled());
}
});
if (0 < fetchNumber.length()) {
childSize = Long.valueOf(fetchNumber.toString());
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
return childSize;
}
use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm method refreshItem.
private void refreshItem(TreeItem item) {
if (item != null && item.getData() != null) {
EHadoopFileTypes type = ((IHDFSNode) item.getData()).getType();
if (type == EHadoopFileTypes.FILE) {
item.setChecked(false);
if (item.getData() != null) {
IHDFSNode node = (IHDFSNode) 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(3, num.toString());
// $NON-NLS-1$
item.setText(4, Messages.getString("HDFSFileSelectorForm.title.success"));
} else {
// retrieve column num again
refreshTable(item, -1);
}
}
}
}
}
}
Aggregations