Search in sources :

Example 1 with DQRepositoryViewLabelProvider

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

the class NominalValuesDPSelectionPage method addListeners.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
     */
@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (object instanceof ColumnRepNode) {
                RepositoryNode repositoryNode = (ColumnRepNode) object;
                DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
                int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
                // int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
                if (Java2SqlType.isTextInSQL(javaSQLType)) {
                    advanceToNextPageOrFinish();
                } else {
                    List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                    tempList.add(columnNode);
                    setAddTextIndicator(false);
                    if (!tempList.isEmpty()) {
                        ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
                        dialog.setElements(tempList.toArray());
                        // $NON-NLS-1$
                        dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
                        // $NON-NLS-1$
                        dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
                        dialog.setSize(80, 20);
                        dialog.create();
                        if (Window.OK == dialog.open()) {
                            // use MetadataHelper
                            for (DFColumnRepNode col : tempList) {
                                MetadataHelper.setDataminingType(DataminingType.NOMINAL, col.getMetadataColumn());
                            }
                            advanceToNextPageOrFinish();
                        }
                    }
                }
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
                nodes = new ArrayList<IRepositoryNode>();
                if (object instanceof ColumnRepNode) {
                    List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
                    nodes.addAll(list);
                    if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
                        List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                        for (IRepositoryNode obj : nodes) {
                            if (object instanceof ColumnRepNode) {
                                RepositoryNode repositoryNode = (ColumnRepNode) obj;
                                DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
                                int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
                                if (!Java2SqlType.isTextInSQL(javaSQLType)) {
                                    tempList.add(columnNode);
                                    setAddTextIndicator(false);
                                }
                            }
                        }
                        if (!tempList.isEmpty()) {
                            ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
                            dialog.setElements(tempList.toArray());
                            // $NON-NLS-1$
                            dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
                            // $NON-NLS-1$
                            dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
                            dialog.setSize(80, 20);
                            dialog.create();
                            if (Window.OK == dialog.open()) {
                                // zqin get the column and change their datamining type to "Nominal"
                                for (DFColumnRepNode column : tempList) {
                                    MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
                                }
                                setPageComplete(true);
                                setMessage(chooseConnStr);
                            }
                        } else {
                            setPageComplete(true);
                            setMessage(chooseConnStr);
                        }
                    } else {
                        setPageComplete(false);
                        // $NON-NLS-1$
                        setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
                    }
                } else {
                    setPageComplete(false);
                    setMessage(chooseConnStr);
                }
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    });
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayList(java.util.ArrayList) List(java.util.List) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 2 with DQRepositoryViewLabelProvider

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

the class UDIUtils method createUdiCheckedTreeSelectionDialog.

/**
 * DOC xqliu Comment method "createUdiCheckedTreeSelectionDialog".
 *
 * @param meIndicator
 * @return
 */
