Beispiel #1
0
 public void buttonClicked(ActionEvent e) {
   CustomButtonNode currentButton = (CustomButtonNode) e.getSource();
   if (currentButton.isExpanded()) {
     collapseNode(currentButton);
   } else {
     expandNode(currentButton);
   }
 }
Beispiel #2
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();
     }
   }
 }
Beispiel #3
0
 private HtmlInputText buildInputTextField(CustomButtonNode parent) {
   HtmlInputText text = new HtmlInputText();
   text.setStyle("margin-left:" + (parent.getOffset() + 5) + "px;");
   text.addValueChangeListener(
       new ValueChangeListener() {
         public void processValueChange(ValueChangeEvent e) throws AbortProcessingException {
           valueChanged(e);
         }
       });
   text.setPartialSubmit(true);
   return text;
 }
Beispiel #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);
        }
      }
    }
  }
Beispiel #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);
    }
  }
Beispiel #6
0
 private HtmlSelectOneMenu buildSelectBox(String[] opts, CustomButtonNode parent) {
   HtmlSelectOneMenu newMenu = new HtmlSelectOneMenu();
   for (int a = 0; a < opts.length; a++) {
     UISelectItem item = new UISelectItem();
     item.setItemValue(opts[a]);
     newMenu.getChildren().add(item);
   }
   newMenu.setStyle("margin-left:" + (parent.getOffset() + 5) + "px;");
   newMenu.addValueChangeListener(
       new ValueChangeListener() {
         public void processValueChange(ValueChangeEvent e) throws AbortProcessingException {
           valueChanged(e);
         }
       });
   newMenu.setPartialSubmit(true);
   return newMenu;
 }
Beispiel #7
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();
 }
Beispiel #8
0
 private CustomButtonNode buildButtonNode(String btnName, CustomButtonNode parent) {
   CustomButtonNode newButton = new CustomButtonNode();
   newButton.setValue(btnName);
   newButton.addActionListener(
       new ActionListener() {
         public void processAction(ActionEvent e) throws AbortProcessingException {
           buttonClicked(e);
         }
       });
   if (parent != null) {
     newButton.setParentButton(parent);
     newButton.setWidth(parent.getWidth() - 15);
     newButton.setOffset(parent.getOffset() + 15);
   } else {
     newButton.setWidth(520);
     newButton.setOffset(0);
   }
   // TODO: better to redesign interface model to support a CSS class with
   // relative positioning for the offset
   newButton.setStyle(
       "width:"
           + newButton.getWidth()
           + "px; "
           + "margin-left:"
           + newButton.getOffset()
           + "px;"
           + "height:100%");
   newButton.setPartialSubmit(true);
   newButton.setId("treeButton" + treeButtonIncr);
   treeButtonIncr++;
   return newButton;
 }
Beispiel #9
0
 // collapses the node, updates its expansion state and updates the panelGrid component
 private void collapseNode(CustomButtonNode button) {
   this.removeAllChildrenOf(button);
   button.setExpanded(false);
   updateInterface();
 }
Beispiel #10
0
 private HtmlOutputText buildOutputTextField(String value, CustomButtonNode parent) {
   HtmlOutputText text = new HtmlOutputText();
   text.setValue(value);
   text.setStyle("margin-left:" + (parent.getOffset() + 5) + "px;");
   return text;
 }