Search in sources :

Example 96 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.

the class CallTreeTabPage method createCallTreeViewer.

/**
     * Creates the call tree viewer.
     * 
     * @param composite The parent composite
     * @param propertySheet The property sheet
     */
private void createCallTreeViewer(Composite composite, PropertySheet propertySheet) {
    filteredTree = new CallTreeFilteredTree(composite, propertySheet.getViewSite().getActionBars()) {

        @Override
        protected void addMenus(IMenuManager manager) {
            super.addMenus(manager);
            manager.add(new Separator());
            manager.add(new ConfigureCpuProfilerAction(cpuSection));
        }
    };
    TreeViewer callTreeViewer = filteredTree.getViewer();
    callTreeViewer.setContentProvider(new CallTreeContentProvider());
    callTreeViewer.setLabelProvider(new CallTreeLabelProvider(callTreeViewer));
    callTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            filteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
}
Also used : ConfigureCpuProfilerAction(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.ConfigureCpuProfilerAction) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator)

Example 97 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.

the class CallerCalleeTabPage method createCallerViewer.

/**
     * Creates the caller viewer.
     * 
     * @param parent The parent composite
     * @param propertySheet The property sheet
     */
private void createCallerViewer(Composite parent, PropertySheet propertySheet) {
    callerFilteredTree = new HotSpotsFilteredTree(parent, propertySheet.getViewSite().getActionBars()) {

        @Override
        protected void addMenus(IMenuManager manager) {
            manager.add(new Separator());
            manager.add(new ConfigureCpuProfilerAction(cpuSection));
        }

        @Override
        public ViewerType getViewerType() {
            return ViewerType.Caller;
        }

        @Override
        protected String getMethodColumnName() {
            return Messages.callerColumnLabel;
        }

        @Override
        protected String getMethodColumnToolTip() {
            return Messages.calleeColumnToolTip;
        }
    };
    TreeViewer callerViewer = callerFilteredTree.getViewer();
    callerViewer.setContentProvider(new AbstractContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICpuModel) {
                return ((ICpuModel) inputElement).getCallers();
            }
            return new Object[0];
        }
    });
    callerViewer.setLabelProvider(new HotSpotsLabelProvider(callerFilteredTree));
    callerViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            callerFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
    callerFilteredTree.sortColumn(callerViewer.getTree().getColumn(1));
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel) ConfigureCpuProfilerAction(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.ConfigureCpuProfilerAction) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 98 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.

the class HL7OutputUI method addXMLViewer.

/**
     * create xml viewer.
     *
     * @param mainComposite
     * @param form
     * @param width
     * @param height
     */
