Search in sources :

Example 41 with LookupComponent

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

the class OperationDetailsHooks method clearLookupField.

public void clearLookupField(final ViewDefinitionState view, String fieldName) {
    LookupComponent lookupComponent = (LookupComponent) view.getComponentByReference(fieldName);
    lookupComponent.setFieldValue(null);
    lookupComponent.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 42 with LookupComponent

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

the class OperationSkillDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent operationSkillForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent skillLookup = (LookupComponent) view.getComponentByReference(OperationSkillFields.SKILL);
    Entity operationSkill = operationSkillForm.getEntity();
    Entity operation = operationSkill.getBelongsToField(OperationSkillFields.OPERATION);
    filterSkillLookup(skillLookup, operation);
    fillMaxSkill(view, skillLookup);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 43 with LookupComponent

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

the class TechnologyDetailsHooks method disableFieldTechnologyFormAndEnabledMaster.

public void disableFieldTechnologyFormAndEnabledMaster(final ViewDefinitionState view) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent masterField = (FieldComponent) view.getComponentByReference(TechnologyFields.MASTER);
    LookupComponent technologyGroupLookup = (LookupComponent) view.getComponentByReference(TechnologyFields.TECHNOLOGY_GROUP);
    boolean disabled = false;
    boolean masterDisabled = false;
    boolean technologyGroupEnabled = false;
    Long technologyId = technologyForm.getEntityId();
    if (Objects.nonNull(technologyId)) {
        Entity technology = getTechnologyDD().get(technologyId);
        if (Objects.isNull(technology)) {
            return;
        }
        String state = technology.getStringField(TechnologyFields.STATE);
        boolean isTemplateAccepted = technology.getBooleanField(TechnologyFields.IS_TEMPLATE_ACCEPTED);
        if (isTemplateAccepted || !TechnologyState.DRAFT.getStringValue().equals(state)) {
            disabled = true;
        }
        if (TechnologyState.ACCEPTED.getStringValue().equals(state)) {
            masterDisabled = true;
        }
        if (TechnologyState.ACCEPTED.getStringValue().equals(state) || TechnologyState.CHECKED.getStringValue().equals(state) || TechnologyState.DRAFT.getStringValue().equals(state)) {
            technologyGroupEnabled = true;
        }
    }
    technologyForm.setFormEnabled(!disabled);
    masterField.setEnabled(masterDisabled);
    masterField.requestComponentUpdateState();
    technologyGroupLookup.setEnabled(technologyGroupEnabled);
    technologyGroupLookup.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 44 with LookupComponent

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

the class TechnologyReferenceTechnologyComponentDetailsHooks method disabledSaveBackButton.

public void disabledSaveBackButton(final ViewDefinitionState viewDefinitionState) {
    WindowComponent window = (WindowComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup actionsGroup = (RibbonGroup) window.getRibbon().getGroupByName("actions");
    RibbonActionItem saveBack = (RibbonActionItem) actionsGroup.getItemByName("saveBack");
    LookupComponent technology = (LookupComponent) viewDefinitionState.getComponentByReference("technology");
    if (technology.getEntity() == null) {
        saveBack.setEnabled(false);
    } else {
        saveBack.setEnabled(true);
    }
    saveBack.requestUpdate(true);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 45 with LookupComponent

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

the class SkillOperationDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity opSkill = form.getEntity();
    FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
    maxSkillLevelField.setFieldValue(opSkill.getBelongsToField(OperationSkillFields.SKILL).getIntegerField(SkillFields.MAXIMUM_LEVEL));
    LookupComponent operationLookup = (LookupComponent) view.getComponentByReference(OperationSkillFields.OPERATION);
    FilterValueHolder filterValueHolder = operationLookup.getFilterValue();
    Long skillId = opSkill.getBelongsToField(StaffSkillsFields.SKILL).getId();
    if (Objects.isNull(skillId)) {
        filterValueHolder.remove(L_SKILL_ID);
    } else {
        filterValueHolder.put(L_SKILL_ID, skillId);
    }
    operationLookup.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

LookupComponent (com.qcadoo.view.api.components.LookupComponent)277 Entity (com.qcadoo.model.api.Entity)182 FieldComponent (com.qcadoo.view.api.components.FieldComponent)105 FormComponent (com.qcadoo.view.api.components.FormComponent)102 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)69 BigDecimal (java.math.BigDecimal)16 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)12 GridComponent (com.qcadoo.view.api.components.GridComponent)11 WindowComponent (com.qcadoo.view.api.components.WindowComponent)8 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)7 Date (java.util.Date)6 JSONObject (org.json.JSONObject)6 ComponentState (com.qcadoo.view.api.ComponentState)5 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)5 JSONException (org.json.JSONException)5 DataDefinition (com.qcadoo.model.api.DataDefinition)3 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)3 Optional (com.google.common.base.Optional)2 ProductFields (com.qcadoo.mes.basic.constants.ProductFields)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2