Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.Destination


            return null;
        } else if (category == SunAlternateMedia.class) {
            return null;
        } else if (category == Destination.class) {
            try {
                return new Destination((new File("out.prn")).toURI());
            } catch (SecurityException se) {
                try {
                    return new Destination(new URI("file:out.prn"));
                } catch (URISyntaxException e) {
                    return null;
                }
            }
        } else if (category == Sides.class) {
View Full Code Here


            } else {
                return null;
            }
        } else if (category == Destination.class) {
            try {
                return new Destination((new File("out.prn")).toURI());
            } catch (SecurityException se) {
                try {
                    return new Destination(new URI("file:out.prn"));
                } catch (URISyntaxException e) {
                    return null;
                }
            }
        } else if (category == OrientationRequested.class) {
View Full Code Here

            Copies copies = (Copies)attributes.get(Copies.class);
            if (copies != null) {
                setCopies(copies.getValue());
            }

            Destination dest = (Destination)attributes.get(Destination.class);

            if (dest != null) {
                try {
                    mDestType = RasterPrinterJob.FILE;
                    mDestination = (new File(dest.getURI())).getPath();
                } catch (Exception e) {
                    mDestination = "out.ps";
                }
            } else {
                mDestType = RasterPrinterJob.PRINTER;
View Full Code Here

        dialog.setRetVal(false);
        dialog.setVisible(true);
        boolean prv = dialog.getRetVal();
        dialog.dispose();

        Destination dest =
                (Destination)attributes.get(Destination.class);
        if ((dest == null) || !prv){
                return prv;
        } else {
            String title = null;
            String strBundle = "sun.print.resources.serviceui";
            ResourceBundle rb = ResourceBundle.getBundle(strBundle);
            try {
                title = rb.getString("dialog.printtofile");
            } catch (MissingResourceException e) {
            }
            FileDialog fileDialog = new FileDialog(ownerFrame, title,
                                                   FileDialog.SAVE);

            URI destURI = dest.getURI();
            // Old code destURI.getPath() would return null for "file:out.prn"
            // so we use getSchemeSpecificPart instead.
            String pathName = (destURI != null) ?
                destURI.getSchemeSpecificPart() : null;
            if (pathName != null) {
               File file = new File(pathName);
               fileDialog.setFile(file.getName());
               File parent = file.getParentFile();
               if (parent != null) {
                   fileDialog.setDirectory(parent.getPath());
               }
            } else {
                fileDialog.setFile("out.prn");
            }

            fileDialog.setVisible(true);
            String fileName = fileDialog.getFile();
            if (fileName == null) {
                fileDialog.dispose();
                return false;
            }
            String fullName = fileDialog.getDirectory() + fileName;
            File f = new File(fullName);
            File pFile = f.getParentFile();
            while ((f.exists() &&
                      (!f.isFile() || !f.canWrite())) ||
                   ((pFile != null) &&
                      (!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) {

                (new PrintToFileErrorDialog(ownerFrame,
                                ServiceDialog.getMsg("dialog.owtitle"),
                                ServiceDialog.getMsg("dialog.writeerror")+" "+fullName,
                                ServiceDialog.getMsg("button.ok"))).setVisible(true);

                fileDialog.setVisible(true);
                fileName = fileDialog.getFile();
                if (fileName == null) {
                    fileDialog.dispose();
                    return false;
                }
                fullName = fileDialog.getDirectory() + fileName;
                f = new File(fullName);
                pFile = f.getParentFile();
            }
            fileDialog.dispose();
            attributes.add(new Destination(f.toURI()));
            return true;
        }

    }
View Full Code Here

    private final void setNativeAttributes(int flags, int fields, int values) {
        if (attributes == null) {
            return;
        }
        if ((flags & PD_PRINTTOFILE) != 0) {
            Destination destPrn = (Destination)attributes.get(
                                                 Destination.class);
            if (destPrn == null) {
                try {
                    attributes.add(new Destination(
                                               new File("./out.prn").toURI()));
                } catch (SecurityException se) {
                    try {
                        attributes.add(new Destination(
                                                new URI("file:out.prn")));
                    } catch (URISyntaxException e) {
                    }
                }
            }
View Full Code Here

            return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
                            null);
        } else if (Destination.class.equals(category)) {
            File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
                            + File.separator + "output.prn"); //$NON-NLS-1$
            return new Destination(file.toURI());
        } else if (OrientationRequested.class.equals(category)) {
            return dm.getOrientation();
        } else if (Paper.class.equals(category)) {
            return getDefaultPaper();
        } else if (Media.class.equals(category)) {
View Full Code Here

            return new RequestingUserName(System.getProperty("user.name"),
                    Locale.US);
        } else if (category.equals(Destination.class)) {
            File file = new File(System.getProperty("user.dir") +
                    File.separator + "output.prn");
            return new Destination(file.toURI());
        } else if (category.equals(SheetCollate.class)) {
            return SheetCollate.COLLATED;
        } else if (category.equals(Copies.class)) {
            return new Copies(1);
        }
View Full Code Here

        Class category = attribute.getCategory();
        if (category.equals(JobName.class) ||
            category.equals(RequestingUserName.class)) {
            return true;
        } else  if (category.equals(Destination.class)) {
            Destination destination = (Destination)attribute;
            if (destination.getURI().getScheme().equals("file")) {
                return true;
            }
        }
        if (flavor != null) {
            if (flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
View Full Code Here

   
    String getDestination(PrintRequestAttributeSet attrs)
            throws PrintException {
        if (attrs != null) {
            if (attrs.containsKey(Destination.class)) {
                Destination destination =
                    (Destination)attrs.get(Destination.class);
                if (!destination.getURI().getScheme().equals("file")) {
                    throw new PrintException(
                            "Only files supported as destinations.");
                }
                String file = destination.getURI().getPath();
                if (file.startsWith("/")) {
                    file = file.substring(1);
                }
                return file;
            }
View Full Code Here

            if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
                    || ms.equalsIgnoreCase("png")
                    || ms.equalsIgnoreCase("postscript")
                    || flavor.getClass() == DocFlavor.SERVICE_FORMATTED.class) {
                try {
                    return new Object[] { new Destination(new URI(
                            "file:///foo/bar")) };
                } catch (URISyntaxException e) {
                    // return empty array - values are not supported
                    return new Object[0];
                }
View Full Code Here

TOP

Related Classes of javax.print.attribute.standard.Destination

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.