Search in sources :

Example 1 with CheckedTreeSelectionDialog

use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog in project tdq-studio-se by Talend.

the class PatternMouseAdapter method mouseDown.

@Override
public void mouseDown(MouseEvent e) {
    DataManager dm = analysis.getContext().getConnection();
    if (dm == null) {
        masterPage.doSave(null);
    }
    // MOD gdbu 2011-8-26 bug : TDQ-2169
    IRepositoryNode patternFolderNode = getPatternSelectDialogInputData();
    if (patternFolderNode == null) {
        return;
    }
    CheckedTreeSelectionDialog dialog = PatternUtilities.createPatternCheckedTreeSelectionDialog(patternFolderNode);
    if (null != filters) {
        for (ViewerFilter filter : filters) {
            dialog.addFilter(filter);
        }
    }
    // ~TDQ-2169
    Object[] selectedRepNodes = PatternUtilities.getPatternRepNodesByIndicator(meIndicator);
    dialog.setInitialSelections(selectedRepNodes);
    dialog.create();
    if (dialog.open() == Window.OK) {
        // MOD qiongli 2012-10-17 TDQ-5923,just remove some deselected indicatorUnit,just create new indicatorUnit
        // for some new added pattern nodes.
        List<PatternRepNode> allSelectedPatternNodes = new ArrayList<PatternRepNode>();
        Set<String> allSelectedNodeNames = new HashSet<String>();
        for (Object obj : dialog.getResult()) {
            if (obj instanceof PatternRepNode) {
                PatternRepNode patternNode = (PatternRepNode) obj;
                allSelectedPatternNodes.add(patternNode);
                allSelectedNodeNames.add(patternNode.getLabel());
            }
        }
        Set<String> oldSelectedNodeNames = new HashSet<String>();
        Map<String, IndicatorUnit> oldSelectedUnits = new HashMap<String, IndicatorUnit>();
        for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
            Indicator indicator = indicatorUnit.getIndicator();
            if (indicator instanceof PatternMatchingIndicator) {
                if (!allSelectedNodeNames.contains(indicator.getName())) {
                    // this method will deal dependency with same time
                    columnDropTree.deleteIndicatorItems(meIndicator, indicatorUnit);
                    if (!columnDropTree.isDirty()) {
                        columnDropTree.setDirty(true);
                    }
                } else {
                    oldSelectedNodeNames.add(indicator.getName());
                    oldSelectedUnits.put(indicator.getName(), indicatorUnit);
                }
            }
        }
        // Added yyin 20121121 TDQ-6329: after remove all, should also add the old selected patterns
        // because the columnset does not have pagination, can not refresh automatically
        boolean addOldSelected = false;
        if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
            addOldSelected = true;
        }
        if (addOldSelected) {
            for (TreeItem child : treeItem.getItems()) {
                masterPage.getTreeViewer().removeItemBranch(child);
            }
        }
        // ~
        treeItem.removeAll();
        for (PatternRepNode patternNode : allSelectedPatternNodes) {
            if (oldSelectedNodeNames.contains(patternNode.getLabel()) && !addOldSelected) {
                continue;
            }
            TypedReturnCode<IndicatorUnit> trc = PatternUtilities.createIndicatorUnit(patternNode.getPattern(), meIndicator, analysis);
            if (trc.isOk()) {
                createOneUnit(trc.getObject());
                // TDQ-8860 add msjian 2014-4-30:check whether show allmatchindicator in the indicators section
                if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
                    EventManager.getInstance().publish(analysis, EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, null);
                }
            // TDQ-8860~
            }
        }
        treeItem.setExpanded(true);
        if (masterPage instanceof ColumnAnalysisDetailsPage) {
            ColumnAnalysisDetailsPage page = (ColumnAnalysisDetailsPage) masterPage;
            page.refreshTheTree(page.getCurrentModelElementIndicators());
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) HashMap(java.util.HashMap) TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) ColumnSetAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnSetAnalysisDetailsPage) ColumnAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnAnalysisDetailsPage) PatternRepNode(org.talend.dq.nodes.PatternRepNode) HashSet(java.util.HashSet)

Example 2 with CheckedTreeSelectionDialog

use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog in project tdq-studio-se by Talend.

the class IndicatorSettingsPage method openAnalysesSelectionDialog.

/**
 * DOC qzhang Comment method "openAnalysesSelectionDialog".
 */
