Search in sources :

Example 1 with DFColumnRepNode

use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.

the class AbstractColumnDropTree method dropModelElements.

public void dropModelElements(List<? extends IRepositoryNode> repositoryNode, int index) {
    int size = repositoryNode.size();
    ModelElementIndicator[] meIndicators = new ModelElementIndicator[size];
    for (int i = 0; i < size; i++) {
        IRepositoryNode repNode = repositoryNode.get(i);
        IRepositoryViewObject repViewObj = repNode.getObject();
        // TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(repViewObj);
        if (repNode instanceof DFColumnRepNode) {
            meIndicators[i] = ModelElementIndicatorHelper.createDFColumnIndicator(repNode);
        } else if (repViewObj != null && repViewObj instanceof MetadataColumnRepositoryObject) {
            meIndicators[i] = ModelElementIndicatorHelper.createColumnIndicator(repNode);
        }
    }
    addElements(meIndicators);
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 2 with DFColumnRepNode

use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.

the class ColumnViewerDND method installDND.

/**
 * DOC qzhang Comment method "installDND".
 */
public static void installDND(final Tree targetControl) {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
    final CommonViewer commonViewer = findView.getCommonViewer();
    final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
    int operations = DND.DROP_COPY | DND.DROP_MOVE;
    Transfer[] transfers = new Transfer[] { transfer };
    DropTarget dropTarget = new DropTarget(targetControl, operations);
    dropTarget.setTransfer(transfers);
    DropTargetListener dndListener = new TreeDropTargetEffect(targetControl) {

        ISelectionReceiver receiver = null;

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.dnd.DropTargetAdapter#dragEnter(org.eclipse.swt .dnd.DropTargetEvent)
             */
        @Override
        public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
            Object object = selection.getFirstElement();
            // if (object instanceof IFile) {
            if (object instanceof SysIndicatorDefinitionRepNode) {
                receiver = new UDIReceiver();
            } else if (object instanceof PatternRepNode) {
                receiver = new PatternReceiver();
            }
            // MOD klliu 15750 2011-01-17 for Drag&Drop On columnset
            if (object instanceof DBColumnRepNode || object instanceof DBTableRepNode || object instanceof DFColumnRepNode) {
                receiver = new ColumnReceiver();
            }
            if (receiver == null) {
                event.detail = DND.DROP_NONE;
            } else {
                event.feedback = DND.FEEDBACK_EXPAND;
                receiver.doDropValidation(event, commonViewer);
            }
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.dnd.TreeDropTargetEffect#dragOver(org.eclipse .swt.dnd.DropTargetEvent)
             */
        @Override
        public void dragOver(DropTargetEvent event) {
            super.dragOver(event);
            // MOD yyi 2009-09-18 bug: 9044
            if (null != receiver) {
                receiver.doDropValidation(event, commonViewer);
            }
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.dnd.DropTargetAdapter#drop(org.eclipse.swt.dnd .DropTargetEvent)
             */
        @Override
        public void drop(DropTargetEvent event) {
            int index = targetControl.getItemCount();
            super.drop(event);
            if (event.item == null) {
                // TreeItem item = new TreeItem(targetControl, SWT.NONE);
                // item.setText(texts);
                // item.setText(text);
                index = 0;
            } else {
                TreeItem item = (TreeItem) event.item;
                TreeItem[] items = targetControl.getItems();
                for (int i = 0; i < items.length; i++) {
                    if (items[i] == item) {
                        index = i;
                        break;
                    }
                }
            }
            receiver.drop(event, commonViewer, index);
        }
    };
    dropTarget.addDropListener(dndListener);
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) TreeItem(org.eclipse.swt.widgets.TreeItem) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) TreeDropTargetEffect(org.eclipse.swt.dnd.TreeDropTargetEffect) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DropTarget(org.eclipse.swt.dnd.DropTarget) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) PatternRepNode(org.talend.dq.nodes.PatternRepNode)

Example 3 with DFColumnRepNode

