use of org.talend.designer.hdfsbrowse.model.EHadoopFileTypes in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm method updateItem.
private void updateItem(final TreeItem item, boolean checked, boolean isEvent, IProgressMonitor monitor) {
if (monitor != null && monitor.isCanceled()) {
return;
}
IHDFSNode node = (IHDFSNode) item.getData();
if (node == null) {
return;
}
EHadoopFileTypes type = node.getType();
if (type != EHadoopFileTypes.FILE) {
item.setChecked(checked);
}
if (type == EHadoopFileTypes.FOLDER) {
for (TreeItem treeItem : item.getItems()) {
updateItem(treeItem, checked, true, monitor);
}
} else if (type == EHadoopFileTypes.FILE) {
String pattern = getNameFilter();
SearchPattern matcher = new SearchPattern();
matcher.setPattern(pattern);
if (!matcher.matches(node.getValue())) {
return;
}
if (checked) {
// $NON-NLS-1$
item.setText(4, Messages.getString("HDFSFileSelectorForm.Pending"));
parentWizardPage.setPageComplete(false);
refreshTable(item, -1);
item.setChecked(true);
} else {
clearTreeItem(item);
item.setChecked(false);
}
}
}
use of org.talend.designer.hdfsbrowse.model.EHadoopFileTypes in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm method addFieldsListeners.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#addFieldsListeners()
*/
@Override
protected void addFieldsListeners() {
nameFilter.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
schemaTreeViewer.refresh();
}
});
schemaTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (e.detail == SWT.CHECK) {
final TreeItem treeItem = (TreeItem) e.item;
IHDFSNode node = (IHDFSNode) treeItem.getData();
final boolean promptNeeded = treeItem.getChecked();
EHadoopFileTypes type = node.getType();
if (type != EHadoopFileTypes.FILE) {
treeItem.setGrayed(promptNeeded);
}
if (type == EHadoopFileTypes.FILE) {
if (promptNeeded) {
treeItem.setText(3, EMPTY_STRING);
// $NON-NLS-1$
treeItem.setText(4, Messages.getString("HDFSFileSelectorForm.Pending"));
parentWizardPage.setPageComplete(false);
selectedNode = (IHDFSNode) treeItem.getData();
refreshTable(treeItem, -1);
} else {
clearTreeItem(treeItem);
}
} else if (type == EHadoopFileTypes.FOLDER) {
if (!promptNeeded) {
threadExecutor.clearRunnable(node.getPath());
}
long checkedSize = fetchAllChildren(new TreeItem[] { treeItem });
boolean continueCheck = true;
if (promptNeeded && INFORM_SIZE < checkedSize) {
continueCheck = MessageDialog.openConfirm(getShell(), Messages.getString("HDFSFileSelectorForm.title.confirm"), // $NON-NLS-1$
Messages.getString("HDFSFileSelectorForm.confirm.executeConfirm", // $NON-NLS-1$
new Object[] { INFORM_SIZE }));
}
if (continueCheck) {
selectedNode = (IHDFSNode) treeItem.getData();
updateItems(treeItem.getItems(), promptNeeded, true);
} else {
treeItem.setGrayed(!promptNeeded);
treeItem.setChecked(!promptNeeded);
}
}
}
}
});
}
use of org.talend.designer.hdfsbrowse.model.EHadoopFileTypes 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);
}
}
}
}
}
}
use of org.talend.designer.hdfsbrowse.model.EHadoopFileTypes in project tbd-studio-se by Talend.
the class FileSelectorTreeViewerProvider method getColumnText.
public String getColumnText(Object element, int columnIndex) {
IHDFSNode content = (IHDFSNode) element;
EHadoopFileTypes type = content.getType();
switch(columnIndex) {
case 0:
return StringUtils.trimToEmpty(content.getValue());
case 1:
return StringUtils.trimToEmpty(type.getValue());
case 2:
if (content instanceof HDFSFile) {
HDFSFile file = (HDFSFile) content;
return StringUtils.trimToEmpty(file.getSize());
} else {
return EMPTY_STRING;
}
default:
return EMPTY_STRING;
}
}
use of org.talend.designer.hdfsbrowse.model.EHadoopFileTypes in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm 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;
}
IHDFSNode node = (IHDFSNode) treeItem.getData();
if (node == null) {
return;
}
EHadoopFileTypes type = node.getType();
if (type == EHadoopFileTypes.FOLDER) {
for (TreeItem item : treeItem.getItems()) {
IHDFSNode childNode = (IHDFSNode) item.getData();
if (childNode == null) {
node.getChildren();
}
restoreCheckItems(item, checkedItems);
}
} else if (type == EHadoopFileTypes.FILE) {
refreshItem(treeItem);
checkedItems.remove(node.getTable().getName());
}
}
Aggregations