Search in sources :

Example 11 with SourceFileRepNode

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

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

the class TOPRepositoryServiceTest method testSourceFileOpening.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.service.TOPRepositoryService#sourceFileOpening(org.talend.repository.model.RepositoryNode)}
 * .
 */
@Test
public void testSourceFileOpening() {
    // test for SourceFileRepNode
    SourceFileRepNode fileNodeMock = mock(SourceFileRepNode.class);
    // $NON-NLS-1$
    String nodeLabel = "nodeLabel";
    when(fileNodeMock.getLabel()).thenReturn(nodeLabel);
    // $NON-NLS-1$
    stub(method(WorkspaceResourceHelper.class, "sourceFileHasBeenOpened", SourceFileRepNode.class)).toReturn(Boolean.TRUE);
    TOPRepositoryService service = new TOPRepositoryService();
    assertTrue(service.sourceFileOpening(fileNodeMock));
}
Also used : SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with SourceFileRepNode

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

the class WorkspaceResourceHelperTest method testCheckSourceFileSubFolderNodeOpening.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.helper.WorkspaceResourceHelper#checkSourceFileSubFolderNodeOpening(org.talend.dq.nodes.SourceFileSubFolderNode)}
 * .
 */
@Test
public void testCheckSourceFileSubFolderNodeOpening() {
    SourceFileSubFolderNode folderNodeMock = mock(SourceFileSubFolderNode.class);
    SourceFileRepNode nodeMock = mock(SourceFileRepNode.class);
    List<IRepositoryNode> nodeList = new ArrayList<IRepositoryNode>();
    nodeList.add(nodeMock);
    when(folderNodeMock.getChildren()).thenReturn(nodeList);
    boolean ok = Boolean.TRUE;
    // $NON-NLS-1$
    String msg = "msg";
    ReturnCode rc = new ReturnCode(msg, ok);
    // $NON-NLS-1$
    stub(method(WorkspaceResourceHelper.class, "checkSourceFileNodeOpening", SourceFileRepNode.class)).toReturn(rc);
    ReturnCode rc2 = WorkspaceResourceHelper.checkSourceFileSubFolderNodeOpening(folderNodeMock);
    assertEquals(rc.isOk(), rc2.isOk());
    assertEquals(rc.getMessage(), rc2.getMessage());
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with SourceFileRepNode

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

the class WorkspaceResourceHelperTest method testSourceFileHasBeenOpened.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.helper.WorkspaceResourceHelper#sourceFileHasBeenOpened(org.talend.repository.model.IRepositoryNode)}
 * .
 */
@Test
public void testSourceFileHasBeenOpened() {
    SourceFileRepNode fileNode = mock(SourceFileRepNode.class);
    CorePlugin cpMock = mock(CorePlugin.class);
    PowerMockito.mockStatic(CorePlugin.class);
    when(CorePlugin.getDefault()).thenReturn(cpMock);
    IWorkbench workbenchMock = mock(IWorkbench.class);
    when(cpMock.getWorkbench()).thenReturn(workbenchMock);
    IWorkbenchWindow workbenchWindowMock = mock(IWorkbenchWindow.class);
    when(workbenchMock.getActiveWorkbenchWindow()).thenReturn(workbenchWindowMock);
    IWorkbenchPage workbenchPageMock = mock(IWorkbenchPage.class);
    when(workbenchWindowMock.getActivePage()).thenReturn(workbenchPageMock);
    IEditorReference editorRefMock = mock(IEditorReference.class);
    IEditorReference[] editorRefMocks = new IEditorReference[] { editorRefMock };
    when(workbenchPageMock.getEditorReferences()).thenReturn(editorRefMocks);
    FileEditorInput fileEditorInputMock = mock(FileEditorInput.class);
    try {
        when(editorRefMock.getEditorInput()).thenReturn(fileEditorInputMock);
    } catch (PartInitException e) {
        fail(e.getMessage());
    }
    IFile nodeFileMock = mock(IFile.class);
    // $NON-NLS-1$
    stub(method(RepositoryNodeHelper.class, "getIFile", SourceFileRepNode.class)).toReturn(nodeFileMock);
    IPath nodeFilePathMock = mock(IPath.class);
    when(nodeFileMock.getFullPath()).thenReturn(nodeFilePathMock);
    // $NON-NLS-1$
    String path = "/abc";
    when(nodeFilePathMock.toString()).thenReturn(path);
    IFile inputFileMock = mock(IFile.class);
    when(fileEditorInputMock.getFile()).thenReturn(inputFileMock);
    IPath inputFilePathMock = mock(IPath.class);
    when(inputFileMock.getFullPath()).thenReturn(inputFilePathMock);
    when(inputFilePathMock.toString()).thenReturn(path);
    assertTrue(WorkspaceResourceHelper.sourceFileHasBeenOpened(fileNode));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) CorePlugin(org.talend.dataprofiler.core.CorePlugin) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with SourceFileRepNode

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

the class DQDeleteAction method checkSourceFilesEditorOpening.

/**
 * DOC xqliu Comment method "checkSourceFilesEditorOpening".
 *
 * @param deleteElements
 * @return
 */
@SuppressWarnings({ "hiding", "rawtypes", "unchecked" })
private Object[] checkSourceFilesEditorOpening(Object[] deleteElements) {
    List list = new ArrayList();
    boolean opened = false;
    // $NON-NLS-1$
    String openSourceFileNames = "";
    for (Object obj : deleteElements) {
        if (obj instanceof SourceFileRepNode || obj instanceof JrxmlTempleteRepNode) {
            ReturnCode rc = WorkspaceResourceHelper.checkSourceFileNodeOpening((RepositoryNode) obj);
            if (rc.isOk()) {
                opened = rc.isOk();
                openSourceFileNames += rc.getMessage();
            } else {
                list.add(obj);
            }
        } else if (obj instanceof SourceFileSubFolderNode || obj instanceof JrxmlTempSubFolderNode) {
            ReturnCode rc = WorkspaceResourceHelper.checkSourceFileSubFolderNodeOpening((RepositoryNode) obj);
            if (rc.isOk()) {
                opened = rc.isOk();
                openSourceFileNames += rc.getMessage();
            } else {
                list.add(obj);
            }
        } else {
            list.add(obj);
        }
    }
    if (opened) {
        WorkspaceResourceHelper.showSourceFilesOpeningWarnMessages(openSourceFileNames);
    }
    return list.toArray();
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) ArrayList(java.util.ArrayList) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) List(java.util.List) ArrayList(java.util.ArrayList) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) JrxmlTempSubFolderNode(org.talend.dq.nodes.JrxmlTempSubFolderNode)

Aggregations

SourceFileRepNode (org.talend.dq.nodes.SourceFileRepNode)15 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 JrxmlTempleteRepNode (org.talend.dq.nodes.JrxmlTempleteRepNode)6 SourceFileSubFolderNode (org.talend.dq.nodes.SourceFileSubFolderNode)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 ReturnCode (org.talend.utils.sugars.ReturnCode)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 IFile (org.eclipse.core.resources.IFile)3 IPath (org.eclipse.core.runtime.IPath)3 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)3 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)3 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)3 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)3 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)3 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)3