use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class AnomalyDetailsListeners method completeWithoutIssue.
public void completeWithoutIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity anomaly = form.getEntity();
if (anomaly.getId() == null) {
return;
}
anomaly.setField(AnomalyFields.STATE, AnomalyFields.State.COMPLETED);
anomaly.setField(AnomalyFields.ISSUED, false);
anomaly.getDataDefinition().save(anomaly);
state.performEvent(view, "reset", new String[0]);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class AnomalyExplanationDetailsListeners method onRemoveSelectedEntity.
public void onRemoveSelectedEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent anomalyExplanationsGrid = (GridComponent) view.getComponentByReference("anomalyExplanations");
DataDefinition dataDefinition = dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_ANOMALY_EXPLANATION);
dataDefinition.delete(toArray(anomalyExplanationsGrid.getSelectedEntitiesIds(), Long.class));
FormComponent documentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
documentForm.performEvent(view, "reset");
}
use of com.qcadoo.view.api.components.FormComponent 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);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionTrackingDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
setCriteriaModifierParameters(view);
productionTrackingService.fillProductionLineLookup(view);
if ((view.isViewAfterRedirect() || view.isViewAfterReload()) && !((CheckBoxComponent) view.getComponentByReference(ProductionTrackingFields.ADD_BATCH)).isChecked()) {
FieldComponent batchNumber = (FieldComponent) view.getComponentByReference(ProductionTrackingFields.BATCH_NUMBER);
batchNumber.setEnabled(false);
}
if (Objects.isNull(productionTrackingForm.getEntityId())) {
setStateFieldValueToDraft(view);
} else {
Entity productionTracking = getProductionTrackingFromDB(productionTrackingForm.getEntityId());
initializeProductionTrackingDetailsView(view);
showLastStateChangeFailNotification(productionTrackingForm, productionTracking);
changeFieldComponentsEnabledAndGridsEditable(view);
updateRibbonState(view);
toggleCorrectButton(view, productionTracking);
toggleCorrectionFields(view, productionTracking);
fetchNumberFromDatabase(view, productionTracking);
}
fillBatchOrderedProductLabel(view);
changeStoppagesTabVisible(view);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPC method setTechnologyDefaultValues.
public void setTechnologyDefaultValues(final ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent typeOfProductionRecordingField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
if (Objects.nonNull(orderForm.getEntityId())) {
return;
}
for (String fieldComponentName : L_TECHNOLOGY_FIELD_NAMES) {
FieldComponent fieldComponent = (FieldComponent) view.getComponentByReference(fieldComponentName);
if (Objects.isNull(fieldComponent.getFieldValue())) {
fieldComponent.setFieldValue(getDefaultValueForProductionCountingFromParameter(fieldComponentName));
fieldComponent.requestComponentUpdateState();
}
fieldComponent.setEnabled(false);
}
if (Objects.isNull(typeOfProductionRecordingField.getFieldValue())) {
typeOfProductionRecordingField.setFieldValue(getDefaultValueForTypeOfProductionRecordingParameter(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING));
}
}
Aggregations