Search in sources :

Example 6 with CheckedTreeSelectionDialog

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

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

the class AnalysisColumnTreeViewer method addColumnUdi.

/**
 * DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
 *
 * @param treeItem
 * @param meIndicator
 * @param columnIndex
 * @return
 */
private TreeEditor addColumnUdi(final TreeItem treeItem, final ModelElementIndicator meIndicator, int columnIndex) {
    TreeEditor addUdiEditor = new TreeEditor(tree);
    // $NON-NLS-1$
    Label addUdiLabl = createTreeItemLabel(tree, ImageLib.ADD_IND_DEFINITION, "AnalysisColumnTreeViewer.addUdi");
    addUdiLabl.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            DataManager dm = getAnalysis().getContext().getConnection();
            if (dm == null) {
                masterPage.doSave(null);
            }
            CheckedTreeSelectionDialog dialog = UDIUtils.createUdiCheckedTreeSelectionDialog(meIndicator);
            if (dialog.open() == Window.OK) {
                // MOD qiongli 2012-10-24 TDQ-6308,just remove some deselected indicatorUnit then set dirty to
                // true,just create new indicatorUnit for some new added UDI then set dirty to true.
                List<IndicatorDefinition> allSelectedIndicatorDefinitions = new ArrayList<IndicatorDefinition>();
                Set<String> allSelectedIndNames = new HashSet<String>();
                for (Object obj : dialog.getResult()) {
                    if (obj instanceof SysIndicatorDefinitionRepNode) {
                        IndicatorDefinition udid = ((SysIndicatorDefinitionRepNode) obj).getIndicatorDefinition();
                        allSelectedIndicatorDefinitions.add(udid);
                        if (udid != null) {
                            allSelectedIndNames.add(udid.getName());
                        }
                    }
                }
                Set<String> oldSelectedIndNames = new HashSet<String>();
                for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
                    Indicator indicator = indicatorUnit.getIndicator();
                    if (indicator instanceof UserDefIndicator) {
                        if (allSelectedIndNames.contains(indicator.getName())) {
                            oldSelectedIndNames.add(indicator.getName());
                        } else {
                            // remove the UDI from UI need to insert this UDI into removeList
                            deleteIndicatorItems(meIndicator, indicatorUnit);
                            if (!isDirty()) {
                                setDirty(true);
                            }
                        }
                    }
                }
                treeItem.removeAll();
                for (IndicatorDefinition udid : allSelectedIndicatorDefinitions) {
                    if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
                        continue;
                    }
                    IndicatorUnit[] addIndicatorUnits = null;
                    try {
                        addIndicatorUnits = UDIUtils.createIndicatorUnit(udid, meIndicator, getAnalysis());
                    } catch (Throwable e1) {
                        log.warn(e1, e1);
                    }
                    if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
                        for (IndicatorUnit unit : addIndicatorUnits) {
                            createOneUnit(treeItem, unit);
                        }
                        if (!isDirty()) {
                            setDirty(true);
                        }
                    }
                }
                treeItem.setExpanded(true);
                masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
            }
        }
    });
    addUdiEditor.minimumWidth = addUdiLabl.getImage().getBounds().width;
    addUdiEditor.setEditor(addUdiLabl, treeItem, columnIndex);
    return addUdiEditor;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Set(java.util.Set) HashSet(java.util.HashSet) TreeEditor(org.eclipse.swt.custom.TreeEditor) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) List(java.util.List) ArrayList(java.util.ArrayList) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 8 with CheckedTreeSelectionDialog

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

the class PatternLabelProvider method createPatternCheckedTreeSelectionDialog.

/**
 * create CheckedTreeSelectionDialog for patterns.
 *
 * @param node Pattern root RepositoryNode.
 * @return
 */
public static CheckedTreeSelectionDialog createPatternCheckedTreeSelectionDialog(IRepositoryNode node) {
    CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
    dialog.setInput(node);
    dialog.setValidator(new ISelectionStatusValidator() {

        public IStatus validate(Object[] selection) {
            for (Object patte : selection) {
                if (patte instanceof PatternRepNode) {
                    PatternRepNode patternNode = (PatternRepNode) patte;
                    Pattern findPattern = patternNode.getPattern();
                    boolean validStatus = TaggedValueHelper.getValidStatus(findPattern);
                    if (!validStatus) {
                        return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
                        "AnalysisColumnTreeViewer.chooseValidPatterns"));
                    }
                }
            }
            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("AnalysisColumnTreeViewer.patternSelector"));
    // $NON-NLS-1$
    dialog.setMessage(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.patterns"));
    dialog.setSize(80, 30);
    return dialog;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Pattern(org.talend.dataquality.domain.pattern.Pattern) IStatus(org.eclipse.core.runtime.IStatus) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider) PatternRepNode(org.talend.dq.nodes.PatternRepNode)

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