Package javax.print.attribute

Examples of javax.print.attribute.PrintServiceAttributeSet


          PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
          printRequestAttributeSet.add(new Copies(mod.getPrintCopies()));


          PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
          printServiceAttributeSet.add(new PrinterName(JPrint.getPrinterServicebyName(printQueue).getName(), Locale.getDefault()));

          SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
          configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
          configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
          configuration.setDisplayPageDialog(false);
View Full Code Here


    JasperPrint jasperPrint = new JasperPrint();
    Connection connection;
    JInternalFrameReportViewer reportviewer;
    Icon reportIcon;
    JRPrintServiceExporter exporter;
    PrintServiceAttributeSet serviceAttributeSet;
    String reportFilename = "";
   
    mod.setModuleId(moduleId);

    if (mod.getModuleProperties() == true)
    {
      reportFilename = Common.report_path  + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml") + ".jasper";
     
      if (parameterValues==null)
      {
        parameterValues = new HashMap<String, Object>();
      }
      parameterValues.putAll(stdparams);

      printQueue = JUtility.replaceNullStringwithBlank(printQueue);
     
      if (printQueue.equals(""))
      {
        printQueue = JPrint.getDefaultPrinterQueueName();
      }
      else
      {
        if (JPrint.getDefaultPrinterQueueName().equals(printQueue) == false)
        {
          JPrint.setPreferredPrinterQueueName(printQueue);
        }
      }

      try
      {
        //jasperReport = (JasperReport) JRLoader.loadObjectFromLocation(Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml")+ ".jasper");
        //jasperReport = (JasperReport) RepositoryUtil.getReport(Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml")+ ".jasper");
        connection = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID);

        sql = JUtility.replaceNullStringwithBlank(sql);

        if (sql.isEmpty())
        {
          if (preparedstatement==null)
          {
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, connection);
          }
          else
          {
            resultset = preparedstatement.executeQuery();
            jasperresultset = new JRResultSetDataSource(resultset);
            parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
          }
        }
        else
        {
          statement = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID).createStatement();
          statement.setFetchSize(1);
          resultset = statement.executeQuery(sql);
          jasperresultset = new JRResultSetDataSource(resultset);
          parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
          parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
          jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
        }

        if (mod.isPrintPreview() == true)
        {
          reportviewer = new JInternalFrameReportViewer(jasperPrint, false);
          reportIcon = Common.imageIconloader.getImageIcon(Common.image_report);
          reportviewer.setFrameIcon(reportIcon);
          reportviewer.setLocation(JLaunchMenu.getNextWindowPosition().x, JLaunchMenu.getNextWindowPosition().y);
          Common.mainForm.desktopPane.add(reportviewer);
          reportviewer.setVisible(true);
          reportviewer.setSelected(true);

        }
        else
        {
          exporter = new JRPrintServiceExporter();
          exporter.setParameter(JRPrintServiceExporterParameter.JASPER_PRINT, jasperPrint);
          serviceAttributeSet = new HashPrintServiceAttributeSet();
          serviceAttributeSet.add(new PrinterName(JPrint.getPrinterShortName(JPrint.getPreferredPrinterQueueName()), null));
          exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet);
          exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
          exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, mod.isPrintDialog());
          PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
          printRequestAttributeSet.add(new Copies(mod.getPrintCopies()));
View Full Code Here

        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]);
                }
            }
        }

        /*
         * Special case: If client is asking for a particular printer
         * (by name) then we can save time by getting just that service
         * to check against the rest of the specified attributes.
         */
        PrintService[] services = null;
        if (serviceSet != null && serviceSet.get(PrinterName.class) != null) {
            PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
            PrintService service = getPrintServiceByName(name.getValue());
            if (service == null || !matchingService(service, serviceSet)) {
                services = new PrintService[0];
            } else {
                services = new PrintService[1];
View Full Code Here

      }
        return new Win32PrintJob(this);
    }

    private PrintServiceAttributeSet getDynamicAttributes() {
        PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
        attrs.add(getPrinterIsAcceptingJobs());
        attrs.add(getQueuedJobCount());
        return attrs;
    }
