Search in sources :

Example 1 with ReportFileRepNode

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

the class DuplicateResourceProvider method shouldShowMenu.

/**
 * DOC xqliu Comment method "shouldShowMenu".
 *
 * @param array
 * @return
 */
private boolean shouldShowMenu(Object[] array) {
    List<ENodeType> nodeTypes = new ArrayList<ENodeType>();
    nodeTypes.add(ENodeType.REPOSITORY_ELEMENT);
    nodeTypes.add(ENodeType.TDQ_REPOSITORY_ELEMENT);
    List<IRepositoryNode> repositoryNodeList = RepositoryNodeHelper.getRepositoryNodeList(array, nodeTypes);
    if (repositoryNodeList.size() == 0) {
        return false;
    }
    List<ERepositoryObjectType> objectTypes = new ArrayList<ERepositoryObjectType>();
    objectTypes.add(ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
    objectTypes.add(ERepositoryObjectType.TDQ_REPORT_ELEMENT);
    objectTypes.add(ERepositoryObjectType.TDQ_INDICATOR_ELEMENT);
    objectTypes.add(ERepositoryObjectType.TDQ_RULES_SQL);
    objectTypes.add(ERepositoryObjectType.TDQ_RULES);
    objectTypes.add(ERepositoryObjectType.TDQ_RULES_PARSER);
    objectTypes.add(ERepositoryObjectType.TDQ_PATTERN_ELEMENT);
    objectTypes.add(ERepositoryObjectType.TDQ_JRAXML_ELEMENT);
    objectTypes.add(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
    objectTypes.add(ERepositoryObjectType.METADATA_CONNECTIONS);
    objectTypes.add(ERepositoryObjectType.TDQ_RULES_MATCHER);
    objectTypes.add(ERepositoryObjectType.CONTEXT);
    for (IRepositoryNode node : repositoryNodeList) {
        // MOD qiongli 2011-2-12.filter elements in recycle bin.
        if (RepositoryNodeHelper.isStateDeleted(node)) {
            return false;
        }
        ERepositoryObjectType contentType = node.getObjectType();
        if (contentType == null || (!objectTypes.contains(contentType) && !ConnectionUtils.isTcompJdbc(contentType.getLabel()))) {
            return false;
        }
        RepositoryNode parent = node.getParent();
        if ((parent instanceof ReportSubFolderRepNode) && (node instanceof AnalysisRepNode)) {
            return false;
        }
        if (node instanceof ReportFileRepNode || node instanceof ReportAnalysisRepNode) {
            return false;
        }
    }
    return true;
}
Also used : ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ReportFileRepNode(org.talend.dq.nodes.ReportFileRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) ReportSubFolderRepNode(org.talend.dq.nodes.ReportSubFolderRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Example 2 with ReportFileRepNode

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

the class RepositoryNodeHelper method isStateDeleted.

/**
 * if logical delete state is true .
 *
 * @param node
 * @return
 */
public static boolean isStateDeleted(IRepositoryNode node) {
    final IRepositoryViewObject viewObject = node.getObject();
    final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    // TDQ's ISubRepositoryObject will return a null when call getAbstractMetadataObject()
    if (viewObject instanceof ISubRepositoryObject) {
        ISubRepositoryObject subRepositoryObject = (ISubRepositoryObject) viewObject;
        if (subRepositoryObject.getAbstractMetadataObject() == null) {
            return false;
        }
    }
    if (node instanceof ReportAnalysisRepNode || node instanceof ReportFileRepNode) {
        return false;
    } else {
        if (viewObject != null && factory.getStatus(viewObject) == ERepositoryStatus.DELETED) {
            return true;
        }
    }
    return false;
}
Also used : ReportFileRepNode(org.talend.dq.nodes.ReportFileRepNode) ISubRepositoryObject(org.talend.core.model.repository.ISubRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 3 with ReportFileRepNode

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

the class OpenItemEditorAction method duRun.

protected void duRun(IRepositoryNode repNode) throws BusinessException {
    // TDQ-12200: fix a NPE when the open item is unsynchronized status(for example is deleted by others).
    repositoryObjectCRUD.refreshDQViewForRemoteProject();
    // TDQ-13357: fix NPE, because for ReportFileRepNode, repNode.getObject() == null
    if (repNode.getObject() != null) {
        if (repNode.getObject().getProperty() == null) {
            repositoryObjectCRUD.showWarningDialog();
            return;
        }
        // TDQ-12771: for local, also can avoid error when the cache node is changed but not save it.
        try {
            ProxyRepositoryFactory.getInstance().reload(repNode.getObject().getProperty());
            IFile objFile = PropertyHelper.getItemFile(repNode.getObject().getProperty());
            objFile.refreshLocal(IResource.DEPTH_INFINITE, null);
        } catch (Exception e1) {
            log.error(e1, e1);
        }
    }
    // TDQ-12034~
    IEditorInput itemEditorInput = computeEditorInput(repNode, true);
    if (itemEditorInput != null) {
        // open ItemEditorInput
        CorePlugin.getDefault().openEditor(itemEditorInput, editorID);
    } else {
        // not find ItemEditorInput
        if (repNode.getObject() == null) {
            // open Report's genetated doc file
            if (repNode != null && repNode instanceof ReportFileRepNode) {
                ReportFileRepNode reportFileNode = (ReportFileRepNode) repNode;
                IPath location = Path.fromOSString(reportFileNode.getResource().getRawLocation().toOSString());
                // TDQ-5458 sizhaoliu 2012-07-17 add "." before the full name to make sure it is ignored by SVN.
                IFile latestRepIFile = ResourceManager.getRootProject().getFile(PluginConstant.DOT_STRING + location.lastSegment());
                try {
                    // TDQ-5458 sizhaoliu 2012-07-17 the link creation should be after report generation, but not at
                    // the openning.
                    // latestRepIFile.createLink(location, IResource.REPLACE, null);
                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                    // MOD yyin 20121224 TDQ-5329, using the default editor setted by the user.
                    IDE.openEditor(page, latestRepIFile);
                } catch (PartInitException e) {
                    MessageDialog.openError(Display.getCurrent().getActiveShell(), // $NON-NLS-1$
                    Messages.getString("NewFolderWizard.failureTitle"), e.getMessage());
                    ExceptionHandler.process(e);
                }
            }
        } else {
            // if there don't found the correct ItemEditorInput and it is not Report's genetated doc file, try to
            // open it as a File, this code will not be execute when method computeEditorInput() work well
            IPath append = WorkbenchUtils.getFilePath(repNode.getObject().getRepositoryNode());
            DQRepositoryNode node = (DQRepositoryNode) repNode.getObject().getRepositoryNode();
            file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(append);
            if (!file.exists()) {
                throw ExceptionFactory.getInstance().createBusinessException(repNode.getObject());
            }
            try {
                IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
            } catch (PartInitException e) {
                log.error(e, e);
            }
        }
    }
}
Also used : DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) IFile(org.eclipse.core.resources.IFile) ReportFileRepNode(org.talend.dq.nodes.ReportFileRepNode) IPath(org.eclipse.core.runtime.IPath) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) PartInitException(org.eclipse.ui.PartInitException) BusinessException(org.talend.commons.exception.BusinessException) PersistenceException(org.talend.commons.exception.PersistenceException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 4 with ReportFileRepNode

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

the class DQDeleteAction method logicDelete.

/**
 * logical delete the selected nodes
 */
private void logicDelete() {
    for (int i = selectedNodes.size() - 1; i >= 0; i--) {
        IRepositoryNode node = selectedNodes.get(i);
        // handle generating report file.bug 18805 .
        if (node instanceof ReportFileRepNode) {
            try {
                deleteReportFile((ReportFileRepNode) node);
            } catch (PersistenceException e) {
                log.error(e, e);
            }
            continue;
        }
        this.checkIsHiveConnectionUnderHC(node);
    }
    RepositoryNode parent = selectedNodes.get(0).getParent();
    // only need to run one time, because in the super.run() can handle all selected node.
    excuteSuperRun(null, parent);
    // TDQ-7298: refresh all the selected node' parent node when delete different items.
    for (IRepositoryNode node : selectedNodes) {
        refreshParentNode(node.getParent());
    }
}
Also used : ReportFileRepNode(org.talend.dq.nodes.ReportFileRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) PersistenceException(org.talend.commons.exception.PersistenceException) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 5 with ReportFileRepNode

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

the class DQRespositoryView method createPartControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse .swt.widgets.Composite)
     */
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new BorderLayout());
    Composite topComp = new Composite(parent, SWT.NONE);
    topComp.setFont(parent.getFont());
    topComp.setLayoutData(BorderLayout.NORTH);
    Composite bottomComp = new Composite(parent, SWT.NONE);
    bottomComp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    bottomComp.setFont(parent.getFont());
    bottomComp.setLayoutData(BorderLayout.CENTER);
    topComp.setLayout(new BorderLayout());
    FillLayout bottomLayout = new FillLayout(SWT.VERTICAL);
    bottomComp.setLayout(bottomLayout);
    createTreeFilter(topComp);
    super.createPartControl(bottomComp);
    // For removing the popup menu of DQRepositoryView.
    // $NON-NLS-1$
    MenuManager menuMgr = new MenuManager("org.talend.dataprofiler.core.ui.views.DQRespositoryView");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menuManager) {
            ISelection selection = getCommonViewer().getSelection();
            getNavigatorActionService().setContext(new ActionContext(selection));
            getNavigatorActionService().fillContextMenu(menuManager);
        }
    });
    Menu menu = menuMgr.createContextMenu(getCommonViewer().getTree());
    getCommonViewer().getTree().setMenu(menu);
    this.addViewerFilter(EMFObjFilter.FILTER_ID);
    this.addViewerFilter(ReportingFilter.FILTER_ID);
    this.addViewerFilter(FolderObjFilter.FILTER_ID);
    adjustFilter();
    activateContext();
    getCommonViewer().setSorter(null);
    getCommonViewer().getTree().addTreeListener(new TreeAdapter() {

        @Override
        public void treeExpanded(TreeEvent e) {
            TreeItem item = (TreeItem) e.item;
            if (!item.getText().endsWith(")")) {
                // $NON-NLS-1$
                Object obj = item.getData();
                if (obj instanceof TableFolderNode || obj instanceof ViewFolderNode || obj instanceof ColumnFolderNode) {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    item.setText(item.getText() + "(" + item.getItemCount() + ")");
                }
            }
            super.treeExpanded(e);
        }
    });
    getCommonViewer().getTree().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            boolean superDoubleClick = true;
            Tree tree = (Tree) e.getSource();
            Point point = new Point(e.x, e.y);
            final TreeItem item = tree.getItem(point);
            if (item != null) {
                Object obj = item.getData();
                if (obj instanceof AbstractFolderNode) {
                    AbstractFolderNode node = (AbstractFolderNode) obj;
                    node.loadChildren();
                    Object[] children = node.getChildren();
                    if (children != null) {
                        if (item.getText().indexOf("(") > 0) {
                            // $NON-NLS-1$
                            item.setText(// $NON-NLS-1$ //$NON-NLS-2$
                            item.getText().substring(0, item.getText().indexOf("(")) + "(" + children.length + // $NON-NLS-1$
                            ")");
                        } else {
                            // $NON-NLS-1$ //$NON-NLS-2$
                            item.setText(item.getText() + "(" + children.length + ")");
                        }
                    }
                }
                if (obj instanceof IndicatorDefinition) {
                    IndicatorDefinition indicatorDefinition = (IndicatorDefinition) obj;
                    // reload object
                    indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(indicatorDefinition.getLabel());
                    IndicatorEditorInput input = new IndicatorEditorInput(indicatorDefinition);
                    try {
                        CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, IndicatorEditor.class.getName());
                    } catch (PartInitException e1) {
                        log.error(e1, e1);
                    }
                }
                if (obj instanceof DQRepositoryNode) {
                    if (obj instanceof ReportFileRepNode) {
                        new OpenItemEditorAction(new IRepositoryNode[] { (IRepositoryNode) obj }).run();
                    } else if (obj instanceof DFConnectionRepNode) {
                        new EditFileDelimitedAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof HadoopClusterConnectionRepNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
                        new EditHadoopClusterAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof HDFSOfHCConnectionNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
                        new EditHDFSConnectionAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof DFTableRepNode) {
                        new EditDFTableAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof ContextRepNode) {
                        new DQEditContextAction((ContextRepNode) obj, false).run();
                    } else {
                        DQRepositoryNode repoNode = (DQRepositoryNode) obj;
                        if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
                            OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
                            openItemEditorAction.run();
                        }
                        if (repoNode instanceof AnalysisRepNode || repoNode instanceof ReportRepNode || repoNode instanceof SysIndicatorDefinitionRepNode || repoNode instanceof PatternRepNode || repoNode instanceof RuleRepNode) {
                            superDoubleClick = false;
                        }
                    }
                }
            }
            if (superDoubleClick) {
                super.mouseDoubleClick(e);
            }
        }
    });
    getCommonViewer().getTree().addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                Tree tree = (Tree) e.getSource();
                TreeItem[] selection = tree.getSelection();
                for (TreeItem item : selection) {
                    Object data = item.getData();
                    DQRepositoryNode repoNode = (DQRepositoryNode) data;
                    if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
                        OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
                        openItemEditorAction.run();
                    }
                }
            }
        }

        public void keyReleased(KeyEvent e) {
        // do nothing here until now
        }
    });
    // ~ADD mzhao for feature 6233 Load columns when selecting a table (or
    // view) in DQ Repository view
    getCommonViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            TreeSelection selection = (TreeSelection) event.getSelection();
            Iterator<?> iterator = selection.iterator();
            while (iterator.hasNext()) {
                Object selectedElement = iterator.next();
                if (selectedElement instanceof DBTableRepNode || selectedElement instanceof DBViewRepNode) {
                    ((RepositoryNode) selectedElement).getChildren().get(0).getChildren();
                }
            }
        }
    });
    // MOD mzhao 2011-03-10 bug 19147: filter MDM entries.
    getCommonViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IProject) {
                return false;
            }
            return true;
        }
    });
