public void update() {
for (Canvas child : getChildren()) {
child.destroy();
}
final EnhancedHLayout hlayout = new EnhancedHLayout();
hlayout.setStyleName("resourceSummary");
addMember(hlayout);
this.title = new HTMLFlow();
this.title.setWidth("*");
this.explicitAvailabilityImage = new Img(ImageManager.getAvailabilityLargeIcon(null), 24, 24);
this.explicitAvailabilityImage.setTooltip(MSG.view_group_detail_explicitAvail());
this.implicitAvailabilityImage = new Img(ImageManager.getAvailabilityLargeIcon(null), 24, 24);
this.implicitAvailabilityImage.setTooltip(MSG.view_group_detail_implicitAvail());
if (this.supportsFavorite) {
this.favoriteButton = new Img(NOT_FAV_ICON, 24, 24);
this.favoriteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
Set<Integer> favorites = toggleFavoriteLocally();
UserSessionManager.getUserPreferences().setFavoriteResourceGroups(favorites,
new UpdateFavoritesCallback());
}
});
}
expandCollapseArrow = new Img("[SKIN]/ListGrid/row_collapsed.png", 16, 16);
expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP);
expandCollapseArrow.setLayoutAlign(VerticalAlignment.CENTER);
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.addFilterId(this.group.getId());
// for autoclusters and autogroups we need to add more criteria
if (isAutoCluster) {
criteria.addFilterVisible(false);
} else if (isAutoGroup) {
criteria.addFilterVisible(false);
criteria.addFilterPrivate(true);
}
GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceGroupComposite>>() {
@Override
public void onSuccess(PageList<ResourceGroupComposite> result) {
if (result == null || result.size() != 1) {
CoreGUI.getErrorHandler().handleError(
MSG.view_titleBar_group_failInfo(group.getName(),
String.valueOf(ResourceGroupTitleBar.this.group.getId())));
return;
}
ResourceGroupComposite resultComposite = result.get(0);
setGroupIcons(resultComposite);
// Localize the default group name for an AutoCluster with disparate members (see setGroup()).
if (isAutoCluster) {
resultComposite.getResourceGroup().setName(group.getName());
}
generalProperties = new GeneralProperties(resultComposite, ResourceGroupTitleBar.this,
(!(isAutoGroup || isAutoCluster)));
generalProperties.setVisible(false);
ResourceGroupTitleBar.this.addMember(generalProperties);
expandCollapseArrow.addClickHandler(new ClickHandler() {
private boolean collapsed = true;
@Override
public void onClick(ClickEvent event) {
collapsed = !collapsed;
if (collapsed) {
expandCollapseArrow.setSrc("[SKIN]/ListGrid/row_collapsed.png");
expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP);
generalProperties.hide();
} else {
expandCollapseArrow.setSrc("[SKIN]/ListGrid/row_expanded.png");
expandCollapseArrow.setTooltip(EXPANDED_TOOLTIP);
generalProperties.show();
}
ResourceGroupTitleBar.this.markForRedraw();
}
});
}
@Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
MSG.view_titleBar_group_failInfo(group.getName(),
String.valueOf(ResourceGroupTitleBar.this.group.getId())), caught);
}
});
badge = new Img(ImageManager.getGroupLargeIcon(GroupCategory.MIXED), 24, 24);
badge.setLayoutAlign(VerticalAlignment.CENTER);
TagEditorView tagEditorView = new TagEditorView(group.getTags(), false, new TagsChangedCallback() {
public void tagsChanged(final HashSet<Tag> tags) {
GWTServiceLookup.getTagService().updateResourceGroupTags(group.getId(), tags,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
MSG.view_titleBar_common_updateTagsFailure(group.getName()), caught);
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_titleBar_common_updateTagsSuccessful(group.getName()),
Message.Severity.Info));
// update what is essentially our local cache
group.setTags(tags);
}
});
}
});
loadTags(tagEditorView);
hlayout.addMember(expandCollapseArrow);
hlayout.addMember(badge);
hlayout.addMember(title);
hlayout.addMember(explicitAvailabilityImage);
hlayout.addMember(implicitAvailabilityImage);
if (this.supportsFavorite) {
hlayout.addMember(favoriteButton);
}
//conditionally add tags. Defaults to true, not available in JON builds.
if (CoreGUI.isTagsEnabledForUI()) {
addMember(tagEditorView);