Search in sources :

Example 11 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class AnalysisColumnNominalIntervalTreeViewer method createTreeMenu.

/**
 * DOC xzhao Comment method "createTreeMenu".
 *
 * @param newTree
 * @param containEdit
 */
private void createTreeMenu(final Tree newTree, boolean containEdit) {
    Menu oldMenu = newTree.getMenu();
    if (oldMenu != null && !oldMenu.isDisposed()) {
        oldMenu.dispose();
    }
    menu = new Menu(newTree);
    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) {
            removeSelectedElements(newTree);
        // MOD mzhao 2005-05-05 bug 6587.
        // MOD mzhao 2009-06-8, bug 5887.
        // updateBindConnection(masterPage, tree);
        }
    });
    // ADD 2009-01-07 mzhao for feature:0005664
    MenuItem showMenuItem = new MenuItem(menu, SWT.CASCADE);
    // $NON-NLS-1$
    showMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
    showMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
    showMenuItem.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 = newTree.getSelection();
            if (selection.length > 0) {
                // if DqRepository view is not openning we will not do anything
                DQRespositoryView dqview = CorePlugin.getDefault().findAndOpenRepositoryView();
                if (dqview == null) {
                    return;
                }
                // TdColumn tdColumn = (TdColumn) selection[0].getData(COLUMN_INDICATOR_KEY);
                dqview.showSelectedElements(selection[0].getData(COLUMN_INDICATOR_KEY));
            }
        }
    });
    if (containEdit) {
        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)
                 * 
                 * @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) {
                    TreeItem treeItem = selection[0];
                    IndicatorUnit indicatorUnit = (IndicatorUnit) treeItem.getData(INDICATOR_UNIT_KEY);
                    PatternMatchingIndicator indicator = (PatternMatchingIndicator) indicatorUnit.getIndicator();
                    Pattern pattern = indicator.getParameters().getDataValidDomain().getPatterns().get(0);
                    // MOD mzhao 2009-03-13 Feature 6066 Move all folders
                    // into one project.
                    IFile file = ResourceFileMap.findCorrespondingFile(pattern);
                    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                    try {
                        activePage.openEditor(new FileEditorInput(file), // $NON-NLS-1$
                        "org.talend.dataprofiler.core.ui.editor.pattern.PatternEditor");
                    } catch (PartInitException e1) {
                        log.error(e1, e1);
                    }
                }
            }
        });
    }
    newTree.setMenu(menu);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IFile(org.eclipse.core.resources.IFile) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) MenuItem(org.eclipse.swt.widgets.MenuItem) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) FileEditorInput(org.eclipse.ui.part.FileEditorInput) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Menu(org.eclipse.swt.widgets.Menu) PartInitException(org.eclipse.ui.PartInitException) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView)

Example 12 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class AnalysisColumnNominalIntervalTreeViewer method addTreeListener.

private void addTreeListener(final Tree tree) {
    tree.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            if (e.getSource() instanceof Tree) {
                Tree currentTree = (Tree) e.getSource();
                if (currentTree.getSelection().length > 0) {
                    enabledButtons(true);
                }
            }
        }

        public void focusLost(FocusEvent e) {
            if (e.getSource() instanceof Tree) {
                Tree currentTree = (Tree) e.getSource();
                if (currentTree.getSelection().length <= 0) {
                    enabledButtons(false);
                }
            }
        }
    });
    tree.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean con = false;
            if (e.item instanceof TreeItem) {
                enabledButtons(true);
                TreeItem item = (TreeItem) e.item;
                if (item.getData(INDICATOR_UNIT_KEY) != null) {
                    IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
                    IndicatorEnum type = indicatorUnit.getType();
                    con = IndicatorEnum.RegexpMatchingIndicatorEnum.compareTo(type) == 0 || IndicatorEnum.SqlPatternMatchingIndicatorEnum.compareTo(type) == 0;
                }
            }
            createTreeMenu(tree, con);
            showDetailView(tree);
        }
    });
    tree.addTreeListener(treeAdapter);
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) Tree(org.eclipse.swt.widgets.Tree) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 13 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class AnalysisColumnSetTreeViewer method removeItemBranch.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.core.ui.editor.composite.AbstractColumnDropTree#removeItemBranch(org.eclipse.swt.widgets
     * .TreeItem)
     */
@Override
protected void removeItemBranch(TreeItem item) {
    // MOD yyi 2011-03-22 19460: The "remove elements" option on the contextual menu does not work
    IndicatorUnit unit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
    ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
    // MOD klliu check the item is column or pattern
    if (item.getData(COLUMN_INDICATOR_KEY) != null) {
        deleteColumnItems(meIndicator.getModelElementRepositoryNode());
        deleteModelElementItems(meIndicator);
        masterPage.setCurrentModelElementIndicators(modelElementIndicators);
    }
    if (null != unit) {
        meIndicator.removeIndicatorUnit(unit);
    }
    super.removeItemBranch(item);
    // add msjian TDQ-8860 2014-4-30:check whether show allmatchindicator in the indicators section.
    EventManager.getInstance().publish(this.getAnalysis(), EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, null);
    // TDQ-8860~
    // MOD mzhao 2009-06-8, bug 5887.
    updateBindConnection(masterPage, tree);
    enabledButtons(false);
    tree.setFocus();
}
Also used : IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 14 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method sortIndicatorUnits.

/**
 * DOC yyi Sort indicators.
 *
 * @param units
 * @param targetUnit
 * @param step
 * @return
 */
private TypedReturnCode<IndicatorUnit[]> sortIndicatorUnits(IndicatorUnit[] units, IndicatorUnit targetUnit, int step, List<IndicatorUnit> indicatorUnitList) {
    TypedReturnCode<IndicatorUnit[]> code = new TypedReturnCode<IndicatorUnit[]>();
    int index = -1;
    for (int i = 0; i < units.length; i++) {
        if (targetUnit.getIndicator() == units[i].getIndicator()) {
            index = i;
            break;
        } else if (null != units[i].getChildren()) {
            TypedReturnCode<IndicatorUnit[]> code2 = sortIndicatorUnits(units[i].getChildren(), targetUnit, step, indicatorUnitList);
            if (null != code2.getObject()) {
                units[i].setChildren(code2.getObject());
                code.setOk(true);
                break;
            }
        }
    }
    int changeIndex = index + step;
    if (-1 != index && changeIndex > -1 && changeIndex < units.length) {
        IndicatorUnit tmpUnit = units[changeIndex];
        // when the changed one is the selected one too, get next one
        while (indicatorUnitList.contains(tmpUnit)) {
            tmpUnit = units[++changeIndex];
        }
        units[changeIndex] = units[index];
        units[index] = tmpUnit;
        // after the data changed successfully remove it from the selected list
        indicatorUnitList.remove(targetUnit);
        // $NON-NLS-1$
        code.setReturnCode("", true, units);
    }
    return code;
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)

Example 15 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method isExpressionNull.

private String isExpressionNull(TreeItem item) {
    String expressContent = null;
    ModelElement me = null;
    IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
    ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
    if (indicatorUnit != null) {
        IRepositoryViewObject reposViewObj = meIndicator.getModelElementRepositoryNode().getObject();
        // MetadataXmlElementTypeRepositoryObject
        if (reposViewObj instanceof MetadataColumnRepositoryObject) {
            me = ((MetadataColumnRepositoryObject) reposViewObj).getTdColumn();
        }
        Connection dataprovider = ModelElementHelper.getTdDataProvider(me);
        DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
        Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
        if (expression != null) {
            expressContent = expression.getBody();
        }
    } else {
        IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
        expressContent = DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
        parentNodeForColumnNode.getObject().getLabel());
    }
    return expressContent;
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Expression(orgomg.cwm.objectmodel.core.Expression) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)54 ArrayList (java.util.ArrayList)24 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)17 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)17 ColumnIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit)13 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)10 TreeItem (org.eclipse.swt.widgets.TreeItem)9 Indicator (org.talend.dataquality.indicators.Indicator)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 FrequencyExt (org.talend.dq.indicators.ext.FrequencyExt)7 BoxIndicator (org.talend.dataquality.indicators.BoxIndicator)5 CountsIndicator (org.talend.dataquality.indicators.CountsIndicator)5 IQRIndicator (org.talend.dataquality.indicators.IQRIndicator)5 PhoneNumbStatisticsIndicator (org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator)5 IRepositoryNode (org.talend.repository.model.IRepositoryNode)5 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)4 ColumnSetIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.ColumnSetIndicatorUnit)4 IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)4 IChartTypeStates (org.talend.dataprofiler.core.ui.editor.preview.model.states.IChartTypeStates)3 AverageLengthIndicator (org.talend.dataquality.indicators.AverageLengthIndicator)3