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.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.AttributeSet;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.attribute.standard.Destination;
|
||||
import javax.print.attribute.standard.Fidelity;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.JDialog;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
@ -48,17 +53,16 @@ public class PrintDialog {
|
||||
attrs.add(PrintUtilities.getDefaultMedia().getMediaSizeName());
|
||||
|
||||
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) {
|
||||
DocPrintJob dpj = ps.createPrintJob();
|
||||
try {
|
||||
ByteArrayOutputStream baos = panel.generateReport();
|
||||
dpj.print(new PDFPrintStreamDoc(baos, null), attrs);
|
||||
}
|
||||
catch (PrintException e) {
|
||||
e.printStackTrace();
|
||||
//dgp
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +88,6 @@ public class PrintDialog {
|
||||
/**
|
||||
* 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 y location of dialog including border in screen coordinates
|
||||
* @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
|
||||
* 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
|
||||
*
|
||||
* @return print service selected by the user, or null if the user cancelled the dialog.
|
||||
*
|
||||
* @throws HeadlessException if GraphicsEnvironment.isHeadless() returns true.
|
||||
* @throws IllegalArgumentException if services is null or empty, or attributes is null, or the initial PrintService
|
||||
* is not in the list of browsable services.
|
||||
*/
|
||||
private PrintService printDialog (GraphicsConfiguration gc,
|
||||
int x, int y,
|
||||
private PrintService printDialog(int x, int y,
|
||||
PrintService[] services,
|
||||
PrintService defaultService,
|
||||
DocFlavor flavor,
|
||||
PrintRequestAttributeSet attributes,
|
||||
PrintPanel addnl)
|
||||
throws HeadlessException {
|
||||
throws HeadlessException, IllegalArgumentException {
|
||||
int defaultIndex = -1;
|
||||
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
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) {
|
||||
throw new IllegalArgumentException("attributes must be non-null");
|
||||
}
|
||||
|
||||
if (defaultService != null) {
|
||||
if (defaultService != null && services != null) {
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
if (services[i].equals(defaultService)) {
|
||||
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) {
|
||||
throw new IllegalArgumentException("services must contain " +
|
||||
"defaultService");
|
||||
defaultIndex = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
defaultIndex = 0;
|
||||
defaultIndex = -1;
|
||||
}
|
||||
|
||||
Rectangle gcBounds = (gc == null) ? GraphicsEnvironment.
|
||||
getLocalGraphicsEnvironment().getDefaultScreenDevice().
|
||||
getDefaultConfiguration().getBounds() : gc.getBounds();
|
||||
|
||||
dialog = new PrintServiceDialog(gc,
|
||||
x + gcBounds.x,
|
||||
y + gcBounds.y,
|
||||
dialog = new PrintServiceDialog(
|
||||
x,
|
||||
y,
|
||||
services, defaultIndex,
|
||||
flavor, attributes,
|
||||
(Dialog) null);
|
||||
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) null, addnl);
|
||||
dialog.setVisible(true);
|
||||
|
||||
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
|
||||
* combination.
|
||||
|
@ -18,13 +18,23 @@ import net.sf.openrocket.startup.Application;
|
||||
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
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.TreeSelectionListener;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import javax.swing.tree.TreeNode;
|
||||
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.ActionListener;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -165,6 +175,11 @@ public class PrintPanel extends JPanel implements TreeSelectionListener {
|
||||
return TAB_TITLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged (final TreeSelectionEvent e) {
|
||||
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.PdfWriter;
|
||||
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.PartsDetailVisitorStrategy;
|
||||
|
||||
@ -35,7 +36,8 @@ public class PrintController {
|
||||
* @param outputFile the file being written to
|
||||
* @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));
|
||||
PdfWriter writer = null;
|
||||
@ -86,8 +88,10 @@ public class PrintController {
|
||||
idoc.close();
|
||||
}
|
||||
catch (DocumentException e) {
|
||||
ExceptionHandler.handleErrorCondition("Could not create document.", e);
|
||||
}
|
||||
catch (ExceptionConverter ec) {
|
||||
ExceptionHandler.handleErrorCondition("Could not create document.", ec);
|
||||
}
|
||||
finally {
|
||||
if (outputFile != null) {
|
||||
@ -98,9 +102,14 @@ public class PrintController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
if (result == null) {
|
||||
@ -108,5 +117,4 @@ public class PrintController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,14 +12,32 @@ import javax.print.ServiceUIFactory;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
import javax.print.attribute.standard.*;
|
||||
import javax.swing.*;
|
||||
import javax.print.attribute.standard.Destination;
|
||||
import javax.print.attribute.standard.Media;
|
||||
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.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.Container;
|
||||
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.Iterator;
|
||||
import java.util.Set;
|
||||
@ -31,7 +49,8 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
private JButton btnCancel, btnPrint;
|
||||
private boolean pdfFlavorSupported = true;
|
||||
private PrintService services[];
|
||||
private int defaultServiceIndex, status;
|
||||
private int defaultServiceIndex = -1;
|
||||
private int status;
|
||||
private PrintRequestAttributeSet asOriginal;
|
||||
private HashPrintRequestAttributeSet asCurrent;
|
||||
private PrintService psCurrent;
|
||||
@ -61,7 +80,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
|
||||
public void itemStateChanged(ItemEvent itemevent) {
|
||||
Object obj = itemevent.getSource();
|
||||
if (itemevent.getStateChange() == 1) {
|
||||
if (itemevent.getStateChange() == ItemEvent.SELECTED) {
|
||||
if (obj == cbSize) {
|
||||
int i = cbSize.getSelectedIndex();
|
||||
if (i >= 0 && i < sizes.size()) {
|
||||
@ -100,7 +119,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
cbSource.addItem(getMediaName("auto-select"));
|
||||
sizes.clear();
|
||||
sources.clear();
|
||||
if (psCurrent.isAttributeCategorySupported(Media.class)) {
|
||||
if (psCurrent != null && psCurrent.isAttributeCategorySupported(Media.class)) {
|
||||
flag = true;
|
||||
Object obj = null;
|
||||
try {
|
||||
@ -141,15 +160,16 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
cbSize.setEnabled(flag1);
|
||||
cbSource.setEnabled(false);
|
||||
lblSource.setEnabled(false);
|
||||
if (flag) {
|
||||
if (flag && psCurrent != null) {
|
||||
Media media = (Media) asCurrent.get(Media.class);
|
||||
boolean attributeValueSupported = false;
|
||||
try {
|
||||
attributeValueSupported = psCurrent.isAttributeValueSupported(media, docFlavor, asCurrent);
|
||||
attributeValueSupported = media == null ? false : psCurrent.isAttributeValueSupported(media,
|
||||
docFlavor,
|
||||
asCurrent);
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
pdfFlavorSupported = false;
|
||||
//dgp
|
||||
}
|
||||
if (media == null || !attributeValueSupported) {
|
||||
media = (Media) psCurrent.getDefaultAttributeValue(Media.class);
|
||||
@ -267,15 +287,15 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
private final String strTitle = "Print Service";
|
||||
private JButton btnProperties;
|
||||
private JComboBox cbName;
|
||||
private JLabel lblType, lblStatus, lblInfo;
|
||||
private JLabel vType, vStatus, vInfo;
|
||||
private ServiceUIFactory uiFactory;
|
||||
private boolean changedService;
|
||||
|
||||
public PrintServicePanel() {
|
||||
super(new MigLayout("fill, gap rel unrel"));
|
||||
changedService = false;
|
||||
if (psCurrent != null) {
|
||||
uiFactory = psCurrent.getServiceUIFactory();
|
||||
}
|
||||
setBorder(BorderFactory.createTitledBorder(strTitle));
|
||||
String as[] = new String[services.length];
|
||||
for (int i = 0; i < as.length; i++) {
|
||||
@ -283,7 +303,9 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
}
|
||||
|
||||
cbName = new JComboBox(as);
|
||||
if (defaultServiceIndex != -1 && defaultServiceIndex < services.length) {
|
||||
cbName.setSelectedIndex(defaultServiceIndex);
|
||||
}
|
||||
cbName.addItemListener(this);
|
||||
cbName.addPopupMenuListener(this);
|
||||
JLabel jlabel = new JLabel(("Name:"), 11);
|
||||
@ -293,24 +315,12 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
add(cbName);
|
||||
btnProperties = PrintServiceDialog.createButton("Properties...", this);
|
||||
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) {
|
||||
Object obj = actionevent.getSource();
|
||||
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) {
|
||||
jdialog.show();
|
||||
}
|
||||
@ -320,13 +330,20 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param itemevent the event that indicates what changed
|
||||
*/
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent itemevent) {
|
||||
if (itemevent.getStateChange() == 1) {
|
||||
if (itemevent.getStateChange() == ItemEvent.SELECTED) {
|
||||
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];
|
||||
uiFactory = psCurrent.getServiceUIFactory();
|
||||
changedService = true;
|
||||
if (asOriginal != null) {
|
||||
Destination destination = (Destination) asOriginal.get(
|
||||
Destination.class);
|
||||
if ((destination != null) && psCurrent.isAttributeCategorySupported(
|
||||
@ -339,11 +356,24 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param popupmenuevent
|
||||
*/
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent popupmenuevent) {
|
||||
changedService = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param popupmenuevent
|
||||
*/
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent popupmenuevent) {
|
||||
if (changedService) {
|
||||
changedService = false;
|
||||
@ -351,34 +381,29 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param popupmenuevent
|
||||
*/
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent popupmenuevent) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the enablement of the properties button.
|
||||
*/
|
||||
public void updateInfo() {
|
||||
PrintServiceAttribute psa = psCurrent.getAttribute(PrinterMakeAndModel.class);
|
||||
if (psa != null) {
|
||||
vType.setText(psa.toString());
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The panel for general print services info.
|
||||
*/
|
||||
private class GeneralPanel extends JPanel {
|
||||
|
||||
public void updateInfo () {
|
||||
pnlPrintService.updateInfo();
|
||||
pnlMedia.updateInfo();
|
||||
}
|
||||
|
||||
private PrintServicePanel pnlPrintService;
|
||||
private MediaPanel pnlMedia;
|
||||
|
||||
@ -389,27 +414,44 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
pnlMedia = new MediaPanel();
|
||||
add(pnlMedia, "wrap");
|
||||
}
|
||||
|
||||
public void updateInfo() {
|
||||
pnlPrintService.updateInfo();
|
||||
pnlMedia.updateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public PrintServiceDialog (GraphicsConfiguration graphicsconfiguration, int i, int j, PrintService aprintservice[],
|
||||
int k, DocFlavor docflavor, PrintRequestAttributeSet printrequestattributeset,
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @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) {
|
||||
super(dialog, PRINT_BUTTON_LABEL, true, graphicsconfiguration);
|
||||
initPrintDialog(i, j, aprintservice, k, docflavor, printrequestattributeset, additional);
|
||||
}
|
||||
super(dialog, PRINT_BUTTON_LABEL, true);
|
||||
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,
|
||||
PrintRequestAttributeSet printrequestattributeset,
|
||||
JPanel... additional) {
|
||||
services = aprintservice;
|
||||
defaultServiceIndex = k;
|
||||
asOriginal = printrequestattributeset;
|
||||
asCurrent = new HashPrintRequestAttributeSet(printrequestattributeset);
|
||||
psCurrent = aprintservice[k];
|
||||
if (services != null && defaultServiceIndex < services.length && defaultServiceIndex >= 0) {
|
||||
psCurrent = services[defaultServiceIndex];
|
||||
}
|
||||
docFlavor = docflavor;
|
||||
Container container = getContentPane();
|
||||
container.setLayout(new BorderLayout());
|
||||
container.setLayout(new MigLayout("fill, gap rel unrel"));
|
||||
// container.setLayout(new BorderLayout());
|
||||
final JTabbedPane tpTabs = new JTabbedPane();
|
||||
tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
@ -418,16 +460,19 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
tpTabs.add(anAdditional, anAdditional.getName(), 0);
|
||||
}
|
||||
}
|
||||
if (psCurrent != null) {
|
||||
pnlGeneral = new GeneralPanel();
|
||||
tpTabs.add(GENERAL_TAB_TITLE, pnlGeneral);
|
||||
}
|
||||
|
||||
container.add(tpTabs, "Center");
|
||||
container.add(tpTabs, "growx");
|
||||
updatePanels();
|
||||
|
||||
JPanel jpanel = new JPanel(new MigLayout());
|
||||
btnPrint = createExitButton(PRINT_BUTTON_LABEL, this);
|
||||
jpanel.add(btnPrint, "x 300");
|
||||
getRootPane().setDefaultButton(btnPrint);
|
||||
btnPrint.setEnabled(pdfFlavorSupported);
|
||||
btnPrint.setEnabled(pdfFlavorSupported && psCurrent != null);
|
||||
|
||||
btnCancel = createExitButton(CANCEL_BUTTON_LABEL, this);
|
||||
handleEscKey(btnCancel);
|
||||
@ -440,7 +485,7 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
}
|
||||
);
|
||||
setResizable(false);
|
||||
setLocation(i, j);
|
||||
setLocation(x, y);
|
||||
pack();
|
||||
}
|
||||
|
||||
@ -502,8 +547,10 @@ public class PrintServiceDialog extends JDialog implements ActionListener {
|
||||
|
||||
|
||||
private void updatePanels() {
|
||||
if (pnlGeneral != null) {
|
||||
pnlGeneral.updateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private static char getMnemonic(String s) {
|
||||
if (s != null && s.length() > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user