Search in sources :

Example 26 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.

the class TechnologyDetailsHooksCNFM method updateViewCostsButtonState.

public void updateViewCostsButtonState(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup materials = window.getRibbon().getGroupByName("materials");
    RibbonActionItem viewCosts = materials.getItemByName("viewCosts");
    viewCosts.setEnabled(orderForm.getEntityId() != null);
    viewCosts.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) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 27 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.

the class DeliveryDetailsHooks method updateRelatedDeliveryButtonsState.

private void updateRelatedDeliveryButtonsState(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long deliveryId = deliveryForm.getEntityId();
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup reports = window.getRibbon().getGroupByName(L_RELATED_DELIVERY);
    RibbonActionItem createRelatedDelivery = reports.getItemByName(L_CREATE_RELATED_DELIVERY);
    RibbonActionItem showRelatedDelivery = reports.getItemByName(L_SHOW_RELATED_DELIVERIES);
    if (Objects.isNull(deliveryId)) {
        return;
    }
    Entity delivery = deliveriesService.getDelivery(deliveryId);
    List<Entity> relatedDeliveries = delivery.getHasManyField(DeliveryFields.RELATED_DELIVERIES);
    boolean received = DeliveryState.RECEIVED.getStringValue().equals(delivery.getStringField(DeliveryFields.STATE));
    boolean receiveConfirmWaiting = DeliveryState.RECEIVE_CONFIRM_WAITING.getStringValue().equals(delivery.getStringField(DeliveryFields.STATE));
    boolean created = (Objects.nonNull(relatedDeliveries) && !relatedDeliveries.isEmpty());
    updateButtonState(createRelatedDelivery, (received || receiveConfirmWaiting) && !created);
    updateButtonState(showRelatedDelivery, (received || receiveConfirmWaiting) && created);
}
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 28 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.

the class DeliveryDetailsHooks method updateAssignStorageLocationsButton.

private void updateAssignStorageLocationsButton(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup group = ribbon.getGroupByName(L_DELIVERY_POSITIONS);
    RibbonActionItem assignStorageLocations = group.getItemByName(ASSIGN_STORAGE_LOCATIONS);
    Long deliveryId = deliveryForm.getEntityId();
    boolean enabled = false;
    if (Objects.nonNull(deliveryId)) {
        Entity delivery = deliveriesService.getDelivery(deliveryId);
        String state = delivery.getStringField(DeliveryFields.STATE);
        enabled = !DeliveryState.RECEIVED.getStringValue().equals(state) && !DeliveryState.RECEIVE_CONFIRM_WAITING.getStringValue().equals(state) && !DeliveryState.DECLINED.getStringValue().equals(state);
    }
    updateButtonState(assignStorageLocations, enabled);
}
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) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 29 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.

the class MasterOrderDetailsHooks method ribbonRender.

public void ribbonRender(final ViewDefinitionState view) {
    GridComponent masterOrderProductsGrid = (GridComponent) view.getComponentByReference(MasterOrderFields.MASTER_ORDER_PRODUCTS);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup orders = (RibbonGroup) window.getRibbon().getGroupByName(L_ORDERS);
    RibbonActionItem createOrder = (RibbonActionItem) orders.getItemByName(L_CREATE_ORDER);
    if (masterOrderProductsGrid.getSelectedEntities().isEmpty()) {
        createOrder.setEnabled(false);
    } else
        createOrder.setEnabled(masterOrderProductsGrid.getSelectedEntities().size() == 1);
    if (PluginUtils.isEnabled("goodFood") && !masterOrderProductsGrid.getEntities().isEmpty()) {
        createOrder.setEnabled(true);
    } else {
        createOrder.setMessage("masterOrders.order.ribbon.message.selectOneProduct");
    }
    createOrder.requestUpdate(true);
    toggleGenerateButton(view);
    window.requestRibbonRender();
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 30 with WindowComponent

use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.

the class MasterOrdersMaterialRequirementDetailsHooks method setRibbonEnabled.

private void setRibbonEnabled(final ViewDefinitionState view) {
    FormComponent masterOrdersMaterialRequirementForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent generatedCheckBox = (CheckBoxComponent) view.getComponentByReference(MasterOrdersMaterialRequirementFields.GENERATED);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup generateRibbonGroup = ribbon.getGroupByName(L_GENERATE);
    RibbonActionItem generateRibbonActionItem = generateRibbonGroup.getItemByName(L_GENERATE_MASTER_ORDERS_MATERIAL_REQUIREMENT);
    Long masterOrdersMaterialRequirementId = masterOrdersMaterialRequirementForm.getEntityId();
    boolean isEnabled = Objects.nonNull(masterOrdersMaterialRequirementId);
    boolean isGenerated = generatedCheckBox.isChecked();
    generateRibbonActionItem.setEnabled(isEnabled && !isGenerated);
    generateRibbonActionItem.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) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

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