示例#1
0
  private DynamicForm createSummaryForm() {

    DynamicForm form = new DynamicForm();
    form.setWidth100();
    form.setColWidths("20%", "40%", "40%");
    form.setNumCols(3);
    form.setAutoHeight();
    form.setWrapItemTitles(false);
    form.setExtraSpace(10);
    form.setIsGroup(true);
    form.setGroupTitle(MSG.common_title_summary());
    form.setPadding(5);

    CanvasItem actionItem = new CanvasItem("actions");
    actionItem.setColSpan(1);
    actionItem.setRowSpan(4);
    actionItem.setShowTitle(false);
    actionItem.setCanvas(getActionLayout());

    StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version());
    versionItem.setValue(version.getVersion());

    StaticTextItem liveDeploymentsItem =
        new StaticTextItem("deployments", MSG.view_bundle_deployments());
    liveDeploymentsItem.setValue(version.getBundleDeployments().size());

    StaticTextItem filesItems = new StaticTextItem("files", MSG.view_bundle_files());
    filesItems.setValue(version.getBundleFiles().size());

    StaticTextItem descriptionItem =
        new StaticTextItem("description", MSG.common_title_description());
    descriptionItem.setValue(version.getDescription());

    form.setFields(versionItem, actionItem, liveDeploymentsItem, filesItems, descriptionItem);
    return form;
  }
