示例#1
0
  private Layout getButtons() {
    buttonsForm = new HLayout();

    installButton = new EnhancedIButton(MSG.view_remoteAgentInstall_installAgent());
    installButton.setExtraSpace(10);
    installButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            absPathValidator.setPerformCheck(true);
            try {
              if (connectionForm.validate()) {
                new CheckSSHConnectionCallback() {
                  @Override
                  protected void doActualWork() {
                    installAgent();
                  }
                }.execute();
              }
            } finally {
              absPathValidator.setPerformCheck(false);
            }
          }
        });

    uninstallButton = new EnhancedIButton(MSG.view_remoteAgentInstall_uninstallAgent());
    uninstallButton.setExtraSpace(10);
    uninstallButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            absPathValidator.setPerformCheck(true);
            try {
              if (connectionForm.validate()) {
                new CheckSSHConnectionCallback() {
                  @Override
                  protected void doActualWork() {
                    uninstallAgent();
                  }
                }.execute();
              }
            } finally {
              absPathValidator.setPerformCheck(false);
            }
          }
        });

    startButton = new EnhancedIButton(MSG.common_label_startAgent());
    startButton.setExtraSpace(10);
    startButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            if (connectionForm.validate()) {
              new CheckSSHConnectionCallback() {
                @Override
                protected void doActualWork() {
                  startAgent();
                }
              }.execute();
            }
          }
        });

    stopButton = new EnhancedIButton(MSG.view_remoteAgentInstall_stopAgent());
    stopButton.setExtraSpace(10);
    stopButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            if (connectionForm.validate()) {
              new CheckSSHConnectionCallback() {
                @Override
                protected void doActualWork() {
                  stopAgent();
                }
              }.execute();
            }
          }
        });

    ArrayList<Canvas> buttons = new ArrayList<Canvas>(3);
    if (this.showInstallButton) {
      buttons.add(installButton);
    }
    if (this.showUninstallButton
        && initialAgentInstall != null
        && initialAgentInstall.getAgentName() != null) {
      buttons.add(
          uninstallButton); // note we only show this if we were given the agent name because that
                            // is required to be known to uninstall
    }
    if (this.showStartButton) {
      buttons.add(startButton);
    }
    if (this.showStopButton) {
      buttons.add(stopButton);
    }

    if (buttons.size() > 0) {
      buttonsForm.setAlign(Alignment.CENTER);
      buttonsForm.setMembers(buttons.toArray(new Canvas[buttons.size()]));
    }

    return buttonsForm;
  }