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