public static void listGrammars(final ApplicationNode application, final TreeItem applicationTreeItem) {
Vector buttonTreeItems = WadlTreeRoot.removeChildrenXKeepButtons(applicationTreeItem, WadlXml.grammarsNode);
if ((application.getGrammars() != null) && (application.getGrammars().getAllIncludes().size() > 0)) {
GrammarsNode grammars = application.getGrammars();
GrammarsItem grammarsItem = new GrammarsItem(grammars, applicationTreeItem);
TreeItem grammarsTreeItem = new TreeItem(grammarsItem);
grammarsTreeItem.setUserObject(WadlXml.grammarsNode);
applicationTreeItem.addItem(grammarsTreeItem);
final VerticalPanel includePanel = new VerticalPanel();
// include items
grammarsTreeItem.addItem(includePanel);
IncludeItem.listIncludes(grammars, includePanel);
grammarsTreeItem.setState(SettingsDialog.treeItemsAlwaysOpen);
// close grammars item
TreeItem grammarsCloseItem = new TreeItem(new GenericClosingItem(WadlXml.grammarsNode));
grammarsCloseItem.setUserObject(WadlXml.grammarsNode);
applicationTreeItem.addItem(grammarsCloseItem);
}
else {
if (!WadlTreeRoot.containsButton(buttonTreeItems, ApplicationItem.button + WadlXml.grammarsNode)) {
// add grammars button
HorizontalPanel addGrammarsPanel = new HorizontalPanel();
Button addGrammarsButton = new Button(GuiFactory.strings.addGrammars());
addGrammarsButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
application.addGrammars(new GrammarsNode(application));
application.getGrammars().addInclude(GuiFactory.strings.newInclude());
listGrammars(application, applicationTreeItem);
}
});
addGrammarsPanel.add(addGrammarsButton);