Search in sources :

Example 71 with WindowComponent

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

the class OrderDetailsHooksCNFM 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");
    Long orderId = orderForm.getEntityId();
    if (orderId != null) {
        Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(orderId);
        if ((order != null) && orderStateService.isSynchronized(order)) {
            Entity technology = order.getBelongsToField(TECHNOLOGY);
            if ((technology != null)) {
                viewCosts.setEnabled(true);
                viewCosts.requestUpdate(true);
                return;
            }
        }
    }
    viewCosts.setEnabled(false);
    viewCosts.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 72 with WindowComponent

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

the class MasterOrderDetailsHooks method toggleGenerateButton.

private void toggleGenerateButton(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup orders = (RibbonGroup) window.getRibbon().getGroupByName(L_ORDERS);
    RibbonActionItem createOrder = (RibbonActionItem) orders.getItemByName("generateOrders");
    createOrder.setMessage("qcadooView.ribbon.orders.generateOrders.message");
    GridComponent masterOrderProductsGrid = (GridComponent) view.getComponentByReference(MasterOrderFields.MASTER_ORDER_PRODUCTS);
    createOrder.setEnabled(!masterOrderProductsGrid.getSelectedEntities().isEmpty());
    createOrder.requestUpdate(true);
}
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 73 with WindowComponent

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

the class MasterOrderPositionsListHooks method disableButton.

public void disableButton(final ViewDefinitionState view) {
    GridComponent masterOrderPositionComponent = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup ordersRibbonGroup = window.getRibbon().getGroupByName(L_ORDERS);
    RibbonGroup groupingRibbonGroup = window.getRibbon().getGroupByName("grouping");
    RibbonActionItem createOrderRibbonActionItem = ordersRibbonGroup.getItemByName(L_CREATE_ORDER);
    RibbonActionItem showGroupedByProduct = groupingRibbonGroup.getItemByName("showGroupedByProduct");
    RibbonActionItem showGroupedByProductAndDate = groupingRibbonGroup.getItemByName("showGroupedByProductAndDate");
    RibbonActionItem generateOrders = ordersRibbonGroup.getItemByName("generateOrders");
    generateOrders.setMessage("qcadooView.ribbon.orders.generateOrders.message");
    List<Entity> selectedEntities = masterOrderPositionComponent.getSelectedEntities();
    if (selectedEntities.isEmpty()) {
        generateOrders.setEnabled(false);
        showGroupedByProduct.setEnabled(false);
        showGroupedByProductAndDate.setEnabled(false);
    } else {
        generateOrders.setEnabled(true);
        showGroupedByProduct.setEnabled(true);
        showGroupedByProductAndDate.setEnabled(true);
    }
    generateOrders.requestUpdate(true);
    showGroupedByProduct.setMessage("masterOrders.masterOrderPositionsList.window.ribbon.grouping.showGroupedByProduct.description");
    showGroupedByProduct.requestUpdate(true);
    showGroupedByProductAndDate.setMessage("masterOrders.masterOrderPositionsList.window.ribbon.grouping.showGroupedByProductAndDate.description");
    showGroupedByProductAndDate.requestUpdate(true);
    boolean isEnabled = (selectedEntities.size() == 1);
    createOrderRibbonActionItem.setEnabled(isEnabled);
    createOrderRibbonActionItem.requestUpdate(true);
    window.requestRibbonRender();
    createOrderRibbonActionItem.setMessage("masterOrders.masterOrder.masterOrdersPosition.lessEntitiesSelectedThanAllowed");
}
Also used : Entity(com.qcadoo.model.api.Entity) 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 74 with WindowComponent

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

the class MatchingChangeoverNormsDetailsListeners method enabledButtonAfterSelectionTechnologies.

