Search in sources :

Example 11 with DQRespositoryView

use of org.talend.dataprofiler.core.ui.views.DQRespositoryView in project tdq-studio-se by Talend.

the class CorePlugin method getCurrentSelectionNodes.

/**
 * get Current all selected nodes from DQRespositoryView.
 *
 * @return
 */
public IRepositoryNode[] getCurrentSelectionNodes() {
    DQRespositoryView repositoryView = getRepositoryView();
    if (repositoryView == null) {
        return null;
    }
    TreeItem[] selectionTreeItem = repositoryView.getCommonViewer().getTree().getSelection();
    if (null == selectionTreeItem || selectionTreeItem.length == 0) {
        return null;
    }
    IRepositoryNode[] currentSelectionNodes = new IRepositoryNode[selectionTreeItem.length];
    for (int i = 0; i < selectionTreeItem.length; i++) {
        currentSelectionNodes[i] = (IRepositoryNode) selectionTreeItem[i].getData();
    }
    return currentSelectionNodes;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView)

Example 12 with DQRespositoryView

use of org.talend.dataprofiler.core.ui.views.DQRespositoryView in project tdq-studio-se by Talend.

the class CorePlugin method getCurrentSelectionNode.

/**
 * get Current the first selected node from DQRespositoryView.
 *
 * @return
 */
public IRepositoryNode getCurrentSelectionNode() {
    DQRespositoryView repositoryView = getRepositoryView();
    if (repositoryView == null) {
        return null;
    }
    TreeItem[] selectionTreeItem = repositoryView.getCommonViewer().getTree().getSelection();
    if (null != selectionTreeItem && selectionTreeItem.length > 0 && null != selectionTreeItem[0]) {
        IRepositoryNode repoNode = (IRepositoryNode) selectionTreeItem[0].getData();
        return repoNode;
    } else {
        return null;
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView)

Example 13 with DQRespositoryView

use of org.talend.dataprofiler.core.ui.views.DQRespositoryView in project tdq-studio-se by Talend.

the class RemoveAnalysisAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    DQRespositoryView findView = CorePlugin.getDefault().getRepositoryView();
    if (findView == null) {
        return;
    }
    TreeSelection treeSelection = (TreeSelection) findView.getCommonViewer().getSelection();
    TreePath[] paths = treeSelection.getPaths();
    List<Analysis> analysisList;
    Analysis analysisObj = null;
    Map<TDQReportItem, List<Analysis>> removeMap = new HashMap<TDQReportItem, List<Analysis>>();
    for (TreePath path : paths) {
        Object lastSegment = path.getLastSegment();
        if (!(lastSegment instanceof ReportAnalysisRepNode)) {
            return;
        }
        // MOD sizhaoliu 2012-06-12 TDQ-5051 "Remove Anaysis" menu item is not in the right place
        ReportAnalysisRepNode repNode = (ReportAnalysisRepNode) lastSegment;
        analysisObj = repNode.getAnalysis();
        TDQReportItem reportItem = repNode.getReportItem();
        analysisList = removeMap.get(reportItem);
        if (analysisList == null) {
            analysisList = new ArrayList<Analysis>();
            analysisList.add(analysisObj);
            removeMap.put(reportItem, analysisList);
        } else {
            analysisList.add(analysisObj);
        }
    }
    if (analysisObj == null) {
        return;
    }
    String message = paths.length > 1 ? DefaultMessagesImpl.getString("RemoveAnalysisAction.areYouDeleteElement0", // $NON-NLS-1$
    paths.length) : // $NON-NLS-1$
    DefaultMessagesImpl.getString("RemoveAnalysisAction.areYouDeleteElement2", analysisObj.getName());
    boolean openConfirm = MessageDialog.openConfirm(null, DefaultMessagesImpl.getString("RemoveAnalysisAction.confirmResourceDelete"), // $NON-NLS-1$
    message);
    if (openConfirm) {
        Iterator<TDQReportItem> iterator = removeMap.keySet().iterator();
        while (iterator.hasNext()) {
            TDQReportItem reportItem = iterator.next();
            ReportHelper.removeAnalyses((TdReport) reportItem.getReport(), removeMap.get(reportItem));
            // save now modified resources (that contain the Dependency
            // objects)
            ElementWriterFactory.getInstance().createReportWriter().save(reportItem, true);
        }
        IFolder reportsFolder = ResourceManager.getReportsFolder();
        try {
            reportsFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
        } catch (CoreException e) {
            log.error(e, e);
        }
        findView.getCommonViewer().refresh();
    }
}
Also used : HashMap(java.util.HashMap) TreePath(org.eclipse.jface.viewers.TreePath) CoreException(org.eclipse.core.runtime.CoreException) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) List(java.util.List) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) IFolder(org.eclipse.core.resources.IFolder)

