Search in sources :

Example 1 with IHDFSNode

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;
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Button(org.eclipse.swt.widgets.Button) Text(org.eclipse.swt.widgets.Text) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Example 2 with IHDFSNode

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;
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Example 3 with IHDFSNode

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);
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) EHadoopFileTypes(org.talend.designer.hdfsbrowse.model.EHadoopFileTypes) SearchPattern(org.eclipse.ui.dialogs.SearchPattern) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Example 4 with IHDFSNode

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);
        }
    }
}
Also used : TreeEditor(org.eclipse.swt.custom.TreeEditor) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Example 5 with IHDFSNode

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);
                    }
                }
            }
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EHadoopFileTypes(org.talend.designer.hdfsbrowse.model.EHadoopFileTypes) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Aggregations

IHDFSNode (org.talend.designer.hdfsbrowse.model.IHDFSNode)13 TreeItem (org.eclipse.swt.widgets.TreeItem)6 EHadoopFileTypes (org.talend.designer.hdfsbrowse.model.EHadoopFileTypes)6 TreeEditor (org.eclipse.swt.custom.TreeEditor)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 Point (org.eclipse.swt.graphics.Point)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 Text (org.eclipse.swt.widgets.Text)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 ContainerCheckedTreeViewer (org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)1