示例#1
0
  public OperationDialog(
      CliGuiContext cliGuiCtx,
      ManagementModelNode node,
      String opName,
      String strDescription,
      ModelNode requestProperties) {
    super(cliGuiCtx.getMainWindow(), opName, Dialog.ModalityType.APPLICATION_MODAL);
    this.cliGuiCtx = cliGuiCtx;
    this.node = node;
    this.opName = opName;

    try {
      setProps(requestProperties);
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout(10, 10));

    // the html table allows word wrap and constant max width
    JLabel opDescription = new WordWrapLabel(strDescription, 400);
    JPanel opDescPanel = new JPanel();
    opDescPanel.add(opDescription);
    contentPane.add(opDescPanel, BorderLayout.NORTH);

    contentPane.add(makeInputPanel(), BorderLayout.CENTER);

    contentPane.add(makeButtonPanel(), BorderLayout.SOUTH);
    pack();
    setResizable(true);
  }
  private OperationResponse execute(ModelNode request, boolean useWaitCursor) throws IOException {

    if (request.get(Util.OPERATION).asString().equals(Util.COMPOSITE)
        && (!request.get(Util.STEPS).isDefined() || request.get(Util.STEPS).asList().isEmpty())) {
      return OperationResponse.Factory.createSimple(
          new ModelNode(
              "WARN: no request was sent as there were no server-side operations to execute"));
    }

    try {
      if (useWaitCursor) {
        cliGuiCtx.getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      }
      return client.executeOperation(
          OperationBuilder.create(request).build(), OperationMessageHandler.DISCARD);
    } finally {
      if (useWaitCursor) {
        cliGuiCtx.getMainWindow().setCursor(Cursor.getDefaultCursor());
      }
    }
  }