Search in sources :

Example 31 with GridComponent

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

the class OffersItemsListeners method redirectToOfferDetails.

public void redirectToOfferDetails(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    if (grid.getSelectedEntities().isEmpty()) {
        return;
    }
    Entity offerProduct = grid.getSelectedEntities().get(0);
    Entity offer = offerProduct.getBelongsToField(OFFER);
    if (offer == null) {
        return;
    }
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put("form.id", offer.getId());
    String url = "../page/supplyNegotiations/offerDetails.html";
    view.redirectTo(url, false, true, parameters);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 32 with GridComponent

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

the class GeneratorViewListeners method goToGeneratedTechnologies.

public void goToGeneratedTechnologies(final ViewDefinitionState view, final ComponentState eventPerformer, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference("generatorTechnologiesForProducts");
    if (!grid.getSelectedEntitiesIds().isEmpty()) {
        String url = "../page/technologies/technologyDetails.html";
        Entity e = grid.getSelectedEntities().get(0).getDataDefinition().get(grid.getSelectedEntities().get(0).getId());
        view.redirectTo(url, false, true, ImmutableMap.of("form.id", e.getBelongsToField("technology").getId()));
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 33 with GridComponent

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

the class OperationDetailsHooks method disableWorkstationsTabFieldsIfOperationIsNotSaved.

private void disableWorkstationsTabFieldsIfOperationIsNotSaved(ViewDefinitionState view) {
    FormComponent operationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent workstations = (GridComponent) view.getComponentByReference(OperationFields.WORKSTATIONS);
    if (operationForm.getEntityId() == null) {
        changedEnabledFields(view, L_WORKSTATIONS_TAB_FIELDS, false);
        changeEnabledLookups(view, L_WORKSTATIONS_TAB_LOOKUPS, Lists.newArrayList(""));
        workstations.setEnabled(false);
    } else {
        changedEnabledFields(view, L_WORKSTATIONS_TAB_FIELDS, true);
        changeEnabledLookups(view, L_WORKSTATIONS_TAB_LOOKUPS, L_WORKSTATIONS_TAB_LOOKUPS);
        workstations.setEnabled(true);
        setWorkstationsTabFields(view);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 34 with GridComponent

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

the class AddProcessesListeners method addProcesses.

public void addProcesses(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent technologicalProcesses = (GridComponent) view.getComponentByReference(L_TECHNOLOGICAL_PROCESSES);
    Set<Long> selectedEntities = technologicalProcesses.getSelectedEntitiesIds();
    if (selectedEntities.isEmpty()) {
        view.addMessage("technologies.addProcesses.noSelectedProcesses", ComponentState.MessageType.INFO);
        return;
    }
    for (Long technologicalProcessId : selectedEntities) {
        Entity technologicalProcess = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS).get(technologicalProcessId);
        Entity technologicalProcessComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_COMPONENT).create();
        technologicalProcessComponent.setField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS, technologicalProcess);
        technologicalProcessComponent.setField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_LIST, form.getEntityId());
        technologicalProcessComponent.setField(TechnologicalProcessFields.TPZ, technologicalProcess.getField(TechnologicalProcessFields.TPZ));
        technologicalProcessComponent.setField(TechnologicalProcessFields.TJ, technologicalProcess.getField(TechnologicalProcessFields.TJ));
        technologicalProcessComponent.setField(TechnologicalProcessFields.ADDITIONAL_TIME, technologicalProcess.getField(TechnologicalProcessFields.ADDITIONAL_TIME));
        technologicalProcessComponent.setField(TechnologicalProcessFields.EXTENDED_TIME_FOR_SIZE_GROUP, technologicalProcess.getField(TechnologicalProcessFields.EXTENDED_TIME_FOR_SIZE_GROUP));
        technologicalProcessComponent.setField(TechnologicalProcessFields.INCREASE_PERCENT, technologicalProcess.getField(TechnologicalProcessFields.INCREASE_PERCENT));
        technologicalProcessComponent.setField(TechnologicalProcessFields.SIZE_GROUP, technologicalProcess.getField(TechnologicalProcessFields.SIZE_GROUP));
        technologicalProcessComponent.getDataDefinition().save(technologicalProcessComponent);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 35 with GridComponent

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

the class TechnologiesListListeners method trySetAsDefault.

@Transactional
public void trySetAsDefault(ViewDefinitionState view) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Set<Long> selectedEntities = grid.getSelectedEntitiesIds();
    selectedEntities.forEach(techId -> {
        Entity technology = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY).get(techId);
        technology.setField(TechnologyFields.MASTER, Boolean.TRUE);
        technology = technology.getDataDefinition().save(technology);
        if (!technology.isValid()) {
            throw new EntityRuntimeException(technology);
        }
    });
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) EntityRuntimeException(com.qcadoo.model.api.exception.EntityRuntimeException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12