Search in sources :

Example 51 with Anchor

use of com.google.gwt.user.client.ui.Anchor in project opennms by OpenNMS.

the class TagPanel method updatePanel.

private void updatePanel() {
    int minCount = Integer.MAX_VALUE, maxCount = Integer.MIN_VALUE;
    Map<String, Integer> tagCounts = new TreeMap<String, Integer>();
    for (String tag : m_delegate) {
        if (tagCounts.containsKey(tag)) {
            tagCounts.put(tag, tagCounts.get(tag).intValue() + 1);
        } else {
            tagCounts.put(tag, 1);
        }
    }
    for (int entry : tagCounts.values()) {
        if (entry < minCount)
            minCount = entry;
        if (entry > maxCount)
            maxCount = entry;
    }
    tagPanel.clear();
    for (final Map.Entry<String, Integer> entry : tagCounts.entrySet()) {
        final String tagText = entry.getKey();
        final Anchor tagLabel = new Anchor();
        double rawValue = (double) (entry.getValue() - minCount) * TagStyles.COUNT / (double) (maxCount - minCount);
        tagLabel.setHTML(tagText.replace(" ", "&nbsp;"));
        tagLabel.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                selectTag(tagText);
                m_eventBus.fireEvent(new TagSelectedEvent(tagText));
            }
        });
        switch((int) Math.round(rawValue)) {
            case (0):
                tagLabel.addStyleName(tagStyles.tag0());
                break;
            case (1):
                tagLabel.addStyleName(tagStyles.tag1());
                break;
            case (2):
                tagLabel.addStyleName(tagStyles.tag2());
                break;
            case (3):
                tagLabel.addStyleName(tagStyles.tag3());
                break;
            case (4):
                tagLabel.addStyleName(tagStyles.tag4());
                break;
            case (5):
                tagLabel.addStyleName(tagStyles.tag5());
                break;
            case (6):
                tagLabel.addStyleName(tagStyles.tag6());
                break;
            case (7):
                tagLabel.addStyleName(tagStyles.tag7());
                break;
            case (8):
                tagLabel.addStyleName(tagStyles.tag8());
                break;
            case (9):
                tagLabel.addStyleName(tagStyles.tag9());
                break;
            default:
                tagLabel.addStyleName(tagStyles.tag9());
        }
        tagPanel.add(tagLabel);
        // without this, the tag cloud doesn't wrap properly
        tagPanel.add(new InlineHTML(" "));
    }
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) InlineHTML(com.google.gwt.user.client.ui.InlineHTML) TreeMap(java.util.TreeMap) Anchor(com.google.gwt.user.client.ui.Anchor) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 52 with Anchor

use of com.google.gwt.user.client.ui.Anchor in project gwt-cs by iSergio.

the class ShowcaseBrandsProvider method get.

@Override
public List<Anchor> get() {
    Anchor anchor = new Anchor("Ol3-Cesium");
    List<Anchor> list = new ArrayList<Anchor>();
    list.add(anchor);
    return list;
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) ArrayList(java.util.ArrayList)

Example 53 with Anchor

use of com.google.gwt.user.client.ui.Anchor in project activityinfo by bedatadriven.

the class DataEntryPage method createNewInterfaceLink.

private Component createNewInterfaceLink() {
    betaLinkPanel = new ContentPanel();
    betaLinkPanel.setHeaderVisible(false);
    betaLinkPanel.setLayout(new CenterLayout());
    Anchor betaLink = new Anchor(I18N.CONSTANTS.tryNewDataEntryInterface());
    betaLink.addClickHandler(clickEvent -> {
        if (!clickEvent.isControlKeyDown()) {
            navigateToNewNewInterface();
        } else {
            navigateToNewInterface();
        }
    });
    betaLinkPanel.add(betaLink);
    return betaLinkPanel;
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) CenterLayout(com.extjs.gxt.ui.client.widget.layout.CenterLayout)

Example 54 with Anchor

use of com.google.gwt.user.client.ui.Anchor in project ovirt-engine by oVirt.

the class SubTabClusterGeneralPresenter method addTextAndLinkAlert.

/**
 * Create a widget containing text and a link that triggers the execution of a command.
 *
 * @param view
 *            the view where the alert should be added
 * @param text
 *            the text content of the alert
 * @param commands
 *            the command that should be executed when the link is clicked
 */
private void addTextAndLinkAlert(final ViewDef view, final String text, final UICommand... commands) {
    // Create a flow panel containing the text and the link:
    final FlowPanel alertPanel = new FlowPanel();
    int start = 0;
    for (final UICommand command : commands) {
        // Find the open and close positions of the link within the message:
        // $NON-NLS-1$
        final int openIndex = text.indexOf("<a>", start);
        // $NON-NLS-1$
        final int closeIndex = text.indexOf("</a>", start);
        if (openIndex == -1 || closeIndex == -1 || closeIndex < openIndex) {
            break;
        }
        // Extract the text before, inside and after the tags:
        final String beforeText = text.substring(start, openIndex);
        final String betweenText = text.substring(openIndex + 3, closeIndex);
        start = closeIndex + 4;
        // Create the label for the text before the tag:
        final Label beforeLabel = new Label(beforeText);
        // $NON-NLS-1$ //$NON-NLS-2$
        beforeLabel.getElement().getStyle().setProperty("display", "inline");
        alertPanel.add(beforeLabel);
        // Create the anchor:
        final Anchor betweenAnchor = new Anchor(betweenText);
        // $NON-NLS-1$ //$NON-NLS-2$
        betweenAnchor.getElement().getStyle().setProperty("display", "inline");
        alertPanel.add(betweenAnchor);
        // Add a listener to the anchor so that the command is executed when
        // it is clicked:
        betweenAnchor.addClickHandler(event -> command.execute());
    }
    if (start < text.length()) {
        final String afterText = text.substring(start);
        // Create the label for the text after the tag:
        final Label afterLabel = new Label(afterText);
        // $NON-NLS-1$ //$NON-NLS-2$
        afterLabel.getElement().getStyle().setProperty("display", "inline");
        alertPanel.add(afterLabel);
    }
    if (start > 0) {
        // Add the alert to the view:
        view.addAlert(alertPanel);
    }
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Label(com.google.gwt.user.client.ui.Label) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 55 with Anchor

use of com.google.gwt.user.client.ui.Anchor in project ovirt-engine by oVirt.

the class HostFenceAgentPopupView method initEditors.

private void initEditors() {
    pmTypeEditor = new ListModelListBoxEditor<>(new StringRenderer<String>());
    pmEncryptOptionsEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    pmEncryptOptionsEditor.setUsePatternFly(true);
    pmSecureEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    pmSecureEditor.setUsePatternFly(true);
    fencingOptionsUrl = new Anchor(constants.fencingOptionsLabel());
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) StringRenderer(org.ovirt.engine.ui.common.widget.renderer.StringRenderer) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)

Aggregations

Anchor (com.google.gwt.user.client.ui.Anchor)90 Test (org.junit.Test)63 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)51 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)4 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 Label (com.google.gwt.user.client.ui.Label)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 CenterLayout (com.extjs.gxt.ui.client.widget.layout.CenterLayout)1 AvatarImage (com.google.gerrit.client.AvatarImage)1 DiffObject (com.google.gerrit.client.DiffObject)1