Search in sources :

Example 6 with DBColumnRepNode

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

the class AbstractPagePart method updateBindConnection.

/**
 * ADD mzhao 2009-05-05 bug:6587.
 */
protected void updateBindConnection(AbstractAnalysisMetadataPage masterPage, List<TableViewer> tableViewerPosStack) {
    boolean isEmpty1 = tableViewerPosStack.get(0) == null || tableViewerPosStack.get(0).getInput() == null || ((List) tableViewerPosStack.get(0).getInput()).size() == 0;
    boolean isEmpty2 = tableViewerPosStack.get(1) == null || tableViewerPosStack.get(1).getInput() == null || ((List) tableViewerPosStack.get(1).getInput()).size() == 0;
    if (isEmpty1 && isEmpty2) {
        return;
    } else {
        TableViewer columnsElementViewer = null;
        if (!isEmpty1) {
            columnsElementViewer = tableViewerPosStack.get(0);
        } else {
            columnsElementViewer = tableViewerPosStack.get(1);
        }
        Connection tdProvider = null;
        Object input = columnsElementViewer.getInput();
        List<DBColumnRepNode> columnSet = (List<DBColumnRepNode>) input;
        if (columnSet != null && columnSet.size() != 0) {
            TdColumn column = (TdColumn) ((MetadataColumnRepositoryObject) columnSet.get(0).getObject()).getTdColumn();
            if (column != null && column.eIsProxy()) {
                column = (TdColumn) EObjectHelper.resolveObject(column);
            }
            tdProvider = ConnectionHelper.getTdDataProvider(column);
            setConnectionState(masterPage, tdProvider);
        }
    }
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) List(java.util.List) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 7 with DBColumnRepNode

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

the class AnalysisColumnSetTreeViewer method setInput.

@Override
public void setInput(Object[] objs) {
    if (objs != null && objs.length != 0) {
        List<DBColumnRepNode> columnList = new ArrayList<DBColumnRepNode>();
        for (Object obj : objs) {
            // default is should be sql engine.
            if (obj instanceof DBTableRepNode || obj instanceof DBViewRepNode) {
                columnList.addAll((Collection<? extends DBColumnRepNode>) ((ColumnSetRepNode) obj).getAllColumns());
            } else if (obj instanceof DBColumnRepNode) {
                columnList.add((DBColumnRepNode) obj);
            }
        }
        // MOD yyi 2010-05-13 12828
        Collections.reverse(columnList);
        // MOD qiongli 2011-3-15 set DataFilterText disabled except TdColumn.
        if (masterPage.getDataFilterComp() != null) {
            masterPage.getDataFilterComp().getDataFilterText().setEnabled(!columnList.isEmpty());
            if (columnList.isEmpty()) {
                // when the selected column is not DB type,will disable the execute engine
                // combobox.
                masterPage.changeExecuteLanguageToJava(true);
            } else {
                // when the selected column is back to DB type, should enable the execute engine combobox again.
                masterPage.enableExecuteLanguage();
            }
        }
        ModelElementIndicator[] newSelects = translateSelectedNodeIntoIndicator(objs);
        List<ModelElementIndicator> indicatorList = new ArrayList<ModelElementIndicator>();
        if (newSelects != null) {
            // indicator;
            for (ModelElementIndicator column : newSelects) {
                // if the modelElementIndicators contains selected column, add the column in modelElementIndicators
                // to ColumnIndicatorList
                boolean isOld = false;
                for (ModelElementIndicator oldColumn : modelElementIndicators) {
                    if (oldColumn.getModelElementRepositoryNode().equals(column.getModelElementRepositoryNode())) {
                        indicatorList.add(oldColumn);
                        isOld = true;
                        break;
                    }
                }
                // else add this column in filterInputData to ColumnIndicatorList
                if (!isOld) {
                    indicatorList.add(column);
                }
            }
            this.modelElementIndicators = indicatorList.toArray(new ModelElementIndicator[indicatorList.size()]);
            this.setElements(modelElementIndicators);
        }
    } else {
        TreeItem[] items = this.tree.getItems();
        for (TreeItem item : items) {
            this.removeItemBranch(item);
        }
        super.setInput(objs);
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ColumnSetRepNode(org.talend.dq.nodes.ColumnSetRepNode) EObject(org.eclipse.emf.ecore.EObject) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 8 with DBColumnRepNode

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

the class ComparisonTableViewerDNDDecorate method validateColumnType.

// MOD mzhao 2009-09-14 Bug 8839.
@SuppressWarnings("unchecked")
private boolean validateColumnType(StructuredSelection selection, TableViewer targetViewer) {
    if (selection == null) {
        return false;
    }
    boolean isValidation = true;
    List selectionList = selection.toList();
    if (!allowDuplication) {
        List elements = (List) targetViewer.getInput();
        if (elements != null) {
            for (Object element : elements) {
                if (selectionList.contains(element)) {
                    isValidation = false;
                    break;
                }
            }
        }
    }
    for (Object obj : selectionList) {
        if (!(obj instanceof DBColumnRepNode)) {
            isValidation = false;
            break;
        }
    }
    return isValidation;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode)

Example 9 with DBColumnRepNode

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

the class WhereClauseDND 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) {
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event.detail != DND.DROP_NONE) {
                IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
                if (!selection.isEmpty()) {
                    Iterator<DBColumnRepNode> it = selection.iterator();
                    IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
                    if (currentActiveEditor instanceof DQRuleEditor) {
                        // // Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(input.getFile());
                        while (it.hasNext()) {
                            // DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(lang, null);
                            DBColumnRepNode next = it.next();
                            String name = next.getTdColumn().getName();
                            targetControl.insert(name);
                            targetControl.forceFocus();
                        }
                    }
                }
            }
        }
    });
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) DQRuleEditor(org.talend.dataprofiler.core.ui.editor.dqrules.DQRuleEditor) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Iterator(java.util.Iterator) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DropTarget(org.eclipse.swt.dnd.DropTarget) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 10 with DBColumnRepNode

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

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