Search in sources :

Example 1 with HashPrintJobAttributeSet

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

the class UnixPrintJob method addPrintJobAttributeListener.

public void addPrintJobAttributeListener(PrintJobAttributeListener listener, PrintJobAttributeSet attributes) {
    synchronized (this) {
        if (listener == null) {
            return;
        }
        if (attrListeners == null) {
            attrListeners = new Vector();
            listenedAttributeSets = new Vector();
        }
        attrListeners.add(listener);
        if (attributes == null) {
            attributes = new HashPrintJobAttributeSet();
        }
        listenedAttributeSets.add(attributes);
    }
}
Also used : HashPrintJobAttributeSet(javax.print.attribute.HashPrintJobAttributeSet) Vector(java.util.Vector)

Example 2 with HashPrintJobAttributeSet

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

the class Win32PrintJob method addPrintJobAttributeListener.

public void addPrintJobAttributeListener(PrintJobAttributeListener listener, PrintJobAttributeSet attributes) {
    synchronized (this) {
        if (listener == null) {
            return;
        }
        if (attrListeners == null) {
            attrListeners = new Vector();
            listenedAttributeSets = new Vector();
        }
        attrListeners.add(listener);
        if (attributes == null) {
            attributes = new HashPrintJobAttributeSet();
        }
        listenedAttributeSets.add(attributes);
    }
}
Also used : HashPrintJobAttributeSet(javax.print.attribute.HashPrintJobAttributeSet) Vector(java.util.Vector)

Example 3 with HashPrintJobAttributeSet

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

the class Win32PrintJob method initializeAttributeSets.

/* There's some inefficiency here as the job set is created even though
     * it may never be requested.
     */
private synchronized void initializeAttributeSets(Doc doc, PrintRequestAttributeSet reqSet) {
    reqAttrSet = new HashPrintRequestAttributeSet();
    jobAttrSet = new HashPrintJobAttributeSet();
    Attribute[] attrs;
    if (reqSet != null) {
        reqAttrSet.addAll(reqSet);
        attrs = reqSet.toArray();
        for (int i = 0; i < attrs.length; i++) {
            if (attrs[i] instanceof PrintJobAttribute) {
                jobAttrSet.add(attrs[i]);
            }
        }
    }
    DocAttributeSet docSet = doc.getAttributes();
    if (docSet != null) {
        attrs = docSet.toArray();
        for (int i = 0; i < attrs.length; i++) {
            if (attrs[i] instanceof PrintRequestAttribute) {
                reqAttrSet.add(attrs[i]);
            }
            if (attrs[i] instanceof PrintJobAttribute) {
                jobAttrSet.add(attrs[i]);
            }
        }
    }
    /* add the user name to the job */
    String userName = "";
    try {
        userName = System.getProperty("user.name");
    } catch (SecurityException se) {
    }
    if (userName == null || userName.equals("")) {
        RequestingUserName ruName = (RequestingUserName) reqSet.get(RequestingUserName.class);
        if (ruName != null) {
            jobAttrSet.add(new JobOriginatingUserName(ruName.getValue(), ruName.getLocale()));
        } else {
            jobAttrSet.add(new JobOriginatingUserName("", null));
        }
    } else {
        jobAttrSet.add(new JobOriginatingUserName(userName, null));
    }
    /* if no job name supplied use doc name (if supplied), if none and
         * its a URL use that, else finally anything .. */
    if (jobAttrSet.get(JobName.class) == null) {
        JobName jobName;
        if (docSet != null && docSet.get(DocumentName.class) != null) {
            DocumentName docName = (DocumentName) docSet.get(DocumentName.class);
            jobName = new JobName(docName.getValue(), docName.getLocale());
            jobAttrSet.add(jobName);
        } else {
            String str = "JPS Job:" + doc;
            try {
                Object printData = doc.getPrintData();
                if (printData instanceof URL) {
                    str = ((URL) (doc.getPrintData())).toString();
                }
            } catch (IOException e) {
            }
            jobName = new JobName(str, null);
            jobAttrSet.add(jobName);
        }
    }
    jobAttrSet = AttributeSetUtilities.unmodifiableView(jobAttrSet);
}
Also used : PrintJobAttribute(javax.print.attribute.PrintJobAttribute) PrintJobAttribute(javax.print.attribute.PrintJobAttribute) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) Attribute(javax.print.attribute.Attribute) HashPrintJobAttributeSet(javax.print.attribute.HashPrintJobAttributeSet) JobName(javax.print.attribute.standard.JobName) IOException(java.io.IOException) java.awt.print(java.awt.print) URL(java.net.URL) DocAttributeSet(javax.print.attribute.DocAttributeSet) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) RequestingUserName(javax.print.attribute.standard.RequestingUserName) JobOriginatingUserName(javax.print.attribute.standard.JobOriginatingUserName) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) DocumentName(javax.print.attribute.standard.DocumentName)

Example 4 with HashPrintJobAttributeSet

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

the class PSStreamPrintJob method initializeAttributeSets.

