Search in sources :

Example 11 with DBColumnRepNode

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

the class DataFilterDND method installDND.

public static void installDND(final Text 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);
    dropTarget.addDropListener(new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetEvent event) {
            Object obj = ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
            if (!(obj instanceof DBColumnRepNode)) {
                event.detail = DND.DROP_NONE;
            } else {
                event.detail = DND.DROP_MOVE;
                event.feedback = DND.FEEDBACK_INSERT_AFTER;
            }
        }

        @Override
        public void dropAccept(DropTargetEvent event) {
        // do nothing until now
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event.detail != DND.DROP_NONE) {
                IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
                if (!selection.isEmpty()) {
                    List list = selection.toList();
                    IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
                    if (currentActiveEditor instanceof AnalysisEditor) {
                        AnalysisEditor editor = (AnalysisEditor) currentActiveEditor;
                        AnalysisItemEditorInput input = (AnalysisItemEditorInput) editor.getEditorInput();
                        for (Object object : list) {
                            DBColumnRepNode node = (DBColumnRepNode) object;
                            DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage((Analysis) input.getModel());
                            MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
                            String name = columnObject.getTdColumn().getName();
                            targetControl.insert(language.quote(name));
                            // Focus text.
                            targetControl.forceFocus();
                        }
                    }
                }
            }
        }
    });
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Analysis(org.talend.dataquality.analysis.Analysis) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) List(java.util.List) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DropTarget(org.eclipse.swt.dnd.DropTarget) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 12 with DBColumnRepNode

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

the class AbstractIndicatorSelectGrid method initializeGrid.

protected void initializeGrid() {
    // first column is for indicator labels, it is hided from the cells but shown as row header.
    createIndicatorLabelColumn();
    // column
    // select all column
    createRowSelectColumn();
    // database columns
    for (int index = 0; index < _modelElementIndicators.length; index++) {
        ModelElementIndicator _modelElementIndicator = _modelElementIndicators[index];
        final GridColumn newCol = new TalendGridColumn(this, SWT.CHECK);
        AbstractColumnHerderRenderer headerRenderer = getColumnHeaderRenderer();
        headerRenderer.setRotation(COLUMN_HEADER_ROTATION);
        newCol.setHeaderRenderer(headerRenderer);
        newCol.setCellRenderer(getCellRenderer());
        newCol.setText(ModelElementIndicatorHelper.getModelElementDisplayName(_modelElementIndicator));
        newCol.setWidth(getPreferWidth(index));
        newCol.setData(_modelElementIndicator);
        newCol.setMoveable(true);
        newCol.setResizeable(true);
        newCol.setHeaderFont(headerFont);
        IRepositoryNode repNode = _modelElementIndicator.getModelElementRepositoryNode();
        if (repNode instanceof DBColumnRepNode && ((DBColumnRepNode) repNode).isKey()) {
            newCol.setImage(ImageLib.getImage(ImageLib.PK_ICON));
        }
        newCol.addListener(SWT.Resize, new Listener() {

            public void handleEvent(Event event) {
                notifyObservers(event);
            }
        });
        newCol.addListener(SWT.Move, new Listener() {

            public void handleEvent(Event event) {
                notifyObservers(event);
                isColumnMoved = true;
            }
        });
    }
    recalculateHeader();
    // initialize grid contents
    createTableContent();
    // show fixed column header
    setHeaderVisible(true);
    setTopLeftRenderer(new TdTopLeftRenderer());
    // setCellHeaderSelectionBackground(IndicatorSelectGrid.standardYellow);
    setEmptyColumnHeaderRenderer(new TdEmptyColumnHeaderRenderer());
    setEmptyRowHeaderRenderer(new TdEmptyCellRenderer());
    setEmptyCellRenderer(new TdEmptyCellRenderer());
    // show fixed row header
    TdRowHeaderRenderer rowHeaderRenderer = new TdRowHeaderRenderer();
    setRowHeaderRenderer(rowHeaderRenderer);
    rowHeaderRenderer.setTree(true);
    rowHeaderRenderer.setWordWrap(false);
    setRowHeaderVisible(true);
    setLinesVisible(true);
    setColumnScrolling(true);
    setSelectionEnabled(false);
    setCellSelectionEnabled(false);
    setRowsResizeable(false);
    setItemHeight(21);
    setLineColor(lineColor);
    setFont(itemFont);
    setFocusRenderer(null);
    for (GridItem gridItem : getItems()) {
        gridItem.setBackground(0, gray);
    }
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) Listener(org.eclipse.swt.widgets.Listener) MouseListener(org.eclipse.swt.events.MouseListener) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) Point(org.eclipse.swt.graphics.Point) TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) Event(org.eclipse.swt.widgets.Event) MouseEvent(org.eclipse.swt.events.MouseEvent) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 13 with DBColumnRepNode

use of org.talend.dq.nodes.DBColumnRepNode 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 14 with DBColumnRepNode

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

the class AnalyzeColumnCorrelationAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    hasDateColumn = false;
    hasNumberColumn = false;
    if (openStandardAnalysisDialog(AnalysisType.COLUMN_CORRELATION) == Window.OK) {
        AnalysisEditor editor = (AnalysisEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (editor != null) {
            CorrelationAnalysisDetailsPage page = (CorrelationAnalysisDetailsPage) editor.getMasterPage();
            if (!this.selection.isEmpty()) {
                DBColumnRepNode[] columns = new DBColumnRepNode[selection.size()];
                Iterator it = this.selection.iterator();
                int i = 0;
                while (it.hasNext()) {
                    columns[i] = (DBColumnRepNode) it.next();
                    i++;
                }
                if (page != null) {
                    page.getTreeViewer().setInput(columns);
                    page.doSave(null);
                }
            }
        }
    }
}
Also used : CorrelationAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.CorrelationAnalysisDetailsPage) Iterator(java.util.Iterator) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Example 15 with DBColumnRepNode

use of org.talend.dq.nodes.DBColumnRepNode 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

DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)31 IRepositoryNode (org.talend.repository.model.IRepositoryNode)15 TdColumn (org.talend.cwm.relational.TdColumn)14 RepositoryNode (org.talend.repository.model.RepositoryNode)13 ArrayList (java.util.ArrayList)12 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)9 TdTable (org.talend.cwm.relational.TdTable)7 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)7 List (java.util.List)6 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)6 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)5 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 DropTarget (org.eclipse.swt.dnd.DropTarget)4 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)4 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)4 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)4 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)4