Search in sources :

Example 61 with GridComponent

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

the class EventHooks method disableFieldsForState.

private void disableFieldsForState(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity event = form.getPersistedEntityWithIncludedFormValues();
    MaintenanceEventState state = MaintenanceEventState.of(event);
    if (state.compareTo(MaintenanceEventState.CLOSED) == 0 || state.compareTo(MaintenanceEventState.REVOKED) == 0 || state.compareTo(MaintenanceEventState.PLANNED) == 0) {
        form.setFormEnabled(false);
        GridComponent staffWorkTimes = (GridComponent) view.getComponentByReference(MaintenanceEventFields.STAFF_WORK_TIMES);
        GridComponent machineParts = (GridComponent) view.getComponentByReference(MaintenanceEventFields.MACHINE_PARTS_FOR_EVENT);
        staffWorkTimes.setEnabled(false);
        machineParts.setEnabled(false);
    }
}
Also used : MaintenanceEventState(com.qcadoo.mes.cmmsMachineParts.states.constants.MaintenanceEventState) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 62 with GridComponent

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

the class MaintenanceEventContextService method onSelectedEventChange.

public void onSelectedEventChange(ViewDefinitionState view) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    DataDefinition maintenanceEventDD = dataDefinitionService.get(CmmsMachinePartsConstants.PLUGIN_IDENTIFIER, CmmsMachinePartsConstants.MODEL_MAINTENANCE_EVENT);
    for (Entity eventEntity : grid.getSelectedEntities()) {
        eventEntity.setField(MaintenanceEventFields.MAINTENANCE_EVENT_CONTEXT, form.getEntityId());
        maintenanceEventDD.save(eventEntity);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 63 with GridComponent

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

the class PlannedEventDetailsListeners method addActions.

public void addActions(final ViewDefinitionState view, final ComponentState state, final String[] args) throws JSONException {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    List<Entity> selectedEntities = grid.getSelectedEntities();
    DataDefinition actionForPlannedEventDD = dataDefinitionService.get(CmmsMachinePartsConstants.PLUGIN_IDENTIFIER, CmmsMachinePartsConstants.MODEL_ACTION_PLANNED_EVENT);
    DataDefinition plannedEventDD = dataDefinitionService.get(CmmsMachinePartsConstants.PLUGIN_IDENTIFIER, CmmsMachinePartsConstants.MODEL_PLANNED_EVENT);
    Long plannedEventId = Long.valueOf(view.getJsonContext().get("window.mainTab.plannedEvent").toString());
    Entity plannedEvent = plannedEventDD.get(plannedEventId);
    for (Entity selectedAction : selectedEntities) {
        Entity actionForPlannedEvent = actionForPlannedEventDD.create();
        actionForPlannedEvent.setField(ActionForPlannedEventFields.ACTION, selectedAction);
        actionForPlannedEvent.setField(ActionForPlannedEventFields.PLANNED_EVENT, plannedEvent);
        actionForPlannedEventDD.save(actionForPlannedEvent);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 64 with GridComponent

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

the class TimeUsageReportListeners method workersSelectionChanged.

public void workersSelectionChanged(final ViewDefinitionState state, final ComponentState componentState, final String[] args) {
    GridComponent workersGrid = (GridComponent) state.getComponentByReference("workers");
    String selected = (String) componentState.getFieldValue();
    if ("01all".equals(selected)) {
        workersGrid.setEntities(Collections.emptyList());
        workersGrid.setEnabled(false);
    } else {
        workersGrid.setEnabled(true);
    }
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 65 with GridComponent

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

the class MachinePartDetailsListeners method downloadAtachment.

public void downloadAtachment(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference("machinePartAttachments");
    if (grid.getSelectedEntitiesIds() == null || grid.getSelectedEntitiesIds().size() == 0) {
        state.addMessage("technologies.technologyDetails.window.ribbon.atachments.nonSelectedAtachment", ComponentState.MessageType.INFO);
        return;
    }
    DataDefinition attachmentDD = dataDefinitionService.get("cmmsMachineParts", "machinePartAttachment");
    List<File> atachments = Lists.newArrayList();
    for (Long confectionProtocolId : grid.getSelectedEntitiesIds()) {
        Entity attachment = attachmentDD.get(confectionProtocolId);
        File file = new File(attachment.getStringField(TechnologyAttachmentFields.ATTACHMENT));
        atachments.add(file);
    }
    File zipFile = null;
    try {
        zipFile = fileService.compressToZipFile(atachments, false);
    } catch (IOException e) {
        LOG.error("Unable to compress documents to zip file.", e);
        return;
    }
    view.redirectTo(fileService.getUrl(zipFile.getAbsolutePath()) + "?clean", true, false);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) IOException(java.io.IOException) DataDefinition(com.qcadoo.model.api.DataDefinition) File(java.io.File)

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