private void addXMLViewer(final Composite mainComposite, final int width, final int height) {
    // Group Schema Viewer
    Group group = Form.createGroup(mainComposite, 1, "Linker Target", height);
    // group.setBackgroundMode(SWT.INHERIT_FORCE);
    xmlViewer = new TreeViewer(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    xmlViewer.getControl().setLayoutData(gridData);
    xmlViewer.setUseHashlookup(true);
    Tree tree = xmlViewer.getTree();
    if (canModify || isRespo) {
        tree.setEnabled(false);
    }
    tree.setLinesVisible(true);
    tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("HL7 Structure");
    column1.setWidth(170);
    // Related Column
    TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
    column2.setText("Related Column");
    column2.setWidth(100);
    TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
    column3.setText("Node Status");
    column3.setWidth(90);
    TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
    column4.setText("Default Value");
    column4.setWidth(90);
    tree.setHeaderVisible(true);
    // tree.setBackgroundMode(SWT.INHERIT_NONE);
    HL7TargetTreeViewerProvider provider = new HL7TargetTreeViewerProvider();
    xmlViewer.setLabelProvider(provider);
    xmlViewer.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(Object element, String property) {
            HL7TreeNode node = (HL7TreeNode) element;
            if (property.equals("C1")) {
                if (node.getLabel() != null && node.getLabel().length() > 0) {
                    return true;
                }
            }
            if (property.equals("C4")) {
                if (node.getDefaultValue() != null && node.getDefaultValue().length() > 0) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public Object getValue(Object element, String property) {
            HL7TreeNode node = (HL7TreeNode) element;
            if (property.equals("C1")) {
                return node.getLabel();
            }
            if (property.equals("C4")) {
                return node.getDefaultValue();
            }
            return null;
        }

        @Override
        public void modify(Object element, String property, Object value) {
            TreeItem treeItem = (TreeItem) element;
            HL7TreeNode node = (HL7TreeNode) treeItem.getData();
            if (property.equals("C1")) {
                if (value != null && value.toString().length() == 0) {
                    value = node.getLabel();
                }
                node.setLabel((String) value);
            }
            if (property.equals("C4")) {
                node.setDefaultValue((String) value);
            }
            xmlViewer.refresh(node);
        }
    });
    //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    xmlViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
    CellEditor editor = new TextCellEditor(xmlViewer.getTree());
    editor.addListener(new DialogErrorXMLLabelCellEditor(editor, "C1"));
    // add by wzhang for bug 8572. set Default value column to be edit.
    CellEditor editorDefault = new TextCellEditor(xmlViewer.getTree());
    editorDefault.addListener(new DialogErrorXMLLabelCellEditor(editorDefault, "C4"));
    xmlViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
    xmlViewer.setContentProvider(provider);
    xmlViewer.setInput(this.hl7Manager.getTreeData());
    xmlViewer.expandAll();
    createAction();
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            HL7OutputUI.this.fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(xmlViewer.getControl());
    xmlViewer.getControl().setMenu(menu);
    xmlViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
        // TODO Auto-generated method stub
        }
    });
    refreshXMLViewer(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) HL7TargetTreeViewerProvider(org.talend.designer.hl7.ui.edit.HL7TargetTreeViewerProvider) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 99 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.

the class SaveChartSetAsDialog method createChartSetViewer.

/**
     * Creates the chart set viewer.
     * 
     * @param parent The parent composite
     * @return The chart set viewer
     */
private TableViewer createChartSetViewer(Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 300;
    viewer.getTable().setLayoutData(gridData);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setInput(chartSets.toArray(new String[chartSets.size()]));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (ignoreSelection) {
                return;
            }
            ISelection selection = event.getSelection();
            if (selection instanceof StructuredSelection) {
                Object element = ((StructuredSelection) selection).getFirstElement();
                if (element != null) {
                    chartSetText.setText(element.toString());
                    deleteButton.setEnabled(true);
                }
            }
        }
    });
    return viewer;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 100 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.

the class ExportItemWizardPage method addTreeCheckedSelection.

private void addTreeCheckedSelection() {
    final CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
    exportItemsTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
        // refreshExportDependNodes();
        }
    });
    exportItemsTreeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                initcheckedNodes.add(event.getElement());
                // remove children and parent from uncheckednodes
                TreeItem treeItem = getTreeItem(exportItemsTreeViewer.getTree().getItems(), event.getElement());
                Set subItems = collectSubData(treeItem);
                Set parent = collectParentData(treeItem);
                uncheckedNodes.removeAll(subItems);
                uncheckedNodes.removeAll(parent);
            } else {
                uncheckedNodes.add(event.getElement());
                // remove children from initcheckedNodes
                TreeItem treeItem = getTreeItem(exportItemsTreeViewer.getTree().getItems(), event.getElement());
                Set subItems = collectSubData(treeItem);
                initcheckedNodes.removeAll(subItems);
            }
        }
    });
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Set(java.util.Set) HashSet(java.util.HashSet) TreeItem(org.eclipse.swt.widgets.TreeItem) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)130 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)127 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)71 GridData (org.eclipse.swt.layout.GridData)68 Composite (org.eclipse.swt.widgets.Composite)60 GridLayout (org.eclipse.swt.layout.GridLayout)52 TableViewer (org.eclipse.jface.viewers.TableViewer)47 SelectionEvent (org.eclipse.swt.events.SelectionEvent)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)42 Label (org.eclipse.swt.widgets.Label)34 Table (org.eclipse.swt.widgets.Table)33 ISelection (org.eclipse.jface.viewers.ISelection)30 TreeViewer (org.eclipse.jface.viewers.TreeViewer)28 Button (org.eclipse.swt.widgets.Button)24 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)21 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)16 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)16 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14