Search in sources :

Example 41 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AbstractColumnDropTree method deleteModelElementItems.

/**
 * DOC rli Comment method "deleteTreeElements".
 *
 * @param deleteModelElementIndiciator
 */
public void deleteModelElementItems(ModelElementIndicator deleteModelElementIndiciator) {
    ModelElementIndicator[] remainIndicators = new ModelElementIndicator[modelElementIndicators.length - 1];
    int i = 0;
    for (ModelElementIndicator indicator : modelElementIndicators) {
        if (deleteModelElementIndiciator.equals(indicator)) {
            continue;
        } else {
            remainIndicators[i] = indicator;
            i++;
        }
    }
    this.modelElementIndicators = remainIndicators;
    initializedConnection(this.modelElementIndicators);
}
Also used : ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 42 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AbstractColumnDropTree method translateSelectedNodeIntoIndicator.

// translate the selected nodes into related indicators, without set the values to this.modelElementIndicators
// directly
protected ModelElementIndicator[] translateSelectedNodeIntoIndicator(Object[] objs) {
    List<IRepositoryNode> reposList = RepNodeUtils.translateSelectedToStandardReposityoryNode(objs);
    if (reposList.size() == 0) {
        // this.modelElementIndicators = new ModelElementIndicator[0];
        return new ModelElementIndicator[0];
    }
    // MOD qiongli 2011-1-7 feature 16796.
    boolean isDelimitedFile = false;
    if (objs != null && objs.length != 0) {
        // MOD klliu 2011-02-16 feature 15387
        isDelimitedFile = RepNodeUtils.isDelimitedFile(objs[0]);
        if (!(reposList.get(0) instanceof DBColumnRepNode || isDelimitedFile)) {
            return null;
        }
    }
    List<ModelElementIndicator> modelElementIndicatorList = new ArrayList<ModelElementIndicator>();
    for (ModelElementIndicator modelElementIndicator : getAllTheElementIndicator()) {
        if (reposList.contains(modelElementIndicator.getModelElementRepositoryNode())) {
            modelElementIndicatorList.add(modelElementIndicator);
            reposList.remove(modelElementIndicator.getModelElementRepositoryNode());
        }
    }
    for (IRepositoryNode repObj : reposList) {
        ModelElementIndicator temp = isDelimitedFile ? ModelElementIndicatorHelper.createDFColumnIndicator(repObj) : ModelElementIndicatorHelper.createColumnIndicator(repObj);
        modelElementIndicatorList.add(temp);
    }
    return modelElementIndicatorList.toArray(new ModelElementIndicator[modelElementIndicatorList.size()]);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 43 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AnalysisColumnSetTreeViewer method addItemElements.

private void addItemElements(final ModelElementIndicator[] elements) {
    // MOD qiongli 2011-1-27,change TdColumn to MetadataColumn for supporting delimited file.
    for (ModelElementIndicator element2 : elements) {
        final ModelElementIndicator meIndicator = element2;
        final ModelElement modelElement = RepositoryNodeHelper.getSubModelElement(meIndicator.getModelElementRepositoryNode());
        final TreeItem treeItem = new TreeItem(tree, SWT.NONE);
        MetadataHelper.setDefaultDataminingType(modelElement);
        columnSetMultiValueList.add(meIndicator.getModelElementRepositoryNode());
        treeItem.setImage(ImageLib.getImage(ImageLib.TD_COLUMN));
        treeItem.setText(0, getModelElemetnDisplayName(meIndicator));
        treeItem.setData(COLUMN_INDICATOR_KEY, modelElement);
        treeItem.setData(MODELELEMENT_INDICATOR_KEY, meIndicator);
        // MOD mzhao feature 13040 , 2010-05-21
        TreeEditor comboEditor = new TreeEditor(tree);
        final CCombo combo = new CCombo(tree, SWT.BORDER);
        for (DataminingType type : DataminingType.values()) {
            // MODSCA 2008-04-10 use literal
            combo.add(type.getLiteral());
        // for presentation
        }
        DataminingType dataminingType = MetadataHelper.getDataminingType(modelElement);
        if (dataminingType == null) {
            combo.select(0);
        } else {
            combo.setText(dataminingType.getLiteral());
        }
        combo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                MetadataHelper.setDataminingType(DataminingType.get(combo.getText()), modelElement);
                setDirty(true);
            }
        });
        combo.setEditable(false);
        comboEditor.minimumWidth = WIDTH1_CELL;
        comboEditor.setEditor(combo, treeItem, 1);
        TreeEditor addPatternEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label addPatternLabl = createTreeItemLabel(tree, ImageLib.ADD_PATTERN, "AnalysisColumnTreeViewer.addPattern");
        PatternMouseAdapter mouseAdapter = new PatternMouseAdapter(this, masterPage, meIndicator, treeItem);
        mouseAdapter.addFilter(new ViewerFilter() {

            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (element instanceof IFolder) {
                    IFolder folder = (IFolder) element;
                    // $NON-NLS-1$
                    return !folder.getName().endsWith("SQL");
                }
                return true;
            }
        });
        addPatternLabl.addMouseListener(mouseAdapter);
        addPatternEditor.minimumWidth = addPatternLabl.getImage().getBounds().width;
        addPatternEditor.setEditor(addPatternLabl, treeItem, 2);
        TreeEditor delLabelEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisColumnTreeViewer.delete");
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                deleteColumnItems(meIndicator.getModelElementRepositoryNode());
                if (treeItem.getParentItem() != null && treeItem.getParentItem().getData(INDICATOR_UNIT_KEY) != null) {
                    setElements(modelElementIndicators);
                } else {
                    deleteIndicatorItems(meIndicator);
                    removeItemBranch(treeItem);
                    enabledButtons(false);
                }
                notifyObservers();
            }
        });
        delLabelEditor.minimumWidth = delLabel.getImage().getBounds().width;
        delLabelEditor.horizontalAlignment = SWT.CENTER;
        delLabelEditor.setEditor(delLabel, treeItem, 3);
        treeItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { comboEditor, addPatternEditor, delLabelEditor });
        if (meIndicator.hasIndicators()) {
            createIndicatorItems(treeItem, meIndicator.getIndicatorUnits());
        }
        delLabelEditor.layout();
        treeItem.setExpanded(false);
    }
    tree.layout();
    tree.redraw();
    this.setDirty(true);
    tree.forceFocus();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeEditor(org.eclipse.swt.custom.TreeEditor) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Viewer(org.eclipse.jface.viewers.Viewer) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) CCombo(org.eclipse.swt.custom.CCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EObject(org.eclipse.emf.ecore.EObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) IFolder(org.eclipse.core.resources.IFolder)

Example 44 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AnalysisColumnSetTreeViewer method createTree.

/**
 * @param parent
 */
private Tree createTree(Composite parent) {
    final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER) {

        @Override
        protected String getItemTooltipText(TreeItem item) {
            ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
            IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
            return DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
            parentNodeForColumnNode.getObject().getLabel());
        }
    };
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
    newTree.setHeaderVisible(true);
    // $NON-NLS-1$
    createTreeItem(newTree, 300, "AnalysisColumnTreeViewer.analyzedColumns");
    createTreeDataminingItem(newTree);
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.pattern");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
    parent.layout();
    AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {

        @Override
        protected void handleRemove() {
            removeSelectedElements(newTree);
            // MOD mzhao 2005-05-05 bug 6587.
            // MOD mzhao 2009-06-8, bug 5887.
            updateBindConnection(masterPage, tree);
        }
    };
    parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
    addTargetDND(newTree);
    addTreeListener(newTree);
    return newTree;
}
Also used : AbstractAnalysisActionHandler(org.talend.dataprofiler.core.ui.editor.AbstractAnalysisActionHandler) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) Tree(org.eclipse.swt.widgets.Tree) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 45 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method addItemElements.

