Example usage for com.google.gwt.user.client.ui Hyperlink addClickHandler

List of usage examples for com.google.gwt.user.client.ui Hyperlink addClickHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Hyperlink addClickHandler.

Prototype

@Deprecated
public HandlerRegistration addClickHandler(ClickHandler handler) 

Source Link

Usage

From source file:com.edgenius.wiki.gwt.client.page.widgets.TagPopup.java

License:Open Source License

public TagPopup(UIObject target, String spaceUname, String tagname) {
    super(target, true, true, true);
    this.spaceUname = spaceUname;
    this.tagname = tagname;

    VerticalPanel panel = new VerticalPanel();
    panel.add(message);/*from  www  .java  2  s. c o m*/
    panel.add(new HTML("<b>" + tagname + "</b>"));
    panel.add(new Hr());
    panel.add(pagesPanel);
    if (!AbstractEntryPoint.isOffline()) {
        //so far, have to block tag cloud in offline model as the macro render logic is on MacroHandler side, it is not easy to do in 
        //offline model.
        Hyperlink tagCloud = new Hyperlink(Msg.consts.goto_tagcloud(),
                GwtUtils.buildToken(GwtUtils.getCPageToken(SharedConstants.CPAGE_TAG_CLOUD), spaceUname));
        tagCloud.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                TagPopup.this.hide();
            }
        });
        panel.add(tagCloud);
        panel.setCellHorizontalAlignment(tagCloud, HasHorizontalAlignment.ALIGN_RIGHT);
    }
    panel.setSize("100%", "100%");
    this.setWidget(panel);

}

From source file:com.edgenius.wiki.gwt.client.page.widgets.TagPopup.java

License:Open Source License

public void onSuccess(PageItemListModel model) {
    if (!GwtClientUtils.preSuccessCheck(model, message)) {
        return;/*  w  ww .j  a v a 2s.c o  m*/
    }

    pagesPanel.clear();
    for (PageItemModel item : model.itemList) {
        Hyperlink link = new Hyperlink(item.title, GwtUtils.getSpacePageToken(item.spaceUname, item.title));
        link.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                TagPopup.this.hide();
            }
        });
        pagesPanel.add(link);
    }

    resized();
}

From source file:com.edgenius.wiki.gwt.client.user.UserInfoPanel.java

License:Open Source License

private void refresh(final PageItemListModel model) {
    List<PageItemModel> pages = model.itemList;
    pagesPanel.clear();/* w  ww  .jav  a 2s  .  c  o m*/
    status.setText(model.userStatus);
    //don't need update... this is just for user portrait is not input when the user portrait URL is not available when popup initial.
    if (this.showPortrait && portraitPanel.getWidgetCount() == 0) {
        portraitPanel.add(GwtClientUtils.createUserPortrait(model.userPortrait));
    }
    if (pages != null && pages.size() > 0) {
        for (Iterator<PageItemModel> iter = pages.iterator(); iter.hasNext();) {
            PageItemModel item = iter.next();
            Hyperlink link = new Hyperlink(item.title, GwtUtils.getSpacePageToken(item.spaceUname, item.title));
            if (parent instanceof Popup) {
                link.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        ((Popup) parent).hide();
                    }
                });
            }
            ;
            pagesPanel.add(link);
        }
    } else {
        pagesPanel.add(new HTML("(" + Msg.consts.none() + ")"));
    }

    if (!AbstractEntryPoint.isOffline()) {
        if (model.isFollowing >= 0) {

            ClickLink sendMsg = new ClickLink(Msg.consts.send_message());
            sendMsg.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    if (parent instanceof Popup) {
                        ((Popup) parent).hide();
                    }
                    //show send message dialogue
                    SendMessageDialog msgDlg = new SendMessageDialog(username);
                    msgDlg.showbox();
                }
            });
            func.add(sendMsg);

            func.add(new FollowLink(model.isFollowing, username));
        }

        //so far, have to block profile page in offline model as the macro render logic is on MacroHandler side, it is not easy to do in 
        //offline model.
        Hyperlink link = new Hyperlink(Msg.consts.goto_profile(),
                GwtUtils.buildToken(GwtUtils.getCPageToken(SharedConstants.CPAGE_USER_PROFILE), username));
        if (parent instanceof Popup) {
            link.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    ((Popup) parent).hide();
                }
            });
        }
        func.add(link);
    }
    if (parent instanceof Popup) {
        ((Popup) parent).resized();
    }
}

From source file:com.google.gwt.gen2.demo.fasttree.client.FastTreeDemo.java

License:Apache License

