Search in sources :

Example 26 with TreeViewer

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

the class ConfigureChartDialog method createAttributesViewer.

/**
     * Creates the attributes viewer.
     * 
     * @param parent The parent composite
     * @return The attribute viewer
     */
private TreeViewer createAttributesViewer(Composite parent) {
    TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer.setContentProvider(new MBeanAttributeContentProvider());
    viewer.setLabelProvider(new MBeanAttributeLabelProvider(viewer));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            viewerSlectionChanged((IStructuredSelection) event.getSelection());
        }
    });
    configureTree(viewer.getTree());
    viewer.setInput(attributes.toArray(new MBeanAttribute[attributes.size()]));
    return viewer;
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 27 with TreeViewer

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

the class SWTResourcesPage method createSashFormControls.

/*
     * @see AbstractSashForm#createSashFormControls(SashForm, IActionBars)
     */
@Override
protected void createSashFormControls(SashForm sashForm, IActionBars actionBars) {
    resourceFilteredTree = new SWTResourceFilteredTree(sashForm, actionBars);
    TreeViewer resourceViewer = resourceFilteredTree.getViewer();
    resourceViewer.setContentProvider(new SWTResourceContentProvider(resourceViewer));
    resourceViewer.setLabelProvider(new SWTResourceLabelProvider());
    resourceViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                selection = null;
            }
            stackTraceViewer.setInput(selection);
        }
    });
    stackTraceViewer = new StackTraceViewer(sashForm, actionBars);
}
Also used : StackTraceViewer(org.talend.designer.runtime.visualization.internal.ui.properties.StackTraceViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 28 with TreeViewer

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

the class AllTypeDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite createDialogArea = (Composite) super.createDialogArea(parent);
    createDialogArea.setLayout(new FillLayout());
    SashForm baseCom = new SashForm(createDialogArea, SWT.VERTICAL | SWT.BORDER);
    baseCom.setLayout(new GridLayout(1, true));
    Group group1 = new Group(baseCom, SWT.None);
    group1.setText(Messages.getString("AllTypeDialog.Group1Text"));
    group1.setLayoutData(new GridData(GridData.FILL_BOTH));
    group1.setLayout(new FillLayout());
    Font font = new Font(Display.getCurrent(), "Arial", 43, 3);
    group1.setFont(font);
    font.dispose();
    Group group2 = new Group(baseCom, SWT.None);
    group2.setText(Messages.getString("AllTypeDialog.Group2Text"));
    group2.setLayoutData(new GridData(GridData.FILL_BOTH));
    font = new Font(Display.getCurrent(), "Arial", 43, 3);
    group2.setFont(font);
    group2.setLayout(new FillLayout());
    font.dispose();
    list = new List(group1, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    list.setItems(allXMLSchemaTypeName);
    treeViewer = new TreeViewer(group2, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    tree = treeViewer.getTree();
    tree.setHeaderVisible(false);
    tree.setLinesVisible(true);
    treeViewer.setContentProvider(new WebServiceTreeContentProvider());
    treeViewer.setLabelProvider(new AllTypeLabelProvider());
    treeViewer.setInput(null);
    treeViewer.refresh();
    list.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            String selection = list.getSelection()[0];
            if (selection.contains(COMPLEXTYPE)) {
                String[] split = selection.split(":");
                String complexTypeName = split[1];
                for (XmlSchemaType xmlSchemaType : allXmlSchemaType) {
                    if (xmlSchemaType.getName().equals(complexTypeName)) {
                        ParameterInfo parameterRoot = new ParameterInfo();
                        parameterRoot.setName("parameters");
                        ParameterInfo parameterSon = new ParameterInfo();
                        parameterSon.setName(complexTypeName);
                        parameterSon.setParent(parameterRoot);
                        parameterRoot.getParameterInfos().add(parameterSon);
                        XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaType;
                        XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
                        if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                            XmlSchemaObjectCollection childCollection = xmlSchemaGroupBase.getItems();
                            if (childCollection != null) {
                                buildParameterFromCollection(childCollection, parameterSon);
                            }
                        }
                        treeViewer.setInput(parameterRoot);
                        treeViewer.refresh();
                        selectedParaInfo = parameterSon;
                    }
                }
            } else {
                treeViewer.setInput(null);
                treeViewer.refresh();
                selectedParaInfo = null;
            }
        }
    });
    return baseCom;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) FillLayout(org.eclipse.swt.layout.FillLayout) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) Font(org.eclipse.swt.graphics.Font) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) WebServiceTreeContentProvider(org.talend.designer.webservice.ui.tree.WebServiceTreeContentProvider) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Example 29 with TreeViewer

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

the class DB2ExplainPlanExecution method displayResults.

