Search in sources :

Example 51 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project statecharts by Yakindu.

the class SGenWizardPage2 method createObjectTree.

private void createObjectTree(Composite container) {
    lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    lblNewLabel.setText("Choose: " + getSelectedGenerator().getContentType());
    resourceTree = new CheckboxTreeViewer(container, SWT.BORDER);
    resourceTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    resourceTree.setContentProvider(new WorkspaceTreeContentProvider());
    resourceTree.setLabelProvider(new SGenWorkspaceLabelProvider());
    TreePropagatingCheckStateListener checkStateListener = new TreePropagatingCheckStateListener(resourceTree) {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            super.checkStateChanged(event);
        }
    };
    resourceTree.addCheckStateListener(checkStateListener);
    resourceTree.addDoubleClickListener(new TreeExpandingDoubleClickListener(resourceTree, checkStateListener));
    resourceTree.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    resourceTree.setFilters(new ViewerFilter[] { new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            // '.' prefixed folder
            if (element instanceof IFolder) {
                return !((IFolder) element).getName().startsWith(".");
            }
            return true;
        }
    } });
}
Also used : WorkspaceTreeContentProvider(org.yakindu.sct.ui.wizards.WorkspaceTreeContentProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Label(org.eclipse.swt.widgets.Label) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridData(org.eclipse.swt.layout.GridData) EObject(org.eclipse.emf.ecore.EObject) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) IFolder(org.eclipse.core.resources.IFolder)

Example 52 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project tdq-studio-se by Talend.

the class AbstractJarSelectDialog method createManageTreeViewer.

/**
 * DOC msjian Comment method "createManageTreeViewer".
 *
 * @param parent
 * @return
 */
protected CheckboxTreeViewer createManageTreeViewer(Composite parent) {
    if (fContainerMode) {
        fManageViewer = new ContainerCheckedTreeViewer(parent, SWT.BORDER);
    } else {
        fManageViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
    }
    fManageViewer.setContentProvider(fContentProvider);
    fManageViewer.setLabelProvider(fLabelProvider);
    fManageViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateOKStatus();
        }
    });
    fManageViewer.setComparator(fComparator);
    if (fFilters != null) {
        for (int i = 0; i != fFilters.size(); i++) {
            fManageViewer.addFilter((ViewerFilter) fFilters.get(i));
        }
    }
    fManageViewer.setInput(fInput);
    return fManageViewer;
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 53 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project tdq-studio-se by Talend.

the class TablesSelectionDialog method addCheckedListener.

@Override
protected void addCheckedListener() {
    // When user checks a checkbox in the tree, check all its children
    getTreeViewer().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            TreePath treePath = new TreePath(new Object[] { event.getElement() });
            getTreeViewer().setSelection(new TreeSelection(treePath));
            if (event.getChecked()) {
                Object element = event.getElement();
                getTreeViewer().setSubtreeChecked(element, true);
                if (element instanceof IRepositoryNode) {
                    setOutput(element);
                    handleTablesChecked((IRepositoryNode) element, true);
                }
            } else {
                Object element = event.getElement();
                getTreeViewer().setSubtreeChecked(element, false);
                if (element instanceof IRepositoryNode) {
                    setOutput(element);
                    handleTablesChecked((IRepositoryNode) element, false);
                }
            }
            updateOKStatus();
        }
    });
    getTableViewer().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof DBTableRepNode || element instanceof DBViewRepNode) {
                handleTableChecked((IRepositoryNode) element, event.getChecked());
            }
        }
    });
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TreePath(org.eclipse.jface.viewers.TreePath) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TreeSelection(org.eclipse.jface.viewers.TreeSelection) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 54 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project tdq-studio-se by Talend.

the class TwoPartCheckSelectionDialog method createFirstPart.

