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;
}
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;
}
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();
}
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;
}
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());
}
Aggregations