private void displayResults(final ExplainNode node) {
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        @SuppressWarnings("deprecation")
        public void run() {
            clearCanvas();
            GridLayout gLayout = new GridLayout();
            gLayout.numColumns = 2;
            gLayout.marginLeft = 0;
            gLayout.horizontalSpacing = 0;
            gLayout.verticalSpacing = 0;
            gLayout.marginWidth = 0;
            gLayout.marginHeight = 0;
            composite.setLayout(gLayout);
            try {
                //$NON-NLS-1$
                composite.setData("parenttab", parentTab);
                Composite pp = new Composite(composite, SWT.NULL);
                pp.setLayout(new FillLayout());
                pp.setLayoutData(new GridData(GridData.FILL_BOTH));
                TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
                Tree tree = tv.getTree();
                tree.setLinesVisible(true);
                tree.setHeaderVisible(true);
                TreeColumn tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText("");
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText1"));
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText2"));
                TableLayout tableLayout = new TableLayout();
                tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tree.setLayout(tableLayout);
                tv.setContentProvider(new ITreeContentProvider() {

                    @Override
                    public void dispose() {
                    }

                    @Override
                    public Object[] getChildren(Object parentElement) {
                        return ((ExplainNode) parentElement).getChildren();
                    }

                    @Override
                    public Object[] getElements(Object inputElement) {
                        ExplainNode nd = ((ExplainNode) inputElement);
                        return nd.getChildren();
                    }

                    @Override
                    public Object getParent(Object element) {
                        return ((ExplainNode) element).getParent();
                    }

                    @Override
                    public boolean hasChildren(Object element) {
                        if (((ExplainNode) element).getChildren().length > 0) {
                            return true;
                        }
                        return false;
                    }

                    @Override
                    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                    }
                });
                tv.setLabelProvider(new TreeLabelProvider() {
                });
                tv.setInput(node);
                tv.refresh();
                tv.expandAll();
                // make columns full size
                for (int i = 0; i < tree.getColumnCount(); i++) {
                    tree.getColumn(i).pack();
                }
                final Composite parent = composite;
                tree.addKeyListener(new KeyAdapter() {

                    @Override
                    public void keyReleased(KeyEvent e) {
                        switch(e.keyCode) {
                            case SWT.F5:
                                // refresh SQL Results
                                try {
                                    //$NON-NLS-1$
                                    Object o = parent.getData("parenttab");
                                    if (o != null) {
                                        AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
                                        if (sqlExec != null) {
                                            sqlExec.startExecution();
                                        }
                                    }
                                } catch (Exception e1) {
                                    //$NON-NLS-1$
                                    SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError1"), e1);
                                }
                                break;
                            default:
                                return;
                        }
                    }
                });
            } catch (Exception e) {
                // add message
                String message = e.getMessage();
                Label errorLabel = new Label(composite, SWT.FILL);
                errorLabel.setText(message);
                errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError2"), e);
            }
            composite.layout();
            composite.redraw();
        }

        ;
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FillLayout(org.eclipse.swt.layout.FillLayout) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) AbstractSQLExecution(org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 30 with TreeViewer

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

the class OracleExplainPlanExecution method displayResults.

private void displayResults(final ExplainNode node) {
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        @SuppressWarnings("deprecation")
        public void run() {
            clearCanvas();
            GridLayout gLayout = new GridLayout();
            gLayout.numColumns = 2;
            gLayout.marginLeft = 0;
            gLayout.horizontalSpacing = 0;
            gLayout.verticalSpacing = 0;
            gLayout.marginWidth = 0;
            gLayout.marginHeight = 0;
            composite.setLayout(gLayout);
            try {
                //$NON-NLS-1$
                composite.setData("parenttab", parentTab);
                Composite pp = new Composite(composite, SWT.NULL);
                pp.setLayout(new FillLayout());
                pp.setLayoutData(new GridData(GridData.FILL_BOTH));
                TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
                Tree tree = tv.getTree();
                tree.setLinesVisible(true);
                tree.setHeaderVisible(true);
                TreeColumn tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText("");
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText1"));
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText2"));
                TableLayout tableLayout = new TableLayout();
                tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tree.setLayout(tableLayout);
                tv.setContentProvider(new ITreeContentProvider() {

                    @Override
                    public void dispose() {
                    }

                    @Override
                    public Object[] getChildren(Object parentElement) {
                        return ((ExplainNode) parentElement).getChildren();
                    }

                    @Override
                    public Object[] getElements(Object inputElement) {
                        ExplainNode nd = ((ExplainNode) inputElement);
                        return nd.getChildren();
                    }

                    @Override
                    public Object getParent(Object element) {
                        return ((ExplainNode) element).getParent();
                    }

                    @Override
                    public boolean hasChildren(Object element) {
                        if (((ExplainNode) element).getChildren().length > 0) {
                            return true;
                        }
                        return false;
                    }

                    @Override
                    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                    }
                });
                tv.setLabelProvider(new TreeLabelProvider() {
                });
                tv.setInput(node);
                tv.refresh();
                tv.expandAll();
                // make columns full size
                for (int i = 0; i < tree.getColumnCount(); i++) {
                    tree.getColumn(i).pack();
                }
                final Composite parent = composite;
                tree.addKeyListener(new KeyAdapter() {

                    @Override
                    public void keyReleased(KeyEvent e) {
                        switch(e.keyCode) {
                            case SWT.F5:
                                // refresh SQL Results
                                try {
                                    //$NON-NLS-1$
                                    Object o = parent.getData("parenttab");
                                    if (o != null) {
                                        AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
                                        if (sqlExec != null) {
                                            sqlExec.startExecution();
                                        }
                                    }
                                } catch (Exception e1) {
                                    //$NON-NLS-1$
                                    SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage1"), e1);
                                }
                                break;
                            default:
                                return;
                        }
                    }
                });
            } catch (Exception e) {
                // add message
                String message = e.getMessage();
                Label errorLabel = new Label(composite, SWT.FILL);
                errorLabel.setText(message);
                errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage2"), e);
            }
            composite.layout();
            composite.redraw();
        }

        ;
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FillLayout(org.eclipse.swt.layout.FillLayout) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) AbstractSQLExecution(org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) TableLayout(org.eclipse.jface.viewers.TableLayout)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)199 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)45 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)38 GridData (org.eclipse.swt.layout.GridData)37 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)36 Tree (org.eclipse.swt.widgets.Tree)34 Composite (org.eclipse.swt.widgets.Composite)33 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)28 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)28 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)27 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)27 ArrayList (java.util.ArrayList)24 GridLayout (org.eclipse.swt.layout.GridLayout)23 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)22