Search in sources :

Example 1 with CreatePatternAction

use of org.talend.dataprofiler.core.pattern.actions.CreatePatternAction in project tdq-studio-se by Talend.

the class NewSourcePatternActionProvider method fillContextMenu.

public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    TreeSelection treeSelection = ((TreeSelection) this.getContext().getSelection());
    List<IFile> selectedFiles = new ArrayList<IFile>();
    if (treeSelection.size() == 1) {
        Object obj = treeSelection.getFirstElement();
        if (obj instanceof RepositoryNode) {
            RepositoryNode node = (RepositoryNode) obj;
            if (ENodeType.SYSTEM_FOLDER.equals(node.getType()) || ENodeType.SIMPLE_FOLDER.equals(node.getType())) {
                try {
                    IFolder folder = WorkbenchUtils.getFolder(node);
                    ExpressionType type = null;
                    if (ResourceService.isSubFolder(ResourceManager.getPatternRegexFolder(), folder)) {
                        type = ExpressionType.REGEXP;
                    } else if (ResourceService.isSubFolder(ResourceManager.getPatternSQLFolder(), folder)) {
                        type = ExpressionType.SQL_LIKE;
                    }
                    if (type != null) {
                        menu.add(new CreatePatternAction(folder, type));
                        menu.add(new ImportPatternsAction(node, type));
                        menu.add(new ExportPatternsAction(node, false));
                        menu.add(new ExportPatternsAction(node, true));
                    }
                } catch (Exception e) {
                    log.error(e, e);
                }
            }
        }
    // else if (obj instanceof IFile) {
    // IFile file = (IFile) obj;
    // if (EXTENSION_PATTERN.equalsIgnoreCase(file.getFileExtension())) {
    // // menu.add(new RenameSqlFileAction((IFile) obj));
    // }
    // }
    }
    boolean isSelectFile = computeSelectedFiles(treeSelection, selectedFiles);
    if (!isSelectFile && !selectedFiles.isEmpty()) {
    // menu.add(new OpenSqlFileAction(selectedFiles));
    // menu.add(new DeletePatternAction(selectedFiles));
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) ImportPatternsAction(org.talend.dataprofiler.core.pattern.actions.ImportPatternsAction) RepositoryNode(org.talend.repository.model.RepositoryNode) ExportPatternsAction(org.talend.dataprofiler.core.pattern.actions.ExportPatternsAction) TreeSelection(org.eclipse.jface.viewers.TreeSelection) CreatePatternAction(org.talend.dataprofiler.core.pattern.actions.CreatePatternAction) ExpressionType(org.talend.dataquality.domain.pattern.ExpressionType) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with CreatePatternAction

use of org.talend.dataprofiler.core.pattern.actions.CreatePatternAction in project tdq-studio-se by Talend.

the class PatternTestView method createPatternTestCom.

