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