Search in sources :

Example 11 with AnalysisRepNode

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

the class LocalRepositoryObjectCRUD method moveRepositoryNodes.

/**
 * move RepositoryNodes to the target RepositoryNode.
 *
 * @param repositoryNodes
 * @param targetNode
 * @throws PersistenceException
 */
private void moveRepositoryNodes(IRepositoryNode[] repositoryNodes, IRepositoryNode targetNode) throws PersistenceException {
    if (repositoryNodes != null) {
        for (IRepositoryNode sourceNode : repositoryNodes) {
            if (sourceNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                if (sourceNode instanceof AnalysisRepNode || sourceNode instanceof ConnectionRepNode) {
                    moveAnaConNode(sourceNode, targetNode);
                } else if (sourceNode instanceof ReportRepNode) {
                    moveReportRepNode(sourceNode, targetNode);
                } else {
                    IPath makeRelativeTo = getMakeRelativeTo(sourceNode);
                    IPath removeLastSegments = makeRelativeTo.removeLastSegments(1);
                    if (sourceNode instanceof SysIndicatorDefinitionRepNode) {
                        // SystemIndicatorDefinition can't be moved
                        if (!((SysIndicatorDefinitionRepNode) sourceNode).isSystemIndicator()) {
                            moveOthersNode(sourceNode, targetNode, removeLastSegments);
                        }
                    } else if (sourceNode instanceof PatternRepNode) {
                        moveOthersNode(sourceNode, targetNode, removeLastSegments);
                    } else if (sourceNode instanceof JrxmlTempleteRepNode) {
                        moveJrxmlFileRepNode(sourceNode, targetNode, makeRelativeTo);
                    } else if (sourceNode instanceof SourceFileRepNode || sourceNode instanceof RuleRepNode) {
                        moveOthersNode(sourceNode, targetNode, makeRelativeTo);
                    } else {
                        moveOthersNode(sourceNode, targetNode, removeLastSegments);
                    }
                }
            } else if (sourceNode.getType() == ENodeType.SIMPLE_FOLDER) {
                moveFolderRepNode(sourceNode, targetNode);
            }
            // refresh the dq repository tree view
            CorePlugin.getDefault().refreshDQView(targetNode.getParent());
            // MOD qiongli 2012-4-23,only refresh the parent of source node at here.
            CorePlugin.getDefault().refreshDQView(sourceNode.getParent());
        }
    }
}
Also used : ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ConnectionRepNode(org.talend.dq.nodes.ConnectionRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IPath(org.eclipse.core.runtime.IPath) ReportRepNode(org.talend.dq.nodes.ReportRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode)

Example 12 with AnalysisRepNode

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

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

the class AbstractCommonActionProviderTest method createAnalysisNode.

private RepositoryNode createAnalysisNode(String name, IFolder folder, boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    // connection
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    createAnalysis.setName(name);
    // ~connection
    TDQAnalysisItem createAnalysisItem = org.talend.dataquality.properties.PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
    org.talend.core.model.properties.Property createAnaProperty = PropertiesFactory.eINSTANCE.createProperty();
    createAnaProperty.setId(EcoreUtil.generateUUID());
    createAnaProperty.setItem(createAnalysisItem);
    createAnaProperty.setLabel(createAnalysis.getName());
    createAnalysisItem.setProperty(createAnaProperty);
    createAnalysisItem.setAnalysis(createAnalysis);
    ItemState createItemState = PropertiesFactory.eINSTANCE.createItemState();
    createItemState.setDeleted(isDelete);
    createAnalysisItem.setState(createItemState);
    // Indicator
    CountsIndicator createCountsIndicator = IndicatorsFactory.eINSTANCE.createCountsIndicator();
    List<IRepositoryViewObject> all = null;
    IndicatorDefinition createIndicatorDefinition = null;
    try {
        all = factory.getAll(ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
        for (IRepositoryViewObject indicatorViewObject : all) {
            if (indicatorViewObject.getLabel().equalsIgnoreCase("ROW COUNT")) {
                // $NON-NLS-1$
                createIndicatorDefinition = (IndicatorDefinition) PropertyHelper.getModelElement(indicatorViewObject.getProperty());
                break;
            }
        }
    } catch (PersistenceException e1) {
        e1.printStackTrace();
        Assert.fail(e1.getMessage());
    }
    createCountsIndicator.setIndicatorDefinition(createIndicatorDefinition);
    AnalysisParameters createAnalysisParameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
    createAnalysis.setContext(createAnalysisContext);
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
    createAnalysisResult.setResultMetadata(createExecutionInformations);
    createAnalysisResult.getIndicators().add(createCountsIndicator);
    createAnalysis.setResults(createAnalysisResult);
    createAnalysis.setParameters(createAnalysisParameters);
    IRepositoryViewObject repViewObject = null;
    try {
        factory.create(createAnalysisItem, createPath, false);
        repViewObject = factory.getLastVersion(createAnaProperty.getId());
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    RepositoryNode anaRepNode = new AnalysisRepNode(repViewObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
    // set the contentType for anaRepNode from its parentNode
    setParentNode(anaRepNode, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
    // ~
    return anaRepNode;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) CountsIndicator(org.talend.dataquality.indicators.CountsIndicator) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) RepositoryNode(org.talend.repository.model.RepositoryNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 14 with AnalysisRepNode

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

the class EMFSharedResourcesTest method testReloadModelElementInNode.

/**
 * Test method for
 * {@link org.talend.dq.writer.EMFSharedResources#reloadModelElementInNode(org.talend.repository.model.IRepositoryNode)}
 * .
 */
@Test
public void testReloadModelElementInNode() {
    IRepositoryViewObject viewObject = UnitTestBuildHelper.buildRepositoryViewObjectSystemFolder(currentProject.getEmfProject(), currentProject.getAuthor(), ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
    RepositoryNode node = new RepositoryNode(viewObject, null, ENodeType.SYSTEM_FOLDER);
    viewObject.setRepositoryNode(node);
    // $NON-NLS-1$
    Item anaItem = createRealAnalysis("analysis_emfreload", null, false);
    IRepositoryViewObject object = null;
    try {
        object = ProxyRepositoryFactory.getInstance().getLastVersion(anaItem.getProperty().getId());
    } catch (PersistenceException e1) {
        // $NON-NLS-1$
        fail("testReloadModelElementInNode fail: " + e1.getMessage());
    }
    anaNode = new AnalysisRepNode(object, node, ENodeType.REPOSITORY_ELEMENT, currentProject);
    anaNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
    anaNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
    URI uri = anaItem.eResource().getURI();
    String fileExtension = anaItem.getFileExtension();
    // $NON-NLS-1$
    String removeEnd = StringUtils.removeEnd(uri.path(), "." + FactoriesUtil.PROPERTIES_EXTENSION);
    Analysis analysis = ((TDQAnalysisItem) anaItem).getAnalysis();
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        ProxyRepositoryFactory.getInstance().unloadResources(uri.scheme() + ":" + removeEnd + "." + fileExtension);
    } catch (PersistenceException e) {
        // $NON-NLS-1$
        fail("testReloadModelElementInNode fail: " + e.getMessage());
    }
    // ModelElement modelElement = PropertyHelper.getModelElement(anaItem.getProperty());
    assertTrue(analysis.eIsProxy());
    ModelElement reloadModelElement = EMFSharedResources.getInstance().reloadModelElementInNode(anaNode);
    assertFalse(reloadModelElement.eIsProxy());
}
Also used : TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Item(org.talend.core.model.properties.Item) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNode(org.talend.repository.model.RepositoryNode) URI(org.eclipse.emf.common.util.URI) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 15 with AnalysisRepNode

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

the class ModelElementTreeMenuProvider method createTreeMenu.

/**
 * DOC qzhang Comment method "createTreeMenu". MOD qiongli bug 16252.Add a param of 'isColumnSetMenu'
 *
 * @param newTree
 * @param containEdit
 */
public void createTreeMenu(boolean isColumnSetMenu) {
    Menu oldMenu = tree.getMenu();
    if (oldMenu != null && !oldMenu.isDisposed()) {
        oldMenu.dispose();
    }
    Menu menu = new Menu(tree);
    if (isSelectedColumn(tree.getSelection())) {
        if (!isMetadataColumnSelected(tree.getSelection())) {
            MenuItem previewMenuItem = new MenuItem(menu, SWT.CASCADE);
            // $NON-NLS-1$
            previewMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.previewDQElement"));
            previewMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
            previewMenuItem.addSelectionListener(new SelectionAdapter() {

                /*
                     * (non-Javadoc)
                     * 
                     * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse
                     * .swt.events.SelectionEvent)
                     */
                @Override
                public void widgetSelected(SelectionEvent e) {
                    previewSelectedElements(tree);
                }
            });
        }
        if (isColumnSetMenu) {
            MenuItem createColumnAnalysisMenuItem = new MenuItem(menu, SWT.CASCADE);
            // $NON-NLS-1$
            createColumnAnalysisMenuItem.setText(DefaultMessagesImpl.getString("CreateColumnAnalysisAction.columnAnalysis"));
            createColumnAnalysisMenuItem.setImage(ImageLib.getImage(ImageLib.ACTION_NEW_ANALYSIS));
            createColumnAnalysisMenuItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    createColumnAnalysis(tree);
                }
            });
        }
        MenuItem showLocationMenuItem = new MenuItem(menu, SWT.CASCADE);
        // $NON-NLS-1$
        showLocationMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
        showLocationMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
        showLocationMenuItem.addSelectionListener(new SelectionAdapter() {

            /*
                 * (non-Javadoc)
                 * 
                 * @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org.eclipse .swt.events.SelectionEvent)
                 */
            @Override
            public void widgetSelected(SelectionEvent e) {
                showSelectedElements(tree);
            }
        });
    }
    if (isSelectedIndicator(tree.getSelection()) && !isMetadataColumnIndicatorSelected(tree.getSelection())) {
        // MOD 2009-01-04 mzhao
        MenuItem showQueryMenuItem = new MenuItem(menu, SWT.CASCADE);
        // $NON-NLS-1$
        showQueryMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.viewQuery"));
        showQueryMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
        showQueryMenuItem.addSelectionListener(new SelectionAdapter() {

            /*
                 * (non-Javadoc)
                 * 
                 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse .swt.events.SelectionEvent)
                 */
            @Override
            public void widgetSelected(SelectionEvent e) {
                viewQueryForSelectedElement(tree);
            }
        });
    }
    if (isSelectedPatternIndicator(tree.getSelection())) {
        MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
        // $NON-NLS-1$
        editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editPattern"));
        editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
        editPatternMenuItem.addSelectionListener(new SelectionAdapter() {

            /*
                 * (non-Javadoc)
                 * 
                 * @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
                 */
            @Override
            public void widgetSelected(SelectionEvent e) {
                editPattern(tree);
            }
        });
    }
    // judge to indicator whether is frequency
    if (isSelectedFrequencyIndicator(tree.getSelection()) && PluginChecker.isTDCPLoaded()) {
        MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
        // $NON-NLS-1$
        editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.generateJob"));
        editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.ICON_PROCESS));
        editPatternMenuItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                final IDatabaseJobService service = (IDatabaseJobService) GlobalServiceRegister.getDefault().getService(IJobService.class);
                if (service != null) {
                    service.setIndicator(getSelectedIndicator(tree.getSelection()));
                    IRepositoryNode anaNode = getAnalysis2();
                    Analysis ana;
                    if (anaNode instanceof ReportAnalysisRepNode) {
                        ana = ((ReportAnalysisRepNode) anaNode).getAnalysis();
                    } else {
                        ana = ((AnalysisRepNode) anaNode).getAnalysis();
                    }
                    service.setAnalysis(ana);
                    service.executeJob();
                }
            }
        });
    }
    if (isSelectedUDIndicator(tree.getSelection())) {
        MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
        // $NON-NLS-1$
        editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editUDIndicator"));
        editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.IND_DEFINITION));
        editPatternMenuItem.addSelectionListener(new SelectionAdapter() {

            /*
                 * (non-Javadoc)
                 * 
                 * @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
                 */
            @Override
            public void widgetSelected(SelectionEvent e) {
                editUDIndicator(tree);
            }
        });
    }
    // add common menu to the tree
    MenuItem addTaskItem = new MenuItem(menu, SWT.CASCADE);
    // $NON-NLS-1$
    addTaskItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.AddTask"));
    addTaskItem.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
    addTaskItem.addSelectionListener(new SelectionAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse .swt.events.SelectionEvent)
             */
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeItem[] selection = tree.getSelection();
            if (selection.length > 0) {
                IRepositoryNode ana = getAnalysis2();
                // MOD qiongli 2011-1-12 feature 16796 :handle the case of ModelElement name is null
                (new TdAddTaskAction(tree.getShell(), ana)).run();
            }
        }
    });
    MenuItem deleteMenuItem = new MenuItem(menu, SWT.CASCADE);
    // $NON-NLS-1$
    deleteMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.removeElement"));
    deleteMenuItem.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
    deleteMenuItem.addSelectionListener(new SelectionAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse .swt.events.SelectionEvent)
             */
        @Override
        public void widgetSelected(SelectionEvent e) {
            removeSelectedElements2(tree);
        }
    });
    tree.setMenu(menu);
}
Also used : TdAddTaskAction(org.talend.dataprofiler.core.ui.action.actions.TdAddTaskAction) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IDatabaseJobService(org.talend.dataprofiler.core.service.IDatabaseJobService) Analysis(org.talend.dataquality.analysis.Analysis) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Aggregations

AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)17 IRepositoryNode (org.talend.repository.model.IRepositoryNode)10 ReportAnalysisRepNode (org.talend.dq.nodes.ReportAnalysisRepNode)8 ReportRepNode (org.talend.dq.nodes.ReportRepNode)6 RepositoryNode (org.talend.repository.model.RepositoryNode)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 Analysis (org.talend.dataquality.analysis.Analysis)5 PatternRepNode (org.talend.dq.nodes.PatternRepNode)5 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)4 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)4 RuleRepNode (org.talend.dq.nodes.RuleRepNode)4 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)4 ENodeType (org.talend.repository.model.IRepositoryNode.ENodeType)4 IPath (org.eclipse.core.runtime.IPath)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)3 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)3 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3