protected Widget basicTree() {
    FastTree t = new FastTree();
    FastTreeItem a = t.addItem("A root tree item");
    a.addItem("A child with different style");
    a.addItem("regular style");
    FastTreeItem aXb = a.addItem("Another child");
    aXb.addItem("a grand child");
    FastTreeItem widgetBranch = a.addItem(new CheckBox("A checkbox child"));
    FastTreeItem textBoxParent = widgetBranch.addItem("A TextBox parent");
    textBoxParent.addItem(new TextBox());
    textBoxParent.addItem("and another one...");
    textBoxParent.addItem(new TextArea());

    // Add an item with basic elements inside of it
    {//from  w ww. ja v  a 2 s.c  o m
        final TextBox textBox = new TextBox();
        Hyperlink link = new Hyperlink("change focus", "blah");
        link.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                textBox.setFocus(true);
                event.getNativeEvent().stopPropagation();
            }
        });
        VerticalPanel vPanel = new VerticalPanel();
        vPanel.add(link);
        vPanel.add(textBox);
        a.addItem(vPanel);
    }

    // Add a large item
    FastTreeItem hugeParent = a.addItem("I contain a huge item");
    SimplePanel hugePanel = new SimplePanel();
    hugePanel.setPixelSize(1000, 1000);
    hugePanel.getElement().getStyle().setProperty("border", "2px solid blue");
    hugePanel.getElement().getStyle().setPropertyPx("padding", 50);
    Label clickableLabel = new Label("Click Me");
    clickableLabel.setWidth("70px");
    clickableLabel.getElement().getStyle().setProperty("border", "1px solid blue");
    clickableLabel.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("You clicked the label");
        }
    });
    hugePanel.setWidget(clickableLabel);
    hugeParent.addItem(hugePanel);

    ListBox lb = new ListBox();
    for (int i = 0; i < 100; i++) {
        lb.addItem(i + "");
    }
    widgetBranch.addItem("A ListBox parent").addItem(lb);
    return t;
}

From source file:com.pietschy.gwt.pectin.client.components.AbstractDynamicList.java

License:Apache License

public AbstractDynamicList(String addLinkText, String removeLinkText, boolean allowEmpty) {
    layout.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);
    layout.setSpacing(0);//from w  ww . ja v  a 2 s  . com
    list.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);

    DOM.setStyleAttribute(list.getElement(), "marginBottom", "0.3em");

    this.allowEmpty = allowEmpty;
    if (!this.allowEmpty) {
        list.add(new Row(createWidget()));
    }

    this.removeLinkText = removeLinkText;
    Hyperlink add = new Hyperlink(addLinkText, "");
    add.addClickHandler(listener);

    layout.add(list);
    layout.add(add);

    initWidget(layout);
    updateUI();
}

From source file:com.qualogy.qafe.gwt.client.component.MenuItemComponent.java

License:Apache License

public MenuItemComponent(final String menuItemName, final String uuid, final String windowId) {
    setSpacing(2);/*from ww  w . ja v  a 2 s. c  o  m*/

    Hyperlink hyperlink = new Hyperlink(menuItemName, "history");

    hyperlink.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (event.getSource() instanceof Widget) {
                Widget sender = (Widget) event.getSource();
                ClientApplicationContext.getInstance().removeWindow(windowId, null, uuid);
                MainFactoryActions.getUIByUUID(uuid, windowId);

                // try to close the disclosurePanel

                Widget parent = sender.getParent();
                boolean found = false;
                while (parent != null && !found) {
                    if (parent instanceof DisclosurePanel) {
                        DisclosurePanel disclosurePanel = (DisclosurePanel) (parent);
                        disclosurePanel.setOpen(false);
                        found = true;
                    } else {
                        parent = parent.getParent();
                    }
                }

                if (sender.getParent() != null && sender.getParent().getParent() != null) {
                    if (sender.getParent().getParent() instanceof DisclosurePanel) {
                        DisclosurePanel disclosurePanel = (DisclosurePanel) (sender.getParent().getParent());
                        disclosurePanel.setOpen(false);

                    }
                }

            }

        }
    });
    add(hyperlink);
    setStyleName(DEFAULT_STYLE);

}

From source file:com.qualogy.qafe.gwt.client.component.MenuItemComponent.java

License:Apache License

public MenuItemComponent(final String menuItemName, String history, String styleName, final String url) {

    setSpacing(2);/*from   www . j a  va2 s.  c o m*/

    Hyperlink hyperlink = new Hyperlink(menuItemName, "history");

    hyperlink.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            MainFactory.createWindowWithUrl(menuItemName, url);

            postRender();

        }
    });
    add(hyperlink);
    setStyleName(styleName);
}

From source file:de.lilawelt.zmachine.client.offline.OfflineMenuImplReal.java

License:Open Source License

public void showGames() {
    if (showing) {
        return;/*w ww. ja v  a 2 s .c  o  m*/
    }

    showing = true;

    p.remove(statusLabel);

    Label title = new Label("Available games:");
    p.add(title, DockPanel.NORTH);

    HTMLTable h = new FlexTable();
    h.setText(0, 0, "Game Name:");

    p.add(h, DockPanel.NORTH);

    try {
        Database db = f.createDatabase();
        db.open("textadventure-saves");

        ResultSet rs = db.execute("Select gamename, gameuid from offlinegames;");
        for (int i = 0; rs.isValidRow(); ++i, rs.next()) {

            final String name = rs.getFieldAsString(0);
            final String uid = rs.getFieldAsString(1);

            Hyperlink link = new Hyperlink();
            link.setText(rs.getFieldAsString(0));
            link.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    Machine.get().loadStory("/games/" + name + ".sto", uid);
                }
            });
            h.setWidget(i + 1, 0, link);
        }
    } catch (Exception e) {
        Window.alert("Error: " + e.getMessage());
    }

}

