Search in sources :

Example 6 with WindowComponent

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");
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) EntityTree(com.qcadoo.model.api.EntityTree)

Example 7 with WindowComponent

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");
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) EntityTree(com.qcadoo.model.api.EntityTree)

Example 8 with WindowComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) Date(java.util.Date)

Example 9 with WindowComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) BalanceGenerationStrategy(com.qcadoo.mes.productionPerShift.BalanceGenerationStrategy) WindowComponent(com.qcadoo.view.api.components.WindowComponent)

Example 10 with WindowComponent

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);
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) JSONObject(org.json.JSONObject) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) 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