Search in sources :

Example 11 with CharactersMapping

use of org.talend.dataquality.indicators.definition.CharactersMapping in project tdq-studio-se by Talend.

the class IndicatorDefinitionMaterPage method createCMAddButton.

/**
 * DOC xqliu Comment method "createCMAddButton".
 *
 * @param composite
 */
private void createCMAddButton(Composite composite) {
    final Button addButton = new Button(composite, SWT.NONE);
    addButton.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
    // $NON-NLS-1$
    addButton.setToolTipText(DefaultMessagesImpl.getString("PatternMasterDetailsPage.add"));
    GridData labelGd = new GridData();
    labelGd.horizontalAlignment = SWT.CENTER;
    labelGd.widthHint = 65;
    addButton.setLayoutData(labelGd);
    addButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            remainDBTypeListCM.clear();
            remainDBTypeListCM.addAll(allDBTypeList);
            for (CharactersMapping cm : charactersMappingMapTemp.values()) {
                String language = cm.getLanguage();
                String languageName = PatternLanguageType.findNameByLanguage(language);
                remainDBTypeListCM.remove(languageName);
            }
            if (remainDBTypeListCM.size() == 0) {
                MessageDialog.openWarning(Display.getCurrent().getActiveShell(), // $NON-NLS-1$
                DefaultMessagesImpl.getString("PatternMasterDetailsPage.warning"), // $NON-NLS-1$
                DefaultMessagesImpl.getString("PatternMasterDetailsPage.patternExpression"));
                return;
            }
            String language = PatternLanguageType.findLanguageByName(remainDBTypeListCM.get(0));
            CharactersMapping cm = DefinitionFactory.eINSTANCE.createCharactersMapping();
            cm.setLanguage(language);
            cm.setCharactersToReplace(BODY_CHARACTERS_TO_REPLACE);
            cm.setReplacementCharacters(BODY_REPLACEMENT_CHARACTERS);
            createNewCharactersMappingLine(language, cm);
            charactersMappingMapTemp.put(language, cm);
            charactersMappingSection.setExpanded(true);
            setDirty(true);
        }
    });
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 12 with CharactersMapping

use of org.talend.dataquality.indicators.definition.CharactersMapping in project tdq-studio-se by Talend.

the class IndicatorDefinitionMaterPage method createCharactersMappingComp.

/**
 * DOC xqliu Comment method "createCharactersMappingComp".
 *
 * @param charactersMappingSection
 * @return
 */
private Composite createCharactersMappingComp() {
    Composite composite = toolkit.createComposite(charactersMappingSection);
    composite.setLayout(new GridLayout());
    charactersMappingLineComp = new Composite(composite, SWT.NONE);
    charactersMappingLineComp.setLayout(new GridLayout());
    charactersMappingLineComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (getCurrentModelElement() != null) {
        EList<CharactersMapping> charactersMappings = getCurrentModelElement().getCharactersMapping();
        if (charactersMappings != null && charactersMappings.size() > 0) {
            for (CharactersMapping charactersMapping : charactersMappings) {
                recordCharactersMapping(charactersMapping);
            }
        }
        charactersMappingMapTemp.clear();
        for (String key : charactersMappingMap.keySet()) {
            charactersMappingMapTemp.put(key, cloneCharactersMapping(charactersMappingMap.get(key)));
        }
        for (String language : charactersMappingMapTemp.keySet()) {
            createNewCharactersMappingLine(language, charactersMappingMapTemp.get(language));
        }
    }
    createCMAddButton(composite);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData)

Aggregations

CharactersMapping (org.talend.dataquality.indicators.definition.CharactersMapping)12 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)4 Test (org.junit.Test)3 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)3 GridData (org.eclipse.swt.layout.GridData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)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 TdColumn (org.talend.cwm.relational.TdColumn)1 ReturnCode (org.talend.utils.sugars.ReturnCode)1 Expression (orgomg.cwm.objectmodel.core.Expression)1