示例#2
0
  private DynamicForm getConnectionForm() {
    connectionForm = new DynamicForm();
    connectionForm.setNumCols(4);
    connectionForm.setWrapItemTitles(false);
    connectionForm.setColWidths("130", "450", "110");
    connectionForm.setExtraSpace(15);
    connectionForm.setWidth(790);
    connectionForm.setPadding(5);
    connectionForm.setIsGroup(true);
    connectionForm.setGroupTitle(MSG.view_remoteAgentInstall_connInfo());
    final int textFieldWidth = 440;

    TextItem host = new TextItem("host", MSG.common_title_host());
    host.setRequired(true);
    host.setWidth(textFieldWidth);
    host.setPrompt(MSG.view_remoteAgentInstall_promptHost());
    host.setHoverWidth(300);
    host.setEndRow(true);
    host.addChangedHandler(
        new ChangedHandler() {
          @Override
          public void onChanged(ChangedEvent event) {
            hostAuthorized =
                false; // if the host changes, we need to make sure the user authorizes it if needed
          }
        });

    TextItem port = new TextItem("port", MSG.common_title_port());
    port.setRequired(false);
    port.setWidth(textFieldWidth);
    port.setPrompt(MSG.view_remoteAgentInstall_promptPort());
    port.setHoverWidth(300);
    port.setEndRow(true);
    IntegerRangeValidator portValidator = new IntegerRangeValidator();
    portValidator.setMin(1);
    portValidator.setMax(65535);
    port.setValidators(new IsIntegerValidator(), portValidator);

    TextItem username = new TextItem("username", MSG.common_title_user());
    username.setRequired(
        false); // if not specified, the server will attempt to use the default ssh user defined in
                // system settings
    username.setWidth(textFieldWidth);
    username.setPrompt(MSG.view_remoteAgentInstall_promptUser());
    username.setHoverWidth(300);
    username.setEndRow(true);

    PasswordItem password = new PasswordItem("password", MSG.common_title_password());
    password.setRequired(
        false); // if not specified, the server will attempt to use the default ssh pw defined in
                // system settings
    password.setWidth(textFieldWidth);
    password.setPrompt(MSG.view_remoteAgentInstall_promptPassword());
    password.setHoverWidth(300);
    password.setEndRow(true);
    password.setAttribute("autocomplete", "off");

    rememberMeCheckbox = new CheckboxItem("rememberme", MSG.view_remoteAgentInstall_rememberMe());
    rememberMeCheckbox.setRequired(false);
    rememberMeCheckbox.setPrompt(MSG.view_remoteAgentInstall_promptRememberMe());
    rememberMeCheckbox.setHoverWidth(300);
    rememberMeCheckbox.setColSpan(2);
    rememberMeCheckbox.setEndRow(true);

    agentInstallPath = new TextItem("agentInstallPath", MSG.view_remoteAgentInstall_installPath());
    agentInstallPath.setWidth(textFieldWidth);
    agentInstallPath.setPrompt(MSG.view_remoteAgentInstall_promptInstallPath());
    agentInstallPath.setHoverWidth(300);
    agentInstallPath.setStartRow(true);
    agentInstallPath.setEndRow(false);
    agentInstallPath.setValidators(
        absPathValidator); // we will "turn this on" when needed - this is to ensure we create paths
                           // properly and it doesn't go in places user isn't expecting

    findAgentInstallPathButton =
        new ButtonItem("findAgentInstallPathButton", MSG.view_remoteAgentInstall_buttonFindAgent());
    findAgentInstallPathButton.setStartRow(false);
    findAgentInstallPathButton.setEndRow(true);
    if (findAgentInstallPathButton.getTitle().length() < 15) { // i18n may prolong the title
      findAgentInstallPathButton.setWidth(100);
    }
    findAgentInstallPathButton.addClickHandler(
        new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
          public void onClick(
              com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) {
            // we only want to validate host
            if (connectionForm.getValueAsString("host") == null
                || connectionForm.getValueAsString("host").trim().isEmpty()) {
              final HashMap<String, String> errors = new HashMap<String, String>(1);
              errors.put("host", CoreGUI.getSmartGwtMessages().validator_requiredField());
              connectionForm.setErrors(errors, true);
              return;
            }

            new CheckSSHConnectionCallback() {
              @Override
              protected void doActualWork() {
                findAgentInstallPath();
              }
            }.execute();
          }
        });

    createAgentStatusTextItem();

    statusCheckButton = new ButtonItem("updateStatus", MSG.common_title_updateStatus());
    statusCheckButton.setStartRow(false);
    statusCheckButton.setEndRow(true);
    if (findAgentInstallPathButton.getTitle().length() < 15) { // i18n may prolong the title
      statusCheckButton.setWidth(100);
    }
    statusCheckButton.addClickHandler(
        new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
          public void onClick(
              com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) {
            if (connectionForm.validate()) {
              new CheckSSHConnectionCallback() {
                @Override
                protected void doActualWork() {
                  agentStatusCheck();
                }
              }.execute();
            }
          }
        });

    if (initialAgentInstall != null) {
      host.setValue(initialAgentInstall.getSshHost());
      if (initialAgentInstall.getSshPort() != null) {
        port.setValue(String.valueOf(initialAgentInstall.getSshPort()));
      }
      username.setValue(initialAgentInstall.getSshUsername());
      password.setValue(initialAgentInstall.getSshPassword());
      agentInstallPath.setValue(initialAgentInstall.getInstallLocation());
      // if it was already saved, assume they want it to stay remembered
      // however, because the uninstall page is getting rid of the agent, we don't need or want to
      // remember the credentials anymore
      if (!this.showUninstallButton) {
        rememberMeCheckbox.setValue(initialAgentInstall.getSshPassword() != null);
      }
    }

    // disable some form elements if we don't want the user changing them - they should have been
    // filled in by who ever created this view
    if (this.showUninstallButton || this.showStartButton || this.showStopButton) {
      host.setDisabled(true);
      port.setDisabled(true);
      agentInstallPath.setDisabled(true);
      findAgentInstallPathButton.setDisabled(true);
    }

    if (this.showUninstallButton) {
      // don't show rememberMe checkbox - we're getting rid of this agent so there won't be a record
      // to store the creds
      connectionForm.setFields(
          host,
          port,
          username,
          password,
          agentInstallPath,
          findAgentInstallPathButton,
          agentStatusText,
          statusCheckButton);
    } else {
      connectionForm.setFields(
          host,
          port,
          username,
          password,
          rememberMeCheckbox,
          agentInstallPath,
          findAgentInstallPathButton,
          agentStatusText,
          statusCheckButton);
    }

    return connectionForm;
  }
