int paramCounter = 0;
Iterator paramIterator = allParams.iterator();
while (paramIterator.hasNext()) {
ParamNode param = (ParamNode) paramIterator.next();
ParamItem paramItem = new ParamItem(param, (GenericNode) parentNode, parentTreeItem, paramCounter, requestString);
TreeItem parameterTreeItem = new TreeItem(paramItem);
parameterTreeItem.setUserObject(WadlXml.paramNode);
parentTreeItem.addItem(parameterTreeItem);
parameterTreeItem.setState(SettingsDialog.treeItemsAlwaysOpen);
paramCounter++;
}
if (!WadlTreeRoot.containsButton(buttonTreeItems, ApplicationItem.button + WadlXml.paramNode)) {
// add param button
HorizontalPanel addParamPanel = new HorizontalPanel();
Button addParamButton = new Button(GuiFactory.strings.addParam());
addParamButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
Analyzer analyzer = null;
if (parentNode instanceof RequestNode) {
((RequestNode) parentNode).addParam(new ParamNode(GuiFactory.strings.newParam(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
analyzer = ((RequestNode) parentNode).getApplication().getAnalyzer();
}
else if (parentNode instanceof ResponseNode) {
((ResponseNode) parentNode).addParam(new ParamNode(GuiFactory.strings.newParam(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
analyzer = ((ResponseNode) parentNode).getApplication().getAnalyzer();
}
else if (parentNode instanceof ResourceTypeNode) {
((ResourceTypeNode) parentNode).addParam(new ParamNode(GuiFactory.strings.newParam(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
analyzer = ((ResourceTypeNode) parentNode).getApplication().getAnalyzer();
}
else if (parentNode instanceof ResourceNode) {
((ResourceNode) parentNode).addParam(new ParamNode(GuiFactory.strings.newParam(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
analyzer = ((ResourceNode) parentNode).getApplication().getAnalyzer();
}
else if (parentNode instanceof FaultNode) {
((FaultNode) parentNode).addParam(new ParamNode(GuiFactory.strings.newParam(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
analyzer = ((FaultNode) parentNode).getApplication().getAnalyzer();
}
else if (parentNode instanceof RepresentationNode) {
((RepresentationNode) parentNode).addParam(new ParamNode(GuiFactory.strings.newParam(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
analyzer = ((RepresentationNode) parentNode).getApplication().getAnalyzer();
}
else if (parentNode instanceof ApplicationNode) {
ParamNode param = new ParamNode(GuiFactory.strings.newParam(), (GenericNode) parentNode, (ApplicationNode) parentNode);
param.setId(GuiFactory.strings.newId());
((ApplicationNode) parentNode).addParam(param);
analyzer = ((ApplicationNode) parentNode).getAnalyzer();
}
String newRequestString = analyzer.getRequestString();
if (!newRequestString.equals("")) {
TextBox requestUriTextBox = ReferenceManager.getRequestUriTextBox(newRequestString);
Uri uri = new Uri(requestUriTextBox.getText());
String newUri = uri.getScheme() + "://" + uri.getAuthority() + uri.getPath() + "?";
String[] queryParameters = uri.getQueryParameters();
String[] queryValues = uri.getQueryValues();
for (int i = 0; i < queryParameters.length; i++) {
if (i > 0) newUri += "&";
newUri += queryParameters[i] + "=" + queryValues[i];
}
if (queryParameters.length > 0) {
newUri += "&";
}
newUri += GuiFactory.strings.newParam() + "=" + GuiFactory.strings.paramValue();
ListBox httpMethodListBox = ReferenceManager.getHttpMethodListBox(newRequestString);
ParameterTree parameterTree = ReferenceManager.getParameterTree(newRequestString);
parameterTree.updateReferences(requestUriTextBox, newUri);
parameterTree.updateTree();
newRequestString = httpMethodListBox.getItemText(httpMethodListBox.getSelectedIndex()) + " " + newUri;
analyzer.setRequestString(newRequestString);
}
listParams(parentNode, parentTreeItem, newRequestString);
}
});
addParamPanel.add(addParamButton);
TreeItem addParamTreeItem = new TreeItem(addParamPanel);
addParamTreeItem.setUserObject(ApplicationItem.button + WadlXml.paramNode);
parentTreeItem.addItem(addParamTreeItem);
}
WadlTreeRoot.addButtons(buttonTreeItems, parentTreeItem);