Search in sources :

Example 36 with Anchor

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);
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(com.google.gwt.user.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Grid(com.google.gwt.user.client.ui.Grid) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) NativeString(com.google.gerrit.client.rpc.NativeString) CopyableLabel(com.google.gwtexpui.clippy.client.CopyableLabel) CellFormatter(com.google.gwt.user.client.ui.HTMLTable.CellFormatter)

Example 37 with Anchor

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);
    }
}
Also used : ProjectLinkMenuItem(com.google.gerrit.client.ui.ProjectLinkMenuItem) LinkMenuItem(com.google.gerrit.client.ui.LinkMenuItem) Anchor(com.google.gwt.user.client.ui.Anchor)

Example 38 with Anchor

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);
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 39 with Anchor

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");
    }
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 40 with Anchor

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]\">");
    }
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Aggregations

Anchor (com.google.gwt.user.client.ui.Anchor)80 Test (org.junit.Test)59 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)47 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)4 Image (com.google.gwt.user.client.ui.Image)4 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)4 ImageResourceRenderer (com.google.gwt.user.client.ui.ImageResourceRenderer)3 RestApi (com.google.gerrit.client.rpc.RestApi)2 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)2 Grid (com.google.gwt.user.client.ui.Grid)2 CellFormatter (com.google.gwt.user.client.ui.HTMLTable.CellFormatter)2 InlineHTML (com.google.gwt.user.client.ui.InlineHTML)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 AvatarImage (com.google.gerrit.client.AvatarImage)1 DiffObject (com.google.gerrit.client.DiffObject)1 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)1 BlameInfo (com.google.gerrit.client.blame.BlameInfo)1 ProjectInfo (com.google.gerrit.client.projects.ProjectInfo)1