Search in sources :

Example 21 with WindowComponent

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

the class NumberPatternDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity numberPattern = form.getPersistedEntityWithIncludedFormValues();
    if (numberPattern.getBooleanField(NumberPatternFields.USED)) {
        form.setFormEnabled(false);
        GridComponent grid = (GridComponent) view.getComponentByReference("numberPatternElements");
        grid.setEditable(false);
        WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
        RibbonGroup actions = window.getRibbon().getGroupByName("actions");
        RibbonActionItem save = actions.getItemByName("save");
        save.setEnabled(false);
        save.requestUpdate(true);
        RibbonActionItem saveBack = actions.getItemByName("saveBack");
        saveBack.setEnabled(false);
        saveBack.requestUpdate(true);
        RibbonActionItem saveNew = actions.getItemByName("saveNew");
        saveNew.setEnabled(false);
        saveNew.requestUpdate(true);
        window.requestRibbonRender();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) 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)

Example 22 with WindowComponent

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

the class EventHooks method toggleOldSolutionsButton.

private void toggleOldSolutionsButton(ViewDefinitionState view) {
    WindowComponent windowComponent = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = windowComponent.getRibbon();
    RibbonGroup solutionsRibbonGroup = ribbon.getGroupByName("solutions");
    RibbonActionItem showSolutionsRibbonActionItem = solutionsRibbonGroup.getItemByName("showSolutions");
    FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity event = formComponent.getPersistedEntityWithIncludedFormValues();
    showSolutionsRibbonActionItem.setEnabled(event.getId() != null);
    showSolutionsRibbonActionItem.requestUpdate(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 23 with WindowComponent

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

the class EventHooks method toggleRibbonButton.

private void toggleRibbonButton(final ViewDefinitionState view, String groupName, String itemName, boolean enabled) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup group = ribbon.getGroupByName(groupName);
    RibbonActionItem item = group.getItemByName(itemName);
    item.setEnabled(enabled);
    item.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) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 24 with WindowComponent

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

the class CostCalculationDetailsHooks method setButtonsEnabled.

private void setButtonsEnabled(ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonActionItem saveNominalCosts = window.getRibbon().getGroupByName(CostCalculationFields.SAVE_COSTS).getItemByName(CostCalculationFields.NOMINAL_COSTS);
    RibbonActionItem generate = window.getRibbon().getGroupByName("generate").getItemByName("generate");
    RibbonActionItem pdfButton = window.getRibbon().getGroupByName("export").getItemByName("pdf");
    RibbonActionItem xlsButton = window.getRibbon().getGroupByName("export").getItemByName("xls");
    RibbonActionItem save = window.getRibbon().getGroupByName(ACTIONS).getItemByName("save");
    RibbonActionItem saveBack = window.getRibbon().getGroupByName(ACTIONS).getItemByName("saveBack");
    RibbonActionItem saveNew = window.getRibbon().getGroupByName(ACTIONS).getItemByName("saveNew");
    RibbonActionItem copy = window.getRibbon().getGroupByName(ACTIONS).getItemByName("copy");
    RibbonActionItem cancel = window.getRibbon().getGroupByName(ACTIONS).getItemByName("cancel");
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    boolean pdf = form.getPersistedEntityWithIncludedFormValues().getBooleanField(CostCalculationFields.PDF);
    boolean entityExists = form.getEntityId() != null;
    if (entityExists) {
        CheckBoxComponent generatedField = (CheckBoxComponent) view.getComponentByReference(CostCalculationFields.GENERATED);
        int technologiesCount = ((GridComponent) view.getComponentByReference(CostCalculationFields.TECHNOLOGIES)).getEntities().size();
        generate.setEnabled(technologiesCount > 0);
        generate.requestUpdate(true);
        saveNominalCosts.setEnabled(generatedField.isChecked());
        saveNominalCosts.requestUpdate(true);
        if (generatedField.isChecked()) {
            if (pdf) {
                pdfButton.setEnabled(true);
                pdfButton.requestUpdate(true);
            } else {
                xlsButton.setEnabled(true);
                xlsButton.requestUpdate(true);
            }
            generate.setEnabled(false);
            generate.requestUpdate(true);
            save.setEnabled(false);
            save.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
            save.requestUpdate(true);
            saveNew.setEnabled(false);
            saveNew.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
            saveNew.requestUpdate(true);
            saveBack.setEnabled(false);
            saveBack.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
            saveBack.requestUpdate(true);
            cancel.setEnabled(false);
            cancel.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
        } else {
            pdfButton.setEnabled(false);
            pdfButton.setMessage("costCalculation.ribbon.message.recordNotGenerated");
            pdfButton.requestUpdate(true);
            xlsButton.setEnabled(false);
            xlsButton.setMessage("costCalculation.ribbon.message.recordNotGenerated");
            xlsButton.requestUpdate(true);
            save.setEnabled(true);
            save.requestUpdate(true);
            cancel.setEnabled(true);
        }
    } else {
        copy.setEnabled(false);
        copy.setMessage(RECORD_NOT_CREATED);
        copy.requestUpdate(true);
        pdfButton.setEnabled(false);
        pdfButton.setMessage(RECORD_NOT_CREATED);
        pdfButton.requestUpdate(true);
        xlsButton.setEnabled(false);
        xlsButton.setMessage(RECORD_NOT_CREATED);
        xlsButton.requestUpdate(true);
        save.setEnabled(true);
        save.requestUpdate(true);
        cancel.setEnabled(true);
    }
    cancel.requestUpdate(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 25 with WindowComponent

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

the class TechnologiesListHooksCC method toggleGenerateCostCalculationButton.

public void toggleGenerateCostCalculationButton(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonActionItem generateCostCalculation = window.getRibbon().getGroupByName("costCalculation").getItemByName("createCostCalculation");
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    generateCostCalculation.setEnabled(!grid.getSelectedEntities().isEmpty());
    generateCostCalculation.requestUpdate(true);
}
Also used : WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) 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