protected void openAnalysesSelectionDialog(boolean isLowCase) {
    SpecialLimitFrequencyAnalysisFilter limitFilter = new SpecialLimitFrequencyAnalysisFilter(isLowCase ? 0 : freResultLimit, isLowCase ? lowFreResultLimit : 0);
    CheckedTreeSelectionDialog checkedTreeSelectionDialog = new CheckedTreeSelectionDialog(this.getShell(), new DQRepositoryViewLabelProviderWithFilter(limitFilter), new ResourceViewContentProvider());
    // $NON-NLS-1$
    checkedTreeSelectionDialog.setTitle(DefaultMessagesImpl.getString("IndicatorSettingsPage.analysisSelectDialog.title"));
    checkedTreeSelectionDialog.setMessage(// $NON-NLS-1$
    DefaultMessagesImpl.getString("IndicatorSettingsPage.analysisSelectDialog.message"));
    checkedTreeSelectionDialog.setContainerMode(true);
    checkedTreeSelectionDialog.addFilter(new SelectAnalysisDialogNodeFilter());
    checkedTreeSelectionDialog.addFilter(limitFilter);
    DQRepositoryNode analysisSelectDialogInputData = AnalysisUtils.getAnalysisSelectDialogInputDataWithoutRef(EResourceConstant.ANALYSIS);
    checkedTreeSelectionDialog.setInput(analysisSelectDialogInputData);
    if (checkedTreeSelectionDialog.open() == Dialog.OK) {
        Object[] result = checkedTreeSelectionDialog.getResult();
        for (Object obj : result) {
            if (obj instanceof AnalysisRepNode) {
                AnalysisRepNode anaNode = (AnalysisRepNode) obj;
                modifyAndSaveLimit(anaNode, isLowCase);
            }
        }
    }
}
Also used : DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) SpecialLimitFrequencyAnalysisFilter(org.talend.dataprofiler.core.ui.filters.SpecialLimitFrequencyAnalysisFilter) SelectAnalysisDialogNodeFilter(org.talend.dataprofiler.core.ui.filters.SelectAnalysisDialogNodeFilter) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) DQRepositoryViewLabelProviderWithFilter(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProviderWithFilter)

Example 3 with CheckedTreeSelectionDialog

use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog in project tdi-studio-se by Talend.

the class ImportRulesFromRepository method selectRules.

private Object[] selectRules(IFolder rulesFolder) {
    CheckedTreeSelectionDialog rsd = getRulesDialog();
    rsd.setInput(rulesFolder);
    if (selectObjects != null) {
        rsd.setInitialSelections(selectObjects);
    }
    rsd.open();
    selectObjects = rsd.getResult();
    return selectObjects;
}
Also used : CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog)

Example 4 with CheckedTreeSelectionDialog

use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog 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 5 with CheckedTreeSelectionDialog

use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog in project tdq-studio-se by Talend.

