/** Validates the model and adds error messages to the ExecutionResult */ private void validateModel(ExecutionResult result) { result.append("-> Validating the project..."); ModelUtility modelUtility = new ModelUtility(); modelUtility.validate(this.getProject(), result); if (result.isOk()) { result.append("-> Validation is OK"); } else { result.append("-> *** ERROR: The project validation FAILED! See messages above. ***"); result.append("-> *** You need to fix the issues before code can be generated. ***"); } }
private void collectAlignableElements( final Section section, final List<Element> collectedElements) { if (section instanceof CrosstabGroup) { return; } final int theElementCount = section.getElementCount(); for (int i = 0; i < theElementCount; i++) { final ReportElement reportElement = section.getElement(i); if (reportElement instanceof Section) { collectAlignableElements((Section) reportElement, collectedElements); } final CachedLayoutData cachedLayoutData = ModelUtility.getCachedLayoutData((Element) reportElement); final long layoutAge = cachedLayoutData.getLayoutAge(); if (layoutAge != -1) { if (reportElement instanceof RootLevelBand) { continue; } if (reportElement instanceof Band || reportElement instanceof Section == false) { collectedElements.add((Element) reportElement); } } } }
public void resizeProportional() { final float originalPageWidth = originalPageDefinition.getWidth(); final float currentPageWidth = currentPageDefinition.getWidth(); final float scaleFactor = currentPageWidth / originalPageWidth; for (int i = 0; i < visualElements.length; i++) { // Resize the element. final CachedLayoutData cachedLayoutData = ModelUtility.getCachedLayoutData(visualElements[i]); final double elementWidth = StrictGeomUtility.toExternalValue(cachedLayoutData.getWidth()); final Element theElement = visualElements[i]; final ElementStyleSheet styleSheet = theElement.getStyle(); styleSheet.setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float(elementWidth * scaleFactor)); // Reposition the element. final double origin = StrictGeomUtility.toExternalValue(cachedLayoutData.getX()); final double destination = scaleFactor * origin; final int theShift = (int) (destination - origin); final Element[] theElements = new Element[1]; theElements[0] = theElement; align(theShift, theElements); } registerChanges(); }
private long computeFarRightPostion() { long theFarRightPostion = 0; for (int i = 0; i < visualElements.length; i++) { final CachedLayoutData theElementData = ModelUtility.getCachedLayoutData(visualElements[i]); final long theCurrentPosition = theElementData.getX() + theElementData.getWidth(); if (i == 0) { theFarRightPostion = theCurrentPosition; } else if (theCurrentPosition > theFarRightPostion) { theFarRightPostion = theCurrentPosition; } } return theFarRightPostion; }
public void run(String option, String projectFile, String outputDirectory, ExecutionResult result) throws Exception { if (option == null || (!option.equals(GENERATE_JAVA) && !option.equals(GENERATE_OBJC) && !option.equals(GENERATE_SWIFT))) { result.append("-> Invalid option! The command line is:"); result.append(COMMAND_HELP); result.setOk(false); return; } if (projectFile == null || !this.getIo().existsFile(projectFile)) { result.append("-> The project file doesn't exists: " + projectFile); result.setOk(false); return; } if (outputDirectory == null || !this.getIo().existsFile(outputDirectory)) { result.append("-> The output directory doesn't exists: " + outputDirectory); result.setOk(false); return; } ModelUtility modelUtility = new ModelUtility(); Project newProject = modelUtility.openProject(projectFile); this.setProject(newProject); this.setOutputDirectory(outputDirectory); if (option.equals(GENERATE_JAVA)) { this.generateJava(result); return; } if (option.equals(GENERATE_OBJC)) { this.generateObjC(result); return; } if (option.equals(GENERATE_SWIFT)) { this.generateSwift(result); return; } }