Search in sources :

Example 61 with WindowComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 62 with WindowComponent

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);
}
Also used : WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 63 with WindowComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 64 with WindowComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 65 with WindowComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) JSONObject(org.json.JSONObject) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Aggregations

WindowComponent (com.qcadoo.view.api.components.WindowComponent)105 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)93 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)75 FormComponent (com.qcadoo.view.api.components.FormComponent)51 Entity (com.qcadoo.model.api.Entity)46 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)31 GridComponent (com.qcadoo.view.api.components.GridComponent)28 FieldComponent (com.qcadoo.view.api.components.FieldComponent)12 LookupComponent (com.qcadoo.view.api.components.LookupComponent)8 EntityTree (com.qcadoo.model.api.EntityTree)4 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)3 JSONObject (org.json.JSONObject)3 Optional (com.google.common.base.Optional)2 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 TreeComponent (com.qcadoo.view.api.components.TreeComponent)2 Date (java.util.Date)2 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1