Exemplo n.º 1
0
  private void setProps(ModelNode requestProperties) throws Exception {
    props = new TreeSet<RequestProp>();
    if (opName.equals("add")) {
      UserObject usrObj = (UserObject) node.getUserObject();
      props.add(
          new RequestProp(
              "/" + usrObj.getName() + "=<name>/",
              "Resource name for the new " + usrObj.getName(),
              true,
              ModelType.STRING));
    }

    if (opName.equals("write-attribute") && node.isLeaf()) {
      ModelNode nameNode = requestProperties.get("name");
      nameNode
          .get("type")
          .set(ModelType.UNDEFINED); // undefined type will display as uneditable String
      UserObject usrObj = (UserObject) node.getUserObject();
      ModelNode nameNodeValue = new ModelNode();
      nameNodeValue.set(usrObj.getName());
      props.add(new RequestProp("name", requestProperties.get("name"), nameNodeValue));

      ModelNode rscDesc =
          cliGuiCtx.getExecutor().doCommand(node.addressPath() + ":read-resource-description");
      ModelNode valueNode = rscDesc.get("result", "attributes", usrObj.getName());
      valueNode.get("required").set(false); // value is never required for write-attribute
      ModelNode valueNodeValue = usrObj.getBackingNode().get(usrObj.getName());
      props.add(new RequestProp("value", valueNode, valueNodeValue));
      return;
    }

    for (Property prop : requestProperties.asPropertyList()) {
      props.add(new RequestProp(prop.getName(), prop.getValue(), null));
    }
  }
Exemplo n.º 2
0
  @Override
  public void setVisible(boolean isVisible) {
    if (node.isLeaf()) {
      // "rightSide" field should have focus for write-attribute dialog
      // where "leftSide" field is already populated
      for (RequestProp prop : props) {
        if (prop.getName().equals("value")) {
          prop.getValueComponent().requestFocus();
        }
      }
    }

    super.setVisible(isVisible);
  }
Exemplo n.º 3
0
  @Override
  public synchronized String getToolTipText(MouseEvent me) {
    if (getRowForLocation(me.getX(), me.getY()) == -1) {
      currentNode = null;
      currentDescription = null;
      return null;
    }

    TreePath treePath = getPathForLocation(me.getX(), me.getY());
    ManagementModelNode node = (ManagementModelNode) treePath.getLastPathComponent();

    // don't read description again when mouse is moved within the same node
    if (node == currentNode) return currentDescription;

    currentNode = node;
    currentDescription = null;

    try {
      ModelNode readResource =
          GuiMain.getExecutor().doCommand(node.addressPath() + ":read-resource-description");
      if (!node.isLeaf()) {
        currentDescription = readResource.get("result", "description").asString();
      } else {
        UserObject usrObj = (UserObject) node.getUserObject();
        ModelNode description =
            readResource.get("result", "attributes", usrObj.getName(), "description");
        if (description.isDefined()) {
          currentDescription = description.asString();
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }

    return currentDescription;
  }