public PrintServiceStub(String name) { _name = name; _flavors = new HashSet<DocFlavor>(); _flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE); _flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE); _attributes = new HashMap<>(); _attributes.put(PrinterName.class, new PrinterName(name, null)); _attributes.put(PrinterState.class, PrinterState.IDLE); _attributes.put(PrinterInfo.class, new PrinterInfo("Custom location", null)); _attributes.put(PrinterIsAcceptingJobs.class, PrinterIsAcceptingJobs.ACCEPTING_JOBS); _attributes.put(PrinterMakeAndModel.class, new PrinterMakeAndModel( "Custom printer", null)); _attributes.put(Media.class, new Media[] { MediaSizeName.ISO_A4 }); }
final public void setValues() { final Attribute objLtypeAttribute = this.objGprintJDialog.getPrintService().getAttribute(PrinterMakeAndModel.class); this.objGtypeJLabel.setText(objLtypeAttribute != null ? objLtypeAttribute.toString() : null); final Attribute objLstatusAttribute = this.objGprintJDialog.getPrintService().getAttribute(PrinterIsAcceptingJobs.class); this.objGstatusJLabel.setText(objLstatusAttribute != null ? Tools.getLocaleString(objLstatusAttribute.toString()) : null); final Attribute objLinfoAttribute = this.objGprintJDialog.getPrintService().getAttribute(PrinterInfo.class); this.objGinfoJLabel.setText(objLinfoAttribute != null ? objLinfoAttribute.toString() : null); this.objGpropertiesJButton.setEnabled(this.objGserviceUIFactory != null); }
/** * Called to update for new selected * print service. Tests if currently * selected attributes are supported. */ void updateForSelectedService() { PrinterMakeAndModel att1 = getSelectedPrintService().getAttribute(PrinterMakeAndModel.class); typValue.setText(att1 == null ? "" : att1.getValue()); PrinterInfo att2 = getSelectedPrintService().getAttribute(PrinterInfo.class); infoValue.setText(att2 == null ? "" : att2.getValue()); PrinterIsAcceptingJobs att3 = getSelectedPrintService().getAttribute(PrinterIsAcceptingJobs.class); PrinterState att4 = getSelectedPrintService().getAttribute(PrinterState.class); String status = att4.toString(); if (att3 == PrinterIsAcceptingJobs.ACCEPTING_JOBS) status += " - " + getLocalizedString("lb.acceptingjobs"); else if (att3 == PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) status += " - " + getLocalizedString("lb.notacceptingjobs"); statusValue.setText(status); if (categorySupported(Destination.class)) { fileRedirection_cb.setEnabled(false); } }
void fillTypeField() { PrinterMakeAndModel type = (PrinterMakeAndModel) myService.getAttribute(PrinterMakeAndModel.class); typeText.setText(type == null ? "" : type.getValue()); }