private void addItemElements(final ModelElementIndicator[] elements, boolean isExpandAll) {
    for (ModelElementIndicator element : elements) {
        final TreeItem treeItem = new TreeItem(tree, SWT.NONE);
        treeItem.setImage(ImageLib.getImage(ImageLib.TD_COLUMN));
        final ModelElementIndicator meIndicator = element;
        treeItem.setText(0, ModelElementIndicatorHelper.getModelElementDisplayName(meIndicator));
        treeItem.setData(MODELELEMENT_INDICATOR_KEY, meIndicator);
        TreeEditor comboEditor = new TreeEditor(tree);
        final CCombo combo = new CCombo(tree, SWT.BORDER);
        for (DataminingType type : DataminingType.values()) {
            // MODSCA 2008-04-10 use literal
            combo.add(type.getLiteral());
        // for presentation
        }
        final ModelElement modelElement = RepositoryNodeHelper.getSubModelElement(meIndicator.getModelElementRepositoryNode());
        DataminingType dataminingType = MetadataHelper.getDataminingType(modelElement);
        // MOD qiongli 2010-11-15 feature 16796
        if (meIndicator instanceof DelimitedFileIndicator) {
            dataminingType = MetadataHelper.getDefaultDataminingType(meIndicator.getJavaType());
        }
        if (dataminingType == null) {
            combo.select(0);
        } else {
            combo.setText(dataminingType.getLiteral());
        }
        combo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                MetadataHelper.setDataminingType(DataminingType.get(combo.getText()), modelElement);
                setDirty(true);
            }
        });
        combo.setEditable(false);
        comboEditor.minimumWidth = WIDTH1_CELL;
        comboEditor.setEditor(combo, treeItem, 1);
        TreeEditor addPatternEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label addPatternLabl = createTreeItemLabel(tree, ImageLib.ADD_PATTERN, "AnalysisColumnTreeViewer.addPattern");
        // MOD mzhao feature:13040, 2010-05-21
        addPatternLabl.addMouseListener(new PatternMouseAdapter(this, masterPage, meIndicator, treeItem));
        addPatternEditor.minimumWidth = addPatternLabl.getImage().getBounds().width;
        addPatternEditor.setEditor(addPatternLabl, treeItem, 2);
        // ADD xqliu 2010-02-23 feature 11617
        TreeEditor addUdiEditor = addColumnUdi(treeItem, meIndicator, 3);
        // ~
        TreeEditor delLabelEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisColumnTreeViewer.delete");
        delLabel.setData(treeItem);
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                // // here is the delLable which is behind of column, so need to remove current column and it's all
                // of
                TreeItem currentTreeItem = (TreeItem) e.widget.getData();
                removeSelectedElements(new TreeItem[] { currentTreeItem });
                notifyObservers();
            }
        });
        delLabelEditor.minimumWidth = delLabel.getImage().getBounds().width;
        delLabelEditor.horizontalAlignment = SWT.CENTER;
        delLabelEditor.setEditor(delLabel, treeItem, 4);
        treeItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { comboEditor, delLabelEditor, addPatternEditor, addUdiEditor });
        if (meIndicator.hasIndicators()) {
            createIndicatorItems(treeItem, meIndicator.getIndicatorUnits());
        }
        treeItem.setExpanded(isExpandAll);
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) CCombo(org.eclipse.swt.custom.CCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)58 IRepositoryNode (org.talend.repository.model.IRepositoryNode)22 ArrayList (java.util.ArrayList)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)16 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)15 Indicator (org.talend.dataquality.indicators.Indicator)13 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)12 TreeItem (org.eclipse.swt.widgets.TreeItem)11 RepositoryNode (org.talend.repository.model.RepositoryNode)10 IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)9 MetadataXmlElementTypeRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject)7 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)6 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)5 TreeEditor (org.eclipse.swt.custom.TreeEditor)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4