public void init(final KieImageType imageType, final int containersRunningCount) { if (imageType == null) return; final SafeUri imageUri = ClientUtils.getImageUri(imageType); typeNameText.setText(imageType.getName()); if (containersRunningCount < 0) { countText.setVisible(false); } else if (containersRunningCount == 0 && showCreateButton && !KieImageCategory.OTHERS.equals(imageType.getCategory())) { countText.setText(Constants.INSTANCE.createNew()); countText.setTitle(Constants.INSTANCE.createNewForThisType()); countText.addStyleName(style.createNewButton()); countText.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { KieImageTypeView.this.fireEvent(new CreateContainerEvent(imageType)); } }); countText.setVisible(true); } else { countText.setText(Integer.toString(containersRunningCount)); countText.removeStyleName(style.createNewButton()); countText.setVisible(true); } typeImage.setUrl(imageUri); typeImage.setSize(size, size); typeImage.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { KieImageTypeView.this.fireEvent(new ImageTypeSelectedEvent(imageType)); } }); mainPanel.setVisible(true); }
@Override protected void render( com.google.gwt.cell.client.Cell.Context context, SafeHtml data, SafeHtmlBuilder sb) { /* * Always do a null check on the value. Cell widgets can pass null to * cells if the underlying data contains a null, or if the data arrives * out of order. */ if (data == null) { return; } final KieContainer container = containersProvider.getContainer(data.asString()); final boolean isUp = SharedUtils.getContainerStatus(container); final boolean isKieApp = container.getType() != null && KieImageCategory.KIEAPP.equals(container.getType().getCategory()); // If the value comes from the user, we escape it to avoid XSS attacks. // SafeHtml safeValue = SafeHtmlUtils.fromString(data.asString()); // Use the template to create the Cell's html. // SafeStyles styles = SafeStylesUtils.fromTrustedString(safeValue // .asString()); // generate the image cell SafeHtml rendered = templates.cell( PLAY, isUp ? disabledStyle : enabledStyle, ICON_PLAY, Constants.INSTANCE.start()); sb.append(rendered); /* -- Disabled STOP container button, as it sometimes fails from the Docker remote API. -- rendered = templates.cell(STOP, isUp ? enabledStyle : disabledStyle, ICON_STOP, Constants.INSTANCE.stop()); sb.append(rendered); */ rendered = templates.cell( RELOAD, isUp ? enabledStyle : disabledStyle, ICON_RELOAD, Constants.INSTANCE.restart()); sb.append(rendered); rendered = templates.cell(REMOVE, enabledStyle, ICON_REMOVE, Constants.INSTANCE.remove()); sb.append(rendered); rendered = templates.cell(VIEW_LOGS, enabledStyle, ICON_VIEW_LOGS, Constants.INSTANCE.viewLogs()); sb.append(rendered); if (isKieApp) { rendered = templates.cell( VIEW_DETAILS, isUp ? enabledStyle : disabledStyle, ICON_VIEW_DETAILS, Constants.INSTANCE.viewDetails()); sb.append(rendered); rendered = templates.cell( NAVIGATE, isUp ? enabledStyle : disabledStyle, ICON_NAVIGATE, Constants.INSTANCE.navigate()); sb.append(rendered); } }