Search in sources :

Example 16 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class AddArrayIndexForParentsDialog method getAllArrayFromParents.

private List<ParameterInfo> getAllArrayFromParents(ParameterInfo parameter, List<ParameterInfo> allArrayParents) {
    if (allArrayParents == null) {
        allArrayParents = new ArrayList<ParameterInfo>();
    }
    if (parameter.getParent() != null) {
        ParameterInfo parent = parameter.getParent();
        if (parent.getArraySize() != 0) {
            allArrayParents.add(parent);
        }
        getAllArrayFromParents(parent, allArrayParents);
    }
    return allArrayParents;
}
Also used : ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)

Example 17 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo 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)

Example 18 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class AddListDialog method okPressed.

@Override
protected void okPressed() {
    boolean falg = false;
    IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
    paramList = selection.toList();
    if (selection.size() == 1) {
        ParameterInfo selPara = getSelectedParaInfo();
        ParameterInfo usePara = null;
        paraUtil = new ParameterInfoUtil();
        int currentindex = -1;
        // if select multi simple type items.
        if (paramList != null && !paramList.isEmpty()) {
        }
        // if selected have branch.
        if (selPara == null) {
            return;
        }
        if (!selPara.getParameterInfos().isEmpty()) {
            MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK);
            //$NON-NLS-1$
            box.setText(Messages.getString("AddListDialog.Error"));
            //$NON-NLS-1$
            box.setMessage("Please Select " + selPara.getName() + " branch Item.");
            box.open();
            return;
        }
    } else if (selection.size() > 1) {
        paraUtil = new ParameterInfoUtil();
        List<ParameterInfo> list = selection.toList();
        for (ParameterInfo info : list) {
            if (!info.getParameterInfos().isEmpty()) {
                MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK);
                //$NON-NLS-1$
                box.setText(Messages.getString("AddListDialog.Error"));
                //$NON-NLS-1$
                box.setMessage("Please Select " + info.getName() + " branch Item.");
                box.open();
                return;
            }
        }
    }
    // if select a array item.
    // if (selPara.getArraySize() == -1) {
    // AddArrayIndexDialog dlg = new AddArrayIndexDialog(parentShell, selPara);
    // int openCode = dlg.open();
    // if (openCode == AddArrayIndexDialog.OK) {
    // String indexValue = dlg.getIndexText();
    // currentindex = Integer.valueOf(indexValue);
    // } else {
    // return;
    // }
    // paraUtil.setCurrentindex(currentindex);
    // // super.okPressed();
    // }
    // if select item's parent is array.
    // if (arraySize == 0 && selPara.getParent() != null && !getAllArrayFromParents(selPara, null).isEmpty()) {
    // List<ParameterInfo> paraList = paraUtil.getAllParameterInfo(selPara);
    // goout: for (ParameterInfo para : paraList) {
    // if (para.getArraySize() != 0) {
    // falg = true;
    // usePara = para;
    // arraySize = para.getArraySize();
    // break goout;
    // }
    // }
    // }
    // if (falg) {
    // String title = "";
    // if (usePara != null && usePara.getName() != null) {
    // title = usePara.getName() + " index is :";
    // }
    // if (getAllArrayFromParents(selPara, null).size() == 1 && "input".equals(inOrOut) && false) {
    //                InputDialog dlg = new InputDialog(parentShell, title, title, "", new InputIndexValidator()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    // int openCode = dlg.open();
    // if (openCode == InputDialog.OK) {
    // String indexValue = dlg.getValue();
    // currentindex = Integer.valueOf(indexValue);
    // } else if (openCode == InputDialog.CANCEL) {
    // // super.cancelPressed();
    // return;
    // }
    // if (arraySize != -1 && currentindex > arraySize) {
    // currentindex = -1;
    // MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK | SWT.CANCEL);
    //                    box.setText(Messages.getString("AddListDialog.Error")); //$NON-NLS-1$
    //                    box.setMessage(Messages.getString("AddListDialog.CHECKSIZE")); //$NON-NLS-1$
    // box.open();
    // return;
    // }
    // paraUtil.setCurrentindex(currentindex);
    // super.okPressed();
    // } else if (getAllArrayFromParents(selPara, null).size() >= 1) {
    //
    // AddArrayIndexForParentsDialog multiDialog = new AddArrayIndexForParentsDialog(parentShell, selPara);
    // int openCode = multiDialog.open();
    // if (openCode == AddArrayIndexForParentsDialog.OK) {
    // List indexList = null;
    // if (multiDialog.getArrayIndexList() != null) {
    // indexList = multiDialog.getArrayIndexList();
    // }
    // paraUtil.setCurrenIndexList(indexList);
    // super.okPressed();
    // } else {
    // return;
    // }
    // }
    //
    // }
    // paraUtil.setCurrentindex(currentindex);
    super.okPressed();
}
Also used : ParameterInfoUtil(org.talend.designer.webservice.ui.ParameterInfoUtil) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 19 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class AddListDialog method getAllArrayFromParents.

