コード例 #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 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);
  }
コード例 #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;
  }
コード例 #4
0
    public void actionPerformed(ActionEvent ae) {

      String addressPath = OperationDialog.this.node.addressPath();
      if (OperationDialog.this.opName.equals("add")) {
        UserObject usrObj = (UserObject) OperationDialog.this.node.getUserObject();
        ManagementModelNode parent = (ManagementModelNode) OperationDialog.this.node.getParent();
        RequestProp resourceProp = OperationDialog.this.props.first();
        String value = resourceProp.getValueAsString();
        value = ManagementModelNode.escapeAddressElement(value);
        addressPath = parent.addressPath() + usrObj.getName() + "=" + value + "/";
        OperationDialog.this.props.remove(resourceProp);
      }

      StringBuilder command = new StringBuilder();
      command.append(addressPath);
      command.append(":");
      command.append(OperationDialog.this.opName);
      addRequestProps(command, OperationDialog.this.props);

      JTextComponent cmdText = cliGuiCtx.getCommandLine().getCmdText();
      cmdText.setText(command.toString());
      OperationDialog.this.dispose();
      cmdText.requestFocus();
    }