Search in sources :

Example 21 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.

the class PlannedEventDetailsHooks method actionsButtonProcess.

private void actionsButtonProcess(Entity plannedEvent, ViewDefinitionState view, FieldsForType ftype) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    PlannedEventType type = PlannedEventType.from(plannedEvent);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup actionsGroup = ribbon.getGroupByName("actionsGroup");
    RibbonActionItem addActionsItem = actionsGroup.getItemByName("actions");
    if (plannedEvent.getId() == null) {
        addActionsItem.setEnabled(false);
        addActionsItem.requestUpdate(true);
        window.requestRibbonRender();
        return;
    }
    boolean enable = false;
    if (type.compareTo(PlannedEventType.REVIEW) == 0) {
        enable = true;
    } else if (type.compareTo(PlannedEventType.REPAIRS) == 0) {
        enable = true;
    } else if (type.compareTo(PlannedEventType.EXTERNAL_SERVICE) == 0) {
        enable = false;
    } else if (type.compareTo(PlannedEventType.ADDITIONAL_WORK) == 0) {
        enable = true;
    } else if (type.compareTo(PlannedEventType.MANUAL) == 0) {
        enable = true;
    } else if (type.compareTo(PlannedEventType.METER_READING) == 0) {
        enable = false;
    } else if (type.compareTo(PlannedEventType.UDT_REVIEW) == 0) {
        enable = false;
    } else if (type.compareTo(PlannedEventType.AFTER_REVIEW) == 0) {
        enable = false;
    }
    addActionsItem.setEnabled(enable);
    addActionsItem.requestUpdate(true);
    window.requestRibbonRender();
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) PlannedEventType(com.qcadoo.mes.cmmsMachineParts.constants.PlannedEventType) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 22 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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 23 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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 24 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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 25 with RibbonGroup

use of com.qcadoo.view.api.ribbon.RibbonGroup 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)

Aggregations

RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)92 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)86 WindowComponent (com.qcadoo.view.api.components.WindowComponent)75 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)37 FormComponent (com.qcadoo.view.api.components.FormComponent)36 Entity (com.qcadoo.model.api.Entity)34 GridComponent (com.qcadoo.view.api.components.GridComponent)23 FieldComponent (com.qcadoo.view.api.components.FieldComponent)9 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)3 LookupComponent (com.qcadoo.view.api.components.LookupComponent)3 JSONObject (org.json.JSONObject)3 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)2 Optional (com.google.common.base.Optional)1 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1