the class SetJDBCDriverPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(new GridLayout(3, false));
    mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout2 = (GridLayout) mainComposite.getLayout();
    layout2.marginHeight = 0;
    layout2.marginTop = 0;
    layout2.marginBottom = 0;
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.horizontalSpan = 3;
    header = new Label(mainComposite, SWT.WRAP);
    header.setLayoutData(gridData);
    // $NON-NLS-1$
    header.setText(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.heard"));
    dbTypeLabel = new Label(mainComposite, SWT.WRAP);
    // $NON-NLS-1$
    dbTypeLabel.setText(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.dbType") + dbType_jdbc);
    dbTypeLabel.setLayoutData(gridData);
    generalJdbcUrlText = new LabelledText(mainComposite, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.general.url"), // $NON-NLS-1$
    2);
    String url = getPreferenceStore().getString(URL_KEY);
    generalJdbcUrlText.setText(url != null ? url : PluginConstant.EMPTY_STRING);
    generalJdbcDriverjarText = new LabelledText(mainComposite, // $NON-NLS-1$
    DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.general.jarfile"), 1);
    String driver = getPreferenceStore().getString(DRIVER_KEY);
    generalJdbcDriverjarText.setText(driver != null ? driver : PluginConstant.EMPTY_STRING);
    browseJarFilesButton = new Button(mainComposite, SWT.NONE);
    // $NON-NLS-1$
    browseJarFilesButton.setText("...");
    generalJdbcClassNameText = new LabelledCombo(mainComposite, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.general.classname"), "", null, 1, true, // $NON-NLS-1$
    SWT.NONE);
    String className = getPreferenceStore().getString(CLASSNAME_KEY);
    generalJdbcClassNameText.setText(className != null ? className : PluginConstant.EMPTY_STRING);
    browseClassButton = new Button(mainComposite, SWT.NONE);
    // $NON-NLS-1$
    browseClassButton.setText("...");
    generalJdbcUserText = new LabelledText(mainComposite, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.general.user"), // $NON-NLS-1$
    2);
    String userName = getPreferenceStore().getString(USERNAME_KEY);
    generalJdbcUserText.setText(userName != null ? userName : PluginConstant.EMPTY_STRING);
    generalJdbcPasswordText = new LabelledText(mainComposite, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.general.password"), // $NON-NLS-1$
    2);
    // see
    generalJdbcPasswordText.getTextControl().setEchoChar('*');
    String password = getPreferenceStore().getString(PASSWORD_KEY);
    generalJdbcPasswordText.setText(password != null ? password : PluginConstant.EMPTY_STRING);
    generalMappingFileText = new LabelledText(mainComposite, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.general.mapping"), // $NON-NLS-1$
    1);
    String mapFile = getPreferenceStore().getString(MAPFILE_KEY);
    generalMappingFileText.setText(mapFile != null ? mapFile : PluginConstant.EMPTY_STRING);
    generalMappingSelectButton = new Button(mainComposite, SWT.NONE);
    // $NON-NLS-1$
    generalMappingSelectButton.setText("...");
    applyButton = new Button(mainComposite, SWT.CENTER | SWT.BOTTOM);
    // $NON-NLS-1$
    applyButton.setText(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.selectConnectionButton"));
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    gd.horizontalSpan = 3;
    applyButton.setLayoutData(gd);
    applyButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            CheckedTreeSelectionDialog dialog = createConnSelectDialog();
            dialog.create();
            if (dialog.open() == Window.OK) {
                Object[] selects = dialog.getResult();
                if (selects != null && selects.length > 0) {
                    boolean isConfirm = MessageDialog.openConfirm(dialog.getShell(), // $NON-NLS-1$
                    DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.confirmTitle"), // $NON-NLS-1$
                    DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.confirmContent"));
                    if (!isConfirm) {
                        return;
                    }
                    saveDatabases(selects);
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    browseJarFilesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            SelectDatabaseJarDialog dialog = new SelectDatabaseJarDialog(getShell(), generalJdbcDriverjarText.getText());
            if (dialog.open() == Window.OK) {
                generalJdbcDriverjarText.setText(dialog.getJarsString());
            }
        }
    });
    browseClassButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            generalJdbcClassNameText.removeAll();
            for (String stringToFile : generalJdbcDriverjarText.getText().trim().split(";")) {
                // $NON-NLS-1$
                File file = new File(stringToFile);
                if (file != null) {
                    try {
                        MyURLClassLoader cl = new MyURLClassLoader(file.toURL());
                        Class[] classes = cl.getAssignableClasses(Driver.class);
                        for (Class classe : classes) {
                            generalJdbcClassNameText.add(classe.getName());
                        }
                    } catch (Exception ex) {
                        ExceptionHandler.process(ex);
                    }
                }
            }
            if (generalJdbcClassNameText.getItemCount() > 0) {
                String driverClassName = generalJdbcClassNameText.getItem(0);
                generalJdbcClassNameText.setText(driverClassName);
            }
        }
    });
    generalMappingSelectButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            MappingFileSelectDialog dialog = new MappingFileSelectDialog(getShell());
            dialog.open();
            generalMappingFileText.setText(dialog.getSelectId());
        }
    });
    return mainComposite;
}
Also used : LabelledText(org.talend.commons.ui.swt.formtools.LabelledText) LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) Composite(org.eclipse.swt.widgets.Composite) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MyURLClassLoader(org.talend.commons.ui.utils.loader.MyURLClassLoader) Driver(java.sql.Driver) PersistenceException(org.talend.commons.exception.PersistenceException) SelectDatabaseJarDialog(org.talend.repository.ui.wizards.metadata.connection.database.SelectDatabaseJarDialog) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MappingFileSelectDialog(org.talend.metadata.managment.ui.dialog.MappingFileSelectDialog) File(java.io.File) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

CheckedTreeSelectionDialog (org.eclipse.ui.dialogs.CheckedTreeSelectionDialog)8 ResourceViewContentProvider (org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider)4 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 ISelectionStatusValidator (org.eclipse.ui.dialogs.ISelectionStatusValidator)3 DQRepositoryViewLabelProvider (org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 Label (org.eclipse.swt.widgets.Label)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)2 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)2 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)2 File (java.io.File)1 Driver (java.sql.Driver)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Set (java.util.Set)1