com.google.gwt.user.client.ui.Anchor Java Examples

The following examples show how to use com.google.gwt.user.client.ui.Anchor. 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: AnchorBuilder.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
public Anchor buildClick() {
	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 (clickHandler != null) {
		anchor.addClickHandler(clickHandler);
	}

	return anchor;
}
 
Example #2
Source File: TaskExecutionsTable.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected Widget getCell(final TaskExecutionInterface e, final TaskExecutionsTableColumn column, final int idx) {
	switch (column) {
	case DATE: return new Label(sDateFormatMeeting.format(e.getExecutionDate()));
	case TIME: return new Label(e.getExecutionTime(CONSTANTS));
	case QUEUED: return new Label(e.getQueued() == null ? "" : sDateFormatTS.format(e.getQueued()));
	case STARTED: return new Label(e.getStarted() == null ? "" : sDateFormatTS.format(e.getStarted()));
	case FINISHED: return new Label(e.getFinished() == null ? "" : sDateFormatTS.format(e.getFinished()));
	case STATUS: return new Label(CONSTANTS.taskStatus()[e.getStatus().ordinal()]);
	case MESSAGE:
		Label message = new Label(e.getStatusMessage() == null ? "" : e.getStatusMessage()); message.addStyleName("status-message");
		if (e.getStatusMessage() != null)
			message.setTitle(e.getStatusMessage());
		return message;
	case OUTPUT:
		if (e.getOutput() != null) return new Anchor(e.getOutput(), GWT.getHostPageBaseURL() + "taskfile?e=" + e.getId());
		return new Label("");
	default:
		return null;
	}
}
 
Example #3
Source File: UniTimeDialogBox.java    From unitime with Apache License 2.0 6 votes vote down vote up
public UniTimeDialogBox(boolean autoHide, boolean modal) {
      super(autoHide, modal);
      
setAnimationEnabled(true);
setGlassEnabled(true);
	
      iContainer = new FlowPanel();
      iContainer.addStyleName("dialogContainer");
      
      iClose = new Anchor();
  	iClose.setTitle(MESSAGES.hintCloseDialog());
      iClose.setStyleName("close");
      iClose.addClickHandler(new ClickHandler() {
      	@Override
          public void onClick(ClickEvent event) {
              onCloseClick(event);
          }
      });
      iClose.setVisible(autoHide);

      iControls = new FlowPanel();
      iControls.setStyleName("dialogControls");        
      iControls.add(iClose);
  }
 
Example #4
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 #5
Source File: UTCTimeBoxImplHtml4.java    From gwt-traction with Apache License 2.0 6 votes vote down vote up
public TimeBoxMenuOption(long offsetFromMidnight) {
    this.offsetFromMidnight = offsetFromMidnight;

    // format the time in the local time zone
    long time = UTCDateBox.timezoneOffsetMillis(new Date(0)) + offsetFromMidnight;
    value = timeFormat.format(new Date(time));

    Anchor anchor = new Anchor(value);
    anchor.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            acceptValue();
            hideMenu();
            clearInvalidStyle();
        }

    });
    setWidget(anchor);
}
 
Example #6
Source File: TractionDialogBox.java    From gwt-traction with Apache License 2.0 6 votes vote down vote up
public TractionDialogBox(boolean autoHide, boolean modal, boolean showCloseIcon) {
super(autoHide, modal, new TractionCaption());

container = new SimplePanel();
container.addStyleName("dialogContainer");

close = new Anchor();
close.setStyleName("x");
close.addClickHandler(new ClickHandler() {
           @Override
           public void onClick(ClickEvent event) {
               onCloseClick(event);
           }
});
setCloseIconVisible(showCloseIcon);

controls = new FlowPanel();
controls.setStyleName("dialogControls");
controls.add(close);

// add the controls to the end of the caption
TractionCaption caption = (TractionCaption) getCaption();
caption.add(controls);
   }
 
Example #7
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private void createLuckyGoogleButton()
{
    Anchor rndGoogleButton = Anchor.wrap(Document.get().getElementById("btn_rnd_google"));
    final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    rndGoogleButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            wcService.getRandomGoogleUrl(new AsyncCallback<String>()
            {
                public void onSuccess(String result)
                {
                    textArea.setText(result);
                }

                public void onFailure(Throwable caught)
                {
                    textArea.setText("google: hot trend");
                }
            });

        }
    });
}
 
Example #8
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private void createLuckyYoutubeButton()
{
    Anchor rndWikiButton = Anchor.wrap(Document.get().getElementById("btn_rnd_youtube"));
    final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    rndWikiButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            wcService.getRandomYoutubeUrl(new AsyncCallback<String>()
            {
                public void onSuccess(String result)
                {
                    textArea.setText(result);
                }

                public void onFailure(Throwable caught)
                {
                    textArea.setText("https://www.youtube.com");
                }
            });

        }
    });
}
 
