Search in sources :

Example 1 with ListGroupItem

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

the class MenuView method getLabelFromHref.

@Override
public String getLabelFromHref(String href) {
    ListGroupItem group = hrefToGroupLabelMap.get(href);
    String result = "";
    if (group != null) {
        result = ((Anchor) group.getWidget(1)).getElement().getInnerText().trim();
    }
    return result;
}
Also used : ListGroupItem(org.gwtbootstrap3.client.ui.ListGroupItem)

Example 2 with ListGroupItem

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

the class MenuView method addPrimaryMenuItemPlace.

private int addPrimaryMenuItemPlace(int index, String label, String href, String iconCssName) {
    ListGroupItem newMenuItem = new ListGroupItem();
    Anchor menuAnchor = new Anchor(hashifyString(href));
    if (index < 0) {
        index = 0;
    }
    Span iconSpan = new Span();
    if (iconCssName != null) {
        iconSpan.addStyleName(determineCssIconBase(iconCssName));
        iconSpan.addStyleName(iconCssName);
        newMenuItem.addStyleName(Styles.ACTIVE);
    }
    menuAnchor.add(iconSpan);
    Span labelSpan = new Span();
    labelSpan.setText(label);
    labelSpan.addStyleName(PatternflyStyles.LIST_GROUP_ITEM_VALUE);
    menuAnchor.add(labelSpan);
    newMenuItem.add(menuAnchor);
    // Insert the new menu item into the href map.
    hrefToGroupLabelMap.put(href, newMenuItem);
    if (index > menuListGroup.getWidgetCount()) {
        menuListGroup.add(newMenuItem);
    } else {
        menuListGroup.insert(newMenuItem, index);
    }
    return menuListGroup.getWidgetIndex(newMenuItem);
}
Also used : Anchor(org.gwtbootstrap3.client.ui.Anchor) ListGroupItem(org.gwtbootstrap3.client.ui.ListGroupItem) Span(org.gwtbootstrap3.client.ui.html.Span)

Example 3 with ListGroupItem

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

the class MenuView method addSecondaryMenuItemPlace.

private int addSecondaryMenuItemPlace(int index, String label, String href, int primaryMenuIndex) {
    // Found an existing primary menu, add the secondary menu.
    int result = -1;
    ListGroupItem primaryMenuItem = (ListGroupItem) menuListGroup.getWidget(primaryMenuIndex);
    FlowPanel secondaryMenuFlowPanel = null;
    IsWidget widget = primaryMenuItem.getWidget(2);
    if (widget instanceof FlowPanel) {
        secondaryMenuFlowPanel = (FlowPanel) widget;
    }
    if (secondaryMenuFlowPanel != null) {
        if (index >= 0 && index < secondaryMenuFlowPanel.getWidgetCount()) {
            secondaryMenuFlowPanel.insert(createSecondaryMenuItem(label, href), index + 1);
            result = index;
        } else {
            secondaryMenuFlowPanel.add(createSecondaryMenuItem(label, href));
            result = secondaryMenuFlowPanel.getWidgetCount() - 1;
        }
    }
    primaryMenuItem.add(secondaryMenuFlowPanel);
    return result;
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) ListGroupItem(org.gwtbootstrap3.client.ui.ListGroupItem)

Example 4 with ListGroupItem

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

the class PatternflyListView method updateInfoPanel.

private void updateInfoPanel() {
    if (getModel().getItems() instanceof List) {
        clearClickHandlers();
        clear();
        int i = 0;
        List<PatternflyListViewItem<T>> newCurrentState = new ArrayList<>();
        Set<Integer> selectedItemsIndexes = new HashSet<>();
        for (T item : getModel().getItems()) {
            if (item == null) {
                continue;
            }
            PatternflyListViewItem<T> newItem = creator.createListViewItem(item);
            handlerRegistrations.add(newItem.addClickHandler(this));
            if (i < currentState.size()) {
                restoreState(currentState.get(i), newItem);
                if (selectedIndexes.contains(i)) {
                    newItem.asListGroupItem().addStyleName(Styles.ACTIVE);
                    selectedItemsIndexes.add(i);
                }
            }
            newCurrentState.add(newItem);
            add(newItem.asListGroupItem());
            i++;
        }
        selectedIndexes = selectedItemsIndexes;
        currentState.clear();
        currentState = newCurrentState;
        if (getWidgetCount() == 0) {
            // No items found.
            ListGroupItem noItems = new ListGroupItem();
            noItems.addStyleName(Styles.LIST_GROUP_ITEM_HEADING);
            noItems.setText(constants.noItemsToDisplay());
            add(noItems);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ListGroupItem(org.gwtbootstrap3.client.ui.ListGroupItem) HashSet(java.util.HashSet)

Example 5 with ListGroupItem

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

the class MenuView method createSecondaryMenuHeader.

private FlowPanel createSecondaryMenuHeader(ListGroupItem primaryMenuItem) {
    FlowPanel secondaryMenuFlowPanel;
    // This is a menu item with no secondary menu
    secondaryMenuFlowPanel = new FlowPanel();
    secondaryMenuFlowPanel.addStyleName(PatternflyStyles.NAV_SECONDARY_NAV);
    FlowPanel secondaryMenuHeader = new FlowPanel();
    secondaryMenuHeader.addStyleName(PatternflyStyles.NAV_ITEM_HEADER);
    secondaryMenuFlowPanel.add(secondaryMenuHeader);
    Anchor secondaryMenuPin = new Anchor();
    secondaryMenuPin.setHref(JAVASCRIPT);
    secondaryMenuPin.addStyleName(PatternflyStyles.SECONDARY_COLLAPSE_TOGGLE);
    secondaryMenuPin.getElement().setAttribute(Attributes.DATA_TOGGLE, PatternflyStyles.NAV_COLLAPSE_SECONDARY_NAV);
    secondaryMenuHeader.add(secondaryMenuPin);
    Span secondaryMenuHeaderLabel = new Span();
    secondaryMenuHeader.add(secondaryMenuHeaderLabel);
    for (int i = 0; i < primaryMenuItem.getWidgetCount(); i++) {
        IsWidget widget = primaryMenuItem.getWidget(i);
        if (widget.asWidget() instanceof Anchor) {
            // This is the anchor with the href, replace it with javascrip:;
            Anchor labelAnchor = (Anchor) widget.asWidget();
            for (int j = 0; j < labelAnchor.getWidgetCount(); j++) {
                if (labelAnchor.getWidget(j).getStyleName().contains(PatternflyStyles.LIST_GROUP_ITEM_VALUE)) {
                    secondaryMenuHeaderLabel.setText(((Span) labelAnchor.getWidget(j)).getText());
                }
            }
        }
    }
    primaryMenuItem.add(secondaryMenuFlowPanel);
    return secondaryMenuFlowPanel;
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) Anchor(org.gwtbootstrap3.client.ui.Anchor) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Span(org.gwtbootstrap3.client.ui.html.Span)

Aggregations

ListGroupItem (org.gwtbootstrap3.client.ui.ListGroupItem)8 Anchor (org.gwtbootstrap3.client.ui.Anchor)4 Span (org.gwtbootstrap3.client.ui.html.Span)4 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 IsWidget (com.google.gwt.user.client.ui.IsWidget)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)1 ListGroup (org.gwtbootstrap3.client.ui.ListGroup)1 TagModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)1