Example usage for javax.print.attribute.standard JobName JobName

List of usage examples for javax.print.attribute.standard JobName JobName

Introduction

In this page you can find the example usage for javax.print.attribute.standard JobName JobName.

Prototype

public JobName(String jobName, Locale locale) 

Source Link

Document

Constructs a new job name attribute with the given job name and locale.

Usage

From source file:org.pentaho.reporting.engine.classic.extensions.modules.java14print.Java14PrintUtil.java

public static PrintRequestAttributeSet copyAuxillaryAttributes(PrintRequestAttributeSet attributes,
        final MasterReport report) {
    if (attributes == null) {
        attributes = new HashPrintRequestAttributeSet();
    }/*  w  w w  . j  a  va 2 s  .c  om*/

    if (attributes.containsKey(JobName.class) == false) {
        final String jobName = report.getReportConfiguration().getConfigProperty(PrintUtil.PRINTER_JOB_NAME_KEY,
                report.getTitle());
        if (jobName != null) {
            attributes.add(new JobName(jobName, null));
        }
    }
    if (attributes.containsKey(Copies.class) == false) {
        final int numberOfCopies = PrintUtil.getNumberOfCopies(report.getReportConfiguration());
        attributes.add(new Copies(numberOfCopies));
    }

    return attributes;
}

From source file:org.springframework.integration.print.outbound.PrintMessageHandler.java

@Override
protected void onInit() throws Exception {

    if (this.copies != null) {
        //Assert.isTrue(printService.isAttributeValueSupported(this.copies, this.docFlavor, this.printService.getAttributes()),
        //   "Attribute '" + this.copies.getName() + "' with value '" + this.copies.getValue() + "' is not supported.");
        this.printRequestAttributeSet.add(this.copies);
    }//from ww w. j  a v a2s.com

    if (this.chromaticity != null) {
        Assert.isTrue(
                this.printServiceExecutor.getPrintService().isAttributeValueSupported(this.chromaticity,
                        this.docFlavor, this.printServiceExecutor.getPrintService().getAttributes()),
                "Attribute '" + this.chromaticity.getName() + "' with value '" + this.chromaticity.getValue()
                        + "' is not supported.");
        this.printRequestAttributeSet.add(this.chromaticity);
    }

    if (this.mediaSizeName != null) {
        Assert.isTrue(
                this.printServiceExecutor.getPrintService().isAttributeValueSupported(this.mediaSizeName, null,
                        null),
                "Attribute '" + this.mediaSizeName.getName() + "' with value '" + this.mediaSizeName.getValue()
                        + "' is not supported.");
        this.printRequestAttributeSet.add(this.mediaSizeName);
    }

    if (this.mediaTray != null) {
        Assert.isTrue(
                this.printServiceExecutor.getPrintService().isAttributeValueSupported(this.mediaTray,
                        this.docFlavor, this.printServiceExecutor.getPrintService().getAttributes()),
                "Attribute value '" + this.mediaTray + "' is not supported.");
        this.printRequestAttributeSet.add(this.mediaTray);
    }

    if (this.sides != null) {
        Assert.isTrue(
                this.printServiceExecutor.getPrintService().isAttributeValueSupported(this.sides,
                        this.docFlavor, this.printServiceExecutor.getPrintService().getAttributes()),
                "Attribute value '" + this.sides + "' is not supported.");
        this.printRequestAttributeSet.add(this.sides);
    }

    if (StringUtils.hasText(this.printJobName)) {
        this.printRequestAttributeSet.add(new JobName(this.printJobName, Locale.getDefault()));
    }

    super.onInit();

}