コード例 #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));
    }
  }
コード例 #2
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;
  }