Search in sources :

Example 86 with WindowComponent

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

the class UserDetailsHooksMF method setupRibbonForAdmin.

public void setupRibbonForAdmin(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    if (!securityService.hasCurrentUserRole("ROLE_SUPERADMIN") && securityService.hasCurrentUserRole("ROLE_ADMIN")) {
        RibbonActionItem saveActionItem = window.getRibbon().getGroupByName("actions").getItemByName("save");
        saveActionItem.setEnabled(true);
        saveActionItem.requestUpdate(true);
    }
}
Also used : WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 87 with WindowComponent

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

the class OperationalTasksDetailsHooks method disableButtons.

public void disableButtons(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    FieldComponent typeField = (FieldComponent) view.getComponentByReference(OperationalTaskFields.TYPE);
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OperationalTaskFields.ORDER);
    LookupComponent technologyOperationComponentLookup = (LookupComponent) view.getComponentByReference(OperationalTaskFields.TECHNOLOGY_OPERATION_COMPONENT);
    String type = (String) typeField.getFieldValue();
    boolean isOperationalTaskTypeExecutionOperationInOrder = operationalTasksService.isOperationalTaskTypeExecutionOperationInOrder(type);
    boolean isOrderSelected = !Objects.isNull(orderLookup.getEntity());
    boolean isTechnologyOperationComponentSelected = !Objects.isNull(technologyOperationComponentLookup.getEntity());
    RibbonGroup order = window.getRibbon().getGroupByName(L_ORDER);
    RibbonGroup technologyOperationComponent = window.getRibbon().getGroupByName(L_TECHNOLOGY_OPERATION_COMPONENT);
    RibbonGroup operationalTasks = window.getRibbon().getGroupByName(L_OPERATIONAL_TASKS);
    RibbonActionItem showOrder = order.getItemByName(L_SHOW_ORDER);
    RibbonActionItem showOperationParameters = technologyOperationComponent.getItemByName(L_SHOW_OPERATION_PARAMETERS);
    RibbonActionItem showOperationalTasksWithOrder = operationalTasks.getItemByName(L_SHOW_OPERATIONAL_TASKS_WITH_ORDER);
    showOrder.setEnabled(isOperationalTaskTypeExecutionOperationInOrder && isOrderSelected);
    showOrder.requestUpdate(true);
    showOperationParameters.setEnabled(isOperationalTaskTypeExecutionOperationInOrder && isOrderSelected && isTechnologyOperationComponentSelected);
    showOperationParameters.requestUpdate(true);
    showOperationalTasksWithOrder.setEnabled(isOperationalTaskTypeExecutionOperationInOrder && isOrderSelected);
    showOperationalTasksWithOrder.requestUpdate(true);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 88 with WindowComponent

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

the class OrderDetailsHooks method disabledRibbonWhenOrderIsSynchronized.

public void disabledRibbonWhenOrderIsSynchronized(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    List<RibbonGroup> ribbonGroups = ribbon.getGroups();
    Long orderId = orderForm.getEntityId();
    if (Objects.isNull(orderId)) {
        return;
    }
    Entity order = orderService.getOrder(orderId);
    if (orderStateService.isSynchronized(order)) {
        return;
    }
    for (RibbonGroup ribbonGroup : ribbonGroups) {
        for (RibbonActionItem ribbonActionItem : ribbonGroup.getItems()) {
            ribbonActionItem.setEnabled(false);
            ribbonActionItem.requestUpdate(true);
        }
    }
    RibbonActionItem refreshRibbonActionItem = ribbon.getGroupByName(L_ORDER_DETAILS_ACTIONS).getItemByName(L_REFRESH);
    RibbonActionItem backRibbonActionItem = ribbon.getGroupByName(L_NAVIGATION).getItemByName(L_BACK);
    refreshRibbonActionItem.setEnabled(true);
    backRibbonActionItem.setEnabled(true);
    refreshRibbonActionItem.requestUpdate(true);
    backRibbonActionItem.requestUpdate(true);
    orderForm.setFormEnabled(false);
}
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 89 with WindowComponent

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

the class OrderPacksSingleOrderListHooks method onBeforeRender.

public final void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(OrdersConstants.MODEL_ORDER);
    Entity order = form.getPersistedEntityWithIncludedFormValues();
    String orderState = order.getStringField(OrderFields.STATE);
    if (OrderState.COMPLETED.getStringValue().equals(orderState) || OrderState.DECLINED.getStringValue().equals(orderState) || OrderState.ABANDONED.getStringValue().equals(orderState) || OrderState.PENDING.getStringValue().equals(orderState)) {
        GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
        grid.setEditable(false);
        grid.setEnabled(false);
        WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
        Ribbon ribbon = window.getRibbon();
        RibbonActionItem generateOrderPacks = ribbon.getGroupByName("orderPacks").getItemByName("generateOrderPacks");
        RibbonActionItem actionsNew = ribbon.getGroupByName(ACTIONS).getItemByName("new");
        generateOrderPacks.setEnabled(false);
        generateOrderPacks.requestUpdate(true);
        actionsNew.setEnabled(false);
        actionsNew.requestUpdate(true);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 90 with WindowComponent

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

the class OrderTechnologicalProcessDetailsHooks method updateRibbonState.

private void updateRibbonState(final ViewDefinitionState view, final Entity orderTechnologicalProcess) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup actionsGroup = window.getRibbon().getGroupByName(L_ACTIONS);
    RibbonActionItem deleteActionItem = actionsGroup.getItemByName(L_DELETE);
    Entity order = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER);
    boolean isOrderStateValid = !checkOrderState(order);
    deleteActionItem.setEnabled(isOrderStateValid);
    deleteActionItem.requestUpdate(true);
}
Also used : 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)

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