Search in sources :

Example 16 with AnchorListItem

use of org.gwtbootstrap3.client.ui.AnchorListItem in project ovirt-engine by oVirt.

the class OvirtBreadCrumbsView method createSelectionDropDown.

// Can't make this a composite class since I can't put anything inside
// an AnchorListItem besides text using ui.xml files. But manually I can
// add widgets without issue.
private AnchorListItem createSelectionDropDown(SafeHtml currentName) {
    OvirtAnchorListItem dropDown = new OvirtAnchorListItem();
    Button exchangeButton = new Button();
    exchangeButton.setIcon(IconType.EXCHANGE);
    exchangeButton.addStyleName(QUICK_SWITCH);
    exchangeButton.getElement().getStyle().setMarginLeft(10, Unit.PX);
    exchangeButton.getElement().getStyle().setMarginTop(-5, Unit.PX);
    Anchor anchor = dropDown.getAnchor();
    anchor.getElement().setInnerHTML(currentName.asString());
    anchor.getElement().getStyle().setFontSize(28, Unit.PX);
    anchor.addClickHandler(e -> {
        if (popover.isVisible()) {
            popover.hide();
        } else {
            popover.show();
        }
    });
    anchor.add(exchangeButton);
    createPopover(anchor);
    dropDown.add(anchor);
    return dropDown;
}
Also used : Anchor(org.gwtbootstrap3.client.ui.Anchor) Button(org.gwtbootstrap3.client.ui.Button)

Example 17 with AnchorListItem

use of org.gwtbootstrap3.client.ui.AnchorListItem in project ovirt-engine by oVirt.

the class ListModelSearchBox method setInternalRowData.

private void setInternalRowData(int start, List<? extends T> values) {
    final int oldCount = menu.getWidgetCount();
    clearMenu();
    emptyMenuHandlers();
    for (T model : values) {
        if (model instanceof Nameable) {
            final String text = getName(model).asString();
            final AnchorListItem item = new SearchBoxAnchorListItem(this);
            item.setText(text);
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    if (StringHelper.isNotNullOrEmpty(currentSearch)) {
                        String newText = text.replaceAll(currentSearch, // $NON-NLS-1$
                        "<strong>" + currentSearch + // $NON-NLS-1$
                        "</strong>");
                        item.getWidget(0).getElement().setInnerHTML(newText);
                    }
                }
            });
            menuHandlers.add(item.addClickHandler(this));
            menu.add(item);
        }
    }
    if (oldCount != menu.getWidgetCount()) {
        currentFocusIndex = 0;
    }
    if (currentFocusIndex >= menu.getWidgetCount() - 1) {
        currentFocusIndex = menu.getWidgetCount() - 1;
    }
    if (currentFocusIndex >= 0) {
        ((AnchorListItem) menu.getWidget(currentFocusIndex)).setFocus(true);
    }
}
Also used : Nameable(org.ovirt.engine.core.common.businessentities.Nameable) AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) GWT(com.google.gwt.core.client.GWT) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 18 with AnchorListItem

use of org.gwtbootstrap3.client.ui.AnchorListItem in project ovirt-engine by oVirt.

the class SearchPanelView method addAvailableBookmarks.

@Override
public HandlerRegistration addAvailableBookmarks(Bookmark bookmark, ClickHandler handler) {
    AnchorListItem bookmarkItem = new AnchorListItem();
    bookmarkItem.setText(bookmark.getName());
    HandlerRegistration registration = bookmarkItem.addClickHandler(handler);
    searchBoxBookmarkListDropDown.add(bookmarkItem);
    searchBoxBookmarkListDropDownButton.setEnabled(searchBoxBookmarkListDropDown.getWidgetCount() > 0);
    return registration;
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem)

Aggregations

AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)17 DropDownMenu (org.gwtbootstrap3.client.ui.DropDownMenu)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 Button (org.gwtbootstrap3.client.ui.Button)5 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 Inject (javax.inject.Inject)4 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)4 ButtonSize (org.gwtbootstrap3.client.ui.constants.ButtonSize)4 IconType (org.gwtbootstrap3.client.ui.constants.IconType)4 Toggle (org.gwtbootstrap3.client.ui.constants.Toggle)4 MenuUtils (org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils)4 MenuItem (org.uberfire.workbench.model.menu.MenuItem)4 Divider (org.gwtbootstrap3.client.ui.Divider)2 DropDownHeader (org.gwtbootstrap3.client.ui.DropDownHeader)2 IconPosition (org.gwtbootstrap3.client.ui.constants.IconPosition)2 Pull (org.gwtbootstrap3.client.ui.constants.Pull)2 ClientTranslationService (org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService)2 Command (org.uberfire.mvp.Command)2