protected void createPatternTestCom(final Composite parent) {
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    final Composite mainComposite = new Composite(scrolledComposite, SWT.NULL);
    scrolledComposite.setContent(mainComposite);
    GridLayout blay = new GridLayout();
    mainComposite.setLayout(blay);
    // create coboCom line
    final Composite coboCom = new Composite(mainComposite, SWT.NULL);
    imgCom = new Composite(mainComposite, SWT.NONE);
    final Composite textCom = new Composite(mainComposite, SWT.NULL);
    final Composite buttonsCom = new Composite(mainComposite, SWT.FILL | SWT.NULL);
    mainComposite.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event event) {
            GridData formData = new GridData(GridData.FILL_HORIZONTAL);
            formData.heightHint = 105;
            textCom.setLayoutData(formData);
            buttonsCom.setLayoutData(formData);
        }
    });
    // ~
    // set cobo com layout
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    coboCom.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    // MOD qiongli feature 16799: Add java in Pattern Test View
    buttonJava = new Button(coboCom, SWT.RADIO);
    buttonJava.setText(ExecutionLanguage.JAVA.getLiteral());
    data = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false);
    buttonJava.setLayoutData(data);
    buttonJava.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isJavaEngine = true;
            sqlButton.setEnabled(false);
            dbCombo.setEnabled(false);
            functionNameText.setEnabled(false);
        }
    });
    buttonSql = new Button(coboCom, SWT.RADIO);
    data = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false);
    // $NON-NLS-1$
    buttonSql.setText(DefaultMessagesImpl.getString("PatternTestView.Connections"));
    buttonSql.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isJavaEngine = false;
            sqlButton.setEnabled(true);
            dbCombo.setEnabled(true);
            functionNameText.setEnabled(true);
        }
    });
    buttonSql.setSelection(true);
    buttonSql.setEnabled(!isJavaEngine);
    buttonSql.setLayoutData(data);
    dbCombo = new CCombo(coboCom, SWT.DROP_DOWN | SWT.BORDER);
    dbCombo.setEditable(false);
    data = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    dbCombo.setLayoutData(data);
    // MOD gdbu 2011-5-31 bug : 19119
    Label dummyLabel = new Label(coboCom, SWT.NONE);
    dummyLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
    functionLabel = new Label(coboCom, SWT.NONE);
    // $NON-NLS-1$
    functionLabel.setText(DefaultMessagesImpl.getString("PatternTestView.FunctionName"));
    functionNameText = new Text(coboCom, SWT.BORDER);
    functionNameText.setText(PluginConstant.EMPTY_STRING);
    GridData functionNameTextGD = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false);
    data = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    functionNameText.setLayoutData(data);
    functionLabel.setLayoutData(functionNameTextGD);
    functionNameText.setVisible(false);
    functionLabel.setVisible(false);
    // ~19119
    GridData comData = new GridData(GridData.FILL_HORIZONTAL);
    comData.heightHint = 50;
    coboCom.setLayoutData(comData);
    // create image com
    layout = new GridLayout();
    layout.numColumns = 2;
    imgCom.setLayout(layout);
    emoticonLabel = new Label(imgCom, SWT.NONE);
    GridData gd = new GridData();
    gd.heightHint = 18;
    gd.widthHint = 18;
    emoticonLabel.setLayoutData(gd);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 18;
    // gd.widthHint = 65;
    // MOD TDQ-4599,mzhao, don't truncate the label.
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = GridData.FILL;
    resultLabel = new Label(imgCom, SWT.NONE);
    resultLabel.setLayoutData(gd);
    GridData imgData = new GridData(GridData.FILL_HORIZONTAL);
    // imgData.heightHint = 0;
    imgData.horizontalAlignment = GridData.FILL;
    imgData.grabExcessHorizontalSpace = true;
    imgCom.setLayoutData(imgData);
    // ~
    // create text com
    layout = new GridLayout();
    layout.numColumns = 2;
    textCom.setLayout(layout);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalAlignment = GridData.BEGINNING;
    // MOD gdbu 2011-5-31 bug : 19119
    textAreaLabel = new Label(textCom, SWT.NONE);
    // $NON-NLS-1$
    textAreaLabel.setText(DefaultMessagesImpl.getString("PatternTestView.area"));
    testText = AutoScrollBarTextFactory.getDefault().createText(textCom, SWT.BORDER | SWT.MULTI | SWT.WRAP);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 40;
    testText.setLayoutData(data);
    // $NON-NLS-1$
    testText.setToolTipText(DefaultMessagesImpl.getString("PatternTestView.enterHere"));
    GridData textAreaLabelGD = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    // textAreaLabelGD.widthHint = 180;
    textAreaLabel.setLayoutData(textAreaLabelGD);
    regularLabel = new Label(textCom, SWT.WRAP);
    // $NON-NLS-1$
    regularLabel.setText(DefaultMessagesImpl.getString("PatternTestView.regularExpressionParameter"));
    // $NON-NLS-1$
    regularLabel.setToolTipText(DefaultMessagesImpl.getString("PatternTestView.regularExpressionParameter"));
    GridData regularLabelGD = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    regularLabelGD.heightHint = 40;
    regularLabelGD.widthHint = 70;
    // regularLabelGD.widthHint = 260;
    regularLabel.setLayoutData(regularLabelGD);
    // ~19119
    this.regularText = AutoScrollBarTextFactory.getDefault().createText(textCom, SWT.BORDER | SWT.MULTI | SWT.WRAP);
    this.regularText.setLayoutData(data);
    // $NON-NLS-1$
    regularText.setToolTipText(DefaultMessagesImpl.getString("PatternTestView.enterHereAgainst"));
    regularText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            boolean enabled = (!regularText.getText().equals(PluginConstant.EMPTY_STRING)) && (CheckValueUtils.isPatternValue(regularText.getText()));
            if (pattern != null) {
                saveButton.setEnabled(enabled);
            }
            createPatternButton.setEnabled(enabled);
        }
    });
    GridData textData = new GridData(GridData.FILL_BOTH);
    textData.heightHint = 400;
    textCom.setLayoutData(textData);
    // ~~~~~~
    GridLayout llayout = new GridLayout();
    llayout.numColumns = 4;
    buttonsCom.setLayout(llayout);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 25;
    data.widthHint = 92;
    sqlButton = new Button(buttonsCom, SWT.PUSH);
    // $NON-NLS-1$
    sqlButton.setText(DefaultMessagesImpl.getString("PatternTestView.SQL"));
    // $NON-NLS-1$
    sqlButton.setToolTipText(DefaultMessagesImpl.getString("PatternTestView.generatedSQLStatement"));
    sqlButton.setLayoutData(data);
    sqlButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            openSQLEditor();
        }
    });
    createPatternButton = new Button(buttonsCom, SWT.PUSH);
    // $NON-NLS-1$
    createPatternButton.setText(DefaultMessagesImpl.getString("PatternTestView.createPattern"));
    // $NON-NLS-1$
    createPatternButton.setToolTipText(DefaultMessagesImpl.getString("PatternTestView.CreateNewPattern"));
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 25;
    data.widthHint = 92;
    createPatternButton.setLayoutData(data);
    createPatternButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String language = null;
            if (regularExpression != null) {
                language = regularExpression.getExpression().getLanguage();
            } else {
                DbmsLanguage dbmsLanguage = getDbmsLanguage();
                // MOD gdbu 2011-5-13 bug : 19119
                if (dbmsLanguage != null) {
                    dbmsLanguage.setRegularExpressionFunction(getFunctionName());
                    language = dbmsLanguage.getDbmsName();
                } else {
                    // ADD msjian 2012-2-10 TDQ-4600: fix set the default language is "Java"
                    language = SupportDBUrlType.JAVADEFAULTURL.getDBKey();
                // TDQ-4600~
                }
            // ~19119
            }
            // MOD mzhao 2009-03-13 Feature 6066 Move all folders into one
            // project.
            // MOD mzhao TDQ-4734 set relative customer pattern folder, same level to the pattern to be replicated.
            IFolder customizedPattFolder = ResourceManager.getPatternRegexFolder();
            if (pattern != null && pattern.eResource() != null) {
                IContainer oriPattContainer = WorkspaceUtils.getModelElementResource(pattern).getParent();
                if (oriPattContainer instanceof IFolder) {
                    customizedPattFolder = (IFolder) oriPattContainer;
                }
            }
            new CreatePatternAction(customizedPattFolder, ExpressionType.REGEXP, regularText.getText(), language).run();
        }
    });
    createPatternButton.setEnabled(false);
    saveButton = new Button(buttonsCom, SWT.PUSH);
    // $NON-NLS-1$
    saveButton.setText(DefaultMessagesImpl.getString("PatternTestView.Save"));
    saveButton.setEnabled(false);
    // $NON-NLS-1$
    saveButton.setToolTipText(DefaultMessagesImpl.getString("PatternTestView.SaveRegularExpression"));
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 25;
    data.widthHint = 92;
    saveButton.setLayoutData(data);
    saveButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            savePattern();
        }
    });
    testButton = new Button(buttonsCom, SWT.PUSH);
    data = new GridData(GridData.FILL_HORIZONTAL);
    testButton.setLayoutData(data);
    // $NON-NLS-1$
    testButton.setText(DefaultMessagesImpl.getString("PatternTestView.test"));
    // $NON-NLS-1$
    testButton.setToolTipText(DefaultMessagesImpl.getString("PatternTestView.ValidateEnteredString"));
    testButton.setLayoutData(data);
    testButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            testRegularText();
        }
    });
    // MOD gdbu TDQ-4153 2011-12-19 Initialize the position error of composite.
    expandImageComposite();
    // ~TDQ-4153
    data = new GridData(GridData.FILL_HORIZONTAL);
    buttonsCom.setLayoutData(data);
    scrolledComposite.setMinSize(mainComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    mainComposite.layout();
    activateContext();
    // MOD gdbu 2011-5-31 bug : 19119
    fillComboData();
// ~19119
}
Also used : SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IContainer(org.eclipse.core.resources.IContainer) CreatePatternAction(org.talend.dataprofiler.core.pattern.actions.CreatePatternAction) IFolder(org.eclipse.core.resources.IFolder)

