private void buildFavoriteGroupsMenu(Favorites favorites, Menu menu, Set<Integer> groupIds) { if (groupIds.isEmpty()) { menu.setItems(); return; } List<MenuItem> items = new ArrayList<MenuItem>(groupIds.size()); for (final Integer groupId : groupIds) { ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId); if (null == groupComposite) { // if the resource group is gone just skip it continue; } final ResourceGroup group = groupComposite.getResourceGroup(); MenuItem item = new MenuItem(String.valueOf(groupId)); item.setTitle(group.getName()); item.setIcon( ImageManager.getGroupIcon( group.getGroupCategory(), groupComposite.getExplicitAvailabilityType())); item.addClickHandler( new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { CoreGUI.goToView(LinkManager.getResourceGroupLink(group)); } }); items.add(item); } menu.setItems(items.toArray(new MenuItem[items.size()])); }
public ResourceGroupComposite getGroupComposite(int groupId) { for (ResourceGroupComposite groupComposite : groupComposites) { if (groupId == groupComposite.getResourceGroup().getId()) { return groupComposite; } } return null; }
private String getImplicitFormatted(ResourceGroupComposite from) { return getAlignedAvailabilityResults( from.getImplicitCount(), from.getImplicitUp(), from.getImplicitDown(), from.getImplicitUnknown(), from.getImplicitDisabled()); }
/** Return the relevant sorted value map for the group */ public static LinkedHashMap<String, String> processPortletNameMapForGroup( ResourceGroupComposite composite) { LinkedHashMap<String, String> groupMenuMap = PortletFactory.getGroupPortletMenuMap(); if ((composite != null) && (composite.getResourceGroup() != null)) { groupMenuMap = new LinkedHashMap<String, String>(groupMenuMap); // filter out portlets not relevent for facets Set<ResourceTypeFacet> facets = composite.getResourceFacets().getFacets(); GroupCategory groupCategory = composite.getResourceGroup().getGroupCategory(); // if not a compatible group do some pruning. if (groupCategory != GroupCategory.COMPATIBLE) { groupMenuMap.remove(GroupOperationsPortlet.KEY); groupMenuMap.remove(GroupMetricsPortlet.KEY); groupMenuMap.remove(GroupOobsPortlet.KEY); groupMenuMap.remove(GroupPkgHistoryPortlet.KEY); groupMenuMap.remove(GroupConfigurationUpdatesPortlet.KEY); groupMenuMap.remove(GroupBundleDeploymentsPortlet.KEY); } else { // for compatible may still need to do some pruning. if (!facets.isEmpty()) { // Operations related portlets(Config,PkgHistory) if (!facets.contains(ResourceTypeFacet.OPERATION)) { groupMenuMap.remove(GroupOperationsPortlet.KEY); } // MEASUREMENT related portlets(METRICS) if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) { groupMenuMap.remove(GroupMetricsPortlet.KEY); groupMenuMap.remove(GroupOobsPortlet.KEY); } // CONTENT related portlets(CONTENT) if (!facets.contains(ResourceTypeFacet.CONTENT)) { groupMenuMap.remove(GroupPkgHistoryPortlet.KEY); } // CONFIGURATION related portlets(CONFIGURATION) if (!facets.contains(ResourceTypeFacet.CONFIGURATION)) { groupMenuMap.remove(GroupConfigurationUpdatesPortlet.KEY); } // BUNDLE related portlets(BUNDLE) if (!facets.contains(ResourceTypeFacet.BUNDLE)) { groupMenuMap.remove(GroupBundleDeploymentsPortlet.KEY); } } } } return groupMenuMap; }
private void buildRecentlyViewedMenu( Favorites favorites, Menu menu, List<Integer> recentResourceIds, List<Integer> recentGroupIds, AncestryUtil.MapWrapper typesWrapper) { if (recentResourceIds.isEmpty() && recentGroupIds.isEmpty()) { return; } List<MenuItem> items = new ArrayList<MenuItem>(recentResourceIds.size() + recentGroupIds.size() + 1); for (final Integer resourceId : recentResourceIds) { Resource resource = favorites.getResource(resourceId); if (null == resource) { // if the resource is gone just skip it continue; } MenuItem item = new MenuItem(resource.getName()); item.setIcon(ImageManager.getResourceIcon(resource)); // build a subMenu to display a disambiguated resource item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId); item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName()); item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry()); item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId()); item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); Menu ancestryMenu = new Menu(); MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, -1)); ancestryItem.setEnabled(false); ancestryMenu.setItems(ancestryItem); ancestryMenu.setSubmenuDirection("left"); ancestryMenu.setAutoWidth(); item.setSubmenu(ancestryMenu); item.addClickHandler( new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { CoreGUI.goToView(LinkManager.getResourceLink(resourceId)); } }); items.add(item); } if (!recentResourceIds.isEmpty() && !recentGroupIds.isEmpty()) { items.add(new MenuItemSeparator()); } for (final Integer groupId : recentGroupIds) { ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId); if (null == groupComposite) { // if the resource group is gone just skip it continue; } final ResourceGroup group = groupComposite.getResourceGroup(); MenuItem item = new MenuItem(String.valueOf(groupId)); item.setTitle(group.getName()); item.setIcon( ImageManager.getGroupIcon( group.getGroupCategory(), groupComposite.getExplicitAvailabilityType())); item.addClickHandler( new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { CoreGUI.goToView(LinkManager.getResourceGroupLink(group)); } }); items.add(item); } menu.setCanSelectParentItems(Boolean.TRUE); menu.setItems(items.toArray(new MenuItem[items.size()])); }
@Override public ListGridRecord copyValues(ResourceGroupComposite from) { ListGridRecord record = new ListGridRecord(); record.setAttribute("group", from); record.setAttribute("id", from.getResourceGroup().getId()); record.setAttribute(NAME.propertyName(), from.getResourceGroup().getName()); record.setAttribute(DESCRIPTION.propertyName(), from.getResourceGroup().getDescription()); record.setAttribute(CATEGORY.propertyName(), from.getResourceGroup().getGroupCategory().name()); record.setAttribute("explicitCount", String.valueOf(from.getExplicitCount())); record.setAttribute("explicitDown", String.valueOf(from.getExplicitDown())); record.setAttribute("explicitDisabled", String.valueOf(from.getExplicitDisabled())); record.setAttribute("implicitCount", String.valueOf(from.getImplicitCount())); record.setAttribute("implicitDown", String.valueOf(from.getImplicitDown())); record.setAttribute("implicitDisabled", String.valueOf(from.getImplicitDisabled())); record.setAttribute(AVAIL_CHILDREN.propertyName(), getExplicitFormatted(from)); record.setAttribute(AVAIL_DESCENDANTS.propertyName(), getImplicitFormatted(from)); if (from.getResourceGroup().getResourceType() != null) { record.setAttribute("resourceType", from.getResourceGroup().getResourceType()); record.setAttribute(TYPE.propertyName(), from.getResourceGroup().getResourceType().getName()); record.setAttribute( PLUGIN.propertyName(), from.getResourceGroup().getResourceType().getPlugin()); } return record; }