Exemplo n.º 1
0
 public InterfaceModel(InputStream iStream) {
   // panelgrid receives children in order
   treeStructure = new HtmlPanelGrid();
   treeStructure.setColumns(1);
   interfaceModelBuilder = new InterfaceModelBuilder(iStream);
   currentPanel = null;
   treeButtonIncr = 0;
   initializeInterface();
 }
Exemplo n.º 2
0
 // expands a node, updates its expansion state. updates its loaded state if
 // applicable and updates the panelGrid
 private void expandNode(CustomButtonNode button) {
   // TODO: add an ordering attribute to the RDF file so the model returns the items
   // in proper order
   if (!button.isLoaded()) {
     int index = treeStructure.getChildren().indexOf(button);
     ElementMold[] fields = interfaceModelBuilder.getChildrenOf(button.getValue().toString());
     HtmlPanelGroup childrenContainer = new HtmlPanelGroup();
     for (int a = 0; a < fields.length; a++) {
       if (fields[a].getInputType().equals("button")) {
         CustomButtonNode newNode = this.buildButtonNode(fields[a].getName(), button);
         button.getChildren().add(newNode);
       }
     }
     for (int a = 0; a < fields.length; a++) {
       if (fields[a].getInputType().equals("outputText")) {
         HtmlOutputText newText = this.buildOutputTextField(fields[a].getText(), button);
         childrenContainer.getChildren().add(newText);
       }
     }
     for (int a = 0; a < fields.length; a++) {
       if (fields[a].getInputType().equals("selectInput")) {
         HtmlSelectOneMenu newSelector = this.buildSelectBox(fields[a].getOptions(), button);
         childrenContainer.getChildren().add(newSelector);
       }
     }
     for (int a = 0; a < fields.length; a++) {
       if (fields[a].getInputType().equals("inputText")) {
         HtmlInputText newText = this.buildInputTextField(button);
         childrenContainer.getChildren().add(newText);
       }
     }
     if (childrenContainer.getChildCount() > 0) {
       button.getChildren().add(childrenContainer);
     }
     button.setLoaded(true);
     treeStructure.getChildren().addAll(index + 1, button.getChildren());
   } else {
     expandChildrenOf(button);
   }
   button.setExpanded(true);
   updateInterface();
 }
Exemplo n.º 3
0
 private void initializeInterface() {
   ElementMold[] rootNodes = interfaceModelBuilder.getRootNodes();
   for (int a = 0; a < rootNodes.length; a++) {
     if (rootNodes[a].getInputType().equals("button")) {
       CustomButtonNode nodeToAdd = buildButtonNode(rootNodes[a].getName(), null);
       nodeToAdd.setLoaded(false);
       nodeToAdd.setExpanded(false);
       treeStructure.getChildren().add(nodeToAdd);
       updateInterface();
     }
   }
 }
Exemplo n.º 4
0
  // called when a component is being expanded that has expanded child button nodes
  private void expandChildrenOf(CustomButtonNode button) {
    int index = treeStructure.getChildren().indexOf(button);
    List children = button.getChildren();

    // inserts node items into the appropriate positions in the panelGrid
    // children collection
    for (int a = 0; a < children.size(); a++) {
      treeStructure.getChildren().add(index + 1 + a, (UIComponent) children.get(a));
    }

    // checks every child, if it is a button and its expanded state is set to true,
    // recursively call the method to expand the child node
    for (int a = 0; a < children.size(); a++) {
      Object curChild = children.get(a);
      if (curChild instanceof CustomButtonNode) {
        CustomButtonNode curButton = (CustomButtonNode) curChild;
        if (curButton.isExpanded()) {
          this.expandChildrenOf(curButton);
        }
      }
    }
  }
Exemplo n.º 5
0
  // removes all children of the button from the panelGrid to give the appearance
  // of the node collapsing
  private void removeAllChildrenOf(CustomButtonNode button) {
    List children = button.getChildren();

    // removes every child of the button from the panel grid.
    // If the node has child buttons that are also expanded, it recursively calls
    // itself to remove their children as well
    for (int a = 0; a < children.size(); a++) {
      Object curChild = children.get(a);
      if (curChild instanceof CustomButtonNode && ((CustomButtonNode) curChild).isExpanded()) {
        removeAllChildrenOf((CustomButtonNode) curChild);
      }
      treeStructure.getChildren().remove(curChild);
    }
  }
Exemplo n.º 6
0
 // necessary housekeeping method that executes updates to the interface
 private void updateInterface() {
   treeStructure.processUpdates(FacesContext.getCurrentInstance());
 }