Iterator methodIterator = methods.iterator();
while (methodIterator.hasNext()) {
MethodNode method = (MethodNode) methodIterator.next();
MethodItem methodItem = new MethodItem(method, method.getParent(), parentTreeItem, requestString);
TreeItem methodTreeItem = new TreeItem(methodItem);
methodTreeItem.setUserObject(WadlXml.methodNode);
parentTreeItem.addItem(methodTreeItem);
if (method.getHref() == null) {
// request
RequestItem.listRequest(method, methodTreeItem);
// response
ResponseItem.listResponse(method, methodTreeItem);
// close method item
GenericClosingItem methodCloseItem = new GenericClosingItem(WadlXml.methodNode);
TreeItem methodCloseTreeItem = new TreeItem(methodCloseItem);
methodCloseTreeItem.setUserObject(WadlXml.methodNode);
parentTreeItem.addItem(methodCloseTreeItem);
}
methodTreeItem.setState(SettingsDialog.treeItemsAlwaysOpen);
}
if (!WadlTreeRoot.containsButton(buttonTreeItems, ApplicationItem.button + WadlXml.methodNode)) {
// add method button
HorizontalPanel addMethodPanel = new HorizontalPanel();
Button addMethodButton = new Button(GuiFactory.strings.addMethod());
addMethodButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
if (parentNode instanceof ResourceNode) {
((ResourceNode) parentNode).directlyAddMethod(new MethodNode(GuiFactory.strings.newMethod(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
listMethods(parentNode, parentTreeItem, requestString);
}
else if (parentNode instanceof ApplicationNode) {
MethodNode method = new MethodNode(GuiFactory.strings.newMethod(), (GenericNode) parentNode, (ApplicationNode) parentNode);
method.setId(GuiFactory.strings.newId());
((ApplicationNode) parentNode).directlyAddMethod(method);
listMethods(parentNode, parentTreeItem, requestString);
}
else if (parentNode instanceof ResourceTypeNode) {
((ResourceTypeNode) parentNode).directlyAddMethod(new MethodNode(GuiFactory.strings.newMethod(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
listMethods(parentNode, parentTreeItem, requestString);
}
}
});
addMethodPanel.add(addMethodButton);
TreeItem addMethodTreeItem = new TreeItem(addMethodPanel);
addMethodTreeItem.setUserObject(ApplicationItem.button + WadlXml.methodNode);
parentTreeItem.addItem(addMethodTreeItem);
}
WadlTreeRoot.addButtons(buttonTreeItems, parentTreeItem);