Search in sources :

Example 11 with HashPrintServiceAttributeSet

use of javax.print.attribute.HashPrintServiceAttributeSet in project jdk8u_jdk by JetBrains.

the class UnixPrintService method getSysVServiceAttributes.

private PrintServiceAttributeSet getSysVServiceAttributes() {
    PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
    attrs.add(getQueuedJobCountSysV());
    attrs.add(getPrinterIsAcceptingJobsSysV());
    return attrs;
}
Also used : HashPrintServiceAttributeSet(javax.print.attribute.HashPrintServiceAttributeSet) PrintServiceAttributeSet(javax.print.attribute.PrintServiceAttributeSet) HashPrintServiceAttributeSet(javax.print.attribute.HashPrintServiceAttributeSet)

Example 12 with HashPrintServiceAttributeSet

use of javax.print.attribute.HashPrintServiceAttributeSet in project jdk8u_jdk by JetBrains.

the class UnixPrintServiceLookup method getPrintServices.

/*
     * If service attributes are specified then there must be additional
     * filtering.
     */
public PrintService[] getPrintServices(DocFlavor flavor, AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPrintJobAccess();
    }
    PrintRequestAttributeSet requestSet = null;
    PrintServiceAttributeSet serviceSet = null;
    if (attributes != null && !attributes.isEmpty()) {
        requestSet = new HashPrintRequestAttributeSet();
        serviceSet = new HashPrintServiceAttributeSet();
        Attribute[] attrs = attributes.toArray();
        for (int i = 0; i < attrs.length; i++) {
            if (attrs[i] instanceof PrintRequestAttribute) {
                requestSet.add(attrs[i]);
            } else if (attrs[i] instanceof PrintServiceAttribute) {
                serviceSet.add(attrs[i]);
            }
        }
    }
    PrintService[] services = getPrintServices(serviceSet);
    if (services.length == 0) {
        return services;
    }
    if (CUPSPrinter.isCupsRunning()) {
        ArrayList matchingServices = new ArrayList();
        for (int i = 0; i < services.length; i++) {
            try {
                if (services[i].getUnsupportedAttributes(flavor, requestSet) == null) {
                    matchingServices.add(services[i]);
                }
            } catch (IllegalArgumentException e) {
            }
        }
        services = new PrintService[matchingServices.size()];
        return (PrintService[]) matchingServices.toArray(services);
    } else {
        // We only need to compare 1 PrintService because all
        // UnixPrintServices are the same anyway.  We will not use
        // default PrintService because it might be null.
        PrintService service = services[0];
        if ((flavor == null || service.isDocFlavorSupported(flavor)) && service.getUnsupportedAttributes(flavor, requestSet) == null) {
            return services;
        } else {
            return new PrintService[0];
        }
    }
}
Also used : PrintServiceAttribute(javax.print.attribute.PrintServiceAttribute) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) Attribute(javax.print.attribute.Attribute) ArrayList(java.util.ArrayList) HashPrintServiceAttributeSet(javax.print.attribute.HashPrintServiceAttributeSet) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) PrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet) MultiDocPrintService(javax.print.MultiDocPrintService) PrintService(javax.print.PrintService) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) PrintServiceAttribute(javax.print.attribute.PrintServiceAttribute) PrintServiceAttributeSet(javax.print.attribute.PrintServiceAttributeSet) HashPrintServiceAttributeSet(javax.print.attribute.HashPrintServiceAttributeSet) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet)

Aggregations

HashPrintServiceAttributeSet (javax.print.attribute.HashPrintServiceAttributeSet)12 PrintServiceAttributeSet (javax.print.attribute.PrintServiceAttributeSet)12 Attribute (javax.print.attribute.Attribute)4 PrintServiceAttribute (javax.print.attribute.PrintServiceAttribute)4 ArrayList (java.util.ArrayList)2 MultiDocPrintService (javax.print.MultiDocPrintService)2 PrintService (javax.print.PrintService)2 HashPrintRequestAttributeSet (javax.print.attribute.HashPrintRequestAttributeSet)2 PrintRequestAttribute (javax.print.attribute.PrintRequestAttribute)2 PrintRequestAttributeSet (javax.print.attribute.PrintRequestAttributeSet)2 PrinterState (javax.print.attribute.standard.PrinterState)2 PrinterStateReasons (javax.print.attribute.standard.PrinterStateReasons)2 PrinterName (javax.print.attribute.standard.PrinterName)1 PrintServiceAttributeEvent (javax.print.event.PrintServiceAttributeEvent)1 PrintServiceAttributeListener (javax.print.event.PrintServiceAttributeListener)1