/* There's some inefficiency here as the job set is created even though
     * it may never be requested.
     */
private synchronized void initializeAttributeSets(Doc doc, PrintRequestAttributeSet reqSet) {
    reqAttrSet = new HashPrintRequestAttributeSet();
    jobAttrSet = new HashPrintJobAttributeSet();
    Attribute[] attrs;
    if (reqSet != null) {
        reqAttrSet.addAll(reqSet);
        attrs = reqSet.toArray();
        for (int i = 0; i < attrs.length; i++) {
            if (attrs[i] instanceof PrintJobAttribute) {
                jobAttrSet.add(attrs[i]);
            }
        }
    }
    DocAttributeSet docSet = doc.getAttributes();
    if (docSet != null) {
        attrs = docSet.toArray();
        for (int i = 0; i < attrs.length; i++) {
            if (attrs[i] instanceof PrintRequestAttribute) {
                reqAttrSet.add(attrs[i]);
            }
            if (attrs[i] instanceof PrintJobAttribute) {
                jobAttrSet.add(attrs[i]);
            }
        }
    }
    /* add the user name to the job */
    String userName = "";
    try {
        userName = System.getProperty("user.name");
    } catch (SecurityException se) {
    }
    if (userName == null || userName.equals("")) {
        RequestingUserName ruName = (RequestingUserName) reqSet.get(RequestingUserName.class);
        if (ruName != null) {
            jobAttrSet.add(new JobOriginatingUserName(ruName.getValue(), ruName.getLocale()));
        } else {
            jobAttrSet.add(new JobOriginatingUserName("", null));
        }
    } else {
        jobAttrSet.add(new JobOriginatingUserName(userName, null));
    }
    /* if no job name supplied use doc name (if supplied), if none and
         * its a URL use that, else finally anything .. */
    if (jobAttrSet.get(JobName.class) == null) {
        JobName jobName;
        if (docSet != null && docSet.get(DocumentName.class) != null) {
            DocumentName docName = (DocumentName) docSet.get(DocumentName.class);
            jobName = new JobName(docName.getValue(), docName.getLocale());
            jobAttrSet.add(jobName);
        } else {
            String str = "JPS Job:" + doc;
            try {
                Object printData = doc.getPrintData();
                if (printData instanceof URL) {
                    str = ((URL) (doc.getPrintData())).toString();
                }
            } catch (IOException e) {
            }
            jobName = new JobName(str, null);
            jobAttrSet.add(jobName);
        }
    }
    jobAttrSet = AttributeSetUtilities.unmodifiableView(jobAttrSet);
}
Also used : PrintJobAttribute(javax.print.attribute.PrintJobAttribute) PrintJobAttribute(javax.print.attribute.PrintJobAttribute) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) Attribute(javax.print.attribute.Attribute) HashPrintJobAttributeSet(javax.print.attribute.HashPrintJobAttributeSet) JobName(javax.print.attribute.standard.JobName) IOException(java.io.IOException) java.awt.print(java.awt.print) URL(java.net.URL) DocAttributeSet(javax.print.attribute.DocAttributeSet) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) RequestingUserName(javax.print.attribute.standard.RequestingUserName) JobOriginatingUserName(javax.print.attribute.standard.JobOriginatingUserName) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) DocumentName(javax.print.attribute.standard.DocumentName)

Example 5 with HashPrintJobAttributeSet

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

the class PSStreamPrintJob method addPrintJobAttributeListener.

public void addPrintJobAttributeListener(PrintJobAttributeListener listener, PrintJobAttributeSet attributes) {
    synchronized (this) {
        if (listener == null) {
            return;
        }
        if (attrListeners == null) {
            attrListeners = new Vector();
            listenedAttributeSets = new Vector();
        }
        attrListeners.add(listener);
        if (attributes == null) {
            attributes = new HashPrintJobAttributeSet();
        }
        listenedAttributeSets.add(attributes);
    }
}
Also used : HashPrintJobAttributeSet(javax.print.attribute.HashPrintJobAttributeSet) Vector(java.util.Vector)

Aggregations

HashPrintJobAttributeSet (javax.print.attribute.HashPrintJobAttributeSet)6 java.awt.print (java.awt.print)3 IOException (java.io.IOException)3 URL (java.net.URL)3 Vector (java.util.Vector)3 Attribute (javax.print.attribute.Attribute)3 DocAttributeSet (javax.print.attribute.DocAttributeSet)3 HashPrintRequestAttributeSet (javax.print.attribute.HashPrintRequestAttributeSet)3 PrintJobAttribute (javax.print.attribute.PrintJobAttribute)3 PrintRequestAttribute (javax.print.attribute.PrintRequestAttribute)3 DocumentName (javax.print.attribute.standard.DocumentName)3 JobName (javax.print.attribute.standard.JobName)3 JobOriginatingUserName (javax.print.attribute.standard.JobOriginatingUserName)3 RequestingUserName (javax.print.attribute.standard.RequestingUserName)3