Search in sources :

Example 1 with WindowComponent

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

the class UserService method setupRibbonForAdmins.

public void setupRibbonForAdmins(final ViewDefinitionState state) {
    WindowComponent window = (WindowComponent) state.getComponentByReference(QcadooViewConstants.L_WINDOW);
    if (!securityService.hasCurrentUserRole("ROLE_SUPERADMIN") && securityService.hasCurrentUserRole("ROLE_ADMIN")) {
        RibbonGroup actions = window.getRibbon().getGroupByName("actions");
        for (RibbonActionItem actionItem : actions.getItems()) {
            actionItem.setEnabled(false);
            actionItem.requestUpdate(true);
        }
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 2 with WindowComponent

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

the class TechnologyDetailsHooksPFTD method changeRibbonState.

private void changeRibbonState(final ViewDefinitionState view) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long technologyId = technologyForm.getEntityId();
    if (Objects.isNull(technologyId)) {
        return;
    }
    Entity technology = technologyForm.getPersistedEntityWithIncludedFormValues();
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup flow = window.getRibbon().getGroupByName(L_PRODUCTS_FLOW);
    RibbonActionItem fillLocationsInComponents = flow.getItemByName(L_FILL_LOCATIONS_IN_COMPONENTS);
    RibbonGroup modelCard = window.getRibbon().getGroupByName(MODEL_CARD);
    RibbonGroup productionLines = window.getRibbon().getGroupByName(PRODUCTION_LINES);
    RibbonActionItem addMultipleProductionLines = productionLines.getItemByName(ADD_MULTIPLE_PRODUCTION_LINES);
    String state = technology.getStringField(TechnologyFields.STATE);
    boolean isTemplateAccepted = technology.getBooleanField(TechnologyFields.IS_TEMPLATE_ACCEPTED);
    fillLocationsInComponents.setEnabled(!isTemplateAccepted && TechnologyState.DRAFT.getStringValue().equals(state));
    fillLocationsInComponents.requestUpdate(true);
    addMultipleProductionLines.setEnabled(!isTemplateAccepted && TechnologyState.DRAFT.getStringValue().equals(state));
    addMultipleProductionLines.requestUpdate(true);
    if (Objects.nonNull(modelCard)) {
        RibbonActionItem createModelCard = modelCard.getItemByName(CREATE_MODEL_CARD);
        createModelCard.setEnabled(TechnologyState.CHECKED.getStringValue().equals(state) || TechnologyState.ACCEPTED.getStringValue().equals(state));
        createModelCard.requestUpdate(true);
    }
    window.requestRibbonRender();
}
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 3 with WindowComponent

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

the class ProductionTrackingDetailsHooks method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup actionsRibbonGroup = window.getRibbon().getGroupByName(L_ACTIONS);
    RibbonGroup productsQuantitiesRibbonGroup = window.getRibbon().getGroupByName(L_PRODUCTS_QUANTITIES);
    RibbonGroup productionCountingQuantitiesRibbonGroup = window.getRibbon().getGroupByName(L_PRODUCTION_COUNTING_QUANTITIES);
    RibbonGroup anomaliesRibbonGroup = window.getRibbon().getGroupByName(L_ANOMALIES);
    RibbonActionItem copyRibbonActionItem = actionsRibbonGroup.getItemByName(L_COPY);
    RibbonActionItem copyPlannedQuantityToUsedQuantityRibbonActionItem = productsQuantitiesRibbonGroup.getItemByName(L_COPY_PLANNED_QUANTITY_TO_USED_QUANTITY);
    RibbonActionItem productionCountingQuantitiesRibbonActionItem = productionCountingQuantitiesRibbonGroup.getItemByName(L_PRODUCTION_COUNTING_QUANTITIES);
    RibbonActionItem addToAnomaliesListRibbonActionItem = anomaliesRibbonGroup.getItemByName(L_ADD_TO_ANOMALIES_LIST);
    if (Objects.isNull(productionTrackingForm.getEntityId())) {
        return;
    }
    Entity productionTracking = productionTrackingForm.getEntity();
    Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);
    if (Objects.isNull(order)) {
        return;
    }
    String state = productionTracking.getStringField(ProductionTrackingFields.STATE);
    String orderState = order.getStringField(OrderFields.STATE);
    boolean isInProgress = OrderStateStringValues.IN_PROGRESS.equals(orderState);
    boolean isDraft = ProductionTrackingStateStringValues.DRAFT.equals(state);
    boolean registerQuantityInProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT);
    boolean registerQuantityOutProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT);
    copyRibbonActionItem.setEnabled(isInProgress);
    String releaseOfMaterials = parameterService.getParameter().getStringField(ParameterFieldsPC.RELEASE_OF_MATERIALS);
    if (ReleaseOfMaterials.MANUALLY_TO_ORDER_OR_GROUP.getStringValue().equals(releaseOfMaterials)) {
        copyPlannedQuantityToUsedQuantityRibbonActionItem.setEnabled(false);
    } else {
        copyPlannedQuantityToUsedQuantityRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
    }
    productionCountingQuantitiesRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
    addToAnomaliesListRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
    copyRibbonActionItem.requestUpdate(true);
    copyPlannedQuantityToUsedQuantityRibbonActionItem.requestUpdate(true);
    productionCountingQuantitiesRibbonActionItem.requestUpdate(true);
    addToAnomaliesListRibbonActionItem.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 4 with WindowComponent

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

the class ProductionTrackingsForProductGroupedListHooks method updateButtonsState.

public void updateButtonsState(final ViewDefinitionState view) {
    GridComponent productionTrackingsForProductGroupedGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup showProductionTrackingsRibbonGroup = ribbon.getGroupByName(L_SHOW_PRODUCTION_TRACKINGS);
    RibbonActionItem showProductionTrackingsForProductRibbonActionItem = showProductionTrackingsRibbonGroup.getItemByName(L_SHOW_PRODUCTION_TRACKINGS_FOR_PRODUCT);
    boolean isSelected = !productionTrackingsForProductGroupedGrid.getSelectedEntities().isEmpty();
    showProductionTrackingsForProductRibbonActionItem.setEnabled(isSelected);
    showProductionTrackingsForProductRibbonActionItem.requestUpdate(true);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) 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 5 with WindowComponent

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

the class AnomalyProductionTrackingDetailsHooks method updateRibbon.

private void updateRibbon(final ViewDefinitionState view) {
    try {
        WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
        RibbonGroup actions = window.getRibbon().getGroupByName(L_ACTIONS);
        RibbonActionItem perform = actions.getItemByName("perform");
        RibbonActionItem performAndAccept = actions.getItemByName("performAndAccept");
        boolean performAndAcceptFlag = view.getJsonContext().getBoolean("window.mainTab.form.performAndAccept");
        perform.setEnabled(!performAndAcceptFlag);
        performAndAccept.setEnabled(performAndAcceptFlag);
        perform.requestUpdate(true);
        performAndAccept.requestUpdate(true);
    } catch (JSONException e) {
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) JSONException(org.json.JSONException) 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