use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.
the class AbstractHDFSBrowseController method createCommand.
protected Command createCommand(SelectionEvent event, HDFSConnectionBean connection) {
HDFSBrowseDialog dial = new HDFSBrowseDialog(composite.getShell(), getHDFSType(), connection);
Button btn = (Button) event.getSource();
String propertyName = (String) btn.getData(PARAMETER_NAME);
Text filePathText = (Text) hashCurControls.get(propertyName);
if (dial.open() == Window.OK) {
IHDFSNode result = dial.getResult();
String path = result.getPath();
path = TalendQuoteUtils.addQuotesIfNotExist(path);
if (!elem.getPropertyValue(propertyName).equals(path)) {
filePathText.setText(path);
return new PropertyChangeCommand(elem, propertyName, path);
}
}
return null;
}
use of org.talend.designer.hdfsbrowse.model.IHDFSNode in project tbd-studio-se by Talend.
the class HDFSBrowseDialog method isSelectionValid.
protected boolean isSelectionValid(SelectionChangedEvent event) {
boolean isValid = true;
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection == null || selection.size() != 1) {
isValid = false;
} else {
IHDFSNode node = (IHDFSNode) selection.getFirstElement();
if (type == EHadoopFileTypes.RESOURCE) {
isValid = true;
} else if (node.getType() != type) {
isValid = false;
}
}
return isValid;
}
use of org.talend.designer.hdfsbrowse.model.IHDFSNode 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.IHDFSNode in project tbd-studio-se by Talend.
the class HDFSFileSelectorForm method clearTreeItem.
private void clearTreeItem(TreeItem item, boolean deleteFromConnection) {
if (item == null || item.isDisposed()) {
return;
}
Object data = item.getData();
if (data != null && data instanceof IHDFSNode) {
IHDFSNode node = (IHDFSNode) data;
if (node.getType() == EHadoopFileTypes.FILE) {
if (deleteFromConnection) {
deleteTable(node);
}
item.setText(3, EMPTY_STRING);
item.setText(4, EMPTY_STRING);
TreeEditor treeEditor = treeEditorMap.get(item);
if (treeEditor != null) {
treeEditor.getEditor().dispose();
treeEditor.dispose();
treeEditorMap.remove(item);
}
}
RetrieveColumnRunnable runnable = threadExecutor.getRunnable(node.getPath());
if (runnable != null) {
runnable.setCanceled(true);
}
}
}
use of org.talend.designer.hdfsbrowse.model.IHDFSNode 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);
}
}
}
}
});
}
Aggregations