Search in sources :

Example 1 with RibbonGroup

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

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

the class RibbonImpl method setPermanentlyDisabled.

@Override
public void setPermanentlyDisabled(final boolean permanentlyDisabled) {
    for (RibbonGroup group : getGroups()) {
        for (RibbonActionItem item : group.getItems()) {
            boolean disabled = permanentlyDisabled && ribbonItemShouldBeDisabled(group, item);
            ((InternalRibbonActionItem) item).setPermanentlyDisabled(disabled);
            item.requestUpdate(true);
        }
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 3 with RibbonGroup

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

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

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

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