// ~
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) HDFSOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HDFSOfHCConnectionNode) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ColumnViewer(org.eclipse.jface.viewers.ColumnViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeAdapter(org.eclipse.swt.events.TreeAdapter) TableFolderNode(org.talend.dataprofiler.core.model.nodes.foldernode.TableFolderNode) TreeEvent(org.eclipse.swt.events.TreeEvent) IndicatorEditorInput(org.talend.dataprofiler.core.ui.editor.indicator.IndicatorEditorInput) ReportFileRepNode(org.talend.dq.nodes.ReportFileRepNode) BorderLayout(org.talend.dataprofiler.core.ui.views.layout.BorderLayout) ReportRepNode(org.talend.dq.nodes.ReportRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Tree(org.eclipse.swt.widgets.Tree) PatternRepNode(org.talend.dq.nodes.PatternRepNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FillLayout(org.eclipse.swt.layout.FillLayout) OpenItemEditorAction(org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction) ViewFolderNode(org.talend.dataprofiler.core.model.nodes.foldernode.ViewFolderNode) DQEditContextAction(org.talend.dataprofiler.core.ui.action.actions.DQEditContextAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ColumnFolderNode(org.talend.dataprofiler.core.model.nodes.foldernode.ColumnFolderNode) EditDFTableAction(org.talend.dataprofiler.core.ui.action.actions.EditDFTableAction) AbstractViewerFilter(org.talend.dataprofiler.core.ui.filters.AbstractViewerFilter) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) AbstractFolderNode(org.talend.dq.nodes.foldernode.AbstractFolderNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) KeyEvent(org.eclipse.swt.events.KeyEvent) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) EditHDFSConnectionAction(org.talend.dataprofiler.core.ui.action.actions.EditHDFSConnectionAction) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) Iterator(java.util.Iterator) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) Menu(org.eclipse.swt.widgets.Menu) PartInitException(org.eclipse.ui.PartInitException) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point) ActionContext(org.eclipse.ui.actions.ActionContext) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IMenuListener(org.eclipse.jface.action.IMenuListener) IProject(org.eclipse.core.resources.IProject) EditFileDelimitedAction(org.talend.dataprofiler.core.ui.action.actions.EditFileDelimitedAction) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) EditHadoopClusterAction(org.talend.dataprofiler.core.ui.action.actions.EditHadoopClusterAction) KeyListener(org.eclipse.swt.events.KeyListener) IMenuManager(org.eclipse.jface.action.IMenuManager) HadoopClusterConnectionRepNode(org.talend.dq.nodes.hadoopcluster.HadoopClusterConnectionRepNode) ContextRepNode(org.talend.dq.nodes.ContextRepNode)

Aggregations

ReportFileRepNode (org.talend.dq.nodes.ReportFileRepNode)6 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)4 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)3 PartInitException (org.eclipse.ui.PartInitException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 ReportAnalysisRepNode (org.talend.dq.nodes.ReportAnalysisRepNode)2 ReportRepNode (org.talend.dq.nodes.ReportRepNode)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ColumnViewer (org.eclipse.jface.viewers.ColumnViewer)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1