Search in sources :

Example 16 with DBViewRepNode

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

the class RespositoryDetailView method selectionChanged.

/*
     * (non-Javadoc)
     * 
     * @seeorg.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui. IWorkbenchPart,
     * org.eclipse.jface.viewers.ISelection)
     */
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    clearContainer();
    boolean isNeedcreateDefault = true;
    try {
        if (part instanceof DQRespositoryView) {
            StructuredSelection sel = (StructuredSelection) selection;
            // MOD by zshen for bug 15750 TODO 39(13) make Detail View can be used.
            Object fe = sel.getFirstElement();
            // MOD klliu 2011-02-24 if choose diffirent node ,that will load diffirent child ,so that not use up.
            if (fe instanceof AnalysisRepNode || fe instanceof ReportRepNode || fe instanceof SysIndicatorDefinitionRepNode || fe instanceof PatternRepNode || fe instanceof RuleRepNode) {
                fe = ((IRepositoryNode) fe).getObject();
            }
            if (fe instanceof IFile) {
                IFile fe2 = (IFile) fe;
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, fe2);
            } else if (fe instanceof IRepositoryViewObject) {
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, (IRepositoryViewObject) fe);
            } else if (fe instanceof DBConnectionRepNode) {
                DBConnectionRepNode connNode = (DBConnectionRepNode) fe;
                // MOD sizhaoliu TDQ-6316
                ConnectionItem connectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
                createDataProviderDetail(connectionItem);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBCatalogRepNode) {
                DBCatalogRepNode catalogNode = (DBCatalogRepNode) fe;
                Catalog catalog = catalogNode.getCatalog();
                createTdCatalogDetail(catalog);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBSchemaRepNode) {
                DBSchemaRepNode schemaNode = (DBSchemaRepNode) fe;
                Schema schema = schemaNode.getSchema();
                createTdSchemaDetail(schema);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBTableRepNode) {
                DBTableRepNode tableNode = (DBTableRepNode) fe;
                // MOD gdbu 2011-9-14 TDQ-3243
                if (!DQRepositoryNode.isOnFilterring()) {
                    tableNode.getChildren().get(0).getChildren();
                }
                // ~TDQ-3243
                TdTable tdTable = tableNode.getTdTable();
                createTableDetail(tdTable);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBViewRepNode) {
                DBViewRepNode viewNode = (DBViewRepNode) fe;
                // MOD gdbu 2011-9-14 TDQ-3243
                if (!DQRepositoryNode.isOnFilterring()) {
                    viewNode.getChildren().get(0).getChildren();
                }
                // ~TDQ-3243
                createNameCommentDetail(viewNode.getTdView());
                isNeedcreateDefault = false;
            } else if (fe instanceof DBColumnRepNode) {
                DBColumnRepNode columnNode = (DBColumnRepNode) fe;
                TdColumn column = columnNode.getTdColumn();
                createTdColumn(column);
                isNeedcreateDefault = false;
            } else if (fe instanceof IEcosComponent) {
                IEcosComponent component = (IEcosComponent) fe;
                createEcosComponent(component);
                isNeedcreateDefault = false;
            } else if (fe instanceof RegularExpression) {
                // MOD mzhao 2009-04-20,Bug 6349.
                RegularExpression regularExpression = (RegularExpression) fe;
                createRegularExpression(regularExpression);
                isNeedcreateDefault = false;
            } else if (fe instanceof PatternLanguageRepNode) {
                // MOD mzhao 2012-08-15,feature TDQ-4037.
                PatternLanguageRepNode pattLangNode = (PatternLanguageRepNode) fe;
                createRegularExpression(pattLangNode.getRegularExpression());
                isNeedcreateDefault = false;
            } else if (fe instanceof SourceFileRepNode) {
                // MOD klliu 2001-02-28 bug 19154
                IPath filePath = WorkbenchUtils.getFilePath((SourceFileRepNode) fe);
                DQRepositoryNode node = (DQRepositoryNode) fe;
                IFile file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(filePath);
                createSqlFileDetail(file);
            } else if (fe instanceof ExchangeComponentRepNode) {
                // MOD klliu 2001-02-28 bug 19154
                IEcosComponent ecosComponent = ((ExchangeComponentRepNode) fe).getEcosComponent();
                IEcosComponent component = ecosComponent;
                createEcosComponent(component);
                isNeedcreateDefault = false;
            // ADD by msjian 2011-5-12 21186: don't check whether the selected object is "MDMConnectionRepNode"
            } else if (fe instanceof DFConnectionRepNode) {
                DFConnectionRepNode dfNode = (DFConnectionRepNode) fe;
                DelimitedFileConnection dfConnection = dfNode.getDfConnection();
                createDFconnectionName(dfNode.getObject().getLabel());
                createDataProviderDetail(dfConnection);
                isNeedcreateDefault = false;
            }
            if (PluginChecker.isTDQLoaded()) {
                if (fe instanceof EObject) {
                    createTechnicalDetail((EObject) fe);
                } else if (fe instanceof IFile) {
                    createTechnicalDetail((IFile) fe);
                } else if (fe instanceof IRepositoryViewObject) {
                    createTechnicalDetail((IRepositoryViewObject) fe);
                } else {
                    createExtDefault();
                }
            }
            if (!scomp.isDisposed()) {
                scomp.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                composite.layout();
            }
        } else if (part instanceof CommonFormEditor) {
            CommonFormEditor editor = (CommonFormEditor) part;
            IEditorInput editorInput = editor.getEditorInput();
            if (editorInput instanceof IFileEditorInput) {
                IFileEditorInput input = (IFileEditorInput) editorInput;
                IFile file = input.getFile();
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, file);
            }
        }
        if (isNeedcreateDefault) {
            createDefault();
        }
        // feature 19053
        if (!gContainer.isDisposed()) {
            gContainer.layout();
            if (tContainer != null) {
                tContainer.layout();
            }
        }
    } catch (MissingDriverException e) {
        if (PluginChecker.isOnlyTopLoaded()) {
            MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
            DefaultMessagesImpl.getString("RespositoryDetailView.warning"), e.getErrorMessage());
        } else {
            log.error(e, e);
        }
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IFile(org.eclipse.core.resources.IFile) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Schema(orgomg.cwm.resource.relational.Schema) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PatternLanguageRepNode(org.talend.dq.nodes.PatternLanguageRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) IFileEditorInput(org.eclipse.ui.IFileEditorInput) EObject(org.eclipse.emf.ecore.EObject) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) IPath(org.eclipse.core.runtime.IPath) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) RuleRepNode(org.talend.dq.nodes.RuleRepNode) Catalog(orgomg.cwm.resource.relational.Catalog) CommonFormEditor(org.talend.dataprofiler.core.ui.editor.CommonFormEditor) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) MissingDriverException(org.talend.utils.exceptions.MissingDriverException) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) TdColumn(org.talend.cwm.relational.TdColumn) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEcosComponent(org.talend.dataprofiler.ecos.model.IEcosComponent) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorInput(org.eclipse.ui.IEditorInput)

