Beispiel #1
0
  private HorizontalPanel makePostRow(final PostData post, final VerticalPanel mainPanel) {
    HorizontalPanel row = new HorizontalPanel();
    Label titleLabel = new Label("Title: " + post.getTitle() + " ");
    titleLabel.addStyleName("postLabel");
    Label descrLabel = new Label(post.getDescription() + " ");
    descrLabel.addStyleName("postLabel");
    Label priceLabel = new Label("Price: $" + post.getPrice() + " ");
    priceLabel.addStyleName("postLabel");
    Label nameLabel = new Label("Seller Name: " + post.getSellerName() + " ");
    nameLabel.addStyleName("postLabel");
    Anchor link = new Anchor("Uploaded File", post.getURL());
    link.setTarget("_blank");
    Button addressButton = new Button("Address");
    addressButton.addStyleName("postInfoButton");
    addressButton.setText("Address");
    // add a clickListener to the button
    addressButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            doMapPopup(post);
          }
        });

    Button deleteButton = new Button("Delete");
    deleteButton.addStyleName("postInfoButton");
    deleteButton.setText("Delete");
    // add a clickListener to the button
    deleteButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            control.handleDeleteRequest(post);
          }
        });
    Button editButton = new Button("Edit");
    editButton.addStyleName("postInfoButton");
    editButton.setText("Edit");
    // add a clickListener to the button
    editButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            viewPostEditForm(post);
          }
        });

    row.add(titleLabel);
    row.add(descrLabel);
    row.add(priceLabel);
    row.add(nameLabel);
    row.add(link);
    row.add(new Label("  "));
    row.add(addressButton);
    row.add(new Label("  "));
    row.add(editButton);
    row.add(new Label("  "));
    row.add(deleteButton);
    return row;
  }
Beispiel #2
0
 private void initialize() {
   String identifier = stableIdentifier.getDisplayName();
   Anchor link = new Anchor(identifier, "/cgi-bin/control_panel_st_id?ST_ID=" + identifier);
   link.setTarget("_blank");
   link.setTitle("Go to REACTOME control panel for " + identifier);
   initWidget(link);
 }
    void addOne(final AgreementInfo info, final String k) {
      final int row = table.getRowCount();
      table.insertRow(row);
      applyDataRowStyle(row);

      final ContributorAgreement cla = info.agreements.get(k);
      final String statusName;
      if (cla == null) {
        statusName = Util.C.agreementStatus_EXPIRED();
      } else {
        statusName = Util.C.agreementStatus_VERIFIED();
      }
      table.setText(row, 1, statusName);

      if (cla == null) {
        table.setText(row, 2, "");
        table.setText(row, 3, "");
      } else {
        final String url = cla.getAgreementUrl();
        if (url != null && url.length() > 0) {
          final Anchor a = new Anchor(cla.getName(), url);
          a.setTarget("_blank");
          table.setWidget(row, 2, a);
        } else {
          table.setText(row, 2, cla.getName());
        }
        table.setText(row, 3, cla.getDescription());
      }
      final FlexCellFormatter fmt = table.getFlexCellFormatter();
      for (int c = 1; c < 4; c++) {
        fmt.addStyleName(row, c, Gerrit.RESOURCES.css().dataCell());
      }

      setRowItem(row, cla);
    }
 @Override
 public void addProperty(EntryDto dto) {
   if (dto.getValue().toLowerCase().startsWith("http")) {
     Anchor a = new Anchor();
     a.setTarget("_blank");
     a.setHref(dto.getValue());
     a.setText(dto.getValue());
     properties.addProperty(new Label(dto.getKey()), a.asWidget());
   } else {
     properties.addProperty(dto.getKey(), dto.getValue());
   }
 }
  public PrefixDisplayViewImpl() {
    initWidget(uiBinder.createAndBindUi(this));

    mainlink.setTarget("_blank");

    settingsForm.setAction("/admin/settings");
    settingsForm.setEncoding(FormPanel.ENCODING_URLENCODED);
    settingsForm.setMethod(FormPanel.METHOD_POST);

    uploadForm.setAction("/admin/upload");
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);

    uploadDialog.setVisible(false);
    uploadDialog.setModal(true);
    uploadDialog.setGlassEnabled(true);
  }
  @Override
  public void render(final Context context, final ResultRowModel result, final SafeHtmlBuilder sb) {
    if (result == null) {
      return;
    }

    final StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(
        "<b>Location</b> " + locationConstants.getString(result.getLocation()) + " <br/>");
    stringBuilder.append("<b>Server</b> " + result.getComputeCost() + " (RAM " + result.getRam());
    if (!ZERO_HERTZ.equals(result.getCpu())) {
      stringBuilder.append(" / CPU " + result.getCpu());
    }
    if (!ZERO_BYTE.equals(result.getStorage())) {
      stringBuilder.append(" / Storage " + result.getStorage());
    }
    stringBuilder.append(
        ") <br/> <b>Bandwidth</b> "
            + result.getBandwidthCost()
            + " (In "
            + result.getBandwidthInCost()
            + " / Out "
            + result.getBandwidthOutCost()
            + ")<br/>");
    final HTML config = new HTML(stringBuilder.toString());
    config.addStyleName("cloud-location-config");

    final String link = providerConstants.getString(result.getProviderName() + "_details_site");
    final Anchor anchor = new Anchor(staticConstants.location_details(), link);
    anchor.setTarget("_top");
    anchor.addStyleName("cloud-location-details");

    final FlowPanel panel = new FlowPanel();
    panel.add(config);
    panel.add(anchor);
    panel.addStyleName("cloud-location");
    final DecoratorPanel decPanel = new DecoratorPanel();
    decPanel.setWidget(panel);
    sb.appendHtmlConstant(decPanel.toString());
  }
