Ejemplo n.º 1
0
  @Override
  protected void onInit() {
    super.onInit();
    Layout layout = new VLayout();
    layout.setPadding(5);
    layout.setMembersMargin(5);
    layout.addMember(getConnectionForm());
    layout.setDefaultLayoutAlign(Alignment.CENTER);
    layout.setLayoutAlign(Alignment.CENTER);

    if (this.showInstallButton) {
      agentConfigXmlUploadForm = createAgentConfigXmlUploadForm();
      layout.addMember(agentConfigXmlUploadForm);
      /* For now, don't allow users to upload and ship their own env script to a remote machine; that might have security implications.
       * If we want to allow this, just uncomment these lines and you are good to go because everything else that is needed
       * is already in place and working as of April 2014.
      rhqAgentEnvUploadForm = createAgentEnvUploadForm();
      layout.addMember(rhqAgentEnvUploadForm);
      */
    }

    HTMLFlow header = new HTMLFlow("");
    header.setStyleName("headerItem");
    header.setExtraSpace(5);
    layout.addMember(header);
    layout.addMember(getButtons());

    addMember(layout);
  }
Ejemplo n.º 2
0
    HtmlUploadComponentImpl(final UploadComponentOptions options, final boolean zip) {
      this.zip = zip;
      if (zip) {
        types = "*.zip";
        typesDescription = "Zip";
      } else {
        types = options.getTypes() == null ? null : options.getTypes();
        typesDescription =
            options.getTypesDescription() == null ? null : options.getTypesDescription();
      }
      this.options = options;
      if (isMultiple()) {
        formPanel.setHeight("125px");
        scrollPanel.setHeight("125px");
        formPanel.setWidth("320px");
        scrollPanel.setWidth("320px");
      } else {
        formPanel.setHeight("30px");
        scrollPanel.setHeight("30px");
        formPanel.setWidth("310px");
        scrollPanel.setWidth("310px");
      }

      panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

      formPanel.setWidget(scrollPanel);
      formPanel.setAction(GWT.getHostPageBaseURL() + "fileupload?zip=" + zip);
      formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
      formPanel.setMethod(FormPanel.METHOD_POST);
      formPanel.addSubmitHandler(
          new SubmitHandler() {
            public void onSubmit(final SubmitEvent submitEvent) {}
          });
      formPanel.addSubmitCompleteHandler(
          new SubmitCompleteHandler() {
            public void onSubmitComplete(final SubmitCompleteEvent completeEvent) {
              System.out.println("Submit complete " + completeEvent.getResults());
              final String result = completeEvent.getResults();
              try {
                final List<FileSource> fileSources = toFileSources(result);
                options.getCompletionCallback().onSuccess(fileSources);
              } catch (final Exception e) {
                options.getCompletionCallback().onFailure(e);
              }
            }
          });
      final Layout parent = getParentCanvas(options);
      // final String parentPreix;
      // if(isZip) {
      //  parentPrefix = DomConstants.UPLOAD_PANEL_ZIP;
      // } else {
      //  parentPrefix = DomConstants.UPLOAD_PANEL_PLAIN;
      // }

      parent.setWidth100();
      if (debug) {
        parent.setBorder("1px solid pink");
      }
      parent.setAlign(VerticalAlignment.CENTER);
      parent.setLayoutAlign(VerticalAlignment.CENTER);
      final Layout wrapperLayout = new VLayout();
      // wrapperLayout.setHeight100();
      wrapperLayout.setWidth100();
      if (isMultiple()) {
        wrapperLayout.setHeight("140px");
      } else {
        wrapperLayout.setHeight("30px");
      }
      if (debug) {
        wrapperLayout.setBorder("1px solid blue");
      }
      wrapperLayout.setAlign(VerticalAlignment.CENTER);
      wrapperLayout.setLayoutAlign(VerticalAlignment.CENTER);
      /*
       * wrapperLayout.setGroupTitle(isMultiple() ? "File(s)" : (zip ? "Zip File" : "File"));
       * wrapperLayout.setIsGroup(true);
       * wrapperLayout.setPadding(15);
       * wrapperLayout.setLayoutAlign(Alignment.CENTER);
       * wrapperLayout.setAlign(Alignment.CENTER);
       */
      if (isMultiple()) {
        final Label addLabel =
            SmartUtils.smartParagraph(
                "<span style=\"color:blue;cursor:pointer; text-decoration: underline;\">Add Upload</span>");
        addLabel.addClickHandler(
            new ClickHandler() {
              public void onClick(final ClickEvent clickEvent) {
                addFileUploadWidget();
              }
            });
        wrapperLayout.addMember(addLabel);
      }
      wrapperLayout.addMember(formPanel);
      parent.addMember(wrapperLayout);
      // parent.setLayoutAlign(Alignment.CENTER);
      // parent.setAlign(Alignment.CENTER);
      addFileUploadWidget();
      setWidget(parent);
      parent.addDrawHandler(
          new DrawHandler() {

            public void onDraw(DrawEvent event) {
              if (zip) {
                parent.getDOM().addClassName(DomConstants.UPLOAD_PANEL_ZIP);
              } else {
                parent.getDOM().addClassName(DomConstants.UPLOAD_PANEL_PLAIN);
              }
            }
          });
    }