use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.

the class NominalValuesDPSelectionPage method addListeners.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
     */
@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (object instanceof ColumnRepNode) {
                RepositoryNode repositoryNode = (ColumnRepNode) object;
                DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
                int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
                // int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
                if (Java2SqlType.isTextInSQL(javaSQLType)) {
                    advanceToNextPageOrFinish();
                } else {
                    List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                    tempList.add(columnNode);
                    setAddTextIndicator(false);
                    if (!tempList.isEmpty()) {
                        ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
                        dialog.setElements(tempList.toArray());
                        // $NON-NLS-1$
                        dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
                        // $NON-NLS-1$
                        dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
                        dialog.setSize(80, 20);
                        dialog.create();
                        if (Window.OK == dialog.open()) {
                            // use MetadataHelper
                            for (DFColumnRepNode col : tempList) {
                                MetadataHelper.setDataminingType(DataminingType.NOMINAL, col.getMetadataColumn());
                            }
                            advanceToNextPageOrFinish();
                        }
                    }
                }
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
                nodes = new ArrayList<IRepositoryNode>();
                if (object instanceof ColumnRepNode) {
                    List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
                    nodes.addAll(list);
                    if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
                        List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                        for (IRepositoryNode obj : nodes) {
                            if (object instanceof ColumnRepNode) {
                                RepositoryNode repositoryNode = (ColumnRepNode) obj;
                                DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
                                int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
                                if (!Java2SqlType.isTextInSQL(javaSQLType)) {
                                    tempList.add(columnNode);
                                    setAddTextIndicator(false);
                                }
                            }
                        }
                        if (!tempList.isEmpty()) {
                            ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
                            dialog.setElements(tempList.toArray());
                            // $NON-NLS-1$
                            dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
                            // $NON-NLS-1$
                            dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
                            dialog.setSize(80, 20);
                            dialog.create();
                            if (Window.OK == dialog.open()) {
                                // zqin get the column and change their datamining type to "Nominal"
                                for (DFColumnRepNode column : tempList) {
                                    MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
                                }
                                setPageComplete(true);
                                setMessage(chooseConnStr);
                            }
                        } else {
                            setPageComplete(true);
                            setMessage(chooseConnStr);
                        }
                    } else {
                        setPageComplete(false);
                        // $NON-NLS-1$
                        setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
                    }
                } else {
                    setPageComplete(false);
                    setMessage(chooseConnStr);
                }
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    });
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayList(java.util.ArrayList) List(java.util.List) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 4 with DFColumnRepNode

use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.

the class ImageLib method getImageNameByRepositoryNode.

