use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class DocumentDetailsHooks method setRibbonState.
private void setRibbonState(final ViewDefinitionState view) {
FormComponent documentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonActionItem printDispositionOrderPdfRibbonActionItem = window.getRibbon().getGroupByName(L_PRINT).getItemByName(L_PRINT_DISPOSITION_ORDER_PDF);
RibbonActionItem openPositionsImportPageRibbonActionItem = window.getRibbon().getGroupByName(L_IMPORT).getItemByName(L_OPEN_POSITIONS_IMPORT_PAGE);
RibbonActionItem showProductAttributesActionItem = window.getRibbon().getGroupByName(L_ATTRIBUTES).getItemByName(L_SHOW_PRODUCT_ATTRIBUTES);
Entity document = documentForm.getEntity();
String state = document.getStringField(DocumentFields.STATE);
String documentType = document.getStringField(DocumentFields.TYPE);
List<String> documentTypesWithDispositionOrder = Lists.newArrayList(DocumentType.TRANSFER.getStringValue(), DocumentType.INTERNAL_OUTBOUND.getStringValue(), DocumentType.RELEASE.getStringValue());
List<String> documentTypesWithAdmission = Lists.newArrayList(DocumentType.RECEIPT.getStringValue(), DocumentType.INTERNAL_INBOUND.getStringValue());
String errorMessage = null;
String descriptionMessage = "materialFlowResources.documentDetails.window.ribbon.import.openPositionsImportPage.description";
boolean isSaved = Objects.nonNull(documentForm.getEntityId());
boolean isDraft = DocumentState.DRAFT.getStringValue().equals(state);
boolean isDispositionOrder = documentTypesWithDispositionOrder.contains(documentType);
boolean isAdmission = documentTypesWithAdmission.contains(documentType);
boolean inBuffer = document.getBooleanField(DocumentFields.IN_BUFFER);
if (isSaved) {
if (Objects.isNull(documentType) || !isDispositionOrder) {
errorMessage = "materialFlowResources.printDispositionOrderPdf.error";
}
if (inBuffer) {
errorMessage = "materialFlowResources.printDispositionOrderPdf.errorInBuffer";
}
}
printDispositionOrderPdfRibbonActionItem.setEnabled(isSaved && isDispositionOrder && !inBuffer);
printDispositionOrderPdfRibbonActionItem.setMessage(errorMessage);
printDispositionOrderPdfRibbonActionItem.requestUpdate(true);
openPositionsImportPageRibbonActionItem.setEnabled(isSaved && isDraft && isAdmission);
openPositionsImportPageRibbonActionItem.setMessage(descriptionMessage);
openPositionsImportPageRibbonActionItem.requestUpdate(true);
showProductAttributesActionItem.setEnabled(isSaved);
showProductAttributesActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class CostCalculationDetailsHooksOFSPG method enableSaveNominalCostForComponentButton.
private void enableSaveNominalCostForComponentButton(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonActionItem saveNominalCostsForComponent = window.getRibbon().getGroupByName(CostCalculationFieldsOFSPG.SAVE_COSTS_EXTENSION).getItemByName(CostCalculationFieldsOFSPG.NOMINAL_COSTS_FOR_COMPONENTS);
CheckBoxComponent generatedField = (CheckBoxComponent) view.getComponentByReference(CostCalculationFields.GENERATED);
CheckBoxComponent includeComponents = (CheckBoxComponent) view.getComponentByReference(CostCalculationFields.INCLUDE_COMPONENTS);
includeComponents.setEnabled(!generatedField.isChecked());
includeComponents.requestComponentUpdateState();
boolean enable = false;
if (generatedField.isChecked() && includeComponents.isChecked()) {
enable = true;
}
saveNominalCostsForComponent.setEnabled(enable);
saveNominalCostsForComponent.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class ProductDetailsHooksPFTD method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup materialFlowRibbonGroup = ribbon.getGroupByName("materialFlow");
RibbonActionItem showProductAvailabilityRibbonActionItem = materialFlowRibbonGroup.getItemByName("productAvailability");
Long id = form.getEntityId();
boolean isEnabled = Objects.nonNull(id);
showProductAvailabilityRibbonActionItem.setEnabled(isEnabled);
showProductAvailabilityRibbonActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class ProductionTrackingDetailsHooksPFTD method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup materialFlowRibbonGroup = (RibbonGroup) window.getRibbon().getGroupByName(L_MATERIAL_FLOW);
RibbonActionItem componentAvailabilityRibbonActionItem = (RibbonActionItem) materialFlowRibbonGroup.getItemByName(L_COMPONENT_AVAILABILITY);
FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productionTracking = productionTrackingForm.getEntity();
boolean isDraft = ProductionTrackingStateStringValues.DRAFT.equals(productionTracking.getStringField(ProductionTrackingFields.STATE));
Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);
if (order == null) {
return;
}
boolean registerQuantityInProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT);
boolean registerQuantityOutProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT);
componentAvailabilityRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
componentAvailabilityRibbonActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OrderWithMaterialAvailabilityListHooks method toggleShowAvailabilityButton.
public void toggleShowAvailabilityButton(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup materialAvailability = window.getRibbon().getGroupByName(L_MATERIAL_AVAILABILITY);
RibbonGroup resources = window.getRibbon().getGroupByName(RESOURCES);
RibbonActionItem showAvailability = materialAvailability.getItemByName(L_SHOW_AVAILABILITY);
RibbonActionItem showReplacementsAvailability = materialAvailability.getItemByName(L_SHOW_REPLACEMENTS_AVAILABILITY);
RibbonActionItem showWarehouseResources = resources.getItemByName(SHOW_WAREHOUSE_RESOURCES);
JSONObject obj = view.getJsonContext();
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
if (grid.getSelectedEntitiesIds().size() != 1) {
showAvailability.setEnabled(false);
showReplacementsAvailability.setEnabled(false);
showWarehouseResources.setEnabled(false);
} else {
showAvailability.setEnabled(true);
showWarehouseResources.setEnabled(true);
Entity selected = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY).get(grid.getSelectedEntitiesIds().stream().findFirst().get());
showReplacementsAvailability.setEnabled(selected.getBooleanField(MaterialAvailabilityFields.REPLACEMENT));
}
showAvailability.setMessage("orderWithMaterialAvailabilityList.materialAvailability.ribbon.message.selectOneRecord");
showReplacementsAvailability.setMessage("orderWithMaterialAvailabilityList.materialAvailability.ribbon.message.selectOneRecordWithReplacements");
showWarehouseResources.setMessage("orderWithMaterialAvailabilityList.resources.ribbon.showWarehouseResources.message");
if (obj.has(FROM_TERMINAL)) {
showAvailability.setEnabled(false);
showAvailability.setMessage(null);
showReplacementsAvailability.setEnabled(false);
showReplacementsAvailability.setMessage(null);
showWarehouseResources.setEnabled(false);
showWarehouseResources.setMessage(null);
}
showAvailability.requestUpdate(true);
showReplacementsAvailability.requestUpdate(true);
showWarehouseResources.requestUpdate(true);
}
Aggregations