Example 17 with DBViewRepNode

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

the class TableViewerDND method installDND.

/**
 * DOC xqliu Comment method "installDND".
 *
 * @param targetControl
 */
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;

        @Override
        public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
            Object object = selection.getFirstElement();
            if (object instanceof RuleRepNode) {
                receiver = new DQRuleReceiver();
            }
            if (object instanceof NamedColumnSet) {
                receiver = new TableReceiver();
            }
            if (object instanceof DBTableRepNode) {
                receiver = new TableReceiver();
            }
            if (object instanceof DBViewRepNode) {
                receiver = new TableReceiver();
            }
            if (receiver == null) {
                event.detail = DND.DROP_NONE;
            } else {
                event.feedback = DND.FEEDBACK_EXPAND;
                receiver.doDropValidation(event, commonViewer);
            }
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            super.dragOver(event);
            if (receiver != null) {
                receiver.doDropValidation(event, commonViewer);
            }
        }

        @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);
            } 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;
                    }
                }
            }
            if (receiver != null) {
                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) RuleRepNode(org.talend.dq.nodes.RuleRepNode) TreeDropTargetEffect(org.eclipse.swt.dnd.TreeDropTargetEffect) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) DropTarget(org.eclipse.swt.dnd.DropTarget) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Example 18 with DBViewRepNode

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

the class RepositoryNodeHelperRealTest method testCreateMysqlViewRepositoryNode.

/**
 * Test method for
 * {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
 * mysql case find View node
 */
@Test
public void testCreateMysqlViewRepositoryNode() {
    // $NON-NLS-1$
    DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
    // $NON-NLS-1$
    Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
    // $NON-NLS-1$
    TdView addView = this.addView(addCatalog, "view1");
    try {
        ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addView);
    if (createRepositoryNode != null) {
        IRepositoryViewObject object = createRepositoryNode.getObject();
        Assert.assertTrue(createRepositoryNode instanceof DBViewRepNode);
        Assert.assertTrue(object != null);
        Assert.assertTrue(object instanceof TdViewRepositoryObject);
        Assert.assertTrue(object.getId().equals(addView.getName()));
        Assert.assertTrue(object.getLabel().equals(addView.getName()));
        Assert.assertTrue(object.getRepositoryNode() != null);
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent() != null);
    }
}
Also used : TdView(org.talend.cwm.relational.TdView) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Example 19 with DBViewRepNode

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

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis_4.

/**
 * Test:4) when the selected nodes are: multiple columns from one same table/view, will be valid.
 */
@Test
public void testIsValidSelectionForMatchAnalysis_4() {
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    DBTableRepNode table1 = mock(DBTableRepNode.class);
    DBViewRepNode view1 = mock(DBViewRepNode.class);
    DFTableRepNode dfTable = mock(DFTableRepNode.class);
    ColumnRepNode col1 = mock(ColumnRepNode.class);
    ColumnRepNode col2 = mock(ColumnRepNode.class);
    when(col1.getParent()).thenReturn(table1);
    when(col2.getParent()).thenReturn(table1);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    when(col1.getParent()).thenReturn(view1);
    when(col2.getParent()).thenReturn(view1);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    when(col1.getParent()).thenReturn(dfTable);
    when(col2.getParent()).thenReturn(dfTable);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 20 with DBViewRepNode

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

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis_3.

/**
 * Test: 3) when the selected node is: one single table/view/file table,will be valid;
 */
@Test
public void testIsValidSelectionForMatchAnalysis_3() {
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    DBTableRepNode table1 = mock(DBTableRepNode.class);
    DBViewRepNode view1 = mock(DBViewRepNode.class);
    // 3) when the selected node is: one single table/view/file table,will be valid;
    nodes.clear();
    nodes.add(table1);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    nodes.clear();
    nodes.add(view1);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DFTableRepNode dfTable = mock(DFTableRepNode.class);
    nodes.clear();
    nodes.add(dfTable);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)25 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)21 IRepositoryNode (org.talend.repository.model.IRepositoryNode)16 ArrayList (java.util.ArrayList)11 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)11 RepositoryNode (org.talend.repository.model.RepositoryNode)8 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)7 TreeSelection (org.eclipse.jface.viewers.TreeSelection)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)5 List (java.util.List)4 Test (org.junit.Test)4 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)4 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)4 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)4 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)4 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 RuleRepNode (org.talend.dq.nodes.RuleRepNode)4 TreeItem (org.eclipse.swt.widgets.TreeItem)3