PlannerDataObjectEditor extends ObjectEditor implements PlannerDataObjectEditorView.Presenter { @Override protected void loadDataObject(DataObject dataObject) { clear(); this.dataObject = dataObject; this.comparatorObject = null; if (dataObject != null) { boolean hasPlanningEntity = dataObject.getAnnotation(PlannerDomainAnnotations.PLANNING_ENTITY_ANNOTATION) != null; boolean hasPlanningSolution = dataObject.getAnnotation(PlannerDomainAnnotations.PLANNING_SOLUTION_ANNOTATION) != null; if (!hasPlanningSolution) { view.enablePlanningSolutionCheckBox(false); view.showPlanningSolutionHelpIcon(false); assetsUsageServiceCaller.call(getFindClassUsagesCallback()).getAssetUsages (PlannerDomainAnnotations.PLANNING_SOLUTION_ANNOTATION, ResourceType.JAVA, context.getCurrentProject().getRootPath()); } else { view.enablePlanningSolutionCheckBox(true); view.showPlanningSolutionHelpIcon(false); adjustSelectedPlanningSolutionScoreType(); } view.setPlanningEntityValue(hasPlanningEntity); view.setPlanningSolutionValue(hasPlanningSolution); view.showPlanningSolutionScoreType(hasPlanningSolution); view.setNotInPlanningValue(!hasPlanningEntity && !hasPlanningSolution); view.destroyFieldPicker(); view.showPlanningSolutionBendableScoreInput(false); if (hasPlanningEntity) { if (!dataObject.getNestedClasses().isEmpty()) { for (JavaClass javaClass : dataObject.getNestedClasses()) { if (javaClass.getAnnotation(ComparatorDefinition.class.getName()) != null) { try { view.initFieldPicker(getContext().getDataModel(), getDataObject(), getObjectPropertyPathList(javaClass.getAnnotation(ComparatorDefinition.class.getName()))); this.comparatorObject = javaClass; break; } catch (IllegalStateException e) { ErrorPopupHelper.showErrorPopup(translationService.getTranslation(DomainEditorConstants.PlannerDataObjectEditorComparatorDefinitionProcessingFailed) + " " + e.getMessage()); } } } } else { view.initFieldPicker(getContext().getDataModel(), getDataObject(), null); } } if (hasPlanningSolution) { ObjectProperty scoreObjectProperty = dataObject.getProperty("score"); if (scoreObjectProperty != null) { if (isBendableScore(scoreObjectProperty.getClassName())) { view.showPlanningSolutionBendableScoreInput(true); Annotation annotation = scoreObjectProperty.getAnnotation(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION); if (annotation != null) { Object hardLevelsSize = annotation.getValue("bendableHardLevelsSize"); if (hardLevelsSize != null) { view.setPlanningSolutionBendableScoreHardLevelsSize((int) hardLevelsSize == -1 ? 0 : (int) hardLevelsSize); } else { view.setPlanningSolutionBendableScoreHardLevelsSize(0); } Object softLevelsSize = annotation.getValue("bendableSoftLevelsSize"); if (softLevelsSize != null) { view.setPlanningSolutionBendableScoreSoftLevelsSize((int) softLevelsSize == -1 ? 0 : (int) softLevelsSize); } else { view.setPlanningSolutionBendableScoreSoftLevelsSize(0); } } } else { view.showPlanningSolutionBendableScoreInput(false); view.setPlanningSolutionBendableScoreHardLevelsSize(0); view.setPlanningSolutionBendableScoreSoftLevelsSize(0); } } } } } @Inject  PlannerDataObjectEditor(PlannerDataObjectEditorView view,
                                   DomainHandlerRegistry handlerRegistry,
                                   Event<DataModelerEvent> dataModelerEvent,
                                   DataModelCommandBuilder commandBuilder,
                                   TranslationService translationService,
                                   Caller<ComparatorDefinitionService> comparatorDefinitionService,
                                   Caller<AssetsUsageService> assetsUsageServiceCaller); @Override Widget asWidget(); @Override String getName(); @Override String getDomainName(); @Override void clear(); @Override void objectPropertyPathChanged(List<ObjectPropertyPath> objectPropertyPaths,
                                          boolean itemsRemoved); @Override void removeComparatorDefinition(DataObject dataObject,
                                           boolean resetPlanningEntityAnnotation); @Override void onNotInPlanningChange(); @Override void onPlanningEntityChange(); @Override void onPlanningSolutionChange(); @Override void onPlanningSolutionScoreTypeChange(); @Override void onPlanningSolutionBendableScoreHardLevelsSizeChange(); @Override void onPlanningSolutionBendableScoreSoftLevelsSizeChange();  }
@Test public void loadDataObject() { PlannerDataObjectEditor objectEditor = createObjectEditor(); objectEditor.onContextChange(context); verify(view, times(1)).clear(); verify(view, times(1)).setPlanningEntityValue(false); verify(view, times(1)).setPlanningSolutionValue(false); verify(view, times(1)).showPlanningSolutionScoreType(false); verify(view, times(2)).setNotInPlanningValue(true); verify(view, times(1)).destroyFieldPicker(); verify(view, times(1)).showPlanningSolutionBendableScoreInput(false); verify(assetsUsageService, times(1)).getAssetUsages(anyString(), any(), any(Path.class)); }