Java Code Examples for com.google.gwt.user.client.ui.Anchor#setHref()

The following examples show how to use com.google.gwt.user.client.ui.Anchor#setHref() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfilePage.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method to validify a hyperlink
 * @param link    the GWT anchor object to validify
 * @param linktext    the actual http link that the anchor should point to
 */
private void makeValidLink(Anchor link, String linktext) {
  if (linktext == null) {
    link.setText("N/A");
  } else {
    if (linktext.isEmpty()) {
      link.setText("N/A");
    } else {
      linktext = linktext.toLowerCase();
      // Validate link format, fill in http part
      if (!linktext.startsWith("http")) {
        linktext = "http://" + linktext;
      }
      link.setText(linktext);
      link.setHref(linktext);
      link.setTarget("_blank");
    }
  }
}
 
Example 2
Source File: AnchorBuilder.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Build the Anchor with target="_blank"
 * 
 * @return Anchor
 */
public Anchor build() {
	final Anchor anchor = new Anchor();

	if (image != null) {
		anchor.getElement().appendChild(image.getElement());
	}
	if (text != null) {
		anchor.setText(text);
	}
	if (title != null) {
		anchor.setTitle(title);
	}
	if (bottomBorderOnMouseOver) {
		anchor.addMouseOverHandler(getMouseOverhandler(anchor));
		anchor.addMouseOutHandler(getMouseOutHandler(anchor));
	}
	anchor.setHref(href);
	anchor.setTarget("_blank");

	return anchor;
}
 
Example 3
Source File: WebTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
public InstructorCell(ArrayList<String> names, ArrayList<String> emails, String separator) {
	super(null, separator);
	if (names != null && !names.isEmpty()) {
		separator = separator.replace(" ", "&nbsp;");
		for (int i = 0; i < names.size(); i++) {
			String text = names.get(i) + (i + 1 < names.size() ? separator : "");
			String email = (emails != null && i < emails.size() ? emails.get(i) : null);
			if (email != null && !email.isEmpty()) {
				iText += text;
				HorizontalPanel p = new HorizontalPanel();
				p.setStyleName("instructor");
				Anchor a = new Anchor();
				a.setHref("mailto:" + email);
				a.setHTML(new Image(RESOURCES.email()).getElement().getString());
				a.setTitle(MESSAGES.sendEmail(names.get(i)));
				a.setStyleName("unitime-SimpleLink");
				a.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						event.stopPropagation();
					}
				});
				p.add(a);
				p.setCellVerticalAlignment(a, HasVerticalAlignment.ALIGN_MIDDLE);
				HTML h = new HTML(text, false);
				h.getElement().getStyle().setMarginLeft(2, Unit.PX);
				p.add(h);
				iPanel.add(p);
				iContent.add(h);
			} else
				add(text);
		}
	} else {
		add("&nbsp;");
	}
}
 
Example 4
Source File: PlaygroundView.java    From caja with Apache License 2.0 5 votes vote down vote up
private void initFeedbackPanel() {
  playgroundUI.feedbackPanel.setHorizontalAlignment(
      HasHorizontalAlignment.ALIGN_RIGHT);
  for (Menu menu : Menu.values()) {
    Anchor menuItem = new Anchor();
    menuItem.setHTML(menu.description);
    menuItem.setHref(menu.url);
    menuItem.setWordWrap(false);
    menuItem.addStyleName("menuItems");
    playgroundUI.feedbackPanel.add(menuItem);
    playgroundUI.feedbackPanel.setCellWidth(menuItem, "100%");
  }
}
 
Example 5
Source File: WordCloudLatestApp.java    From swcv with MIT License 5 votes vote down vote up
private Widget createSourceField(WordCloud cloud, boolean debug)
{
    String inputText = cloud.getInputText().trim();
    if (debug)
    {
        Anchor link = new Anchor(cutString(inputText));
        link.setHref("/cloud/download?ft=source&id=" + cloud.getId());
        return link;
    }
    else
    {
        return new HTML(cutString(inputText));
    }
}
 
Example 6
Source File: WordCloudDetailApp.java    From swcv with MIT License 5 votes vote down vote up
private void addSaveAsLinks(WordCloud cloud)
{
    Anchor link = Anchor.wrap(Document.get().getElementById("save-as-svg"));
    link.setHref("/cloud/download?ft=svg&id=" + cloud.getId());

    Anchor linkPNG = Anchor.wrap(Document.get().getElementById("save-as-png"));
    linkPNG.setHref("/cloud/download?ft=png&id=" + cloud.getId());

    Anchor linkPDF = Anchor.wrap(Document.get().getElementById("save-as-pdf"));
    linkPDF.setHref("/cloud/download?ft=pdf&id=" + cloud.getId());
}