View Full Code Here

        attrs.add(getQueuedJobCount());
        return attrs;
    }

    public PrintServiceAttributeSet getUpdatedAttributes() {
        PrintServiceAttributeSet currSet = getDynamicAttributes();
        if (lastSet == null) {
            lastSet = currSet;
            return AttributeSetUtilities.unmodifiableView(currSet);
        } else {
            PrintServiceAttributeSet updates =
                new HashPrintServiceAttributeSet();
            Attribute []attrs =  currSet.toArray();
            for (int i=0; i<attrs.length; i++) {
                Attribute attr = attrs[i];
                if (!lastSet.containsValue(attr)) {
                    updates.add(attr);
                }
            }
            lastSet = currSet;
            return AttributeSetUtilities.unmodifiableView(updates);
        }
View Full Code Here

        }
    }

    public PrintServiceAttributeSet getAttributes() {

        PrintServiceAttributeSet attrs = new  HashPrintServiceAttributeSet();
        attrs.add(getPrinterName());
        attrs.add(getPrinterIsAcceptingJobs());
        PrinterState prnState = getPrinterState();
        if (prnState != null) {
            attrs.add(prnState);
        }
        PrinterStateReasons prnStateReasons = getPrinterStateReasons();
        if (prnStateReasons != null) {
            attrs.add(prnStateReasons);
        }
        attrs.add(getQueuedJobCount());
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            attrs.add(ColorSupported.SUPPORTED);
        } else {
            attrs.add(ColorSupported.NOT_SUPPORTED);
        }

        return AttributeSetUtilities.unmodifiableView(attrs);
    }
View Full Code Here

       long minSleepTime = 15000;
       long sleepTime = 2000;
       HashPrintServiceAttributeSet attrs;
       PrintServiceAttributeEvent attrEvent;
       PrintServiceAttributeListener listener;
       PrintServiceAttributeSet psa;

       while (!stop) {
           try {
                Thread.sleep(sleepTime);
           } catch (InterruptedException e) {
           }
           synchronized (this) {
               if (listeners == null) {
                   continue;
               }
               long startTime = System.currentTimeMillis();
               if (listeners != null) {
                    if (service instanceof AttributeUpdater) {
                       psa =
                          ((AttributeUpdater)service).getUpdatedAttributes();
                    } else {
                       psa = service.getAttributes();
                    }
                    if (psa != null && !psa.isEmpty()) {
                        for (int i = 0; i < listeners.size() ; i++) {
                            listener = (PrintServiceAttributeListener)
                                listeners.elementAt(i);
                            attrs =
                                new HashPrintServiceAttributeSet(psa);
View Full Code Here

        } else {
            return null;
        }
    }
    public PrintServiceAttributeSet getAttributes() {
        PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
        attrs.add(ColorSupported.SUPPORTED);

        return AttributeSetUtilities.unmodifiableView(attrs);
    }
View Full Code Here

    public PrintServiceAttribute getAttribute(Class category) {
        if (!PrintServiceAttribute.class.isAssignableFrom(category)) {
            throw new IllegalArgumentException();
        }
        PrintServiceAttributeSet attributes = getAttributes();
        if (attributes.containsKey(category)) {
            PrintServiceAttribute attribute = (PrintServiceAttribute) attributes
                    .get(category);
            return attribute;
        }
        return null;
    }
View Full Code Here

            throw new RuntimeException(ex);
        }
    }

    public PrintServiceAttributeSet getAttributes() {
        final PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();

        attrs.add(new PrinterName(printerName, null));
        try {
            attrs.add(WinPrinterFactory.getPrinterState(getPrinterHandle()));
            attrs.add(WinPrinterFactory.getQueuedJobCount(getPrinterHandle()));
        } catch (final PrintException ex) {
            throw new RuntimeException(ex);
        }

        return AttributeSetUtilities.unmodifiableView(attrs);
View Full Code Here

TOP

Related Classes of javax.print.attribute.PrintServiceAttributeSet

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.