public static CheckedTreeSelectionDialog createUdiCheckedTreeSelectionDialog(ModelElementIndicator meIndicator) {
    CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
    dialog.addFilter(new FolderObjFilter());
    DQRepositoryNode udiDialogInputData = AnalysisUtils.getSelectDialogInputData(EResourceConstant.USER_DEFINED_INDICATORS);
    dialog.setInput(udiDialogInputData);
    dialog.setValidator(new ISelectionStatusValidator() {

        public IStatus validate(Object[] selection) {
            for (Object patte : selection) {
                if (patte instanceof SysIndicatorDefinitionRepNode) {
                    SysIndicatorDefinitionRepNode udiNode = (SysIndicatorDefinitionRepNode) patte;
                    IndicatorDefinition indicatorDefinition = udiNode.getIndicatorDefinition();
                    boolean validStatus = TaggedValueHelper.getValidStatus(indicatorDefinition);
                    if (!validStatus) {
                        return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
                        "AnalysisColumnTreeViewer.chooseValidUdis"));
                    }
                }
            }
            return new // $NON-NLS-1$
            Status(// $NON-NLS-1$
            IStatus.OK, // $NON-NLS-1$
            PlatformUI.PLUGIN_ID, // $NON-NLS-1$
            IStatus.OK, // $NON-NLS-1$
            "", null);
        }
    });
    dialog.setContainerMode(true);
    dialog.setInitialSelections(getUDIFilesByIndicator(udiDialogInputData, meIndicator));
    // $NON-NLS-1$
    dialog.setTitle(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.udiSelector"));
    // $NON-NLS-1$
    dialog.setMessage(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.udis"));
    dialog.setSize(80, 30);
    return dialog;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) FolderObjFilter(org.talend.dataprofiler.core.ui.filters.FolderObjFilter) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 3 with DQRepositoryViewLabelProvider

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

the class SetJDBCDriverPreferencePage method createConnSelectDialog.

private CheckedTreeSelectionDialog createConnSelectDialog() {
    RepositoryNode node = (RepositoryNode) RepositoryNodeHelper.getMetadataFolderNode(EResourceConstant.DB_CONNECTIONS);
    CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(getShell(), new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
    dialog.setInput(node);
    dialog.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof DBConnectionRepNode) {
                return isJdbcConnectionNode((DBConnectionRepNode) element);
            } else if (element instanceof DBConnectionSubFolderRepNode) {
                return hasJdbcConnNodeChild((DBConnectionSubFolderRepNode) element);
            }
            return false;
        }
    });
    dialog.setValidator(new ISelectionStatusValidator() {

        public IStatus validate(Object[] selection) {
            for (Object object : selection) {
                if (object instanceof DBConnectionRepNode) {
                    IRepositoryViewObject nodeObject = ((DBConnectionRepNode) object).getObject();
                    // when it's locked, can not modify
                    if (nodeObject != null && nodeObject.getProperty() != null && nodeObject.getProperty().getItem() != null && (nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER || nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_USER || RepositoryManager.isOpenedItemInEditor(nodeObject))) {
                        String displayName = nodeObject.getProperty().getDisplayName();
                        String version = nodeObject.getProperty().getVersion();
                        return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.isLocked", // $NON-NLS-1$ //$NON-NLS-2$
                        displayName + " " + version));
                    }
                }
            }
            return new // $NON-NLS-1$
            Status(// $NON-NLS-1$
            IStatus.OK, // $NON-NLS-1$
            PlatformUI.PLUGIN_ID, // $NON-NLS-1$
            IStatus.OK, // $NON-NLS-1$
            "", null);
        }
    });
    dialog.setContainerMode(true);
    // $NON-NLS-1$
    dialog.setTitle(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.selectConnectionButton"));
    // $NON-NLS-1$
    dialog.setMessage(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.ApplytoConnectionEditors"));
    dialog.setSize(80, 30);
    return dialog;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IStatus(org.eclipse.core.runtime.IStatus) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) Viewer(org.eclipse.jface.viewers.Viewer) DBConnectionSubFolderRepNode(org.talend.dq.nodes.DBConnectionSubFolderRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 4 with DQRepositoryViewLabelProvider

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

the class AnalysisTableTreeViewer method showAddDQRuleDialog.

/**
 * DOC xqliu Comment method "showAddDQRuleDialog".
 *
 * @param treeItem
 * @param tableIndicator
 */
private void showAddDQRuleDialog(final TreeItem treeItem, final TableIndicator tableIndicator) {
    // MOD xqliu 2009-04-30 bug 6808
    IndicatorCheckedTreeSelectionDialog dialog = new IndicatorCheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
    dialog.setInput(AnalysisUtils.getSelectDialogInputData(EResourceConstant.RULES_SQL));
    dialog.setValidator(new ISelectionStatusValidator() {

        public IStatus validate(Object[] selection) {
            for (Object ruleNode : selection) {
                if (ruleNode instanceof RuleRepNode) {
                    IndicatorDefinition findWhereRule = ((RuleRepNode) ruleNode).getRule();
                    boolean validStatus = TaggedValueHelper.getValidStatus(findWhereRule);
                    if (!validStatus) {
                        return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
                        "AnalysisTableTreeViewer.chooseValidDQRules"));
                    }
                }
            }
            // $NON-NLS-1$
            return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, "", null);
        }
    });
    dialog.setContainerMode(true);
    // $NON-NLS-1$
    dialog.setTitle(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.dqruleSelector"));
    // $NON-NLS-1$
    dialog.setMessage(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.dqrules"));
    dialog.setSize(80, 30);
    dialog.create();
    // MOD xqliu 2009-04-30 bug 6808
    Object[] ownedWhereRuleNodes = getOwnedWhereRuleNodes(tableIndicator);
    dialog.setCheckedElements(ownedWhereRuleNodes);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        removeUncheckedWhereRuleIndicator(ownedWhereRuleNodes, result, tableIndicator);
        Object[] results = clearAddedResult(ownedWhereRuleNodes, result);
        for (Object obj : results) {
            if (obj instanceof RuleRepNode) {
                RuleRepNode node = (RuleRepNode) obj;
                TableIndicatorUnit addIndicatorUnit = DQRuleUtilities.createIndicatorUnit(node, tableIndicator, getAnalysis());
                if (addIndicatorUnit != null) {
                    createOneUnit(treeItem, addIndicatorUnit);
                    setDirty(true);
                } else {
                    IndicatorDefinition whereRule = node.getRule();
                    MessageUI.openError(// $NON-NLS-1$
                    DefaultMessagesImpl.getString(// $NON-NLS-1$
                    "AnalysisTableTreeViewer.ErrorWhenAddWhereRule", whereRule.getName()));
                }
            }
        }
    }
// ~
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IndicatorCheckedTreeSelectionDialog(org.talend.dataprofiler.core.ui.dialog.IndicatorCheckedTreeSelectionDialog) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 5 with DQRepositoryViewLabelProvider

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

the class TablesSelectionDialog method initProvider.

@Override
protected void initProvider() {
    fLabelProvider = new DQRepositoryViewLabelProvider();
    fContentProvider = new DBTreeViewContentProvider();
    sLabelProvider = new TableLabelProvider();
    sContentProvider = new TableContentProvider();
}
Also used : TableContentProvider(org.talend.dataprofiler.core.ui.wizard.analysis.table.TableContentProvider) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Aggregations

DQRepositoryViewLabelProvider (org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)8 ResourceViewContentProvider (org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider)5 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)4 ISelectionStatusValidator (org.eclipse.ui.dialogs.ISelectionStatusValidator)4 ArrayList (java.util.ArrayList)3 CheckedTreeSelectionDialog (org.eclipse.ui.dialogs.CheckedTreeSelectionDialog)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)2 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)2 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)2 RuleRepNode (org.talend.dq.nodes.RuleRepNode)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 HashMap (java.util.HashMap)1 List (java.util.List)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1