use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class SubassemblyDetailsListenersPL method generateFactoryStructure.
public void generateFactoryStructure(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity subassembly = form.getEntity();
EntityTree structure = factoryStructureGenerationService.generateFactoryStructureForSubassembly(subassembly);
subassembly.setField(WorkstationFieldsPL.FACTORY_STRUCTURE, structure);
form.setEntity(subassembly);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
window.setActiveTab("factoryStructureTab");
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class WorkstationDetailsListenersPL method generateFactoryStructure.
public void generateFactoryStructure(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity workstation = form.getEntity();
EntityTree structure = factoryStructureGenerationService.generateFactoryStructureForWorkstation(workstation);
workstation.setField(WorkstationFieldsPL.FACTORY_STRUCTURE, structure);
form.setEntity(workstation);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
window.setActiveTab("factoryStructureTab");
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method updateAutoFillButtonState.
private void updateAutoFillButtonState(ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonActionItem button = window.getRibbon().getGroupByName("autoFill").getItemByName("planProgressForDays");
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (!automaticPpsParametersService.isAutomaticPlanForShiftOn()) {
button.setEnabled(false);
button.requestUpdate(true);
window.requestRibbonRender();
return;
}
Entity formEntity = form.getPersistedEntityWithIncludedFormValues();
Date orderStartDate = formEntity.getBelongsToField(ProductionPerShiftFields.ORDER).getDateField(OrderFields.START_DATE);
String orderState = formEntity.getBelongsToField(ProductionPerShiftFields.ORDER).getStringField(OrderFields.STATE);
if (orderStartDate != null && OrderStateStringValues.PENDING.equals(orderState)) {
button.setEnabled(true);
} else {
button.setEnabled(false);
}
button.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class GenerateBalanceListeners method generateBalance.
public void generateBalance(final ViewDefinitionState viewState, final ComponentState formState, final String[] args) {
FormComponent form = (FormComponent) formState;
Entity contextEntity = form.getPersistedEntityWithIncludedFormValues();
// We don't want to reuse contexts - in case of the user working with many browser tabs to compare a couple of results
contextEntity.setId(null);
contextEntity.setField(BalanceContextFields.BALANCES, Collections.<Entity>emptyList());
// Call validation
contextEntity = contextEntity.getDataDefinition().save(contextEntity);
if (!contextEntity.isValid()) {
form.setEntity(contextEntity);
return;
}
BalanceGenerationStrategy strategy = resolveBalanceGenerationStrategy(contextEntity);
List<Entity> balances = productionBalancePerShiftGenerator.generate(strategy);
contextEntity.setField(BalanceContextFields.BALANCES, balances);
Entity persistedContext = contextEntity.getDataDefinition().save(contextEntity);
if (persistedContext.isValid()) {
// Show 'balances' tab
WindowComponent window = (WindowComponent) viewState.getComponentByReference(QcadooViewConstants.L_WINDOW);
window.setActiveTab("balances");
}
form.setEntity(persistedContext);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class StoppageForOrderFormHooks method onRibbonBeforeRender.
public final void onRibbonBeforeRender(final ViewDefinitionState view) throws JSONException {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup actionsRibbonGroup = ribbon.getGroupByName("actions");
RibbonActionItem addNew = actionsRibbonGroup.getItemByName("new");
RibbonActionItem copy = actionsRibbonGroup.getItemByName("copy");
JSONObject context = view.getJsonContext();
if (context.has("window.mainTab.stoppage.forOrder")) {
Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(context.getLong("window.mainTab.stoppage.forOrder"));
if (OrderState.DECLINED.getStringValue().equals(order.getStringField(OrderFields.STATE))) {
addNew.setEnabled(false);
addNew.requestUpdate(true);
copy.setEnabled(false);
copy.requestUpdate(true);
}
}
}
Aggregations