Example 3 with CreatePatternAction

use of org.talend.dataprofiler.core.pattern.actions.CreatePatternAction in project tdq-studio-se by Talend.

the class ChartTableFactory method createPattern.

/**
 * DOC bZhou Comment method "createPattern".
 *
 * @param analysis
 * @param itemEntity
 * @param pattTransformer
 */
public static void createPattern(Analysis analysis, String query) {
    DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(analysis);
    PatternTransformer pattTransformer = new PatternTransformer(language);
    String regex = pattTransformer.getRegexp(query);
    IFolder folder = ResourceManager.getPatternRegexFolder();
    // $NON-NLS-1$ //$NON-NLS-2$
    new CreatePatternAction(folder, ExpressionType.REGEXP, "'" + regex + "'", language.getDbmsName()).run();
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) PatternTransformer(org.talend.dq.pattern.PatternTransformer) CreatePatternAction(org.talend.dataprofiler.core.pattern.actions.CreatePatternAction) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with CreatePatternAction

use of org.talend.dataprofiler.core.pattern.actions.CreatePatternAction in project tdq-studio-se by Talend.

the class ChartTableFactory method addMenuAndTip.

public static void addMenuAndTip(final TableViewer tbViewer, final IDataExplorer explorer, final Analysis analysis) {
    final Table table = tbViewer.getTable();
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            // MOD xqliu 2009-05-11 bug 6561
            if (table.getMenu() != null) {
                table.getMenu().setVisible(false);
            }
            if (e.button == 3) {
                StructuredSelection selection = (StructuredSelection) tbViewer.getSelection();
                final ChartDataEntity dataEntity = (ChartDataEntity) selection.getFirstElement();
                final Indicator indicator = dataEntity != null ? dataEntity.getIndicator() : null;
                if (indicator != null && dataEntity != null) {
                    Menu menu = new Menu(table.getShell(), SWT.POP_UP);
                    table.setMenu(menu);
                    MenuItemEntity[] itemEntities = ChartTableMenuGenerator.generate(explorer, analysis, dataEntity);
                    if (ExecutionLanguage.SQL == analysis.getParameters().getExecutionLanguage()) {
                        boolean showExtraMenu = false;
                        for (final MenuItemEntity itemEntity : itemEntities) {
                            MenuItem item = new MenuItem(menu, SWT.PUSH);
                            item.setText(itemEntity.geti18nLabel());
                            item.setImage(itemEntity.getIcon());
                            item.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e1) {
                                    // DBMSLanguage.
                                    if (isPatternMatchingIndicator(indicator) && !((PatternExplorer) explorer).isImplementRegexFunction(itemEntity.getLabel())) {
                                        MessageDialog.openInformation(null, itemEntity.getLabel(), // $NON-NLS-1$
                                        DefaultMessagesImpl.getString("ChartTableFactory.NoSupportPatternTeradata"));
                                        return;
                                    }
                                    String query = itemEntity.getQuery();
                                    String editorName = indicator.getName();
                                    Connection tdDataProvider = (Connection) analysis.getContext().getConnection();
                                    SqlExplorerUtils.getDefault().runInDQViewer(tdDataProvider, query, editorName);
                                }
                            });
                            // condition columns
                            if (IndicatorHelper.isWhereRuleIndicator(indicator)) {
                                // MOD yyin 20121126 TDQ-6477,show the menu only when Join condition exists
                                WhereRuleIndicator ind = (WhereRuleIndicator) indicator;
                                EList<JoinElement> joinConditions = ind.getJoinConditions();
                                if (joinConditions.size() > 0) {
                                    showExtraMenu = true;
                                }
                            }
                            if (isPatternFrequencyIndicator(indicator) && !isEastAsiaPatternFrequencyIndicator(indicator)) {
                                createMenuOfGenerateRegularPattern(analysis, menu, dataEntity);
                            }
                        }
                        // show extra menu to create simple analysis, help user to find the duplicated rows
                        if (showExtraMenu) {
                            MenuItem itemCreateWhereRule = new MenuItem(menu, SWT.PUSH);
                            itemCreateWhereRule.setText(DefaultMessagesImpl.getString(// $NON-NLS-1$
                            "ChartTableFactory.JoinConditionColumnsAnalysis"));
                            itemCreateWhereRule.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e1) {
                                    final StructuredSelection selectionOne = (StructuredSelection) tbViewer.getSelection();
                                    // MOD xqliu 2012-05-11 TDQ-5314
                                    Object firstElement = selectionOne.getFirstElement();
                                    if (firstElement instanceof WhereRuleChartDataEntity) {
                                        // get the WhereRuleIndicator
                                        WhereRuleChartDataEntity wrChartDataEntity = (WhereRuleChartDataEntity) firstElement;
                                        WhereRuleIndicator wrInd = (WhereRuleIndicator) wrChartDataEntity.getIndicator();
                                        // run the CreateDuplicatesAnalysisAction
                                        CreateDuplicatesAnalysisAction action = new CreateDuplicatesAnalysisAction(buildColumnsMap(wrInd));
                                        action.run();
                                    }
                                // ~ TDQ-5314
                                }

                                /**
                                 * DOC xqliu Comment method "buildColumnsMap".
                                 *
                                 * @param wrInd
                                 * @return
                                 */
                                private Map<ColumnSet, List<TdColumn>> buildColumnsMap(WhereRuleIndicator wrInd) {
                                    Map<ColumnSet, List<TdColumn>> map = new HashMap<ColumnSet, List<TdColumn>>();
                                    // get all columns from the WhereRuleIndicator
                                    List<TdColumn> columns = new ArrayList<TdColumn>();
                                    EList<JoinElement> joinConditions = wrInd.getJoinConditions();
                                    for (JoinElement joinElement : joinConditions) {
                                        // add left column
                                        TdColumn tempColumn = (TdColumn) joinElement.getColA();
                                        if (!columns.contains(tempColumn)) {
                                            columns.add(tempColumn);
                                        }
                                        // add right column
                                        tempColumn = (TdColumn) joinElement.getColB();
                                        if (!columns.contains(tempColumn)) {
                                            columns.add(tempColumn);
                                        }
                                    }
                                    // build the map
                                    for (TdColumn column : columns) {
                                        ColumnSet columnSet = ColumnHelper.getColumnOwnerAsColumnSet(column);
                                        List<TdColumn> list = map.get(columnSet);
                                        if (list == null) {
                                            list = new ArrayList<TdColumn>();
                                            map.put(columnSet, list);
                                        }
                                        list.add(column);
                                    }
                                    // get the user selected map
                                    return getUserSelectedMap(map);
                                }

                                /**
                                 * DOC xqliu Comment method "getUserSelectedMap".
                                 *
                                 * @param map
                                 * @return
                                 */
                                private Map<ColumnSet, List<TdColumn>> getUserSelectedMap(Map<ColumnSet, List<TdColumn>> map) {
                                    Map<ColumnSet, List<TdColumn>> userMap = new HashMap<ColumnSet, List<TdColumn>>();
                                    // get the column nodes
                                    List<RepositoryNode> columnNodes = getColumnNodes(map);
                                    // get the connection node
                                    RepositoryNode rootNode = getConnectionNode(map);
                                    // show the dialog, let user select the columns
                                    if (!columnNodes.isEmpty() && rootNode != null) {
                                        ColumnsMapSelectionDialog dialog = new ColumnsMapSelectionDialog(null, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
                                        DefaultMessagesImpl.getString("ColumnsMapSelectionDialog.columnSelection"), // $NON-NLS-1$
                                        columnNodes, // $NON-NLS-1$
                                        rootNode, // $NON-NLS-1$
                                        DefaultMessagesImpl.getString("ColumnsMapSelectionDialog.columnSelections"));
                                        dialog.setAllMap(map);
                                        if (dialog.open() == Window.OK) {
                                            userMap = dialog.getUserMap();
                                        }
                                    }
                                    return userMap;
                                }

                                /**
                                 * DOC xqliu Comment method "getConnectionNode".
                                 *
                                 * @param map
                                 * @return
                                 */
                                private RepositoryNode getConnectionNode(Map<ColumnSet, List<TdColumn>> map) {
                                    RepositoryNode node = null;
                                    if (map != null && !map.isEmpty()) {
                                        Connection connection = ConnectionHelper.getConnection(map.keySet().iterator().next());
                                        if (connection != null) {
                                            node = RepositoryNodeHelper.recursiveFind(connection);
                                        }
                                    }
                                    return node;
                                }

                                /**
                                 * DOC xqliu Comment method "getColumnNodes".
                                 *
                                 * @param map
                                 * @return
                                 */
                                private List<RepositoryNode> getColumnNodes(Map<ColumnSet, List<TdColumn>> map) {
                                    List<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
                                    if (map != null && !map.isEmpty()) {
                                        List<TdColumn> columns = new ArrayList<TdColumn>();
                                        Set<ColumnSet> keySet = map.keySet();
                                        for (ColumnSet cs : keySet) {
                                            columns.addAll(map.get(cs));
                                        }
                                        if (!columns.isEmpty()) {
                                            for (TdColumn column : columns) {
                                                nodes.add(RepositoryNodeHelper.recursiveFind(column));
                                            }
                                        }
                                    }
                                    return nodes;
                                }
                            });
                        }
                    } else {
                        if (analysis.getParameters().isStoreData()) {
                            // if allow drill down
                            if (indicator.isUsedMapDBMode()) {
                                DrillDownUtils.createDrillDownMenuForMapDB(dataEntity, menu, itemEntities, analysis);
                            } else {
                                DrillDownUtils.createDrillDownMenuForJava(dataEntity, menu, itemEntities, analysis);
                            }
                            if (isPatternFrequencyIndicator(indicator) && !isEastAsiaPatternFrequencyIndicator(indicator)) {
                                for (final MenuItemEntity itemEntity : itemEntities) {
                                    createMenuOfGenerateRegularPattern(analysis, menu, dataEntity);
                                }
                            }
                        }
                        // MOD by zshen feature 11574:add menu "Generate regular pattern" to date pattern
                        if (isDatePatternFrequencyIndicator(indicator)) {
                            final DatePatternFreqIndicator dateIndicator = (DatePatternFreqIndicator) indicator;
                            MenuItem itemCreatePatt = new MenuItem(menu, SWT.PUSH);
                            // $NON-NLS-1$
                            itemCreatePatt.setText(DefaultMessagesImpl.getString("ChartTableFactory.GenerateRegularPattern"));
                            itemCreatePatt.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
                            itemCreatePatt.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e1) {
                                    DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(analysis);
                                    IFolder folder = ResourceManager.getPatternRegexFolder();
                                    String model = dataEntity.getLabel();
                                    String regex = dateIndicator.getRegex(model);
                                    new CreatePatternAction(folder, ExpressionType.REGEXP, "'" + regex + "'", model == null ? "" : "match \"" + model + "\"", language.getDbmsName()).run();
                                }
                            });
                        }
                    }
                    addJobGenerationMenu(menu, analysis, indicator);
                    // ~11574
                    menu.setVisible(true);
                }
            }
        }
    });
    // add tooltip
    TableUtils.addTooltipForTable(table);
    TableUtils.addActionTooltip(table);
}
Also used : HashMap(java.util.HashMap) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) Menu(org.eclipse.swt.widgets.Menu) CreatePatternAction(org.talend.dataprofiler.core.pattern.actions.CreatePatternAction) CreateDuplicatesAnalysisAction(org.talend.dataprofiler.core.ui.action.actions.CreateDuplicatesAnalysisAction) TdTable(org.talend.cwm.relational.TdTable) Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) MenuItem(org.eclipse.swt.widgets.MenuItem) WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) RepositoryNode(org.talend.repository.model.RepositoryNode) ColumnsMapSelectionDialog(org.talend.dataprofiler.core.ui.dialog.ColumnsMapSelectionDialog) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) EastAsiaPatternLowFreqIndicator(org.talend.dataquality.indicators.EastAsiaPatternLowFreqIndicator) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) EastAsiaPatternFreqIndicator(org.talend.dataquality.indicators.EastAsiaPatternFreqIndicator) WellFormE164PhoneCountIndicator(org.talend.dataquality.indicators.WellFormE164PhoneCountIndicator) PatternLowFreqIndicator(org.talend.dataquality.indicators.PatternLowFreqIndicator) PatternFreqIndicator(org.talend.dataquality.indicators.PatternFreqIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) ValidPhoneCountIndicator(org.talend.dataquality.indicators.ValidPhoneCountIndicator) WellFormIntePhoneCountIndicator(org.talend.dataquality.indicators.WellFormIntePhoneCountIndicator) PossiblePhoneCountIndicator(org.talend.dataquality.indicators.PossiblePhoneCountIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) SqlPatternMatchingIndicator(org.talend.dataquality.indicators.SqlPatternMatchingIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) WellFormNationalPhoneCountIndicator(org.talend.dataquality.indicators.WellFormNationalPhoneCountIndicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator) JoinElement(org.talend.dataquality.rules.JoinElement) EList(org.eclipse.emf.common.util.EList) TdColumn(org.talend.cwm.relational.TdColumn) WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) Map(java.util.Map) HashMap(java.util.HashMap) PatternExplorer(org.talend.dq.analysis.explore.PatternExplorer) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IFolder (org.eclipse.core.resources.IFolder)4 CreatePatternAction (org.talend.dataprofiler.core.pattern.actions.CreatePatternAction)4 DbmsLanguage (org.talend.dq.dbms.DbmsLanguage)3 ArrayList (java.util.ArrayList)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 EList (org.eclipse.emf.common.util.EList)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 CCombo (org.eclipse.swt.custom.CCombo)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1