use of com.google.gwt.user.client.ui.Anchor in project gerrit by GerritCodeReview.
the class MyPasswordScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
String url = Gerrit.info().auth().httpPasswordUrl();
if (url != null) {
Anchor link = new Anchor();
link.setText(Util.C.linkObtainPassword());
link.setHref(url);
link.setTarget("_blank");
add(link);
return;
}
password = new CopyableLabel("(click 'generate' to revoke an old password)");
password.addStyleName(Gerrit.RESOURCES.css().accountPassword());
generatePassword = new Button(Util.C.buttonGeneratePassword());
generatePassword.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
doGeneratePassword();
}
});
final Grid userInfo = new Grid(2, 2);
final CellFormatter fmt = userInfo.getCellFormatter();
userInfo.setStyleName(Gerrit.RESOURCES.css().infoBlock());
userInfo.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
add(userInfo);
row(userInfo, 0, Util.C.userName(), new UsernameField());
row(userInfo, 1, Util.C.password(), password);
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader());
final FlowPanel buttons = new FlowPanel();
buttons.add(generatePassword);
add(buttons);
}
use of com.google.gwt.user.client.ui.Anchor in project gerrit by GerritCodeReview.
the class Gerrit method addExtensionLink.
private static void addExtensionLink(LinkMenuBar m, TopMenuItem item) {
if (item.getUrl().startsWith("#") && (item.getTarget() == null || item.getTarget().isEmpty())) {
LinkMenuItem a = new LinkMenuItem(item.getName(), item.getUrl().substring(1));
if (item.getId() != null) {
a.getElement().setAttribute("id", item.getId());
}
m.addItem(a);
} else {
Anchor atag = anchor(item.getName(), isAbsolute(item.getUrl()) ? item.getUrl() : selfRedirect(item.getUrl()));
if (item.getTarget() != null && !item.getTarget().isEmpty()) {
atag.setTarget(item.getTarget());
}
if (item.getId() != null) {
atag.getElement().setAttribute("id", item.getId());
}
m.add(atag);
}
}
use of com.google.gwt.user.client.ui.Anchor in project GwtMobile by dennisjzh.
the class Utils method loadUrl.
//The url loaded by this method can be intercepted by
//WebViewClient.shouldOverrideUrlLoading
public static void loadUrl(String url) {
Anchor a = new Anchor("", url);
RootLayoutPanel.get().add(a);
NativeEvent event = Document.get().createClickEvent(1, 1, 1, 1, 1, false, false, false, false);
a.getElement().dispatchEvent(event);
RootLayoutPanel.get().remove(a);
}
use of com.google.gwt.user.client.ui.Anchor in project gwt-test-utils by gwt-test-utils.
the class WidgetAssertTest method isVisibleAssertionErrorMessage.
@Test
public void isVisibleAssertionErrorMessage() {
// Given
Anchor a = new Anchor();
a.setVisible(false);
// When
try {
GwtAssertions.assertThat(a).isVisible();
fail("AssertionError should be thrown");
} catch (AssertionError e) {
assertThat(e.getMessage()).isEqualTo("[Anchor] should be visible");
}
}
use of com.google.gwt.user.client.ui.Anchor in project gwt-test-utils by gwt-test-utils.
the class WidgetAssertTest method textEqualsWithAsAssertionErrorMessage.
@Test
public void textEqualsWithAsAssertionErrorMessage() {
// Given
Anchor a = new Anchor();
a.setText("Ben Linus");
// When
try {
GwtAssertions.assertThat(a).as("my anchor").textEquals("John Locke");
fail("AssertionError should be thrown");
} catch (AssertionError e) {
assertThat(e.getMessage()).isEqualTo("[my anchor text] expected:<\"[John Locke]\"> but was:<\"[Ben Linus]\">");
}
}
Aggregations