private List<ParameterInfo> getAllArrayFromParents(ParameterInfo parameter, List<ParameterInfo> allArrayParents) {
    if (allArrayParents == null) {
        allArrayParents = new ArrayList<ParameterInfo>();
    }
    if (parameter.getParent() != null) {
        ParameterInfo parent = parameter.getParent();
        if (parent.getArraySize() != 0) {
            allArrayParents.add(parent);
        }
        getAllArrayFromParents(parent, allArrayParents);
    }
    return allArrayParents;
}
Also used : ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)

Example 20 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class ComponentBuilderTest method testBuildParameterFromTypes.

@Test
public void testBuildParameterFromTypes() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, WSDLException {
    ParameterInfo parameter = new ParameterInfo();
    String name = "parameter";
    String nameSpace = "http://parameter";
    parameter.setName(name);
    parameter.setNameSpace(nameSpace);
    ComponentBuilder cb = new ComponentBuilder();
    Field field = cb.getClass().getDeclaredField("allXmlSchemaType");
    field.setAccessible(true);
    List<XmlSchemaType> allXmlSchemaType = (List<XmlSchemaType>) field.get(cb);
    XmlSchema first = new XmlSchema();
    first.setId("first");
    XmlSchemaSimpleType xsst = new XmlSchemaSimpleType(first);
    xsst.setId("first");
    xsst.setName("first");
    xsst.setSourceURI("http://first");
    XmlSchema two = new XmlSchema();
    two.setId("two");
    two.setTargetNamespace(nameSpace);
    String nameSpaceTwo = "http://parameter";
    XmlSchemaComplexType xsc = new XmlSchemaComplexType(two);
    XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
    xmlSchemaSequence.setId("sequence");
    XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
    xmlSchemaElement.setSourceURI(nameSpaceTwo);
    xmlSchemaElement.setQName(new QName(nameSpaceTwo, "parameter"));
    xmlSchemaElement.setName(name);
    xmlSchemaSequence.getItems().add(xmlSchemaElement);
    xsc.setParticle(xmlSchemaSequence);
    xsc.setId("two");
    xsc.setName("parameter");
    XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent();
    XmlSchemaComplexContentExtension xmlSchemaContent = new XmlSchemaComplexContentExtension();
    xmlSchemaContent.setId("two");
    xmlSchemaContent.setBaseTypeName(new QName(nameSpace, "two"));
    xmlSchemaContent.setSourceURI(nameSpaceTwo);
    contentModel.setSourceURI(nameSpace);
    contentModel.setContent(xmlSchemaContent);
    xsc.setContentModel(contentModel);
    allXmlSchemaType.add(xsst);
    allXmlSchemaType.add(xsc);
    Method m = cb.getClass().getDeclaredMethod("buileParameterFromTypes", new Class[] { String.class, String.class, ParameterInfo.class, int.class });
    m.setAccessible(true);
    m.invoke(cb, nameSpace, name, parameter, 5);
    ParameterInfo parameterInfo = parameter.getParameterInfos().get(0);
    Assert.assertNotNull(parameterInfo);
    Assert.assertEquals(nameSpace, parameterInfo.getNameSpace());
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) Method(java.lang.reflect.Method) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaComplexContent(org.apache.ws.commons.schema.XmlSchemaComplexContent) Field(java.lang.reflect.Field) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) List(java.util.List) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) ComponentBuilder(org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder) Test(org.junit.Test)

Aggregations

ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)26 ArrayList (java.util.ArrayList)12 List (java.util.List)8 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)8 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)6 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)6 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)6 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)6 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)6 Iterator (java.util.Iterator)5 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)4 XmlSchemaAny (org.apache.ws.commons.schema.XmlSchemaAny)3 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)3 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)3 ParameterInfoUtil (org.talend.designer.webservice.ui.ParameterInfoUtil)3 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 SashForm (org.eclipse.swt.custom.SashForm)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2