示例#3
0
  private DynamicForm getServerDetails() {
    final DynamicForm form = new LocatableDynamicForm(extendLocatorId("serverDetails"));
    form.setWidth100();
    form.setExtraSpace(15);
    form.setIsGroup(true);
    form.setGroupTitle(MSG.view_admin_systemSettings_serverDetails());

    final StaticTextItem productName = new StaticTextItem("productname", MSG.common_title_name());
    final StaticTextItem productVersion =
        new StaticTextItem("productversion", MSG.common_title_version());
    final StaticTextItem productBuildNumber =
        new StaticTextItem(
            "productbuild", MSG.view_admin_systemSettings_serverDetails_buildNumber());

    final StaticTextItem serverTimezone =
        new StaticTextItem("timezone", MSG.view_admin_systemSettings_serverDetails_tz());
    final StaticTextItem serverTime =
        new StaticTextItem("localtime", MSG.view_admin_systemSettings_serverDetails_time());
    final StaticTextItem serverInstallDir =
        new StaticTextItem("installdir", MSG.view_admin_systemSettings_serverDetails_installDir());
    final StaticTextItem dbUrl =
        new StaticTextItem("dbUrl", MSG.view_admin_systemSettings_serverDetails_dbUrl());
    final StaticTextItem dbProductName =
        new StaticTextItem("dbProductName", MSG.view_admin_systemSettings_serverDetails_dbName());
    final StaticTextItem dbProductVersion =
        new StaticTextItem(
            "dbProductVersion", MSG.view_admin_systemSettings_serverDetails_dbVersion());
    final StaticTextItem dbDriverName =
        new StaticTextItem(
            "dbDriverName", MSG.view_admin_systemSettings_serverDetails_dbDriverName());
    final StaticTextItem dbDriverVersion =
        new StaticTextItem(
            "dbDriverVersion", MSG.view_admin_systemSettings_serverDetails_dbDriverVersion());
    final StaticTextItem currentMeasRawTable =
        new StaticTextItem(
            "currentMeasRawTable", MSG.view_admin_systemSettings_serverDetails_currentTable());
    final StaticTextItem nextMeasTableRotation =
        new StaticTextItem(
            "nextMeasTableRotation", MSG.view_admin_systemSettings_serverDetails_nextRotation());

    productName.setWrapTitle(false);
    productVersion.setWrapTitle(false);
    productBuildNumber.setWrapTitle(false);
    serverTimezone.setWrapTitle(false);
    serverTime.setWrapTitle(false);
    serverInstallDir.setWrapTitle(false);
    dbUrl.setWrapTitle(false);
    dbProductName.setWrapTitle(false);
    dbProductVersion.setWrapTitle(false);
    dbDriverName.setWrapTitle(false);
    dbDriverVersion.setWrapTitle(false);
    currentMeasRawTable.setWrapTitle(false);
    nextMeasTableRotation.setWrapTitle(false);

    form.setItems(
        productName,
        productVersion,
        productBuildNumber,
        serverTimezone,
        serverTime,
        serverInstallDir,
        dbUrl,
        dbProductName,
        dbProductVersion,
        dbDriverName,
        dbDriverVersion,
        currentMeasRawTable,
        nextMeasTableRotation);

    GWTServiceLookup.getSystemService()
        .getServerDetails(
            new AsyncCallback<ServerDetails>() {

              @Override
              public void onSuccess(ServerDetails result) {
                ProductInfo productInfo = result.getProductInfo();
                form.setValue(productName.getName(), productInfo.getName());
                form.setValue(productVersion.getName(), productInfo.getVersion());
                form.setValue(productBuildNumber.getName(), productInfo.getBuildNumber());

                Map<Detail, String> details = result.getDetails();
                form.setValue(
                    serverTimezone.getName(), details.get(ServerDetails.Detail.SERVER_TIMEZONE));
                form.setValue(
                    serverTime.getName(), details.get(ServerDetails.Detail.SERVER_LOCAL_TIME));
                form.setValue(
                    serverInstallDir.getName(),
                    details.get(ServerDetails.Detail.SERVER_INSTALL_DIR));
                form.setValue(
                    dbUrl.getName(), details.get(ServerDetails.Detail.DATABASE_CONNECTION_URL));
                form.setValue(
                    dbProductName.getName(),
                    details.get(ServerDetails.Detail.DATABASE_PRODUCT_NAME));
                form.setValue(
                    dbProductVersion.getName(),
                    details.get(ServerDetails.Detail.DATABASE_PRODUCT_VERSION));
                form.setValue(
                    dbDriverName.getName(), details.get(ServerDetails.Detail.DATABASE_DRIVER_NAME));
                form.setValue(
                    dbDriverVersion.getName(),
                    details.get(ServerDetails.Detail.DATABASE_DRIVER_VERSION));
                form.setValue(
                    currentMeasRawTable.getName(),
                    details.get(ServerDetails.Detail.CURRENT_MEASUREMENT_TABLE));
                form.setValue(
                    nextMeasTableRotation.getName(),
                    details.get(ServerDetails.Detail.NEXT_MEASUREMENT_TABLE_ROTATION));
              }

              @Override
              public void onFailure(Throwable caught) {
                CoreGUI.getErrorHandler()
                    .handleError(MSG.view_admin_systemSettings_cannotLoadServerDetails(), caught);
              }
            });

    return form;
  }