private void drawCalculationItem(FlexTable calculationItemTable, CalculationTreeNode calculationTreeNode) {
CalculationTreeNodeSummary calculationTreeNodeSummary = calculationTreeNode.getSummary();
String pathNodesString = calculationTreeNodeSummary.getPathNodesString();
EditableCalculationItem editableCalculationItem = new EditableCalculationItem();
pathNodesStringToEditableCalculationItemMap.put(pathNodesString, editableCalculationItem);
ComputableCalculationItem computableCalculationItem = new ComputableCalculationItem();
computableCalculationItem.setCalculationItems(calculationTreeNode.getCalculationItems());
computableCalculationItem.setCalculationTreeNodeSummary(calculationTreeNodeSummary);
pathNodesStringToComputableCalculationItemMap.put(pathNodesString, computableCalculationItem);
final int index = calculationItemTable.getRowCount();
String imageUrl = imageUrlProvider.getImage16Url(calculationTreeNodeSummary.getItemCategoryID(), calculationTreeNodeSummary.getItemTypeID(), calculationTreeNodeSummary.getItemTypeIcon());
Image image = new Image(imageUrl);
image.setTitle(calculationTreeNodeSummary.getItemTypeName());
image.addStyleName(resources.css().image16());
EveItemInfoLink imageItemInfoLink = new EveItemInfoLink(ccpJsMessages, image, calculationTreeNodeSummary.getItemTypeID());
calculationItemTable.setWidget(index, 0, imageItemInfoLink);
calculationItemTable.setWidget(index, 1, new EveItemMarketDetailsLink(constants, urlMessages, ccpJsMessages, calculationTreeNodeSummary.getItemTypeName(), calculationTreeNodeSummary.getItemTypeID()));
calculationItemTable.setWidget(index, 2, new Label("x"));
QuantityLabel quantityLabel = new QuantityLabel(calculationTreeNodeSummary.getQuantity());
HorizontalPanel quantityAndDamagePerJobPanel = new HorizontalPanel();
quantityAndDamagePerJobPanel.add(quantityLabel);
BigDecimal damagePerJob = calculationTreeNodeSummary.getDamagePerJob();
if (BigDecimal.ONE.compareTo(damagePerJob) == 1) {
DamagePerJobLabel damagePerJobLabel = new DamagePerJobLabel(damagePerJob);
damagePerJobLabel.addStyleName(resources.css().damagePerJob());
quantityAndDamagePerJobPanel.add(damagePerJobLabel);
quantityAndDamagePerJobPanel.setCellVerticalAlignment(damagePerJobLabel, HasVerticalAlignment.ALIGN_BOTTOM);
}
calculationItemTable.setWidget(index, 3, quantityAndDamagePerJobPanel);
calculationItemTable.setWidget(index, 4, new Label("x"));
PriceLabel priceLabel = new PriceLabel(calculationTreeNodeSummary.getPrice());
calculationItemTable.setWidget(index, 5, priceLabel);
calculationItemTable.setWidget(index, 6, new Label("="));
PriceLabel totalPriceLabel = new PriceLabel(calculationTreeNodeSummary.getTotalPrice());
calculationItemTable.setWidget(index, 7, totalPriceLabel);
calculationItemTable.setWidget(index, 8, new Label("x"));
QuantityLabel parentQuantityLabel = new QuantityLabel(calculationTreeNodeSummary.getParentQuantity());
calculationItemTable.setWidget(index, 9, parentQuantityLabel);
calculationItemTable.setWidget(index, 10, new Label("="));
PriceLabel totalPriceForParentLabel = new PriceLabel(calculationTreeNodeSummary.getTotalPriceForParent());
calculationItemTable.setWidget(index, 11, totalPriceForParentLabel);
if (hasBlueprint(calculationTreeNodeSummary.getItemCategoryID(), calculationTreeNodeSummary.getItemTypeID())) {
OpaqueLoadableBlueprintImage blueprintImage = new OpaqueLoadableBlueprintImage(resources, messages, messages.useBlueprint(), messages.stopUsingBlueprint());
blueprintImage.addStyleName(resources.css().image16());
blueprintImage.addStyleName(resources.css().cursorHand());
blueprintImage.setOpacity();
calculationItemTable.setWidget(index, 12, blueprintImage);
calculationItemTable.setWidget(index, 13, new Label(messages.me() + ":"));
Label meLabel = new Label();
calculationItemTable.setWidget(index, 14, meLabel);
Label peLabel = new Label();
calculationItemTable.setWidget(index, 15, new Label(messages.pe() + ":"));
calculationItemTable.setWidget(index, 16, peLabel);
Button editBlueprintButton = new Button(messages.edit());
calculationItemTable.setWidget(index, 17, editBlueprintButton);
Button detailsBlueprintButton = new Button(messages.details());
calculationItemTable.setWidget(index, 18, detailsBlueprintButton);
FlexTable calculationItemDetailsTable = new FlexTable();
calculationItemTable.setWidget(index + 1, 0, null);
calculationItemTable.setWidget(index + 1, 1, calculationItemDetailsTable);
FlexTable.FlexCellFormatter tableFlexFormatter = calculationItemTable.getFlexCellFormatter();
final HTMLTable.RowFormatter tableRowFormatter = calculationItemTable.getRowFormatter();
tableFlexFormatter.setVisible(index, 13, false);
tableFlexFormatter.setVisible(index, 14, false);
tableFlexFormatter.setVisible(index, 15, false);
tableFlexFormatter.setVisible(index, 16, false);
tableFlexFormatter.setVisible(index, 17, false);
tableFlexFormatter.setVisible(index, 18, false);
tableFlexFormatter.setColSpan(index + 1, 1, 18);
tableRowFormatter.setVisible(index + 1, false);
handlerRegistrations.add(detailsBlueprintButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (tableRowFormatter.isVisible(index + 1)) {
tableRowFormatter.setVisible(index + 1, false);
} else {
tableRowFormatter.setVisible(index + 1, true);
}
}
}));
TextBox meTextBox = new TextBox();
meTextBox.setValue(meLabel.getText());
meTextBox.addStyleName(resources.css().mePeInput());
TextBox peTextBox = new TextBox();
peTextBox.setValue(peLabel.getText());
peTextBox.addStyleName(resources.css().mePeInput());
final DecoratedPopupPanel editCalculationItemPopup = new DecoratedPopupPanel(true);
FlexTable editCalculationItemPopupFlexTable = new FlexTable();
editCalculationItemPopupFlexTable.setWidget(0, 0, new Label(messages.materialLevel() + ":"));
editCalculationItemPopupFlexTable.setWidget(0, 1, meTextBox);
editCalculationItemPopupFlexTable.setWidget(1, 0, new Label(messages.productivityLevel() + ":"));
editCalculationItemPopupFlexTable.setWidget(1, 1, peTextBox);
Button applyButton = new Button(messages.apply());
editCalculationItemPopupFlexTable.setWidget(3, 0, applyButton);
editCalculationItemPopupFlexTable.getFlexCellFormatter().setColSpan(3, 0, 2);
editCalculationItemPopup.setWidget(editCalculationItemPopupFlexTable);
handlerRegistrations.add(editBlueprintButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Widget source = (Widget) event.getSource();
int left = source.getAbsoluteLeft() + 10;
int top = source.getAbsoluteTop() + 10;
editCalculationItemPopup.setPopupPosition(left, top);
editCalculationItemPopup.show();
}
}));
handlerRegistrations.add(applyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
editCalculationItemPopup.hide();
}
}));
editableCalculationItem.setIndex(index);
editableCalculationItem.setBlueprintImage(blueprintImage);
editableCalculationItem.setMeLabel(meLabel);
editableCalculationItem.setPeLabel(peLabel);
editableCalculationItem.setMeTextBox(meTextBox);
editableCalculationItem.setPeTextBox(peTextBox);
editableCalculationItem.setApplyButton(applyButton);
editableCalculationItem.setCalculationItemDetailsTable(calculationItemDetailsTable);
editableCalculationItem.setCalculationItemTable(calculationItemTable);
}
computableCalculationItem.setQuantityLabel(quantityLabel);
computableCalculationItem.setPriceLabel(priceLabel);
computableCalculationItem.setTotalPriceLabel(totalPriceLabel);
computableCalculationItem.setParentQuantityLabel(parentQuantityLabel);
computableCalculationItem.setTotalPriceForParentLabel(totalPriceForParentLabel);
}