Search in sources :

Example 51 with GridComponent

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

the class PalletNumbersListHooks method disableButtonsWhenNotSelected.

public void disableButtonsWhenNotSelected(final ViewDefinitionState view) {
    GridComponent palletNumbersGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup printRibbonGroup = ribbon.getGroupByName(L_PRINT);
    RibbonActionItem printPalletNumbersReportRibbonActionItem = printRibbonGroup.getItemByName(L_PRINT_PALLET_NUMBERS_REPORT);
    boolean palletNumbersAreSelected = !palletNumbersGrid.getSelectedEntities().isEmpty();
    if (printPalletNumbersReportRibbonActionItem != null) {
        printPalletNumbersReportRibbonActionItem.setEnabled(palletNumbersAreSelected);
        printPalletNumbersReportRibbonActionItem.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 52 with GridComponent

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

the class AttributeDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    numberGeneratorService.generateAndInsertNumber(view, BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.ATTRIBUTE, QcadooViewConstants.L_FORM, AttributeFields.NUMBER);
    FieldComponent dataType = (FieldComponent) view.getComponentByReference(AttributeFields.DATA_TYPE);
    FieldComponent valueType = (FieldComponent) view.getComponentByReference(AttributeFields.VALUE_TYPE);
    FieldComponent precision = (FieldComponent) view.getComponentByReference(AttributeFields.PRECISION);
    FieldComponent unit = (FieldComponent) view.getComponentByReference(AttributeFields.UNIT);
    if (Objects.nonNull(valueType.getFieldValue()) && AttributeValueType.NUMERIC.getStringValue().equals(valueType.getFieldValue())) {
        precision.setEnabled(true);
        unit.setEnabled(true);
        if (Objects.isNull(precision.getFieldValue()) || StringUtils.isEmpty((String) precision.getFieldValue())) {
            precision.setFieldValue("0");
            precision.requestComponentUpdateState();
        }
    } else {
        unit.setEnabled(false);
        unit.setFieldValue(null);
        precision.setEnabled(false);
        precision.setFieldValue(null);
        precision.requestComponentUpdateState();
    }
    unit.requestComponentUpdateState();
    GridComponent attributeValues = (GridComponent) view.getComponentByReference(AttributeFields.ATTRIBUTE_VALUES);
    if (Objects.nonNull(dataType.getFieldValue()) && AttributeDataType.CONTINUOUS.getStringValue().equals(dataType.getFieldValue())) {
        attributeValues.setEditable(false);
        attributeValues.setEnabled(false);
    } else {
        attributeValues.setEditable(true);
        attributeValues.setEnabled(true);
    }
    disableFormComponentsIfAttributeAssign(view);
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 53 with GridComponent

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

the class FaultTypeDetailsHooks method disableActionsWhenDefault.

public void disableActionsWhenDefault(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup actions = window.getRibbon().getGroupByName("actions");
    for (RibbonActionItem item : actions.getItems()) {
        item.setEnabled(false);
        item.requestUpdate(true);
    }
    GridComponent workstationsGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.WORKSTATIONS);
    GridComponent subassembliesGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.SUBASSEMBLIES);
    GridComponent workstationTypesGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.WORKSTATION_TYPES);
    workstationsGrid.setEnabled(false);
    subassembliesGrid.setEnabled(false);
    workstationTypesGrid.setEnabled(false);
    FieldComponent nameField = (FieldComponent) view.getComponentByReference(FaultTypeFields.NAME);
    FieldComponent appliesToField = (FieldComponent) view.getComponentByReference(FaultTypeFields.APPLIES_TO);
    nameField.setEnabled(false);
    appliesToField.setEnabled(false);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 54 with GridComponent

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

the class FaultTypeDetailsHooks method toggleGridsEnable.

public void toggleGridsEnable(final ViewDefinitionState view, final String appliesTo, final boolean shouldClear) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent workstationsGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.WORKSTATIONS);
    GridComponent subassembliesGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.SUBASSEMBLIES);
    GridComponent workstationTypesGrid = (GridComponent) view.getComponentByReference(FaultTypeFields.WORKSTATION_TYPES);
    boolean idNotNull = form.getEntityId() != null;
    if (FaultTypeAppliesTo.WORKSTATION_OR_SUBASSEMBLY.getStringValue().equals(appliesTo) && idNotNull) {
        workstationsGrid.setEnabled(true);
        subassembliesGrid.setEnabled(true);
        workstationTypesGrid.setEnabled(false);
        if (shouldClear) {
            workstationTypesGrid.setEntities(Lists.newArrayList());
        }
    } else if (FaultTypeAppliesTo.WORKSTATION_TYPE.getStringValue().equals(appliesTo) && idNotNull) {
        workstationsGrid.setEnabled(false);
        subassembliesGrid.setEnabled(false);
        workstationTypesGrid.setEnabled(true);
        if (shouldClear) {
            workstationsGrid.setEntities(Lists.newArrayList());
            subassembliesGrid.setEntities(Lists.newArrayList());
        }
    } else {
        workstationsGrid.setEnabled(false);
        subassembliesGrid.setEnabled(false);
        workstationTypesGrid.setEnabled(false);
        if (shouldClear) {
            workstationsGrid.setEntities(Lists.newArrayList());
            subassembliesGrid.setEntities(Lists.newArrayList());
            workstationTypesGrid.setEntities(Lists.newArrayList());
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 55 with GridComponent

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

the class FaultTypeListHooks method disableActionsWhenDefault.

private void disableActionsWhenDefault(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup actions = window.getRibbon().getGroupByName("actions");
    RibbonActionItem copyButton = actions.getItemByName("copy");
    RibbonActionItem deleteButton = actions.getItemByName("delete");
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    List<Entity> selectedFaults = grid.getSelectedEntities();
    for (Entity selectedFault : selectedFaults) {
        if (selectedFault.getBooleanField("isDefault")) {
            copyButton.setEnabled(false);
            deleteButton.setEnabled(false);
            copyButton.requestUpdate(true);
            deleteButton.requestUpdate(true);
            return;
        }
    }
    boolean enabled = !selectedFaults.isEmpty();
    copyButton.setEnabled(enabled);
    deleteButton.setEnabled(enabled);
    copyButton.requestUpdate(true);
    deleteButton.requestUpdate(true);
}
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)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12