Example #9
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private void createLuckyTwitterButton()
{
    Anchor rndWikiButton = Anchor.wrap(Document.get().getElementById("btn_rnd_twitter"));
    final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    rndWikiButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            wcService.getRandomTwitterUrl(new AsyncCallback<String>()
            {
                public void onSuccess(String result)
                {
                    textArea.setText(result);
                }

                public void onFailure(Throwable caught)
                {
                    textArea.setText("twitter: hot trend");
                }
            });

        }
    });
}
 
Example #10
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private void createLuckyWikiButton()
{
    Anchor rndWikiButton = Anchor.wrap(Document.get().getElementById("btn_rnd_wiki"));
    final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    rndWikiButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            wcService.getRandomWikiUrl(new AsyncCallback<String>()
            {
                public void onSuccess(String result)
                {
                    textArea.setText(result);
                }

                public void onFailure(Throwable caught)
                {
                    textArea.setText("http://en.wikipedia.org/wiki/Special:random");
                }
            });

        }
    });
}
 
Example #11
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 #12
Source File: AnchorBuilder.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private MouseOverHandler getMouseOverhandler(final Anchor anchor) {
	return new MouseOverHandler() {
		@Override
		public void onMouseOver(MouseOverEvent event) {
			anchor.addStyleName(ThemeStyles.get().style().borderBottom());
		}
	};
}
 
Example #13
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 #14
Source File: MapToolTipPopup.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void addImageAttribute(final StringBuffer htmlString, final String attributeValue) {
	final String url = attributeValue.replace("img:", "");
	final Image image = new Image(url);
	image.setSize("48px", "48px");
	
	final Anchor anchor = new AnchorBuilder().setHref(url)
			.setTitle(UIMessages.INSTANCE.openInNewWindow())
			.setImage(image).build();

	htmlString.append(anchor.getElement().getString());
}
 
Example #15
Source File: MapToolTipPopup.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void addHyperlinkAttribute(final StringBuffer htmlString, final String attributeValue) {
	final Anchor anchor = new AnchorBuilder()
			.setText(attributeValue)
			.setHref(attributeValue)
			.setTitle(UIMessages.INSTANCE.openInNewWindow()).build();

	htmlString.append(anchor.getElement().getString());
}
 
Example #16
Source File: Welcome.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private HorizontalPanel getPanel(final HTML data) {
	HorizontalPanel panel = new HorizontalPanel();
	panel.setSize("520px", "310px");
	panel.setSpacing(5);
	panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
	Anchor anchor = new AnchorBuilder().setHref("http://www.geowe.org")
			.setImage(new Image(ImageProvider.INSTANCE.geoweSquareLogo()))
			.build();

	panel.add(anchor);
	panel.add(data);
	return panel;
}
 
Example #17
Source File: ClientUtils.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and adds a logout link to the Root panel, at the top right absolute position.
 * @param text      text of the logout link
 * @param logoutUrl logout URL
 * @return the logout link
 */
public static Anchor createAndSetupLogoutLink( final String text, final String logoutUrl ) {
	final Anchor logoutLink = new Anchor( text, logoutUrl );
	
	// Absolute position to the top right
	DOM.setStyleAttribute( logoutLink.getElement(), "position", "absolute" );
	DOM.setStyleAttribute( logoutLink.getElement(), "top"     , "2px"      );
	DOM.setStyleAttribute( logoutLink.getElement(), "right"   , "4px"      );
	
	RootPanel.get().add( logoutLink );
	
	return logoutLink;
}
 
Example #18
Source File: FileStatsPage.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns a link with the text being the specified google account and which when clicked
 * opens the complete file stats of the specified account.
 * @param googleAccount google account to create a link for
 * @return the created new link
 */
public static Anchor createLinkForOpenGoogleAccount( final String googleAccount ) {
	final Anchor googleAccountAnchor = new Anchor( googleAccount );
	
	googleAccountAnchor.setTitle( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER.toString() );
	googleAccountAnchor.addClickHandler( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER );
	
	return googleAccountAnchor;
}
 
Example #19
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Refresh proposed query row
 *
 * @param propose
 */
private void refreshProposedQueryRow(final GWTProposedQueryReceived propose, int row) {
	boolean seen = (propose.getSeenDate() == null);
	// Sets folder object
	data.put(new Integer(dataTable.getHTML(row, 5)), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(row, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(row, 0, "");
	}

	dataTable.setHTML(row, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String queryType = "";

	if (!propose.getParams().isDashboard()) {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.query");
	} else {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.user.query");
	}

	dataTable.setHTML(row, 2, UtilComunicator.getTextAsBoldHTML(queryType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(row, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));
	Anchor anchor = new Anchor();
	String queryName = propose.getParams().getQueryName();
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(queryName, seen));
	anchor.setTitle(queryName);
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			WorkspaceComunicator.changeSelectedTab(UIDockPanelConstants.SEARCH);
			SearchComunicator.setSavedSearch(propose.getParams());
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(row, 4, anchor);
}
 
Example #20
Source File: YoungAndroidPalettePanel.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private void initExtensionPanel() {
  Anchor addComponentAnchor = new Anchor(MESSAGES.importExtensionMenuItem());
  addComponentAnchor.setStylePrimaryName("ode-ExtensionAnchor");
  addComponentAnchor.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      new ComponentImportWizard().center();
    }
  });

  categoryPanels.get(ComponentCategory.EXTENSION).add(addComponentAnchor);
  categoryPanels.get(ComponentCategory.EXTENSION).setCellHorizontalAlignment(
      addComponentAnchor, HasHorizontalAlignment.ALIGN_CENTER);
}
 