/**
 * Creates the tree viewer.
 *
 * @param parent the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createFirstPart(Composite parent) {
    if (fContainerMode) {
        if (DIALOG_TYPE_TABLE == this.getDialogType()) {
            fViewer = new TableSelectionViewer(parent, SWT.BORDER);
        } else if (!this.addConnFilter) {
            fViewer = new MatchColumnSelectionViewer(parent, SWT.BORDER);
        } else {
            fViewer = new ColumnSelectionViewer(parent, SWT.BORDER);
        }
    // {
    // 
    // protected void handleTreeExpand(TreeEvent event) {
    // super.handleTreeExpand(event);
    // checkElementChecked();
    // }
    // };
    } else {
        fViewer = new CheckboxTreeViewer(parent, SWT.BORDER) {

            @Override
            protected void handleTreeExpand(TreeEvent event) {
                super.handleTreeExpand(event);
            // checkElementChecked();
            }
        };
    }
    fViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(fViewer.getTree());
    fViewer.setContentProvider(fContentProvider);
    // mod gdbu 2011-7-25 bug 23220
    ((ResourceViewContentProvider) fContentProvider).setTreeViewer(fViewer);
    // ~23220
    fViewer.setLabelProvider(fLabelProvider);
    fViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateOKStatus();
        }
    });
    fViewer.setComparator(fComparator);
    if (fFilters != null) {
        for (int i = 0; i != fFilters.size(); i++) {
            fViewer.addFilter(fFilters.get(i));
        }
    }
    fViewer.setInput(fInput);
    // fViewer.
    fViewer.addSelectionChangedListener(this);
    return fViewer;
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) TreeEvent(org.eclipse.swt.events.TreeEvent) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 55 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project tdq-studio-se by Talend.

the class ColumnsSelectionDialog method addCheckedListener.

/*
     * (non-Javadoc)
     *
     * @seeorg.talend.dataprofiler.core.ui.dialog.TwoPartCheckSelectionDialog# addCheckedListener()
     */
@Override
protected void addCheckedListener() {
    // When user checks a checkbox in the tree, check all its children
    getTreeViewer().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            // Added TDQ-8718 20140506 yyin: should not load from db when checking
            DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
            DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
            try {
                ColumnSelectionViewer columnViewer = (ColumnSelectionViewer) event.getSource();
                TreePath treePath = new TreePath(new Object[] { event.getElement() });
                columnViewer.setSelection(new TreeSelection(treePath));
                setOutput(event.getElement());
                RepositoryNode selectedNode = (RepositoryNode) event.getElement();
                if (selectedNode instanceof DBTableRepNode || selectedNode instanceof DBViewRepNode || selectedNode instanceof DFTableRepNode) {
                    handleTreeElementsChecked(selectedNode, event.getChecked());
                } else {
                    checkChildrenElements(selectedNode, event.getChecked());
                }
                getTreeViewer().setSubtreeChecked(event.getElement(), event.getChecked());
                updateStatusBySelection();
            } finally {
                // Added TDQ-8718 20140506 yyin
                DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
                DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
            }
        }

        private void checkChildrenElements(RepositoryNode repNode, Boolean checkedFlag) {
            Set<?> keySet = modelElementCheckedMap.keySet();
            RepositoryNode[] repNodeArray = (RepositoryNode[]) modelElementCheckedMap.keySet().toArray(new RepositoryNode[keySet.size()]);
            for (RepositoryNode reposNode : repNodeArray) {
                RepositoryNode parentNode = reposNode.getParent();
                while (parentNode != null) {
                    if (repNode.equals(parentNode)) {
                        handleTreeElementsChecked(reposNode, checkedFlag);
                        break;
                    } else {
                        parentNode = parentNode.getParent();
                    }
                }
            }
        }
    });
    getTableViewer().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            handleTableElementsChecked((RepositoryNode) event.getElement(), event.getChecked());
            updateStatusBySelection();
        }
    });
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) Set(java.util.Set) TreePath(org.eclipse.jface.viewers.TreePath) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TreeSelection(org.eclipse.jface.viewers.TreeSelection) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)136 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)133 GridData (org.eclipse.swt.layout.GridData)89 Composite (org.eclipse.swt.widgets.Composite)68 GridLayout (org.eclipse.swt.layout.GridLayout)61 SelectionEvent (org.eclipse.swt.events.SelectionEvent)56 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)45 Button (org.eclipse.swt.widgets.Button)43 Label (org.eclipse.swt.widgets.Label)42 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)31 Table (org.eclipse.swt.widgets.Table)30 Viewer (org.eclipse.jface.viewers.Viewer)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)26 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)26 TableColumn (org.eclipse.swt.widgets.TableColumn)23 ArrayList (java.util.ArrayList)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20 Text (org.eclipse.swt.widgets.Text)18 List (java.util.List)16