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;
}
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);
}
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;
}
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);
}
}
}
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;
}
Aggregations