DGP - Partial workaround for systems with no print services; simplification of the dialog
This commit is contained in:
parent
a0a0317a06
commit
6f840a4277
@ -8,15 +8,20 @@ import net.sf.openrocket.gui.print.PDFPrintStreamDoc;
|
|||||||
import net.sf.openrocket.gui.print.PrintServiceDialog;
|
import net.sf.openrocket.gui.print.PrintServiceDialog;
|
||||||
import net.sf.openrocket.gui.print.PrintUtilities;
|
import net.sf.openrocket.gui.print.PrintUtilities;
|
||||||
|
|
||||||
import javax.print.*;
|
import javax.print.DocFlavor;
|
||||||
|
import javax.print.DocPrintJob;
|
||||||
|
import javax.print.PrintService;
|
||||||
|
import javax.print.PrintServiceLookup;
|
||||||
import javax.print.attribute.Attribute;
|
import javax.print.attribute.Attribute;
|
||||||
import javax.print.attribute.AttributeSet;
|
import javax.print.attribute.AttributeSet;
|
||||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||||
import javax.print.attribute.PrintRequestAttributeSet;
|
import javax.print.attribute.PrintRequestAttributeSet;
|
||||||
import javax.print.attribute.standard.Destination;
|
import javax.print.attribute.standard.Destination;
|
||||||
import javax.print.attribute.standard.Fidelity;
|
import javax.print.attribute.standard.Fidelity;
|
||||||
import javax.swing.*;
|
import javax.swing.JDialog;
|
||||||
import java.awt.*;
|
import java.awt.Dialog;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.HeadlessException;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,24 +46,23 @@ public class PrintDialog {
|
|||||||
*
|
*
|
||||||
* @param orDocument the rocket container
|
* @param orDocument the rocket container
|
||||||
*/
|
*/
|
||||||
public PrintDialog (OpenRocketDocument orDocument) {
|
public PrintDialog(OpenRocketDocument orDocument) {
|
||||||
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
|
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
|
||||||
PrintService svc = PrintServiceLookup.lookupDefaultPrintService();
|
PrintService svc = PrintServiceLookup.lookupDefaultPrintService();
|
||||||
PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
|
PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
|
||||||
attrs.add(PrintUtilities.getDefaultMedia().getMediaSizeName());
|
attrs.add(PrintUtilities.getDefaultMedia().getMediaSizeName());
|
||||||
|
|
||||||
final PrintPanel panel = new PrintPanel(orDocument, this);
|
final PrintPanel panel = new PrintPanel(orDocument, this);
|
||||||
PrintService ps = printDialog(null, 100, 100, services, svc, PDF, attrs, panel);
|
try {
|
||||||
|
PrintService ps = printDialog(100, 100, services, svc, PDF, attrs, panel);
|
||||||
if (ps != null) {
|
if (ps != null) {
|
||||||
DocPrintJob dpj = ps.createPrintJob();
|
DocPrintJob dpj = ps.createPrintJob();
|
||||||
try {
|
|
||||||
ByteArrayOutputStream baos = panel.generateReport();
|
ByteArrayOutputStream baos = panel.generateReport();
|
||||||
dpj.print(new PDFPrintStreamDoc(baos, null), attrs);
|
dpj.print(new PDFPrintStreamDoc(baos, null), attrs);
|
||||||
}
|
}
|
||||||
catch (PrintException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
//dgp
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +71,7 @@ public class PrintDialog {
|
|||||||
*
|
*
|
||||||
* @return a set of print attributes
|
* @return a set of print attributes
|
||||||
*/
|
*/
|
||||||
PrintRequestAttributeSet getAttributes () {
|
PrintRequestAttributeSet getAttributes() {
|
||||||
return dialog.getAttributes();
|
return dialog.getAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,14 +81,13 @@ public class PrintDialog {
|
|||||||
*
|
*
|
||||||
* @return the Java service ui print dialog
|
* @return the Java service ui print dialog
|
||||||
*/
|
*/
|
||||||
JDialog getDialog () {
|
JDialog getDialog() {
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mimics the ServiceUI.printDialog method, but with enhancements for our own print settings tab.
|
* Mimics the ServiceUI.printDialog method, but with enhancements for our own print settings tab.
|
||||||
*
|
*
|
||||||
* @param gc used to select screen. null means primary or default screen.
|
|
||||||
* @param x location of dialog including border in screen coordinates
|
* @param x location of dialog including border in screen coordinates
|
||||||
* @param y location of dialog including border in screen coordinates
|
* @param y location of dialog including border in screen coordinates
|
||||||
* @param services to be browsable, must be non-null.
|
* @param services to be browsable, must be non-null.
|
||||||
@ -93,35 +96,28 @@ public class PrintDialog {
|
|||||||
* @param attributes on input is the initial application supplied preferences. This cannot be null but may be
|
* @param attributes on input is the initial application supplied preferences. This cannot be null but may be
|
||||||
* empty. On output the attributes reflect changes made by the user.
|
* empty. On output the attributes reflect changes made by the user.
|
||||||
* @param addnl a panel to be added, as a tab, to the internal tabbed pane of the resulting print dialog
|
* @param addnl a panel to be added, as a tab, to the internal tabbed pane of the resulting print dialog
|
||||||
*
|
|
||||||
* @return print service selected by the user, or null if the user cancelled the dialog.
|
* @return print service selected by the user, or null if the user cancelled the dialog.
|
||||||
*
|
|
||||||
* @throws HeadlessException if GraphicsEnvironment.isHeadless() returns true.
|
* @throws HeadlessException if GraphicsEnvironment.isHeadless() returns true.
|
||||||
* @throws IllegalArgumentException if services is null or empty, or attributes is null, or the initial PrintService
|
* @throws IllegalArgumentException if services is null or empty, or attributes is null, or the initial PrintService
|
||||||
* is not in the list of browsable services.
|
* is not in the list of browsable services.
|
||||||
*/
|
*/
|
||||||
private PrintService printDialog (GraphicsConfiguration gc,
|
private PrintService printDialog(int x, int y,
|
||||||
int x, int y,
|
|
||||||
PrintService[] services,
|
PrintService[] services,
|
||||||
PrintService defaultService,
|
PrintService defaultService,
|
||||||
DocFlavor flavor,
|
DocFlavor flavor,
|
||||||
PrintRequestAttributeSet attributes,
|
PrintRequestAttributeSet attributes,
|
||||||
PrintPanel addnl)
|
PrintPanel addnl)
|
||||||
throws HeadlessException {
|
throws HeadlessException, IllegalArgumentException {
|
||||||
int defaultIndex = -1;
|
int defaultIndex = -1;
|
||||||
|
|
||||||
if (GraphicsEnvironment.isHeadless()) {
|
if (GraphicsEnvironment.isHeadless()) {
|
||||||
throw new HeadlessException();
|
throw new HeadlessException();
|
||||||
}
|
}
|
||||||
else if ((services == null) || (services.length == 0)) {
|
|
||||||
throw new IllegalArgumentException("services must be non-null " +
|
|
||||||
"and non-empty");
|
|
||||||
}
|
|
||||||
else if (attributes == null) {
|
else if (attributes == null) {
|
||||||
throw new IllegalArgumentException("attributes must be non-null");
|
throw new IllegalArgumentException("attributes must be non-null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultService != null) {
|
if (defaultService != null && services != null) {
|
||||||
for (int i = 0; i < services.length; i++) {
|
for (int i = 0; i < services.length; i++) {
|
||||||
if (services[i].equals(defaultService)) {
|
if (services[i].equals(defaultService)) {
|
||||||
defaultIndex = i;
|
defaultIndex = i;
|
||||||
@ -129,45 +125,21 @@ public class PrintDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the default service is not found just go with the first in the list
|
||||||
if (defaultIndex < 0) {
|
if (defaultIndex < 0) {
|
||||||
throw new IllegalArgumentException("services must contain " +
|
defaultIndex = 0;
|
||||||
"defaultService");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
defaultIndex = 0;
|
defaultIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle gcBounds = (gc == null) ? GraphicsEnvironment.
|
dialog = new PrintServiceDialog(
|
||||||
getLocalGraphicsEnvironment().getDefaultScreenDevice().
|
x,
|
||||||
getDefaultConfiguration().getBounds() : gc.getBounds();
|
y,
|
||||||
|
|
||||||
dialog = new PrintServiceDialog(gc,
|
|
||||||
x + gcBounds.x,
|
|
||||||
y + gcBounds.y,
|
|
||||||
services, defaultIndex,
|
services, defaultIndex,
|
||||||
flavor, attributes,
|
flavor, attributes,
|
||||||
(Dialog) null);
|
(Dialog) null, addnl);
|
||||||
Rectangle dlgBounds = dialog.getBounds();
|
|
||||||
|
|
||||||
// get union of all GC bounds
|
|
||||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
||||||
GraphicsDevice[] gs = ge.getScreenDevices();
|
|
||||||
for (GraphicsDevice g : gs) {
|
|
||||||
gcBounds = gcBounds.union(g.getDefaultConfiguration().getBounds());
|
|
||||||
}
|
|
||||||
|
|
||||||
// if portion of dialog is not within the gc boundary
|
|
||||||
if (!gcBounds.contains(dlgBounds)) {
|
|
||||||
// put in the center relative to parent frame/dialog
|
|
||||||
dialog.setLocationRelativeTo(null);
|
|
||||||
}
|
|
||||||
if (addnl != null && addnl.getTitle() != null) {
|
|
||||||
JTabbedPane tp = (JTabbedPane) getDescendantOfClass(JTabbedPane.class, dialog);
|
|
||||||
tp.add(addnl, addnl.getTitle(), 0);
|
|
||||||
tp.setSelectedIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|
||||||
if (dialog.getStatus() == PrintServiceDialog.APPROVE) {
|
if (dialog.getStatus() == PrintServiceDialog.APPROVE) {
|
||||||
@ -196,26 +168,6 @@ public class PrintDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component getDescendantOfClass (Class c, Container cont) {
|
|
||||||
if (c == null || cont == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Component[] children = (cont instanceof JMenu)
|
|
||||||
? ((JMenu) cont).getMenuComponents()
|
|
||||||
: cont.getComponents();
|
|
||||||
for (int i = 0, n = children.length; i < n; i++) {
|
|
||||||
Component comp = children[i];
|
|
||||||
if (c.isInstance(comp)) {
|
|
||||||
return comp;
|
|
||||||
}
|
|
||||||
comp = getDescendantOfClass(c, (Container) comp);
|
|
||||||
if (comp != null) {
|
|
||||||
return comp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes any attributes from the given AttributeSet that are unsupported by the given PrintService/DocFlavor
|
* Removes any attributes from the given AttributeSet that are unsupported by the given PrintService/DocFlavor
|
||||||
* combination.
|
* combination.
|
||||||
@ -224,7 +176,7 @@ public class PrintDialog {
|
|||||||
* @param flavor the document flavor; PDF in our case
|
* @param flavor the document flavor; PDF in our case
|
||||||
* @param aset the set of attributes requested
|
* @param aset the set of attributes requested
|
||||||
*/
|
*/
|
||||||
private static void removeUnsupportedAttributes (PrintService ps,
|
private static void removeUnsupportedAttributes(PrintService ps,
|
||||||
DocFlavor flavor,
|
DocFlavor flavor,
|
||||||
AttributeSet aset) {
|
AttributeSet aset) {
|
||||||
AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
|
AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
|
||||||
|
@ -18,13 +18,23 @@ import net.sf.openrocket.startup.Application;
|
|||||||
|
|
||||||
import javax.print.attribute.PrintRequestAttributeSet;
|
import javax.print.attribute.PrintRequestAttributeSet;
|
||||||
import javax.print.attribute.standard.MediaSizeName;
|
import javax.print.attribute.standard.MediaSizeName;
|
||||||
import javax.swing.*;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JColorChooser;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
import javax.swing.event.TreeSelectionListener;
|
import javax.swing.event.TreeSelectionListener;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Desktop;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -165,6 +175,11 @@ public class PrintPanel extends JPanel implements TreeSelectionListener {
|
|||||||
return TAB_TITLE;
|
return TAB_TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged (final TreeSelectionEvent e) {
|
public void valueChanged (final TreeSelectionEvent e) {
|
||||||
final TreePath path = e.getNewLeadSelectionPath();
|
final TreePath path = e.getNewLeadSelectionPath();
|
||||||
|
@ -12,6 +12,7 @@ import com.itextpdf.text.pdf.PdfBoolean;
|
|||||||
import com.itextpdf.text.pdf.PdfName;
|
import com.itextpdf.text.pdf.PdfName;
|
||||||
import com.itextpdf.text.pdf.PdfWriter;
|
import com.itextpdf.text.pdf.PdfWriter;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
|
import net.sf.openrocket.gui.main.ExceptionHandler;
|
||||||
import net.sf.openrocket.gui.print.visitor.FinSetVisitorStrategy;
|
import net.sf.openrocket.gui.print.visitor.FinSetVisitorStrategy;
|
||||||
import net.sf.openrocket.gui.print.visitor.PartsDetailVisitorStrategy;
|
import net.sf.openrocket.gui.print.visitor.PartsDetailVisitorStrategy;
|
||||||
|
|
||||||
@ -35,7 +36,8 @@ public class PrintController {
|
|||||||
* @param outputFile the file being written to
|
* @param outputFile the file being written to
|
||||||
* @param msn the paper size
|
* @param msn the paper size
|
||||||
*/
|
*/
|
||||||
public void print (OpenRocketDocument doc, Iterator<PrintableContext> toBePrinted, OutputStream outputFile, MediaSizeName msn) {
|
public void print(OpenRocketDocument doc, Iterator<PrintableContext> toBePrinted, OutputStream outputFile,
|
||||||
|
MediaSizeName msn) {
|
||||||
|
|
||||||
Document idoc = new Document(convertWithDefault(msn));
|
Document idoc = new Document(convertWithDefault(msn));
|
||||||
PdfWriter writer = null;
|
PdfWriter writer = null;
|
||||||
@ -86,8 +88,10 @@ public class PrintController {
|
|||||||
idoc.close();
|
idoc.close();
|
||||||
}
|
}
|
||||||
catch (DocumentException e) {
|
catch (DocumentException e) {
|
||||||
|
ExceptionHandler.handleErrorCondition("Could not create document.", e);
|
||||||
}
|
}
|
||||||
catch (ExceptionConverter ec) {
|
catch (ExceptionConverter ec) {
|
||||||
|
ExceptionHandler.handleErrorCondition("Could not create document.", ec);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (outputFile != null) {
|
if (outputFile != null) {
|
||||||
@ -98,15 +102,19 @@ public class PrintController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rectangle convertWithDefault (final MediaSizeName msn) {
|
/**
|
||||||
|
* Convert a media size name to a rectangle that defines the bounds of the corresponding paper size.
|
||||||
|
*
|
||||||
|
* @param msn the MediaSizeName to convert
|
||||||
|
* @return the corresponding Rectangle
|
||||||
|
*/
|
||||||
|
private Rectangle convertWithDefault(final MediaSizeName msn) {
|
||||||
Rectangle result = PaperSize.convert(msn);
|
Rectangle result = PaperSize.convert(msn);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = PaperSize.convert(PrintUtilities.getDefaultMedia().getMediaSizeName());
|
result = PaperSize.convert(PrintUtilities.getDefaultMedia().getMediaSizeName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,32 @@ import javax.print.ServiceUIFactory;
|
|||||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||||
import javax.print.attribute.PrintRequestAttribute;
|
import javax.print.attribute.PrintRequestAttribute;
|
||||||
import javax.print.attribute.PrintRequestAttributeSet;
|
import javax.print.attribute.PrintRequestAttributeSet;
|
||||||
import javax.print.attribute.PrintServiceAttribute;
|
import javax.print.attribute.standard.Destination;
|
||||||
import javax.print.attribute.standard.*;
|
import javax.print.attribute.standard.Media;
|
||||||
import javax.swing.*;
|
import javax.print.attribute.standard.MediaSizeName;
|
||||||
|
import javax.print.attribute.standard.MediaTray;
|
||||||
|
import javax.swing.AbstractAction;
|
||||||
|
import javax.swing.ActionMap;
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.InputMap;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.PopupMenuEvent;
|
import javax.swing.event.PopupMenuEvent;
|
||||||
import javax.swing.event.PopupMenuListener;
|
import javax.swing.event.PopupMenuListener;
|
||||||
import java.awt.*;
|
import java.awt.Container;
|
||||||
import java.awt.event.*;
|
import java.awt.Dialog;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -31,7 +49,8 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
private JButton btnCancel, btnPrint;
|
private JButton btnCancel, btnPrint;
|
||||||
private boolean pdfFlavorSupported = true;
|
private boolean pdfFlavorSupported = true;
|
||||||
private PrintService services[];
|
private PrintService services[];
|
||||||
private int defaultServiceIndex, status;
|
private int defaultServiceIndex = -1;
|
||||||
|
private int status;
|
||||||
private PrintRequestAttributeSet asOriginal;
|
private PrintRequestAttributeSet asOriginal;
|
||||||
private HashPrintRequestAttributeSet asCurrent;
|
private HashPrintRequestAttributeSet asCurrent;
|
||||||
private PrintService psCurrent;
|
private PrintService psCurrent;
|
||||||
@ -53,15 +72,15 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
private ArrayList<MediaSizeName> sizes;
|
private ArrayList<MediaSizeName> sizes;
|
||||||
private ArrayList sources;
|
private ArrayList sources;
|
||||||
|
|
||||||
private String getMediaName (String s) {
|
private String getMediaName(String s) {
|
||||||
String s1 = s.replace(' ', '-');
|
String s1 = s.replace(' ', '-');
|
||||||
s1 = s1.replace('#', 'n');
|
s1 = s1.replace('#', 'n');
|
||||||
return PaperSize.toDisplayable(s1);
|
return PaperSize.toDisplayable(s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void itemStateChanged (ItemEvent itemevent) {
|
public void itemStateChanged(ItemEvent itemevent) {
|
||||||
Object obj = itemevent.getSource();
|
Object obj = itemevent.getSource();
|
||||||
if (itemevent.getStateChange() == 1) {
|
if (itemevent.getStateChange() == ItemEvent.SELECTED) {
|
||||||
if (obj == cbSize) {
|
if (obj == cbSize) {
|
||||||
int i = cbSize.getSelectedIndex();
|
int i = cbSize.getSelectedIndex();
|
||||||
if (i >= 0 && i < sizes.size()) {
|
if (i >= 0 && i < sizes.size()) {
|
||||||
@ -91,7 +110,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updateInfo () {
|
public void updateInfo() {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
cbSize.removeItemListener(this);
|
cbSize.removeItemListener(this);
|
||||||
cbSize.removeAllItems();
|
cbSize.removeAllItems();
|
||||||
@ -100,7 +119,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
cbSource.addItem(getMediaName("auto-select"));
|
cbSource.addItem(getMediaName("auto-select"));
|
||||||
sizes.clear();
|
sizes.clear();
|
||||||
sources.clear();
|
sources.clear();
|
||||||
if (psCurrent.isAttributeCategorySupported(Media.class)) {
|
if (psCurrent != null && psCurrent.isAttributeCategorySupported(Media.class)) {
|
||||||
flag = true;
|
flag = true;
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
try {
|
try {
|
||||||
@ -141,15 +160,16 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
cbSize.setEnabled(flag1);
|
cbSize.setEnabled(flag1);
|
||||||
cbSource.setEnabled(false);
|
cbSource.setEnabled(false);
|
||||||
lblSource.setEnabled(false);
|
lblSource.setEnabled(false);
|
||||||
if (flag) {
|
if (flag && psCurrent != null) {
|
||||||
Media media = (Media) asCurrent.get(Media.class);
|
Media media = (Media) asCurrent.get(Media.class);
|
||||||
boolean attributeValueSupported = false;
|
boolean attributeValueSupported = false;
|
||||||
try {
|
try {
|
||||||
attributeValueSupported = psCurrent.isAttributeValueSupported(media, docFlavor, asCurrent);
|
attributeValueSupported = media == null ? false : psCurrent.isAttributeValueSupported(media,
|
||||||
|
docFlavor,
|
||||||
|
asCurrent);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch (IllegalArgumentException iae) {
|
||||||
pdfFlavorSupported = false;
|
pdfFlavorSupported = false;
|
||||||
//dgp
|
|
||||||
}
|
}
|
||||||
if (media == null || !attributeValueSupported) {
|
if (media == null || !attributeValueSupported) {
|
||||||
media = (Media) psCurrent.getDefaultAttributeValue(Media.class);
|
media = (Media) psCurrent.getDefaultAttributeValue(Media.class);
|
||||||
@ -187,7 +207,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
cbSource.addItemListener(this);
|
cbSource.addItemListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MediaPanel () {
|
public MediaPanel() {
|
||||||
super(new MigLayout("fill, gap rel unrel"));
|
super(new MigLayout("fill, gap rel unrel"));
|
||||||
sizes = new ArrayList<MediaSizeName>();
|
sizes = new ArrayList<MediaSizeName>();
|
||||||
sources = new ArrayList();
|
sources = new ArrayList();
|
||||||
@ -223,12 +243,12 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
* Returns a string value corresponding to this enumeration value.
|
* Returns a string value corresponding to this enumeration value.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString() {
|
||||||
return displayableName;
|
return displayableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo (final Object o) {
|
public int compareTo(final Object o) {
|
||||||
String name = displayableName;
|
String name = displayableName;
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
return name.compareTo(o.toString());
|
return name.compareTo(o.toString());
|
||||||
@ -237,7 +257,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals (final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -251,7 +271,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode () {
|
public int hashCode() {
|
||||||
return displayableName.hashCode();
|
return displayableName.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,15 +287,15 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
private final String strTitle = "Print Service";
|
private final String strTitle = "Print Service";
|
||||||
private JButton btnProperties;
|
private JButton btnProperties;
|
||||||
private JComboBox cbName;
|
private JComboBox cbName;
|
||||||
private JLabel lblType, lblStatus, lblInfo;
|
|
||||||
private JLabel vType, vStatus, vInfo;
|
|
||||||
private ServiceUIFactory uiFactory;
|
private ServiceUIFactory uiFactory;
|
||||||
private boolean changedService;
|
private boolean changedService;
|
||||||
|
|
||||||
public PrintServicePanel () {
|
public PrintServicePanel() {
|
||||||
super(new MigLayout("fill, gap rel unrel"));
|
super(new MigLayout("fill, gap rel unrel"));
|
||||||
changedService = false;
|
changedService = false;
|
||||||
|
if (psCurrent != null) {
|
||||||
uiFactory = psCurrent.getServiceUIFactory();
|
uiFactory = psCurrent.getServiceUIFactory();
|
||||||
|
}
|
||||||
setBorder(BorderFactory.createTitledBorder(strTitle));
|
setBorder(BorderFactory.createTitledBorder(strTitle));
|
||||||
String as[] = new String[services.length];
|
String as[] = new String[services.length];
|
||||||
for (int i = 0; i < as.length; i++) {
|
for (int i = 0; i < as.length; i++) {
|
||||||
@ -283,7 +303,9 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cbName = new JComboBox(as);
|
cbName = new JComboBox(as);
|
||||||
|
if (defaultServiceIndex != -1 && defaultServiceIndex < services.length) {
|
||||||
cbName.setSelectedIndex(defaultServiceIndex);
|
cbName.setSelectedIndex(defaultServiceIndex);
|
||||||
|
}
|
||||||
cbName.addItemListener(this);
|
cbName.addItemListener(this);
|
||||||
cbName.addPopupMenuListener(this);
|
cbName.addPopupMenuListener(this);
|
||||||
JLabel jlabel = new JLabel(("Name:"), 11);
|
JLabel jlabel = new JLabel(("Name:"), 11);
|
||||||
@ -293,24 +315,12 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
add(cbName);
|
add(cbName);
|
||||||
btnProperties = PrintServiceDialog.createButton("Properties...", this);
|
btnProperties = PrintServiceDialog.createButton("Properties...", this);
|
||||||
add(btnProperties, "wrap");
|
add(btnProperties, "wrap");
|
||||||
lblStatus = new JLabel("Status:", 11);
|
|
||||||
add(lblStatus);
|
|
||||||
vStatus = new JLabel();
|
|
||||||
add(vStatus, "wrap");
|
|
||||||
lblType = new JLabel("Type:", 11);
|
|
||||||
vType = new JLabel();
|
|
||||||
add(lblType);
|
|
||||||
add(vType, "wrap");
|
|
||||||
lblInfo = new JLabel("Info:", 11);
|
|
||||||
vInfo = new JLabel();
|
|
||||||
add(lblInfo);
|
|
||||||
add(vInfo, "wrap");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed (ActionEvent actionevent) {
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
Object obj = actionevent.getSource();
|
Object obj = actionevent.getSource();
|
||||||
if (obj == btnProperties && uiFactory != null) {
|
if (obj == btnProperties && uiFactory != null) {
|
||||||
JDialog jdialog = (JDialog) uiFactory.getUI(3, "javax.swing.JDialog");
|
JDialog jdialog = (JDialog) uiFactory.getUI(ServiceUIFactory.MAIN_UIROLE, "javax.swing.JDialog");
|
||||||
if (jdialog != null) {
|
if (jdialog != null) {
|
||||||
jdialog.show();
|
jdialog.show();
|
||||||
}
|
}
|
||||||
@ -320,13 +330,20 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void itemStateChanged (ItemEvent itemevent) {
|
/**
|
||||||
if (itemevent.getStateChange() == 1) {
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @param itemevent the event that indicates what changed
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void itemStateChanged(ItemEvent itemevent) {
|
||||||
|
if (itemevent.getStateChange() == ItemEvent.SELECTED) {
|
||||||
int i = cbName.getSelectedIndex();
|
int i = cbName.getSelectedIndex();
|
||||||
if (i >= 0 && i < services.length && !services[i].equals(psCurrent)) {
|
if (services != null && i >= 0 && i < services.length && !services[i].equals(psCurrent)) {
|
||||||
psCurrent = services[i];
|
psCurrent = services[i];
|
||||||
uiFactory = psCurrent.getServiceUIFactory();
|
uiFactory = psCurrent.getServiceUIFactory();
|
||||||
changedService = true;
|
changedService = true;
|
||||||
|
if (asOriginal != null) {
|
||||||
Destination destination = (Destination) asOriginal.get(
|
Destination destination = (Destination) asOriginal.get(
|
||||||
Destination.class);
|
Destination.class);
|
||||||
if ((destination != null) && psCurrent.isAttributeCategorySupported(
|
if ((destination != null) && psCurrent.isAttributeCategorySupported(
|
||||||
@ -339,77 +356,102 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void popupMenuWillBecomeVisible (PopupMenuEvent popupmenuevent) {
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @param popupmenuevent
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void popupMenuWillBecomeVisible(PopupMenuEvent popupmenuevent) {
|
||||||
changedService = false;
|
changedService = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void popupMenuWillBecomeInvisible (PopupMenuEvent popupmenuevent) {
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @param popupmenuevent
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void popupMenuWillBecomeInvisible(PopupMenuEvent popupmenuevent) {
|
||||||
if (changedService) {
|
if (changedService) {
|
||||||
changedService = false;
|
changedService = false;
|
||||||
updatePanels();
|
updatePanels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void popupMenuCanceled (PopupMenuEvent popupmenuevent) {
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @param popupmenuevent
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void popupMenuCanceled(PopupMenuEvent popupmenuevent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInfo () {
|
/**
|
||||||
PrintServiceAttribute psa = psCurrent.getAttribute(PrinterMakeAndModel.class);
|
* Modify the enablement of the properties button.
|
||||||
if (psa != null) {
|
*/
|
||||||
vType.setText(psa.toString());
|
public void updateInfo() {
|
||||||
}
|
|
||||||
psa = psCurrent.getAttribute(PrinterIsAcceptingJobs.class);
|
|
||||||
if (psa != null) {
|
|
||||||
vStatus.setText((psa.toString()));
|
|
||||||
}
|
|
||||||
psa = psCurrent.getAttribute(PrinterInfo.class);
|
|
||||||
if (psa != null) {
|
|
||||||
vInfo.setText(psa.toString());
|
|
||||||
}
|
|
||||||
btnProperties.setEnabled(uiFactory != null);
|
btnProperties.setEnabled(uiFactory != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The panel for general print services info.
|
||||||
|
*/
|
||||||
private class GeneralPanel extends JPanel {
|
private class GeneralPanel extends JPanel {
|
||||||
|
|
||||||
public void updateInfo () {
|
|
||||||
pnlPrintService.updateInfo();
|
|
||||||
pnlMedia.updateInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private PrintServicePanel pnlPrintService;
|
private PrintServicePanel pnlPrintService;
|
||||||
private MediaPanel pnlMedia;
|
private MediaPanel pnlMedia;
|
||||||
|
|
||||||
public GeneralPanel () {
|
public GeneralPanel() {
|
||||||
super(new MigLayout("fill, gap rel unrel"));
|
super(new MigLayout("fill, gap rel unrel"));
|
||||||
pnlPrintService = new PrintServicePanel();
|
pnlPrintService = new PrintServicePanel();
|
||||||
add(pnlPrintService, "wrap");
|
add(pnlPrintService, "wrap");
|
||||||
pnlMedia = new MediaPanel();
|
pnlMedia = new MediaPanel();
|
||||||
add(pnlMedia, "wrap");
|
add(pnlMedia, "wrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateInfo() {
|
||||||
|
pnlPrintService.updateInfo();
|
||||||
|
pnlMedia.updateInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public PrintServiceDialog (GraphicsConfiguration graphicsconfiguration, int i, int j, PrintService aprintservice[],
|
* Constructor.
|
||||||
int k, DocFlavor docflavor, PrintRequestAttributeSet printrequestattributeset,
|
*
|
||||||
|
* @param x the <i>x</i>-coordinate of the new location's
|
||||||
|
* top-left corner in the parent's coordinate space
|
||||||
|
* @param y the <i>y</i>-coordinate of the new location's
|
||||||
|
* top-left corner in the parent's coordinate space
|
||||||
|
* @param aPrintService the array of installed print services
|
||||||
|
* @param defaultServiceIndex the default service index (index into aPrintService)
|
||||||
|
* @param docflavor the document flavor (i.e. PDF)
|
||||||
|
* @param attributeSet the set of required attributes
|
||||||
|
* @param dialog the parent
|
||||||
|
* @param additional other panels to add in tabs
|
||||||
|
*/
|
||||||
|
public PrintServiceDialog(int x, int y, PrintService[] aPrintService,
|
||||||
|
int defaultServiceIndex, DocFlavor docflavor, PrintRequestAttributeSet attributeSet,
|
||||||
Dialog dialog, JPanel... additional) {
|
Dialog dialog, JPanel... additional) {
|
||||||
super(dialog, PRINT_BUTTON_LABEL, true, graphicsconfiguration);
|
super(dialog, PRINT_BUTTON_LABEL, true);
|
||||||
initPrintDialog(i, j, aprintservice, k, docflavor, printrequestattributeset, additional);
|
setLayout(new MigLayout("fill, gap rel unrel"));
|
||||||
}
|
services = aPrintService;
|
||||||
|
this.defaultServiceIndex = defaultServiceIndex;
|
||||||
|
asOriginal = attributeSet;
|
||||||
|
asCurrent = new HashPrintRequestAttributeSet(attributeSet);
|
||||||
|
|
||||||
void initPrintDialog (int i, int j, PrintService aprintservice[], int k, DocFlavor docflavor,
|
if (services != null && defaultServiceIndex < services.length && defaultServiceIndex >= 0) {
|
||||||
PrintRequestAttributeSet printrequestattributeset,
|
psCurrent = services[defaultServiceIndex];
|
||||||
JPanel... additional) {
|
}
|
||||||
services = aprintservice;
|
|
||||||
defaultServiceIndex = k;
|
|
||||||
asOriginal = printrequestattributeset;
|
|
||||||
asCurrent = new HashPrintRequestAttributeSet(printrequestattributeset);
|
|
||||||
psCurrent = aprintservice[k];
|
|
||||||
docFlavor = docflavor;
|
docFlavor = docflavor;
|
||||||
Container container = getContentPane();
|
Container container = getContentPane();
|
||||||
container.setLayout(new BorderLayout());
|
container.setLayout(new MigLayout("fill, gap rel unrel"));
|
||||||
|
// container.setLayout(new BorderLayout());
|
||||||
final JTabbedPane tpTabs = new JTabbedPane();
|
final JTabbedPane tpTabs = new JTabbedPane();
|
||||||
tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));
|
tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
@ -418,36 +460,39 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
tpTabs.add(anAdditional, anAdditional.getName(), 0);
|
tpTabs.add(anAdditional, anAdditional.getName(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (psCurrent != null) {
|
||||||
pnlGeneral = new GeneralPanel();
|
pnlGeneral = new GeneralPanel();
|
||||||
tpTabs.add(GENERAL_TAB_TITLE, pnlGeneral);
|
tpTabs.add(GENERAL_TAB_TITLE, pnlGeneral);
|
||||||
|
}
|
||||||
|
|
||||||
container.add(tpTabs, "Center");
|
container.add(tpTabs, "growx");
|
||||||
updatePanels();
|
updatePanels();
|
||||||
|
|
||||||
JPanel jpanel = new JPanel(new MigLayout());
|
JPanel jpanel = new JPanel(new MigLayout());
|
||||||
btnPrint = createExitButton(PRINT_BUTTON_LABEL, this);
|
btnPrint = createExitButton(PRINT_BUTTON_LABEL, this);
|
||||||
jpanel.add(btnPrint, "x 300");
|
jpanel.add(btnPrint, "x 300");
|
||||||
getRootPane().setDefaultButton(btnPrint);
|
getRootPane().setDefaultButton(btnPrint);
|
||||||
btnPrint.setEnabled(pdfFlavorSupported);
|
btnPrint.setEnabled(pdfFlavorSupported && psCurrent != null);
|
||||||
|
|
||||||
btnCancel = createExitButton(CANCEL_BUTTON_LABEL, this);
|
btnCancel = createExitButton(CANCEL_BUTTON_LABEL, this);
|
||||||
handleEscKey(btnCancel);
|
handleEscKey(btnCancel);
|
||||||
jpanel.add(btnCancel, "x 380");
|
jpanel.add(btnCancel, "x 380");
|
||||||
container.add(jpanel, "South");
|
container.add(jpanel, "South");
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
public void windowClosing (WindowEvent windowevent) {
|
public void windowClosing(WindowEvent windowevent) {
|
||||||
dispose(2);
|
dispose(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setLocation(i, j);
|
setLocation(x, y);
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleEscKey (JButton jbutton) {
|
private void handleEscKey(JButton jbutton) {
|
||||||
AbstractAction abstractaction = new AbstractAction() {
|
AbstractAction abstractaction = new AbstractAction() {
|
||||||
|
|
||||||
public void actionPerformed (ActionEvent actionevent) {
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
dispose(2);
|
dispose(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,11 +506,11 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus () {
|
public int getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintRequestAttributeSet getAttributes () {
|
public PrintRequestAttributeSet getAttributes() {
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
return asCurrent;
|
return asCurrent;
|
||||||
}
|
}
|
||||||
@ -474,7 +519,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintService getPrintService () {
|
public PrintService getPrintService() {
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
return psCurrent;
|
return psCurrent;
|
||||||
}
|
}
|
||||||
@ -483,12 +528,12 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose (int i) {
|
public void dispose(int i) {
|
||||||
status = i;
|
status = i;
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed (ActionEvent actionevent) {
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
Object obj = actionevent.getSource();
|
Object obj = actionevent.getSource();
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
if (obj == btnPrint) {
|
if (obj == btnPrint) {
|
||||||
@ -501,11 +546,13 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updatePanels () {
|
private void updatePanels() {
|
||||||
|
if (pnlGeneral != null) {
|
||||||
pnlGeneral.updateInfo();
|
pnlGeneral.updateInfo();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static char getMnemonic (String s) {
|
private static char getMnemonic(String s) {
|
||||||
if (s != null && s.length() > 0) {
|
if (s != null && s.length() > 0) {
|
||||||
return s.charAt(0);
|
return s.charAt(0);
|
||||||
}
|
}
|
||||||
@ -514,14 +561,14 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JButton createButton (String s, ActionListener actionlistener) {
|
private static JButton createButton(String s, ActionListener actionlistener) {
|
||||||
JButton jbutton = new JButton(s);
|
JButton jbutton = new JButton(s);
|
||||||
jbutton.setMnemonic(getMnemonic(s));
|
jbutton.setMnemonic(getMnemonic(s));
|
||||||
jbutton.addActionListener(actionlistener);
|
jbutton.addActionListener(actionlistener);
|
||||||
return jbutton;
|
return jbutton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JButton createExitButton (String s, ActionListener actionlistener) {
|
private static JButton createExitButton(String s, ActionListener actionlistener) {
|
||||||
JButton jbutton = new JButton(s);
|
JButton jbutton = new JButton(s);
|
||||||
jbutton.addActionListener(actionlistener);
|
jbutton.addActionListener(actionlistener);
|
||||||
jbutton.getAccessibleContext().setAccessibleDescription(s);
|
jbutton.getAccessibleContext().setAccessibleDescription(s);
|
||||||
@ -533,27 +580,27 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
|||||||
|
|
||||||
private Media media;
|
private Media media;
|
||||||
|
|
||||||
MediaWrapper (Media theMedia) {
|
MediaWrapper(Media theMedia) {
|
||||||
media = theMedia;
|
media = theMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
Media getMedia () {
|
Media getMedia() {
|
||||||
return media;
|
return media;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Class getCategory () {
|
public final Class getCategory() {
|
||||||
return this.getClass();
|
return this.getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getName () {
|
public final String getName() {
|
||||||
return "mw";
|
return "mw";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString () {
|
public String toString() {
|
||||||
return media.toString();
|
return media.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode () {
|
public int hashCode() {
|
||||||
return media.hashCode();
|
return media.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user