public void enabledButtonAfterSelectionTechnologies(final ViewDefinitionState viewDefinitionState, final ComponentState state, final String[] args) {
    WindowComponent window = (WindowComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonActionItem matchingChangeoverNorm = window.getRibbon().getGroupByName("matching").getItemByName("matchingChangeoverNorm");
    Entity fromTechnology = ((LookupComponent) viewDefinitionState.getComponentByReference(MATCHING_FROM_TECHNOLOGY)).getEntity();
    Entity toTechnology = ((LookupComponent) viewDefinitionState.getComponentByReference(MATCHING_TO_TECHNOLOGY)).getEntity();
    if ((fromTechnology == null) || (toTechnology == null)) {
        matchingChangeoverNorm.setEnabled(false);
    } else {
        matchingChangeoverNorm.setEnabled(true);
    }
    matchingChangeoverNorm.requestUpdate(true);
}
Also used : Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 75 with WindowComponent

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

the class LineChangeoverNormsForOrderDetailsViewHooks method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    FieldComponent productionLineField = (FieldComponent) view.getComponentByReference(OrderFields.PRODUCTION_LINE);
    LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
    LookupComponent lineChangeoverNormLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.LINE_CHANGEOVER_NORM);
    FieldComponent previousOrderTechnologyGroupNumberField = (FieldComponent) view.getComponentByReference("previousOrderTechnologyGroupNumber");
    FieldComponent technologyGroupNumberField = (FieldComponent) view.getComponentByReference("technologyGroupNumber");
    FieldComponent previousOrderTechnologyNumberField = (FieldComponent) view.getComponentByReference("previousOrderTechnologyNumber");
    FieldComponent technologyNumberField = (FieldComponent) view.getComponentByReference("technologyNumber");
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup orders = window.getRibbon().getGroupByName("orders");
    RibbonGroup lineChangeoverNorms = window.getRibbon().getGroupByName("lineChangeoverNorms");
    RibbonActionItem showPreviousOrder = orders.getItemByName("showPreviousOrder");
    RibbonActionItem showBestFittingLineChangeoverNorm = lineChangeoverNorms.getItemByName("showBestFittingLineChangeoverNorm");
    RibbonActionItem showChangeoverNormForGroup = lineChangeoverNorms.getItemByName("showLineChangeoverNormForGroup");
    RibbonActionItem showChangeoverNormForTechnology = lineChangeoverNorms.getItemByName("showLineChangeoverNormForTechnology");
    Entity productionLine = lineChangeoverNormsForOrdersService.getProductionLineFromDB((Long) productionLineField.getFieldValue());
    boolean hasDefinedPreviousOrder = !previousOrderLookup.isEmpty();
    updateButtonState(showPreviousOrder, hasDefinedPreviousOrder);
    boolean hasMatchingChangeoverNorm = !lineChangeoverNormLookup.isEmpty();
    updateButtonState(showBestFittingLineChangeoverNorm, hasMatchingChangeoverNorm);
    if (StringUtils.isEmpty((String) previousOrderTechnologyGroupNumberField.getFieldValue()) || StringUtils.isEmpty((String) technologyGroupNumberField.getFieldValue())) {
        updateButtonState(showChangeoverNormForGroup, false);
    } else {
        Entity fromTechnologyGroup = lineChangeoverNormsForOrdersService.getTechnologyGroupByNumberFromDB((String) previousOrderTechnologyGroupNumberField.getFieldValue());
        Entity toTechnologyGroup = lineChangeoverNormsForOrdersService.getTechnologyGroupByNumberFromDB((String) technologyGroupNumberField.getFieldValue());
        if ((changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyGroupWithLine(fromTechnologyGroup, toTechnologyGroup, productionLine) == null) && (changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyGroupWithLine(fromTechnologyGroup, toTechnologyGroup, null) == null)) {
            updateButtonState(showChangeoverNormForGroup, false);
        } else {
            updateButtonState(showChangeoverNormForGroup, true);
        }
    }
    if (StringUtils.isEmpty((String) previousOrderTechnologyNumberField.getFieldValue()) || StringUtils.isEmpty((String) technologyNumberField.getFieldValue())) {
        updateButtonState(showChangeoverNormForTechnology, false);
    } else {
        Entity fromTechnology = lineChangeoverNormsForOrdersService.getTechnologyByNumberFromDB((String) previousOrderTechnologyNumberField.getFieldValue());
        Entity toTechnology = lineChangeoverNormsForOrdersService.getTechnologyByNumberFromDB((String) technologyNumberField.getFieldValue());
        if ((changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyWithLine(fromTechnology, toTechnology, productionLine) == null) && (changeoverNormsSearchService.searchMatchingChangeroverNormsForTechnologyWithLine(fromTechnology, toTechnology, null) == null)) {
            updateButtonState(showChangeoverNormForTechnology, false);
        } else {
            updateButtonState(showChangeoverNormForTechnology, true);
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) LookupComponent(com.qcadoo.view.api.components.LookupComponent) WindowComponent(com.qcadoo.view.api.components.WindowComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) 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