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);
}
}
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);
}
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);
}
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());
}
}
}
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);
}
Aggregations