Beispiel #7
0
  // Helper method to create the internals of the HTML Form (FormPanel)
  //  Submit form may be for new post, or for editing existing post
  private FormPanel makeSubmitPostForm(final PostData post) {
    final FormPanel submitFormPanel = new FormPanel();
    VerticalPanel postFormPanel = new VerticalPanel();
    postFormPanel.addStyleName("submitPostVertPanel");
    submitFormPanel.add(postFormPanel);

    // Name input
    HorizontalPanel nameRow = new HorizontalPanel();
    Label nameLabel = new Label("Name (First Last");
    final TextBox nameTextbox = new TextBox();
    nameRow.add(nameLabel);
    nameRow.add(nameTextbox);
    postFormPanel.add(nameRow);

    // Title input
    HorizontalPanel titleRow = new HorizontalPanel();
    Label titleLabel = new Label("Title (e.g. car, bike, etc)");
    final TextBox titleTextbox = new TextBox();
    titleRow.add(titleLabel);
    titleRow.add(titleTextbox);
    postFormPanel.add(titleRow);

    // Description input
    HorizontalPanel descrRow = new HorizontalPanel();
    Label descrLabel = new Label("Item Short description");
    final TextArea descrText = new TextArea();
    descrText.setCharacterWidth(40);
    descrText.setVisibleLines(10);
    descrRow.add(descrLabel);
    descrRow.add(descrText);
    postFormPanel.add(descrRow);

    // Price input
    HorizontalPanel priceRow = new HorizontalPanel();
    Label priceLabel = new Label("Price ($)");
    final TextBox priceTextbox = new TextBox();
    priceTextbox.setVisibleLength(6);
    priceRow.add(priceLabel);
    priceRow.add(priceTextbox);
    postFormPanel.add(priceRow);

    // Address input
    HorizontalPanel addressRow = new HorizontalPanel();
    Label addressLabel = new Label("Address");
    final TextArea addressText = new TextArea();
    addressText.setCharacterWidth(40);
    addressText.setVisibleLines(5);
    addressRow.add(addressLabel);
    addressRow.add(addressText);
    postFormPanel.add(addressRow);

    if (post != null) {
      nameTextbox.setText(post.getSellerName());
      titleTextbox.setText(post.getTitle());
      descrText.setText(post.getDescription());
      priceTextbox.setText("" + post.getPrice());
      addressText.setText(post.getAddress());
    }

    // New widget for file upload
    HorizontalPanel fileRow = new HorizontalPanel();
    final FileUpload upload = new FileUpload();
    if (post != null) {
      Anchor link = new Anchor("Stored File", post.getURL());
      link.setTarget("_blank");
      fileRow.add(link);
      upload.setTitle("Change Uploaded File");
    } else upload.setTitle("Upload a File for Post");
    fileRow.add(upload);
    postFormPanel.add(fileRow);

    // Submit button
    Button submitButton;
    if (post != null) {
      submitButton = new Button("Submit Changes");
      submitButton.setText("Submit Changes");
    } else {
      submitButton = new Button("Submit Ad");
      submitButton.setText("Submit Ad");
    }
    submitButton.setStyleName("sideBarButton");
    postFormPanel.add(submitButton);

    // The submitFormPanel, when submitted, will trigger an HTTP call to the
    // servlet.  The following parameters must be set
    submitFormPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    submitFormPanel.setMethod(FormPanel.METHOD_POST);

    // Set Names for the text boxes so that they can be retrieved from the
    // HTTP call as parameters
    nameTextbox.setName("name");
    titleTextbox.setName("title");
    descrText.setName("description");
    priceTextbox.setName("price");
    addressText.setName("address");
    upload.setName("upload");

    // Upon clicking "Submit" control goes to Controller
    submitButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            if (post == null) control.handlePostFromSubmitForm(submitFormPanel);
            else control.handlePostEditFromSubmitForm(post, submitFormPanel);
          }
        });

    // This event handler is "fired" just before the Form causes a doPost
    //  message to server
    submitFormPanel.addSubmitHandler(
        new FormPanel.SubmitHandler() {
          public void onSubmit(SubmitEvent event) {
            // This event is fired just before the form is submitted.
            //  We can take this opportunity to perform validation.
            if (nameTextbox.getText().length() == 0) {
              Window.alert("The author is required.");
              event.cancel();
            }
            if (titleTextbox.getText().length() == 0) {
              Window.alert("The title is required.");
              event.cancel();
            }
            Double price = Double.parseDouble(priceTextbox.getText());
            if (priceTextbox.getText().length() == 0 || Double.isNaN(price)) {
              Window.alert("The price is required. It must be a valid number");
              event.cancel();
            }
            if (addressText.getText().length() == 0) {
              Window.alert("The address is required.");
              event.cancel();
            }
            if (upload.getFilename().length() == 0 && post == null) {
              Window.alert("The upload file is required.");
              event.cancel();
            }
          }
        });

    // The doPost message itself is sent from the Form and not intercepted
    //  by GWT.

    // This event handler is "fired" just after the Form causes a doPost
    //  message to server
    submitFormPanel.addSubmitCompleteHandler(
        new FormPanel.SubmitCompleteHandler() {
          public void onSubmitComplete(SubmitCompleteEvent event) {
            if (post == null) {
              submitFormPanel.reset();
              nameTextbox.setFocus(true);
            } else control.viewAdDataFromServer();
          }
        });
    return submitFormPanel;
  }
  public void setView(UserFollowDo userFollowDo) {
    profileThumbnailImage.setUrl(userFollowDo.getProfileImageUrl());
    profileThumbnailImage.addErrorHandler(
        new ErrorHandler() {

          @Override
          public void onError(ErrorEvent event) {
            profileThumbnailImage.setUrl("images/settings/setting-user-image.png");
          }
        });

    // userNameLabel.setText(userFollowDo.getUsername());
    userNameLabel.getElement().setId(userFollowDo.getGooruUid());

    int collectionCount = userFollowDo.getSummary().getCollection();
    userCollections.setText(
        collectionCount + (collectionCount == 1 ? " Collection" : " Collections"));
    userCollections
        .getElement()
        .setAttribute(
            "alt", collectionCount + (collectionCount == 1 ? " Collection" : " Collections"));
    userCollections
        .getElement()
        .setAttribute(
            "title", collectionCount + (collectionCount == 1 ? " Collection" : " Collections"));

    userFollowDetails.setText(
        userFollowDo.getSummary().getFollowers()
            + (userFollowDo.getSummary().getFollowers() == 1 ? " Follower" : " Followers")
            + " | "
            + userFollowDo.getSummary().getFollowing()
            + " Following");
    userFollowDetails
        .getElement()
        .setAttribute(
            "alt",
            userFollowDo.getSummary().getFollowers()
                + (userFollowDo.getSummary().getFollowers() == 1 ? " Follower" : " Followers")
                + " | "
                + userFollowDo.getSummary().getFollowing()
                + " Following");
    userFollowDetails
        .getElement()
        .setAttribute(
            "title",
            userFollowDo.getSummary().getFollowers()
                + (userFollowDo.getSummary().getFollowers() == 1 ? " Follower" : " Followers")
                + " | "
                + userFollowDo.getSummary().getFollowing()
                + " Following");

    String gooruUid = userNameLabel.getElement().getId();
    Anchor anchor = new Anchor();
    String userName = userFollowDo.getUsername();

    String token = "#" + PlaceTokens.PROFILE_PAGE + "&id=" + gooruUid + "&user="******"style", "font-size: 18px !important");
    anchor.setTarget("_blank");
    userNameLabel.setText("");
    userNameLabel.getElement().setAttribute("alt", "");
    userNameLabel.getElement().setAttribute("title", "");
    //		boolean isEnabled =  userFollowDo.getCustomFields() != null &&
    // userFollowDo.getCustomFields().get(0).getOptionalValue() != null &&
    // userFollowDo.getCustomFields().get(0).getOptionalValue().equalsIgnoreCase("true") ? true :
    // false;
    boolean isEnabled = false;
    if (userFollowDo.getCustomFields() != null) {
      for (int i = 0; i < userFollowDo.getCustomFields().size(); i++)
        if (userFollowDo
            .getCustomFields()
            .get(i)
            .getOptionalKey()
            .equalsIgnoreCase("show_profile_page")) {
          isEnabled =
              userFollowDo.getCustomFields().get(i).getOptionalValue().equalsIgnoreCase("true")
                  ? true
                  : false;
        }
    }
    if (isEnabled) {
      userNameLabel.getElement().appendChild(anchor.getElement());
    } else {
      userNameLabel.setText(userFollowDo.getUsername());
      userNameLabel.getElement().setAttribute("alt", userFollowDo.getUsername());
      userNameLabel.getElement().setAttribute("title", userFollowDo.getUsername());
      userNameLabel.getElement().getStyle().setCursor(Cursor.DEFAULT);
    }
  }