Search in sources :

Example 1 with PatternTestView

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

the class PatternMasterDetailsPage method creatNewExpressLine.

private void creatNewExpressLine(RegularExpression regularExpress) {
    final Composite expressComp = new Composite(componentsComp, SWT.NONE);
    expressComp.setLayout(new GridLayout(10, false));
    final CCombo combo = new CCombo(expressComp, SWT.BORDER);
    combo.setEditable(false);
    combo.setItems(remainDBTypeList.toArray(new String[remainDBTypeList.size()]));
    final RegularExpression finalRegExpress = regularExpress;
    String language = regularExpress.getExpression().getLanguage();
    String body = regularExpress.getExpression().getBody();
    if (language == null) {
        combo.setText(remainDBTypeList.get(0));
    } else {
        combo.setText(PatternLanguageType.findNameByLanguage(language));
    }
    GridDataFactory.fillDefaults().span(2, 1).grab(false, false).applyTo(combo);
    combo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String lang = combo.getText();
            finalRegExpress.getExpression().setLanguage(PatternLanguageType.findLanguageByName(lang));
            // added yyin 20120815 TDQ-5982
            finalRegExpress.getExpression().setModificationDate(getCurrentDateTime());
            setDirty(true);
        }
    });
    final Text patternText = new Text(expressComp, SWT.BORDER);
    patternText.setText(body == null ? PluginConstant.EMPTY_STRING : body);
    GridDataFactory.fillDefaults().span(6, 1).grab(true, true).applyTo(patternText);
    // TDQ-10804, if the content is too long, the below "add" button will be disapper.set widthHint to '0' so that
    // the Text width isn't adaptive width.
    ((GridData) patternText.getLayoutData()).widthHint = 0;
    patternText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            finalRegExpress.getExpression().setBody(patternText.getText());
            // added yyin 20120815 TDQ-5982
            finalRegExpress.getExpression().setModificationDate(getCurrentDateTime());
            setDirty(true);
        }
    });
    Button delButton = new Button(expressComp, SWT.NONE);
    delButton.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
    // $NON-NLS-1$
    delButton.setToolTipText(DefaultMessagesImpl.getString("PatternMasterDetailsPage.delete"));
    GridDataFactory.fillDefaults().span(1, 1).grab(false, false).applyTo(delButton);
    delButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            tempPatternComponents.remove(finalRegExpress);
            expressComp.dispose();
            patternDefinitionSection.setExpanded(true);
            setDirty(true);
        }
    });
    // MOD scorreia 2008-12-15 do not display button when pattern is "SQL Like"
    if (!ExpressionType.SQL_LIKE.getLiteral().equals(expressionType)) {
        Button testPatternButton = new Button(expressComp, SWT.NONE);
        // testPatternButton.setImage(ImageLib.getImage(ImageLib.));
        // $NON-NLS-1$
        testPatternButton.setText(DefaultMessagesImpl.getString("PatternMasterDetailsPage.test"));
        // $NON-NLS-1$
        testPatternButton.setToolTipText(DefaultMessagesImpl.getString("PatternMasterDetailsPage.patternTest"));
        GridDataFactory.fillDefaults().span(1, 1).grab(false, false).applyTo(testPatternButton);
        testPatternButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // Open test pattern viewer
                PatternTestView patternTestView = CorePlugin.getDefault().getPatternTestView();
                patternTestView.setPatternExpression(PatternMasterDetailsPage.this, getCurrentModelElement(), finalRegExpress);
            }
        });
    }
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(expressComp);
}
Also used : RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PatternTestView(org.talend.dataprofiler.core.ui.views.PatternTestView) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

CCombo (org.eclipse.swt.custom.CCombo)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Text (org.eclipse.swt.widgets.Text)1 PatternTestView (org.talend.dataprofiler.core.ui.views.PatternTestView)1 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)1