Example usage for com.lowagie.text Element ALIGN_LEFT

List of usage examples for com.lowagie.text Element ALIGN_LEFT

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_LEFT.

Prototype

int ALIGN_LEFT

To view the source code for com.lowagie.text Element ALIGN_LEFT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:com.qcadoo.mes.qualityControls.print.QualityControlForBatchPdfView.java

License:Open Source License

private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities,
        final Locale locale) throws DocumentException {
    List<String> qualityHeader = new ArrayList<String>();
    qualityHeader/*w  ww . ja v a 2 s .  co  m*/
            .add(translationService.translate("qualityControls.qualityControl.report.product.number", locale));
    qualityHeader.add(translationService.translate(
            "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.controlledQuantity.label",
            locale));
    qualityHeader.add(translationService.translate(
            "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.rejectedQuantity.label",
            locale));
    qualityHeader.add(translationService.translate(
            "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.acceptedDefectsQuantity.label",
            locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate("qualityControls.qualityControl.report.product.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(translationService.translate(
            "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.controlledQuantity.label",
            locale), HeaderAlignment.RIGHT);
    alignments.put(translationService.translate(
            "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.rejectedQuantity.label",
            locale), HeaderAlignment.RIGHT);
    alignments.put(translationService.translate(
            "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.acceptedDefectsQuantity.label",
            locale), HeaderAlignment.RIGHT);

    PdfPTable table = pdfHelper.createTableWithHeader(4, qualityHeader, false, alignments);
    for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) {
        table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("number"),
                FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    document.add(table);
}

From source file:com.qcadoo.mes.qualityControls.print.QualityControlForBatchPdfView.java

License:Open Source License

private void addProductSeries(final Document document, final Entry<Entity, List<Entity>> entry,
        final Locale locale) throws DocumentException {

    document.add(qualityControlsReportService.prepareTitle(entry.getKey(), locale, "batch"));

    List<String> productHeader = new ArrayList<String>();
    productHeader//from w  w  w  . j av  a  2  s . c  om
            .add(translationService.translate("qualityControls.qualityControl.report.batch.number", locale));
    productHeader
            .add(translationService.translate("qualityControls.qualityControl.report.control.number", locale));
    productHeader.add(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale));
    productHeader.add(
            translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale));
    productHeader.add(translationService
            .translate("qualityControls.qualityControl.report.accepted.defects.quantity", locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate("qualityControls.qualityControl.report.batch.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(translationService.translate("qualityControls.qualityControl.report.control.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(translationService.translate(
            "qualityControls.qualityControl.report.accepted.defects.quantity", locale), HeaderAlignment.RIGHT);

    PdfPTable table = pdfHelper.createTableWithHeader(5, productHeader, false, alignments);

    List<Entity> sortedOrders = entry.getValue();

    Collections.sort(sortedOrders, new EntityBatchNumberComparator());

    for (Entity entity : sortedOrders) {
        table.addCell(
                new Phrase(entity.getStringField("batchNr") == null ? "" : entity.getStringField("batchNr"),
                        FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(entity.getStringField("number"), FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(new Phrase(numberService.format(entity.getDecimalField("controlledQuantity")),
                FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(numberService.format(entity.getDecimalField("rejectedQuantity")),
                FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(numberService.format(entity.getDecimalField("acceptedDefectsQuantity")),
                FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    }

    document.add(table);
}

From source file:com.qcadoo.mes.qualityControls.print.QualityControlForOperationPdfView.java

License:Open Source License

private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities,
        final Locale locale) throws DocumentException {
    List<String> qualityHeader = new ArrayList<String>();
    qualityHeader.add(//from  w  ww . j a  v a2  s  .  c om
            translationService.translate("qualityControls.qualityControl.report.operation.number", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.operation.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale),
            HeaderAlignment.RIGHT);

    PdfPTable table = pdfHelper.createTableWithHeader(5, qualityHeader, false, alignments);
    for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) {
        table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("nodeNumber"),
                FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(3)), FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    document.add(table);
}

From source file:com.qcadoo.mes.qualityControls.print.QualityControlForOrderPdfView.java

License:Open Source License

private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities,
        final Locale locale) throws DocumentException {
    List<String> qualityHeader = new ArrayList<String>();
    qualityHeader//w ww.j av  a  2  s  .c o m
            .add(translationService.translate("qualityControls.qualityControl.report.product.number", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale));
    qualityHeader
            .add(translationService.translate("qualityControls.qualityControl.report.done.quantity", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale));
    qualityHeader.add(
            translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate("qualityControls.qualityControl.report.product.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(translationService.translate("qualityControls.qualityControl.report.done.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale),
            HeaderAlignment.RIGHT);

    PdfPTable table = pdfHelper.createTableWithHeader(6, qualityHeader, false, alignments);

    for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) {
        table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("number"),
                FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(4)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(3)), FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    document.add(table);
}

From source file:com.qcadoo.mes.qualityControls.print.QualityControlForUnitPdfView.java

License:Open Source License

private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities,
        final Locale locale) throws DocumentException {
    List<String> qualityHeader = new ArrayList<String>();
    qualityHeader/*from  ww  w  .  j  a v a2 s.c  om*/
            .add(translationService.translate("qualityControls.qualityControl.report.product.number", locale));
    qualityHeader.add(translationService.translate(
            "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label",
            locale));
    qualityHeader.add(translationService.translate(
            "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label",
            locale));
    qualityHeader.add(translationService.translate(
            "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label",
            locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate("qualityControls.qualityControl.report.product.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(translationService.translate(
            "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label",
            locale), HeaderAlignment.RIGHT);
    alignments.put(translationService.translate(
            "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label",
            locale), HeaderAlignment.RIGHT);
    alignments.put(translationService.translate(
            "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label",
            locale), HeaderAlignment.RIGHT);

    PdfPTable table = pdfHelper.createTableWithHeader(4, qualityHeader, false, alignments);

    for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) {
        table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("number"),
                FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark()));
        table.addCell(
                new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    document.add(table);
}

From source file:com.qcadoo.mes.qualityControls.print.QualityControlForUnitPdfView.java

License:Open Source License

private void addProductSeries(final Document document, final Entry<Entity, List<Entity>> entry,
        final Locale locale) throws DocumentException {

    document.add(qualityControlsReportService.prepareTitle(entry.getKey(), locale, "unit"));

    List<String> productHeader = new ArrayList<String>();
    productHeader//from w ww .ja v a 2  s  .c o  m
            .add(translationService.translate("qualityControls.qualityControl.report.control.number", locale));
    productHeader.add(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale));
    productHeader.add(
            translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale));
    productHeader.add(translationService
            .translate("qualityControls.qualityControl.report.accepted.defects.quantity", locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate("qualityControls.qualityControl.report.control.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(translationService.translate(
            "qualityControls.qualityControl.report.accepted.defects.quantity", locale), HeaderAlignment.RIGHT);
    PdfPTable table = pdfHelper.createTableWithHeader(4, productHeader, false, alignments);

    List<Entity> sortedOrders = entry.getValue();

    Collections.sort(sortedOrders, new EntityNumberComparator());

    for (Entity entity : sortedOrders) {
        table.addCell(new Phrase(entity.getStringField("number"), FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(new Phrase(numberService.format(entity.getField("controlledQuantity")),
                FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(numberService.format(entity.getField("rejectedQuantity")),
                FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(numberService.format(entity.getField("acceptedDefectsQuantity")),
                FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    document.add(table);

}

From source file:com.qcadoo.mes.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java

License:Open Source License

private void addBalance(final Document document, final Entity simpleMaterialBalance, final Locale locale)
        throws DocumentException {
    document.add(new Paragraph(
            translationService.translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> simpleMaterialBalanceTableHeader = new ArrayList<String>();
    simpleMaterialBalanceTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale));
    simpleMaterialBalanceTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale));
    simpleMaterialBalanceTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale));
    simpleMaterialBalanceTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale));
    simpleMaterialBalanceTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale));
    simpleMaterialBalanceTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(/*  w w w.  j  a va  2 s  . co m*/
            translationService.translate(
                    "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale),
            HeaderAlignment.LEFT);
    alignments.put(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate(
                    "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate(
                    "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService.translate(
                    "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale),
            HeaderAlignment.RIGHT);
    alignments.put(translationService.translate("basic.product.unit.label", locale), HeaderAlignment.LEFT);

    PdfPTable table = pdfHelper.createTableWithHeader(6, simpleMaterialBalanceTableHeader, false, alignments);
    List<Entity> simpleMaterialBalanceOrdersComponents = simpleMaterialBalance
            .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_ORDERS_COMPONENTS);
    MrpAlgorithm mrpAlgorithm = MrpAlgorithm.parseString(simpleMaterialBalance.getStringField("mrpAlgorithm"));

    Map<Long, BigDecimal> neededProductQuantities = productQuantitiesService
            .getNeededProductQuantitiesForComponents(simpleMaterialBalanceOrdersComponents, mrpAlgorithm);

    List<Entity> simpleMaterialBalanceLocationComponents = simpleMaterialBalance
            .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_LOCATIONS_COMPONENTS);

    // TODO LUPO fix comparator
    // products = SortUtil.sortMapUsingComparator(products, new EntityNumberComparator());

    for (Entry<Long, BigDecimal> neededProductQuantity : neededProductQuantities.entrySet()) {
        Entity product = productQuantitiesService.getProduct(neededProductQuantity.getKey());

        table.addCell(new Phrase(product.getField(L_NUMBER).toString(), FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(product.getField(L_NAME).toString(), FontUtils.getDejavuRegular7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(new Phrase(numberService.format(neededProductQuantity.getValue()),
                FontUtils.getDejavuRegular7Dark()));
        BigDecimal available = BigDecimal.ZERO;
        for (Entity simpleMaterialBalanceLocationComponent : simpleMaterialBalanceLocationComponents) {
            available = available.add(materialFlowService.calculateShouldBeInLocation(
                    simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getId(),
                    product.getId(), (Date) simpleMaterialBalance.getField(L_DATE)));
        }
        table.addCell(new Phrase(numberService.format(available), FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(
                numberService.format(
                        available.subtract(neededProductQuantity.getValue(), numberService.getMathContext())),
                FontUtils.getDejavuBold7Dark()));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(new Phrase(product.getField(L_UNIT).toString(), FontUtils.getDejavuRegular7Dark()));

    }
    document.add(table);
}

From source file:com.qcadoo.mes.technologies.print.TechnologiesTechnologyDetailsPdfView.java

License:Open Source License

@Override
protected final String addContent(final Document document, final Map<String, Object> model, final Locale locale,
        final PdfWriter writer) throws DocumentException, IOException {
    checkState(model.get("id") != null, "Unable to generate report for unsaved technology! (missing id)");

    String documentTitle = translationService
            .translate("technologies.technologiesTechnologyDetails.report.title", locale);
    String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale);

    pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, new Date());

    DataDefinition technologyDD = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER,
            TechnologiesConstants.MODEL_TECHNOLOGY);

    Entity technology = technologyDD.get(valueOf(model.get("id").toString()));

    Map<String, String> panelTableValues = newLinkedHashMap();
    panelTableValues.put(TechnologyFields.NAME, technology.getStringField(TechnologyFields.NAME));
    panelTableValues.put(TechnologyFields.NUMBER, technology.getStringField(TechnologyFields.NUMBER));
    panelTableValues.put(TechnologyFields.PRODUCT,
            technology.getBelongsToField(TechnologyFields.PRODUCT).getStringField(ProductFields.NAME));
    panelTableValues.put("default",
            technology.getBooleanField(TechnologyFields.MASTER)
                    ? translationService.translate("qcadooView.true", locale)
                    : translationService.translate("qcadooView.false", locale));

    panelTableValues.put(TechnologyFields.DESCRIPTION, technology.getStringField(TechnologyFields.DESCRIPTION));

    PdfPTable panelTable = pdfHelper.createPanelTable(2);

    for (Map.Entry<String, String> panelEntry : panelTableValues.entrySet()) {
        pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate(
                "technologies.technologiesTechnologyDetails.report.panel.technology." + panelEntry.getKey(),
                locale), panelEntry.getValue());
    }/*w  ww  . j  a  v a 2 s. c  o  m*/

    panelTable.setSpacingAfter(20);
    panelTable.setSpacingBefore(20);
    document.add(panelTable);

    List<String> technologyDetailsTableHeader = new ArrayList<String>();
    technologyDetailsTableHeader.add(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale));
    technologyDetailsTableHeader.add(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale));
    technologyDetailsTableHeader.add(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale));
    technologyDetailsTableHeader.add(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale));
    technologyDetailsTableHeader.add(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale));
    technologyDetailsTableHeader.add(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale));
    technologyDetailsTableHeader.add(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale),
            HeaderAlignment.LEFT);
    alignments.put(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate(
                    "technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate(
                    "technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate(
                    "technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate(
                    "technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(translationService
            .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale),
            HeaderAlignment.LEFT);

    PdfPTable table = pdfHelper.createTableWithHeader(7, technologyDetailsTableHeader, false, alignments);

    EntityTree technologyTree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
    treeNumberingService.generateTreeNumbers(technologyTree);

    List<Entity> technologyOperationComponents = entityTreeUtilsService.getSortedEntities(technologyTree);

    for (Entity technologyOperationComponent : technologyOperationComponents) {
        String nodeNumber = technologyOperationComponent
                .getStringField(TechnologyOperationComponentFields.NODE_NUMBER);
        String operationName = technologyOperationComponent
                .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                .getStringField(OperationFields.NAME);

        List<Entity> operationProductComponents = newArrayList();

        operationProductComponents.addAll(technologyOperationComponent
                .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS));
        operationProductComponents.addAll(technologyOperationComponent
                .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS));

        for (Entity operationProductComponent : operationProductComponents) {
            Entity product = operationProductComponent.getBelongsToField(L_PRODUCT);

            String productType = "technologies.technologiesTechnologyDetails.report.direction.out";

            if (operationProductComponent.getDataDefinition().getName().equals("operationProductInComponent")) {
                productType = "technologies.technologiesTechnologyDetails.report.direction.in";
            }

            table.addCell(new Phrase(nodeNumber, FontUtils.getDejavuRegular7Dark()));
            table.addCell(new Phrase(operationName, FontUtils.getDejavuRegular7Dark()));
            table.addCell(new Phrase(translationService.translate(productType, locale),
                    FontUtils.getDejavuRegular7Dark()));
            table.addCell(new Phrase(product.getStringField(ProductFields.NUMBER),
                    FontUtils.getDejavuRegular7Dark()));
            table.addCell(
                    new Phrase(product.getStringField(ProductFields.NAME), FontUtils.getDejavuRegular7Dark()));
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(new Phrase(numberService.format(operationProductComponent.getField(L_QUANTITY)),
                    FontUtils.getDejavuRegular7Dark()));
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(
                    new Phrase(product.getStringField(ProductFields.UNIT), FontUtils.getDejavuRegular7Dark()));
        }
    }

    document.add(table);

    return translationService.translate("technologies.technologiesTechnologyDetails.report.fileName", locale);
}

From source file:com.qcadoo.mes.workPlans.pdf.document.operation.component.OperationProductInTable.java

License:Open Source License

private void alignColumn(final PdfPCell cell, final ColumnAlignment columnAlignment) {
    if (ColumnAlignment.LEFT.equals(columnAlignment)) {
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    } else if (ColumnAlignment.RIGHT.equals(columnAlignment)) {
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    }//from ww  w .j a va 2s.c  o m
}

From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java

License:Open Source License

private void alignColumn(final PdfPCell cell, final ColumnAlignment columnAlignment) {
    if (ColumnAlignment.LEFT.equals(columnAlignment)) {
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    } else if (ColumnAlignment.RIGHT.equals(columnAlignment)) {
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    }/*from   w  ww . jav  a2  s .c  om*/
    cell.setBorder(Rectangle.BOX);
    cell.setPadding(2f);
}