From source file:org.eurekastreams.web.client.ui.common.form.elements.UrlValidatorFormElement.java

License:Apache License

/**
 * Default constructor./*from w  ww  .  j a va 2s .  c o  m*/
 *
 * @param labelVal
 *            the label.
 * @param inKey
 *            the key.
 * @param value
 *            the value.
 * @param inInstructions
 *            the instructions.
 * @param required
 *            whether its required.
 * @param inGenerateUrlCommand
 *            generate url command.
 */
public UrlValidatorFormElement(final String labelVal, final String inKey, final String value,
        final String inInstructions, final boolean required, final GenerateUrlCommand inGenerateUrlCommand) {
    super(labelVal, inKey, value, inInstructions, required);
    thisBuffered = this;
    originalValueFormElement = new ValueOnlyFormElement(inKey + "original", value);

    this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().urlValidator());

    generateUrlCommand = inGenerateUrlCommand;

    Hyperlink closeUrlPanel = new Hyperlink("Delete", History.getToken());
    closeUrlPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().smallX());
    closeUrlPanel.addClickHandler(new ClickHandler() {

        public void onClick(final ClickEvent event) {
            urlPanel.setVisible(false);
            getTextBox().setVisible(true);
            getTextBox().setText("");
            importBtn.setVisible(true);
            failed = true;
        }
    });

    urlPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().urlPanel());
    urlPanel.setVisible(false);
    urlLabel.setStyleName(StaticResourceBundle.INSTANCE.coreCss().urlLabel());
    urlPanel.add(closeUrlPanel);
    urlPanel.add(urlLabel);
    mainPanel.insert(urlPanel, 3);

    importBtn = new Hyperlink("import", History.getToken());
    importBtn.addStyleName(StaticResourceBundle.INSTANCE.coreCss().importButton());
    importBtn.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formUploadButton());
    importBtn.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton());
    mainPanel.insert(importBtn, 4);
    processingSpinny.setVisible(false);
    processingSpinny.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formSubmitSpinny());
    mainPanel.insert(processingSpinny, 5);

    errorBox = new FlowPanel();
    errorBox.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formErrorBox());
    errorBox.setVisible(false);

    errorLabel.getElement().setId("url-validator-form-element-error-label");
    errorLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().error());
    errorBox.add(errorLabel);

    errorDetail.addStyleName(StaticResourceBundle.INSTANCE.coreCss().error());
    errorBox.add(errorDetail);

    mainPanel.insert(errorBox, 0);

    importBtn.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            importUrl();
        }
    });
}

From source file:org.eurekastreams.web.client.ui.common.notification.NotificationsDialogContent.java

License:Apache License

/**
 * Constructor.//  www.  ja  v a 2s  . c o  m
 */
public NotificationsDialogContent() {
    // -- build UI --
    main.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifDialogMain());

    Hyperlink editSettings = new Hyperlink("edit settings", Session.getInstance()
            .generateUrl(new CreateUrlRequest(Page.SETTINGS, null, "tab", "Notifications")));
    editSettings.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifEditSettingsLink());
    main.add(editSettings);

    scrollPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifScrollList());

    scrollPanel.add(listPanel);

    main.add(scrollPanel);
    listPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifWait());

    // -- setup events --
    final EventBus eventBus = Session.getInstance().getEventBus();

    eventBus.addObserver(GotNotificationListResponseEvent.class,
            new Observer<GotNotificationListResponseEvent>() {
                public void update(final GotNotificationListResponseEvent ev) {
                    eventBus.removeObserver(ev, this);
                    displayNotifications(ev.getResponse());
                }
            });

    // Since none of the links cause a full page load (which would annihilate the dialog), we must explicitly close
    // the dialog. We cannot count on a history change event (or any of the related events) because the user may
    // already be on the exact page to which the link would send them. (If clicking a link would cause no change to
    // the URL, the GWT does not raise the event.) So we close the dialog on a link being clicked. We directly
    // listen on the "edit settings" link, and have the links in notifications raise an event we listen to.

    editSettings.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent inArg0) {
            close();
        }
    });

    linkClickedObserver = new Observer<DialogLinkClickedEvent>() {
        public void update(final DialogLinkClickedEvent inArg1) {
            close();
        }
    };
    Session.getInstance().getEventBus().addObserver(DialogLinkClickedEvent.class, linkClickedObserver);

    // -- request data --
    NotificationListModel.getInstance().fetch(null, false);
}