public static String getImageNameByRepositoryNode(IRepositoryNode node) {
    String imageName = null;
    IRepositoryViewObject viewObject = node.getObject();
    ENodeType type = node.getType();
    if (node instanceof ReportAnalysisRepNode) {
        imageName = ImageLib.ANALYSIS_OBJECT;
    } else if (node instanceof RecycleBinRepNode) {
        imageName = ImageLib.RECYCLEBIN_EMPTY;
    } else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
        String label = viewObject.getLabel();
        if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
            imageName = ImageLib.DATA_PROFILING;
        } else if (label.equals(EResourceConstant.METADATA.getName())) {
            imageName = ImageLib.METADATA;
        } else if (node instanceof DBConnectionFolderRepNode) {
            imageName = ImageLib.CONNECTION;
        } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
            imageName = ImageLib.HADOOP_CLUSTER;
        } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
            imageName = ImageLib.LIBRARIES;
        } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
            imageName = ImageLib.EXCHANGE;
        } else {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
        imageName = ImageLib.FOLDERNODE_IMAGE;
    } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
        if (node instanceof DBConnectionRepNode) {
            imageName = ImageLib.TD_DATAPROVIDER;
        } else if (node instanceof DFConnectionRepNode) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (node instanceof AnalysisRepNode) {
            imageName = ImageLib.ANALYSIS_OBJECT;
        } else if (node instanceof ReportRepNode) {
            imageName = ImageLib.REPORT_OBJECT;
        } else if (node instanceof SysIndicatorDefinitionRepNode) {
            imageName = ImageLib.IND_DEFINITION;
        } else if (node instanceof PatternRepNode) {
            imageName = ImageLib.PATTERN_REG;
        } else if (node instanceof RuleRepNode) {
            imageName = ImageLib.DQ_RULE;
        } else if (node instanceof SourceFileRepNode) {
            imageName = ImageLib.SOURCE_FILE;
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            imageName = ImageLib.EXCHANGE;
        } else if (node instanceof JrxmlTempleteRepNode) {
            imageName = ImageLib.JRXML_ICON;
        }
    } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
        if (node instanceof DBCatalogRepNode) {
            imageName = ImageLib.CATALOG;
        } else if (node instanceof DBSchemaRepNode) {
            imageName = ImageLib.SCHEMA;
        } else if (node instanceof DBTableFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBViewFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
            imageName = ImageLib.TABLE;
        } else if (node instanceof DBViewRepNode) {
            imageName = ImageLib.VIEW;
        } else if (node instanceof DBColumnRepNode) {
            if (((DBColumnRepNode) node).isKey()) {
                imageName = ImageLib.PK_COLUMN;
            } else {
                imageName = ImageLib.TD_COLUMN;
            }
        } else if (node instanceof DFColumnRepNode) {
            imageName = ImageLib.TD_COLUMN;
        } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    }
    return imageName;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Example 5 with DFColumnRepNode

use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.

the class ColumnsSelectionDialog method getAllCheckElements.

protected void getAllCheckElements() {
    // Added TDQ-8718 20140506 yyin: should not load from DB(connect) when get checked elements
    DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
    DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
    try {
        Object[] checkedNodes = this.getTreeViewer().getCheckedElements();
        for (Object checkedNode : checkedNodes) {
            IRepositoryNode repNode = (IRepositoryNode) checkedNode;
            if (repNode instanceof DBColumnRepNode || repNode instanceof DFColumnRepNode) {
                if (!allCheckedElements.contains(repNode)) {
                    allCheckedElements.add(repNode);
                }
            } else if (repNode instanceof DFTableRepNode || repNode instanceof DBTableRepNode || repNode instanceof DBViewRepNode) {
                if (!getTableviewCheckedElements(allCheckedElements, repNode)) {
                    List<IRepositoryNode> children = repNode.getChildren().get(0).getChildren();
                    for (IRepositoryNode node : children) {
                        if (!allCheckedElements.contains(node)) {
                            allCheckedElements.add(node);
                        }
                    }
                }
            }
        }
    } finally {
        // Added TDQ-8718 20140506 yyin
        DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
        DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
    }
    // ADD msjian 2011-7-8 feature 22206: Add filters
    Iterator<?> it = modelElementCheckedMap.keySet().iterator();
    while (it.hasNext()) {
        RepositoryNode reposNode = (RepositoryNode) it.next();
        List<?> columnList = (ArrayList<?>) modelElementCheckedMap.get(reposNode);
        for (int i = 0; i < columnList.size(); i++) {
            if (columnList.get(i) instanceof DBColumnRepNode || columnList.get(i) instanceof DFColumnRepNode) {
                if (!allCheckedElements.contains(columnList.get(i))) {
                    allCheckedElements.add((IRepositoryNode) columnList.get(i));
                }
            }
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) ArrayList(java.util.ArrayList) List(java.util.List) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Aggregations

DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)6 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)6 ArrayList (java.util.ArrayList)5 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)5 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 List (java.util.List)3 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)3 PatternRepNode (org.talend.dq.nodes.PatternRepNode)3 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)2 ExchangeCategoryRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode)2 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)2 DQRepositoryViewLabelProvider (org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)2 ColumnRepNode (org.talend.dq.nodes.ColumnRepNode)2 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)2