Example 14 with DQRespositoryView

use of org.talend.dataprofiler.core.ui.views.DQRespositoryView in project tdq-studio-se by Talend.

the class ModelElementTreeMenuProvider method showDetailView.

/**
 * DOC Zqin Comment method "showSelectedElements".MOD 2009-01-07 mzhao.
 *
 * @param newTree
 */
public void showDetailView(Tree newTree) {
    TreeItem[] selection = newTree.getSelection();
    if (selection.length > 0) {
        RespositoryDetailView detailView = CorePlugin.getDefault().getRespositoryDetailView();
        if (detailView == null) {
            return;
        }
        DQRespositoryView dqview = CorePlugin.getDefault().getRepositoryView();
        RepositoryNode node = getSelectedNode(selection);
        detailView.selectionChanged(dqview, new StructuredSelection(node));
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView) RespositoryDetailView(org.talend.dataprofiler.core.ui.views.RespositoryDetailView)

Example 15 with DQRespositoryView

use of org.talend.dataprofiler.core.ui.views.DQRespositoryView in project tdq-studio-se by Talend.

the class TOPRepositoryService method refresh.

public void refresh() {
    CorePlugin.getDefault().refreshWorkSpace();
    // ~ TDQ-5133 mzhao 2012-05-31 when there are many children for a db connection, it's more elegant to collapse
    // the metadata folder when refreshing the tree to save time.
    IRepositoryNode metadataNode = RepositoryNodeHelper.getMetadataFolderNode(EResourceConstant.DB_CONNECTIONS);
    // MOD msjian TUP-274 2012-11-14: avoid NPE of metadataNode
    // getRepositoryView() maybe return null when DqRepository veiw not be opened
    DQRespositoryView repositoryView = CorePlugin.getDefault().getRepositoryView();
    if (repositoryView != null) {
        CommonViewer commonViewer = repositoryView.getCommonViewer();
        if (commonViewer != null) {
            if (metadataNode != null) {
                commonViewer.collapseToLevel(metadataNode, AbstractTreeViewer.ALL_LEVELS);
            } else {
                commonViewer.collapseAll();
            }
        }
    }
    // TUP-274~
    // ~ TDQ-5311
    CorePlugin.getDefault().refreshDQView();
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) CommonViewer(org.eclipse.ui.navigator.CommonViewer) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView)

Aggregations

DQRespositoryView (org.talend.dataprofiler.core.ui.views.DQRespositoryView)19 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 TreeItem (org.eclipse.swt.widgets.TreeItem)6 ISelection (org.eclipse.jface.viewers.ISelection)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 RepositoryNode (org.talend.repository.model.RepositoryNode)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)3 RespositoryDetailView (org.talend.dataprofiler.core.ui.views.RespositoryDetailView)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IFolder (org.eclipse.core.resources.IFolder)2 CoreException (org.eclipse.core.runtime.CoreException)2 TableItem (org.eclipse.swt.widgets.TableItem)2 PartInitException (org.eclipse.ui.PartInitException)2 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1