Example #21
Source File: AnchorBuilder.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private MouseOutHandler getMouseOutHandler(final Anchor anchor) {
	return new MouseOutHandler() {
		@Override
		public void onMouseOut(MouseOutEvent event) {
			anchor.removeStyleName(ThemeStyles.get().style().borderBottom());
		}
	};
}
 
Example #22
Source File: ApiCallStatsPage.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns a link with the text being the specified google account and which when clicked
 * opens the complete API call stats of the specified account.
 * @param googleAccount google account to create a link for
 * @return the created new link
 */
public static Anchor createLinkForOpenGoogleAccount( final String googleAccount ) {
	final Anchor googleAccountAnchor = new Anchor( googleAccount );
	
	googleAccountAnchor.setTitle( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER.toString() );
	googleAccountAnchor.addClickHandler( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER );
	
	return googleAccountAnchor;
}
 
Example #23
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 #24
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 #25
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());
}
 
Example #26
Source File: LienzoDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Override
public void addFilterReset() {
    Anchor anchor = new Anchor(LienzoDisplayerConstants.INSTANCE.resetAnchor());
    filterPanel.add(anchor);
    anchor.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getPresenter().onFilterResetClicked();
        }
    });
}
 
Example #27
Source File: ChartJsDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Override
public void addFilterReset() {
    Anchor anchor = new Anchor(ChartJsDisplayerConstants.INSTANCE.chartjsDisplayer_resetAnchor());
    filterPanel.add(anchor);
    anchor.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getPresenter().onFilterResetClicked();
        }
    });
}
 
Example #28
Source File: GwtHyperlinkImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public GwtHyperlinkImpl() {
  setStyleName("ui-hyperlink-root");

  myAnchor = new Anchor();
  myAnchor.setStyleName("ui-hyperlink");

  rebuild();
}
 
Example #29
Source File: SSOAccessControlView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Widget createWidget() {

    VerticalPanel panel = new VerticalPanel();
    panel.add(new ContentHeaderLabel("Access Control"));
    
    ContentDescription description = new ContentDescription(Console.CONSTANTS.sso_access_control_description());

    String text = "<span title=\"" + Console.CONSTANTS.sso_access_control_service_title()
            + "\">" + Console.CONSTANTS.sso_access_control_service_title() + "</span>: <a href=\"" 
            + BootstrapContext.retrieveSsoAuthUrl() + "\" target=\"_blank\">" + BootstrapContext.retrieveSsoAuthUrl() 
            + "</a>";

    Anchor userProfileAnchor = new Anchor(Console.CONSTANTS.sso_access_control_user_profile());
    userProfileAnchor.addClickHandler(clickEvent -> {
        String userMgmt = SSOUtils.getSsoUserManagementUrl();
        Window.Location.replace(userMgmt);
    });
    
    ContentDescription ssoLink = new ContentDescription(text);
    panel.add(description);
    panel.add(userProfileAnchor);
    panel.add(ssoLink);

    VerticalPanel outerPanel = new VerticalPanel();
    outerPanel.setStyleName("rhs-content-panel");
    outerPanel.add(panel);

    DefaultTabLayoutPanel tabLayoutPanel = new DefaultTabLayoutPanel(40, Style.Unit.PX);
    tabLayoutPanel.addStyleName("default-tabpanel");
    tabLayoutPanel.add(outerPanel, "Access Control");
    return tabLayoutPanel;
}
 
Example #30
Source File: DeploymentBrowseContentView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void browseContent(List<ModelNode> contentItems) {

    panel.clear();
    List<ModelNode> contents = new ArrayList<>(contentItems);
    Collections.sort(contents, new Comparator<ModelNode>() {
        @Override
        public int compare(final ModelNode o1, final ModelNode o2) {
            return o1.get(PATH).asString().compareTo(o2.get(PATH).asString());
        }
    });
    
    for (ModelNode file: contents) {
        String contentFile = file.get(PATH).asString();
        boolean isDirectory = file.get("directory").asBoolean();
        long fileLength = 0;
        if (isDirectory) 
            continue;
        else
            fileLength = file.get("file-size").asLong();
        
        String fileLengthDisplay = "";
        if (fileLength > 0) 
            fileLengthDisplay = formatFileUnits(fileLength);
        
        Anchor anchor = new Anchor(contentFile + " | " + fileLengthDisplay);
        anchor.addClickHandler(clickEvent -> {
            Anchor sourceAnchor = (Anchor) clickEvent.getSource();
            String filepath = sourceAnchor.getText();
            // retrieve only the path portion
            filepath = filepath.substring(0, filepath.lastIndexOf('|') - 1);
            presenter.downloadFile(filepath);
        });
                
        panel.add(anchor);
    }
}