Search in sources :

Example 1 with WebServiceTreeContentProvider

use of org.talend.designer.webservice.ui.tree.WebServiceTreeContentProvider 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 2 with WebServiceTreeContentProvider

use of org.talend.designer.webservice.ui.tree.WebServiceTreeContentProvider in project tdi-studio-se by Talend.

the class AddListDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Composite baseCom = (Composite) super.createDialogArea(parent);
    Composite createDialogArea = (Composite) super.createDialogArea(parent);
    createDialogArea.setLayout(new FillLayout());
    SashForm baseCom = new SashForm(createDialogArea, SWT.VERTICAL | SWT.BORDER);
    treeViewer = new TreeViewer(baseCom, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    tree = treeViewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    // Paramater Name Column
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("Parameter Name");
    column1.setWidth(200);
    // Array Index Column
    TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
    column2.setText("Array Index");
    column2.setWidth(100);
    treeViewer.setColumnProperties(new String[] { NAME, INDEX });
    CellEditor editor = new TextCellEditor(treeViewer.getTree());
    // CellEditor nameEditor = new ComboBoxCellEditor(treeViewer.getTree());
    treeViewer.setCellEditors(new CellEditor[] { null, editor });
    treeViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (element instanceof ParameterInfo) {
                ParameterInfo para = (ParameterInfo) element;
                if (INDEX.equals(property) && para.getArraySize() != 0) {
                    // if item is array it can edit.
                    return true;
                }
            }
            return false;
        }

        public Object getValue(Object element, String property) {
            if (element instanceof ParameterInfo) {
                ParameterInfo para = (ParameterInfo) element;
                if (INDEX.equals(property)) {
                    return para.getIndex() == null ? "" : para.getIndex();
                } else if (NAME.equals(property)) {
                    return para.getName();
                }
            }
            return null;
        }

        public void modify(Object element, String property, Object value) {
            if (element instanceof TreeItem) {
                ParameterInfo para = (ParameterInfo) ((TreeItem) element).getData();
                if (INDEX.equals(property)) {
                    para.setIndex(value.toString());
                }
            }
            treeViewer.refresh();
        }
    });
    // DrillDownAdapter adapter = new DrillDownAdapter(treeView);
    treeViewer.setContentProvider(new WebServiceTreeContentProvider());
    treeViewer.setLabelProvider(new WebServiceTreeLabelProvider());
    treeViewer.setInput(para);
    treeViewer.addSelectionChangedListener(selectAction);
    // tree.addSelectionListener(new SelectionAdapter() {
    //
    // @Override
    // public void widgetSelected(SelectionEvent e) {
    // TreeItem[] selects = tree.getSelection();
    // ISelection select = (ISelection) treeViewer.getSelection();
    // Object obj = ((IStructuredSelection) select).getFirstElement();
    // if (obj instanceof ParameterInfo) {
    // // if (((ParameterInfo) obj).getParameterInfos().size() > 0) {
    // // // ErrorDialog dialog = new ErrorDialog(parentShell, "", "", null, 0);
    // // // dialog.open();
    // // selectedParaInfo = null;
    // // } else {
    // selectedParaInfo = (ParameterInfo) obj;
    // // }
    // }
    // }
    //
    // });
    treeViewer.getTree().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            createAllTypeDialog();
        }
    });
    return baseCom;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) SashForm(org.eclipse.swt.custom.SashForm) WebServiceTreeLabelProvider(org.talend.designer.webservice.ui.tree.WebServiceTreeLabelProvider) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) WebServiceTreeContentProvider(org.talend.designer.webservice.ui.tree.WebServiceTreeContentProvider)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 SashForm (org.eclipse.swt.custom.SashForm)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 WebServiceTreeContentProvider (org.talend.designer.webservice.ui.tree.WebServiceTreeContentProvider)2 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)2 ArrayList (java.util.ArrayList)1 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)1 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)1 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)1 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)1 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 ICellModifier (org.eclipse.jface.viewers.ICellModifier)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 Font (org.eclipse.swt.graphics.Font)1