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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations