From: <doc...@us...> - 2007-06-02 00:25:04
|
Revision: 78 http://openpcl.svn.sourceforge.net/openpcl/?rev=78&view=rev Author: documentsystems Date: 2007-06-01 17:25:06 -0700 (Fri, 01 Jun 2007) Log Message: ----------- Howard Hoagland. 1. Improved error dialog messages for Print All, Selected, Changed, Remaining for when the user didn't left click on any tree nodes to select one or more pages, and for when no changed nodes were found. 2. Changed wording on Print Setup Dialog to say "Index numbers that will print" instead of "Page numbers that wll print" because some tree structures where the page numbers are not the same as the index numbers of the selected tree nodes to print. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-01 22:02:30 UTC (rev 77) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-02 00:25:06 UTC (rev 78) @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Font; +import java.awt.Frame; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.ByteArrayInputStream; @@ -44,6 +45,7 @@ public class PosPrintPages { private PosView mPosView = null; + private Frame mParentFrame = null; private PosPrintBufferedImage mPosPrintBufferedImage = null; private PosPrintPageableInterface mPosPrintPageableInterface = null; private PrinterJob mPrinterJob = null; @@ -74,6 +76,7 @@ public PosPrintPages(PosView pPosView) { super(); mPosView = pPosView; + mParentFrame = mPosView.getOpenPCLViewer().getAppFrame(); mPosPrintBufferedImage = new PosPrintBufferedImage(mPosView); mPosPrintPageableInterface = new PosPrintPageableInterface(mPosView); mAttributes = new HashPrintRequestAttributeSet(); @@ -90,7 +93,7 @@ tJPanel.setLayout(new BorderLayout()); tJPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); tJPanel.add(mPrintingProgressBar, BorderLayout.CENTER); - mPrintingProgressJDialog = new JDialog(mPosView.getOpenPCLViewer().getAppFrame(), "Print Progress", true); + mPrintingProgressJDialog = new JDialog(mParentFrame, "Print Progress", true); mPrintingProgressJDialog.setLayout(new BorderLayout()); mPrintingProgressJDialog.add(tJPanel, BorderLayout.CENTER); mPrintingProgressJDialog.pack(); @@ -143,10 +146,33 @@ } if (mPagesToPrintArrayList == null || mPagesToPrintArrayList.size() < 1) { - JOptionPane.showMessageDialog(mPosView.getOpenPCLViewer().getAppFrame(), - "No pages matched for \"" + mTitleBarTextForPrintDialog[pProcessPrintType] + "\".", - "No pages matched", JOptionPane.INFORMATION_MESSAGE); + // Set not in printing mode mPosView.getOpenPCLViewer().setIsDrawingForPrinting(false); + + // Show error dialog depending on if print all, print selected, print changed, print remaining. + switch (pProcessPrintType) { + case sProcessPrintAll: + JOptionPane.showMessageDialog(mParentFrame, "Can't \"" + mTitleBarTextForPrintDialog[pProcessPrintType] + + "\" because no pages found to print", + "No pages to print", JOptionPane.INFORMATION_MESSAGE); + break; + case sProcessPrintSelected: + JOptionPane.showMessageDialog(mParentFrame, "Can't \"" + mTitleBarTextForPrintDialog[pProcessPrintType] + + "\" because you need to Left Click on the tree to select one or more pages.", + "No pages to print", JOptionPane.INFORMATION_MESSAGE); + break; + case sProcessPrintChanged: + JOptionPane.showMessageDialog(mParentFrame, "Can't \"" + mTitleBarTextForPrintDialog[pProcessPrintType] + + "\" because no changed pages were found.", + "No pages to print", JOptionPane.INFORMATION_MESSAGE); + break; + case sProcessPrintRemaining: + JOptionPane.showMessageDialog(mParentFrame, "Can't \"" + mTitleBarTextForPrintDialog[pProcessPrintType] + + "\" because you need to Left Click on the tree to select one or more pages.", + "No pages to print", JOptionPane.INFORMATION_MESSAGE); + break; + } + return false; } @@ -155,9 +181,9 @@ // Append all the selected page numbers to the StringBuffer tStringBuffer.append(" " + tNumberOfPagesThatWillPrint + " page"); if (tNumberOfPagesThatWillPrint == 1) { - tStringBuffer.append(". Page number: "); + tStringBuffer.append(". Index number: "); } else { - tStringBuffer.append("s. Page numbers are: "); + tStringBuffer.append("s. Index numbers are: "); } for (int i = 0; i < tNumberOfPagesThatWillPrint; i++) { @@ -178,7 +204,7 @@ mPosPrintSetupDialog = new PosPrintSetupDialog(mPosView, tDialogTitleBarString, mPosPrintSetupDialogChoices, mAttributes, mPrinterJob, tStringBuffer.toString()); - mPosPrintSetupDialog.setLocationRelativeTo(mPosView.getOpenPCLViewer().getAppFrame()); + mPosPrintSetupDialog.setLocationRelativeTo(mParentFrame); mPosPrintSetupDialog.setVisible(true); if ( !(mPosPrintSetupDialogChoices.getDidUserHitOk()) ) { @@ -190,7 +216,7 @@ // If user didn't pick a printer then put up dialog and return mPrintService = mPosPrintSetupDialogChoices.getSelectedPrintService(); if ( mPrintService == null) { - JOptionPane.showMessageDialog(mPosView.getOpenPCLViewer().getAppFrame(), "A printer was not selected.\n" + + JOptionPane.showMessageDialog(mParentFrame, "A printer was not selected.\n" + "Try again and click on a printer.", "Printer not selected", JOptionPane.ERROR_MESSAGE); @@ -201,7 +227,7 @@ mPrintingProgressBar.setMaximum(tNumberOfPagesThatWillPrint); mPrintingProgressBar.setString("Initializing..."); mPrintingProgressBar.setValue(0); - mPrintingProgressJDialog.setLocationRelativeTo(mPosView.getOpenPCLViewer().getAppFrame()); + mPrintingProgressJDialog.setLocationRelativeTo(mParentFrame); final SwingWorker threadShowProgressBar = new SwingWorker() { public Object construct() { @@ -231,7 +257,7 @@ mPosView.getOpenPCLViewer().setIsDrawingForPrinting(false); mPosView.getOpenPCLViewer().renderImageCurrentPageAndZoom(); JOptionPane.showMessageDialog(mPrintingProgressJDialog, - mPosView.getOpenPCLViewer().getAppName() + "\nFinished printing " + + mParentFrame + "\nFinished printing " + mPagesToPrintArrayList.size() + " page" + (mPagesToPrintArrayList.size() > 1 ? "s." : "."), "Finished Printing", JOptionPane.INFORMATION_MESSAGE); mPrintingProgressJDialog.setVisible(false); @@ -406,7 +432,7 @@ mPosPrintSetupDialogChoices, mAttributes, mPrinterJob, "No pages will print at this time because this is Printer Setup options only. Make sure to hit OK to save your changes."); - mPosPrintSetupDialog.setLocationRelativeTo(mPosView.getOpenPCLViewer().getAppFrame()); + mPosPrintSetupDialog.setLocationRelativeTo(mParentFrame); mPosPrintSetupDialog.setVisible(true); boolean userHitOk = mPosPrintSetupDialogChoices.getDidUserHitOk(); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-01 22:02:30 UTC (rev 77) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-02 00:25:06 UTC (rev 78) @@ -105,7 +105,7 @@ // JLabels private JLabel mAddlCopiesJLabel = new JLabel("Additional Copies: "); private JLabel mFontSizeJLabel = new JLabel("Font size: "); - private JLabel mPageNumbersThatWillPrintJLabel = new JLabel("Page numbers that will print:"); + private JLabel mPageNumbersThatWillPrintJLabel = new JLabel("Index numbers that will print:"); // JTextFields private JTextField mAddlCopiesJTextField = new JTextField(3); @@ -222,7 +222,7 @@ // Add the tab panels to the JTabbedPane mJTabbedPane.add(mTab1, "View Specific"); - mJTabbedPane.add(mTab2, "Page Numbers That Will Print"); + mJTabbedPane.add(mTab2, "Index Numbers That Will Print"); mJTabbedPane.add(mTab3, "Generic Properties"); // Add the Control Panel, JTabbedPane, and buttons panel to the contentPane This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-06-15 05:07:42
|
Revision: 89 http://openpcl.svn.sourceforge.net/openpcl/?rev=89&view=rev Author: documentsystems Date: 2007-06-14 22:07:43 -0700 (Thu, 14 Jun 2007) Log Message: ----------- Howard Hoagland. On the Printer Setup dialog changed Print "PCL Direct" and "GDI Driver" to "Printer supports PCL (is an HP LaserJet xx):" with a check box instead of 2 radio buttons. Also, added a hover tooltip help text of examples of HP LaserJet printers, and added a JTextArea that says: "Note that: 1. If checked then pages print 3X faster but if not an HP LaserJet XX printer then printouts will not be correct. 2. If pages print wrong then uncheck the box and try printing again. 3. If the printer name doesn't say "LaserJet" even though it starts with "HP", then don't check the box." Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-15 01:32:36 UTC (rev 88) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-15 05:07:43 UTC (rev 89) @@ -245,14 +245,14 @@ // Show the JDialog that has the JProgressBar threadShowProgressBar.start(); - // Depending on the choice in our custom printer setup dialog of PCL Direct or GDI Driver + // Depending on the choice in our custom printer setup dialog of PCL Direct or Image Print if (mPosPrintSetupDialogChoices.isPrintFormatPclDirect()) { PriDebug.releaseln("Printing Pcl Direct using printer selected: " + mPrintService.getName()); mPrintedOkReturn = printPclDirect(mPagesToPrintArrayList, mPosPrintSetupDialogChoices, mPrintingProgressBar, mAttributes); } else { - PriDebug.releaseln("Printing Gdi Driver using printer selected: " + mPrintService.getName()); - mPrintedOkReturn = printGdiDriver(mPagesToPrintArrayList, mPosPrintSetupDialogChoices, + PriDebug.releaseln("Image Print using printer selected: " + mPrintService.getName()); + mPrintedOkReturn = imagePrint(mPagesToPrintArrayList, mPosPrintSetupDialogChoices, mPrintingProgressBar, mAttributes); } return null; @@ -390,7 +390,7 @@ } /** - * print Gdi Driver + * Image print (instead of PCL Direct) * @author Howard 6/1/06. Implemented mult page printing on 8/24/06 * @param pPagesToPrintArrayList * @param pPosPrintSetupDialogChoices @@ -398,7 +398,7 @@ * @param pAttributes * @return boolean */ - private boolean printGdiDriver(ArrayList<PosTreeNode> pPagesToPrintArrayList, + private boolean imagePrint(ArrayList<PosTreeNode> pPagesToPrintArrayList, PosPrintSetupDialogChoices pPosPrintSetupDialogChoices, JProgressBar pPrintingProgressBar, PrintRequestAttributeSet pAttributes) { // Set the pages to print so that when PrinterJob calls Printable.print(), it uses the PosTreeNode values Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-15 01:32:36 UTC (rev 88) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-15 05:07:43 UTC (rev 89) @@ -90,7 +90,7 @@ private JPanel mTab1 = new JPanel(); private JPanel mListOfPrintersJPanel = null; private JPanel mAddlCopiesJPanel = null; - private JPanel mPrintFormatJPanel = null; + private JPanel mPrintAsPclJPanel = null; private JPanel mPrintBarCodesJPanel = null; private JPanel mPrintOrderJPanel = null; private JPanel mPrintFormNamesJPanel = null; @@ -112,10 +112,13 @@ // JTextAreas private JTextArea mPageNumbersThatWillPrintJTextArea = new JTextArea(); + private JScrollPane mPageNumbersThatWillPrintJScrollPane = null; + private JTextArea mPrinterSupportsPclJTextArea = new JTextArea(); + private JScrollPane mPrinterSupportsPclJScrollPane = null; + private Color mTextAreaBgColor = new Color(244, 244, 244); // a very light gray + private Font mTextAreaFont = new Font("Arial", Font.PLAIN, 12); // JRadioButtons - private JRadioButton mPrintFormatIsPclDirectJRadioButton = new JRadioButton("PCL Direct"); - private JRadioButton mPrintFormatIsGdiDriverJRadioButton = new JRadioButton("GDI Driver"); private JRadioButton mPrintBarCodesYesJRadioButton = new JRadioButton("Yes"); private JRadioButton mPrintBarCodesNoJRadioButton = new JRadioButton("No"); private JRadioButton mPrintOrderAsDisplayedOrSelectedJRadioButton = new JRadioButton("As Displayed/Selected"); @@ -136,6 +139,7 @@ private JButton mOpenJDKPrintDialogJButton = new JButton("Open JDK Print Dialog"); // JCheckBoxes + private JCheckBox mIsPclPrinterJCheckBox = new JCheckBox("Printer supports PCL (is an HP LaserJet XX)"); private JCheckBox mPrintAllOnLegalSizeJCheckBox = new JCheckBox("Print All Documents on Legal Size"); // JLists @@ -149,6 +153,28 @@ private static final String sBarCodeHoverString = "Bar codes already in the PCL are printed, but bar codes are not generated on the fly."; + private static final String sPrinterSupportsPclString = + "<html>Examples are:" + + "<ul>" + + "<li>HP LaserJet 1022" + + "<li>HP LaserJet P2015" + + "<li>HP LaserJet 2200" + + "<li>HP LaserJet 2400" + + "<li>HP LaserJet P3005" + + "<li>HP LaserJet 4050" + + "<li>HP LaserJet 4250" + + "<li>HP LaserJet 5000" + + "<li>HP LaserJet 5200" + + "<li>HP LaserJet 9040" + + "<li>HP LaserJet etc etc" + + "</ul></html>"; + + private static final String sPrinterSupportsNotesString = + "Note that:\n" + + "1. If checked then pages print 3X faster but if not an HP LaserJet XX printer then printouts will not be correct.\n" + + "2. If pages print wrong then uncheck the box and try printing again.\n" + + "3. If the printer name doesn't say \"LaserJet\" even though it starts with \"HP\", then don't check the box."; + public PosPrintSetupDialog(PosView pPosView, String pTitleBarText, PosPrintSetupDialogChoices pPrintChoices, PrintRequestAttributeSet pAttributes, PrinterJob pPrinterJob, String pSelectedPageNumbers) throws HeadlessException { @@ -171,11 +197,26 @@ private void buildUI() { setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); addWindowListener(new DialogWindowListener()); + + mPrinterSupportsPclJTextArea.setEditable(false); + mPrinterSupportsPclJTextArea.setFont(mTextAreaFont); + mPrinterSupportsPclJTextArea.setLineWrap(true); + mPrinterSupportsPclJTextArea.setWrapStyleWord(true); + mPrinterSupportsPclJTextArea.setText(sPrinterSupportsNotesString); + mPrinterSupportsPclJTextArea.setBackground(mTextAreaBgColor); + mPrinterSupportsPclJTextArea.setForeground(Color.BLACK); + mPrinterSupportsPclJScrollPane = new JScrollPane(mPrinterSupportsPclJTextArea, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + mPrinterSupportsPclJScrollPane.setPreferredSize(new Dimension(380, 100)); + + mPageNumbersThatWillPrintJTextArea.setBackground(mTextAreaBgColor); + mPageNumbersThatWillPrintJTextArea.setForeground(Color.BLACK); + mPageNumbersThatWillPrintJTextArea.setFont(mTextAreaFont); // Make tab 1 items mListOfPrintersJPanel = makeListOfPrintersPanel(); mAddlCopiesJPanel = makeAdditionalCopiesPanel(); - mPrintFormatJPanel = makePrintFormatPanel(); + mPrintAsPclJPanel = makePrintAsPclPanel(); mPrintBarCodesJPanel = makePrintBarCodesPanel(); mPrintOrderJPanel = makePrintOrderPanel(); mPrintFormNamesJPanel = makePrintFormNamesPanel(); @@ -184,17 +225,17 @@ // Lay out tab 1 items double tloTab1GridSpec[][] = new double[][] { { mTloFill, mTloHgap, mTloFill}, // columns - { mTloFill, mTloVgap, mTloPref, mTloVgap, mTloPref, mTloVgap, mTloPref}}; // rows + { mTloFill, mTloVgap, mTloPref, mTloVgap, mTloPref, mTloVgap, mTloPref, mTloVgap, mTloPref}}; // rows TableLayout tloTab1Layout = new TableLayout(tloTab1GridSpec); mTab1.setLayout(tloTab1Layout); mTab1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mTab1.add(mListOfPrintersJPanel, "0, 0, 2, 0"); - mTab1.add(mAddlCopiesJPanel, "0, 2"); - mTab1.add(mPrintFormatJPanel, "2, 2"); - mTab1.add(mPrintBarCodesJPanel, "0, 4"); - mTab1.add(mPrintOrderJPanel, "2, 4"); - mTab1.add(mPrintFormNamesJPanel, "0, 6"); - mTab1.add(mDuplexJPanel, "2, 6"); + mTab1.add(mAddlCopiesJPanel, "0, 2, 2, 2"); + mTab1.add(mPrintAsPclJPanel, "0, 4, 2, 4"); + mTab1.add(mPrintBarCodesJPanel, "0, 6"); + mTab1.add(mPrintOrderJPanel, "2, 6"); + mTab1.add(mPrintFormNamesJPanel, "0, 8"); + mTab1.add(mDuplexJPanel, "2, 8"); // Lay out tab 2 items double tloTab2GridSpec[][] = new double[][] { @@ -208,7 +249,9 @@ mPageNumbersThatWillPrintJTextArea.setWrapStyleWord(true); mPageNumbersThatWillPrintJTextArea.setText(mSelectedPageNumbers); mPageNumbersThatWillPrintJTextArea.setEditable(false); - mTab2.add(new JScrollPane(mPageNumbersThatWillPrintJTextArea), "0, 2, 1, 2"); + mPageNumbersThatWillPrintJScrollPane = new JScrollPane(mPageNumbersThatWillPrintJTextArea, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + mTab2.add(mPageNumbersThatWillPrintJScrollPane, "0, 2, 1, 2"); // Lay out tab 3 items double tloTab3GridSpec[][] = new double[][] { @@ -337,6 +380,9 @@ TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); mListOfPrintersJList = getCurrentInstalledPrinters(); + mListOfPrintersJList.setBackground(mTextAreaBgColor); + mListOfPrintersJList.setForeground(Color.BLACK); + mListOfPrintersJList.setFont(mTextAreaFont); mPrintersListModel = mListOfPrintersJList.getModel(); mListOfPrintersJList.addListSelectionListener(mListOfPrintersSelectionListener); mListOfPrintersJScrollPane = new JScrollPane(mListOfPrintersJList); @@ -356,16 +402,14 @@ return panel; } - private JPanel makePrintFormatPanel() { + private JPanel makePrintAsPclPanel() { JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{ mTloHgap, mTloPref, mTloHgap, mTloPref, mTloFill }, { mTloPref }}; + double tloGridSpec[][] = new double[][] {{ mTloHgap, 20, mTloPref, mTloFill, mTloHgap }, + { mTloPref, mTloPref, mTloVgap }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); - ButtonGroup buttonGroup = new ButtonGroup(); - buttonGroup.add(mPrintFormatIsPclDirectJRadioButton); - buttonGroup.add(mPrintFormatIsGdiDriverJRadioButton); - panel.add(mPrintFormatIsPclDirectJRadioButton," 1, 0"); - panel.add(mPrintFormatIsGdiDriverJRadioButton, "3, 0"); + panel.add(mIsPclPrinterJCheckBox," 1, 0, 2, 0"); + panel.add(mPrinterSupportsPclJScrollPane," 2, 1"); return panel; } @@ -453,8 +497,7 @@ private void putPrintChoicesOnScreen() { mAddlCopiesJTextField.setText(Integer.toString(mPrintChoices.getNumAdditionalCopies())); - mPrintFormatIsPclDirectJRadioButton.setSelected(mPrintChoices.isPrintFormatPclDirect()); - mPrintFormatIsGdiDriverJRadioButton.setSelected(mPrintChoices.isPrintFormatGdiDriver()); + mIsPclPrinterJCheckBox.setSelected(mPrintChoices.isPrintFormatPclDirect()); mPrintBarCodesYesJRadioButton.setSelected(mPrintChoices.shouldPrintBarCodes()); mPrintBarCodesNoJRadioButton.setSelected( !(mPrintChoices.shouldPrintBarCodes()) ); mPrintOrderAsDisplayedOrSelectedJRadioButton.setSelected(mPrintChoices.isPrintOrderAsDisplayedOrSelected()); @@ -481,7 +524,7 @@ } // Print format - if (mPrintFormatIsPclDirectJRadioButton.isSelected()) { + if (mIsPclPrinterJCheckBox.isSelected()) { mPrintChoices.setPrintFormatIsPclDirect(); } else { mPrintChoices.setPrintFormatIsGdiDriver(); @@ -516,8 +559,7 @@ mItemsOnDialogBox.add(mAddlCopiesJLabel); mItemsOnDialogBox.add(mFontSizeJLabel); mItemsOnDialogBox.add(mAddlCopiesJTextField); - mItemsOnDialogBox.add(mPrintFormatIsPclDirectJRadioButton); - mItemsOnDialogBox.add(mPrintFormatIsGdiDriverJRadioButton); + mItemsOnDialogBox.add(mIsPclPrinterJCheckBox); mItemsOnDialogBox.add(mPrintBarCodesYesJRadioButton); mItemsOnDialogBox.add(mPrintBarCodesNoJRadioButton); mItemsOnDialogBox.add(mPrintOrderAsDisplayedOrSelectedJRadioButton); @@ -565,7 +607,7 @@ private void makePanelTitledBorders() { mListOfPrintersJPanel.setBorder(generateTitledBorder("Installed Printers")); - mPrintFormatJPanel.setBorder(generateTitledBorder("Print Format")); + mPrintAsPclJPanel.setBorder(generateTitledBorder("Printer Supports PCL ?")); mPrintBarCodesJPanel.setBorder(generateTitledBorder("Print Bar Codes")); mPrintOrderJPanel.setBorder(generateTitledBorder("Print Order")); mPrintFormNamesJPanel.setBorder(generateTitledBorder("Print Form Names")); @@ -645,8 +687,8 @@ private void setHoverHelpOnItems() { mAddlCopiesJTextField.setToolTipText(sNotImplementedString + "Additional copies"); - mPrintFormatIsPclDirectJRadioButton.setToolTipText("Print PCL direct"); - mPrintFormatIsGdiDriverJRadioButton.setToolTipText("Print GDI driver"); + mIsPclPrinterJCheckBox.setToolTipText(sPrinterSupportsPclString); + mPrinterSupportsPclJTextArea.setToolTipText(sPrinterSupportsPclString); mPrintBarCodesYesJRadioButton.setToolTipText(sBarCodeHoverString); mPrintBarCodesNoJRadioButton.setToolTipText(sBarCodeHoverString); mPrintOrderAsDisplayedOrSelectedJRadioButton.setToolTipText("Print pages in the order shown in the tree"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-06-18 21:35:54
|
Revision: 90 http://openpcl.svn.sourceforge.net/openpcl/?rev=90&view=rev Author: documentsystems Date: 2007-06-18 14:35:52 -0700 (Mon, 18 Jun 2007) Log Message: ----------- Howard Hoagland. Added 2 ints in 2 classes that will be used for "Print Legal first then Letter" Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-06-15 05:07:43 UTC (rev 89) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-06-18 21:35:52 UTC (rev 90) @@ -39,6 +39,8 @@ private static final String sProgressBarBaseString = "Generating page: "; private static final String sCantAllocate = "Can't allocate memory for temporary image used for printing."; private double mPrintScale = 72.0d / 300.0d; // making width and height using 72 / 300 scale + private int mNumberOfPrintPasses = 1; + private int mCurrentPrintPassNumber = 1; public PosPrintBufferedImage(PosView pPosView) { super(); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-15 05:07:43 UTC (rev 89) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-18 21:35:52 UTC (rev 90) @@ -71,6 +71,8 @@ public static byte sbFF = 0xC; // Form Feed ( char(12) ) private PriModifyPclBytes mPriModifyPclBytes = null; private PclParser mPclParser = null; + private int mNumberOfPrintPasses = 1; + private int mCurrentPrintPassNumber = 1; /** * Constructor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-07-03 21:44:08
|
Revision: 100 http://openpcl.svn.sourceforge.net/openpcl/?rev=100&view=rev Author: documentsystems Date: 2007-07-03 14:44:07 -0700 (Tue, 03 Jul 2007) Log Message: ----------- Howard Hoagland. Implemented "Print All Documents on Legal Size" for both Windows Print and PCL Direct print. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java 2007-07-02 23:29:21 UTC (rev 99) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java 2007-07-03 21:44:07 UTC (rev 100) @@ -72,36 +72,36 @@ public PageFormat getPageFormat(int pForPageNumber) throws IndexOutOfBoundsException { PageFormat tBuiltPageFormat = new PageFormat(); - if (mPosPrintSetupDialogChoices != null && mPosPrintSetupDialogChoices.shouldPrintAllOnLegalSize()) { - // The user has a check in the Print Setup dialog box for "Print all Documents on Legal size" - // so FORCE ALL PAGES TO LEGAL SIZE no matter if LTR in the DSP values or no matter if this is a PCL file - tBuiltPageFormat.setPaper(mLegalPaperPortrait); - - } - if (pForPageNumber >= mNumberOfPages) { throw new IndexOutOfBoundsException( makeIndexOutOfBoundsInfoString(pForPageNumber, mNumberOfPages)); + } else { + if (mPosPrintSetupDialogChoices != null && mPosPrintSetupDialogChoices.shouldPrintAllOnLegalSize()) { + // The user has a check in the Print Setup dialog box for "Print all Documents on Legal size" + // so FORCE ALL PAGES TO LEGAL SIZE no matter if LTR in the DSP values or no matter if this is a PCL file + tBuiltPageFormat.setPaper(mLegalPaperPortrait); + } else { + try { + mPosTreeNode = mPagesToPrintArrayList.get(pForPageNumber); + } catch (IndexOutOfBoundsException e) { + mPosTreeNode = null; + throw new IndexOutOfBoundsException( + makeIndexOutOfBoundsInfoString(pForPageNumber, mNumberOfPages)); + } - } else { - try { - mPosTreeNode = mPagesToPrintArrayList.get(pForPageNumber); - } catch (IndexOutOfBoundsException e) { - mPosTreeNode = null; - throw new IndexOutOfBoundsException( - makeIndexOutOfBoundsInfoString(pForPageNumber, mNumberOfPages)); - } - - if (mPosTreeNode != null) { - // Pick the paper size by calling the below method with may be subclassed by a plugin. - // The below uses polymorphism because the method isTreeNodePageLetterSize() is one of the subclassed - // methods specified in the interface IPluginHooksOpenPCL - if (mPosView.getOpenPCLViewer().isTreeNodePageLetterSize(mPosTreeNode)) { - // Letter size - tBuiltPageFormat.setPaper(mLetterPaperPortrait); + if (mPosTreeNode == null) { + tBuiltPageFormat.setPaper(mLegalPaperPortrait); // If tree node is null then make paper Legal (shouldn't happen) } else { - // Legal size - tBuiltPageFormat.setPaper(mLegalPaperPortrait); + // Pick the paper size by calling the below method with may be subclassed by a plugin. + // The below uses polymorphism because the method isTreeNodePageLetterSize() is one of the subclassed + // methods specified in the interface IPluginHooksOpenPCL + if (mPosView.getOpenPCLViewer().isTreeNodePageLetterSize(mPosTreeNode)) { + // Letter size + tBuiltPageFormat.setPaper(mLetterPaperPortrait); + } else { + // Legal size + tBuiltPageFormat.setPaper(mLegalPaperPortrait); + } } } } Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-02 23:29:21 UTC (rev 99) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-03 21:44:07 UTC (rev 100) @@ -2,7 +2,6 @@ import info.clearthought.layout.TableLayout; -import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -37,6 +36,7 @@ import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JList; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -52,6 +52,7 @@ import com.openpcl.pclrenderimage.util.PriDebug; import com.openpcl.viewer.options.PosStartupOptions; import com.openpcl.viewer.panels.PosView; +import com.openpcl.viewer.util.PosReadImageIcon; public class PosPrintSetupDialog extends JDialog { private static final long serialVersionUID = 1L; @@ -93,7 +94,7 @@ private JPanel mTab1 = new JPanel(); private JPanel mListOfPrintersJPanel = null; private JPanel mAddlCopiesJPanel = null; - private JPanel mPrintAsPclJPanel = null; + private JPanel mWindowsPrintOrPclPrintJPanel = null; private JPanel mPrintBarCodesJPanel = null; private JPanel mPrintOrderJPanel = null; private JPanel mPrintFormNamesJPanel = null; @@ -131,6 +132,7 @@ private JRadioButton mDuplexNoJRadioButton = new JRadioButton("No"); // JButtons + private JButton mPrintModeMoreInfoJButton = new JButton(null, PosReadImageIcon.read("QuestionMark.gif")); private JButton mFontSizeDinkyJButton = new JButton("D"); private JButton mFontSizeSmallJButton = new JButton("*S*"); private JButton mFontSizeMediumJButton = new JButton("M"); @@ -140,7 +142,6 @@ private JButton mOpenJDKPrintDialogJButton = new JButton("Open JDK Print Dialog"); private JButton mAdvancedOptionsJButton = new JButton("Advanced Options"); private JButton mAdvancedOptionsOkJButton = null; - private JButton mPrintModeMoreInfoJButton = new JButton("More Info"); // JCheckBoxes private JCheckBox mIsPclPrinterJCheckBox = new JCheckBox("Use Windows Print (recommended)"); @@ -189,10 +190,9 @@ mPageNumbersThatWillPrintJTextArea.setForeground(Color.BLACK); mPageNumbersThatWillPrintJTextArea.setFont(mTextAreaFont); - // Make tab 1 items mListOfPrintersJPanel = makeListOfPrintersPanel(); + mWindowsPrintOrPclPrintJPanel = makeWindowsPrintOrPclPrintPanel(); mAddlCopiesJPanel = makeAdditionalCopiesPanel(); - mPrintAsPclJPanel = makePrintAsPclPanel(); mPrintBarCodesJPanel = makePrintBarCodesPanel(); mPrintOrderJPanel = makePrintOrderPanel(); mPrintFormNamesJPanel = makePrintFormNamesPanel(); @@ -201,13 +201,15 @@ // Lay out tab 1 items double tloTab1GridSpec[][] = new double[][] { { mTloFill, mTloHgap, mTloFill}, // columns - { mTloFill, mTloVgap, mTloPref, 1, mTloPref, 1, mTloPref, 1, mTloPref}}; // rows + { mTloFill, mTloPref, mTloPref, mTloPref}}; // rows TableLayout tloTab1Layout = new TableLayout(tloTab1GridSpec); mTab1.setLayout(tloTab1Layout); mTab1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mTab1.add(mListOfPrintersJPanel, "0, 0, 2, 0"); -// mTab1.add(mAddlCopiesJPanel, "0, 2, 2, 2"); - mTab1.add(mPrintAsPclJPanel, "0, 4, 2, 4"); + mTab1.add(mWindowsPrintOrPclPrintJPanel, "0, 1, 2, 1"); + mTab1.add(mPrintAllOnLegalSizeJCheckBox, "0, 2, 2, 2"); +// mTab1.add(mAddlCopiesJPanel, "0, 3, 2, 3"); + // mTab1.add(mPrintBarCodesJPanel, "0, 6"); // mTab1.add(mPrintOrderJPanel, "2, 6"); // mTab1.add(mPrintFormNamesJPanel, "0, 8"); @@ -272,6 +274,13 @@ add(mBottomButtonsJPanel, "1, 4"); // ActionListeners + mPrintModeMoreInfoJButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(mPosView.getOpenPCLViewer().getAppFrame(), sPrinterModeHoverOverString, + "Info for \"Use Windows Print\"", JOptionPane.INFORMATION_MESSAGE); + } + }); + mFontSizeDinkyJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mFontSizeDinkyJButton.setText("*D*"); @@ -395,26 +404,27 @@ return panel; } - private JPanel makeAdditionalCopiesPanel() { + private JPanel makeWindowsPrintOrPclPrintPanel() { JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{mTloPref, 40, mTloFill }, {mTloFill, mTloPref, mTloFill }}; + double tloGridSpec[][] = new double[][] {{ mTloPref, mTloPref, mTloFill}, + { mTloPref}}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); - mAddlCopiesJLabel.setHorizontalAlignment(SwingConstants.LEFT); - panel.add(mAddlCopiesJLabel, "0, 1"); - panel.add(mAddlCopiesJTextField, "1, 1"); + panel.add(mIsPclPrinterJCheckBox, "0, 0"); + mPrintModeMoreInfoJButton.setMaximumSize(new Dimension(24,24)); + mPrintModeMoreInfoJButton.setPreferredSize(mPrintModeMoreInfoJButton.getMaximumSize()); + panel.add(mPrintModeMoreInfoJButton, "1, 0"); return panel; } - private JPanel makePrintAsPclPanel() { + private JPanel makeAdditionalCopiesPanel() { JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{ mTloPref, mTloFill}, - { mTloPref}}; + double tloGridSpec[][] = new double[][] {{mTloHgap, mTloPref, 40, mTloFill }, {mTloPref}}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); - panel.add(mIsPclPrinterJCheckBox, " 0, 0"); -// panel.add(mPrintModeMoreInfoJButton, "2,0"); -// panel.add(mPrinterSupportsPclJScrollPane," 2, 1"); + mAddlCopiesJLabel.setHorizontalAlignment(SwingConstants.LEFT); + panel.add(mAddlCopiesJLabel, "1, 0"); + panel.add(mAddlCopiesJTextField, "2, 0"); return panel; } @@ -494,7 +504,6 @@ mTloFill, mTloPref, mTloFill}, { mTloPref }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); -// panel.add(mPrintAllOnLegalSizeJCheckBox, "0, 0"); // panel.add(mAdvancedOptionsJButton, "0, 0"); JPanel tGridLayoutJPanel = new JPanel(new GridLayout(1, 2, 5, 5)); tGridLayoutJPanel.add(mOKJButton); @@ -561,14 +570,11 @@ } private void makeArrayListOfDialogItems() { - - // Tab 1 items mItemsOnDialogBox.add(mListOfPrintersJList); + mItemsOnDialogBox.add(mIsPclPrinterJCheckBox); + mItemsOnDialogBox.add(mPrintAllOnLegalSizeJCheckBox); mItemsOnDialogBox.add(mAddlCopiesJLabel); - mItemsOnDialogBox.add(mFontSizeJLabel); mItemsOnDialogBox.add(mAddlCopiesJTextField); - mItemsOnDialogBox.add(mIsPclPrinterJCheckBox); - mItemsOnDialogBox.add(mPrintModeMoreInfoJButton); mItemsOnDialogBox.add(mPrintBarCodesYesJRadioButton); mItemsOnDialogBox.add(mPrintBarCodesNoJRadioButton); mItemsOnDialogBox.add(mPrintOrderAsDisplayedOrSelectedJRadioButton); @@ -579,15 +585,12 @@ mItemsOnDialogBox.add(mDuplexYesJRadioButton); mItemsOnDialogBox.add(mDuplexNoJRadioButton); - // Tab 2 items mItemsOnDialogBox.add(mPageNumbersThatWillPrintJLabel); mItemsOnDialogBox.add(mPageNumbersThatWillPrintJTextArea); - // Tab 3 items mItemsOnDialogBox.add(mOpenJDKPrintDialogJButton); - // not on a tab items - mItemsOnDialogBox.add(mPrintAllOnLegalSizeJCheckBox); + mItemsOnDialogBox.add(mFontSizeJLabel); mItemsOnDialogBox.add(mFontSizeDinkyJButton); mItemsOnDialogBox.add(mFontSizeSmallJButton); mItemsOnDialogBox.add(mFontSizeMediumJButton); @@ -619,8 +622,8 @@ private void makePanelTitledBorders() { // mListOfPrintersJPanel.setBorder(generateTitledBorder("Installed Printers")); mListOfPrintersJPanel.setBorder(generateTitledBorder("Printers")); -// mPrintAsPclJPanel.setBorder(generateTitledBorder("Printer Supports PCL ?")); - mPrintAsPclJPanel.setBorder(BorderFactory.createEmptyBorder()); + mWindowsPrintOrPclPrintJPanel.setBorder(BorderFactory.createEmptyBorder()); + mAddlCopiesJPanel.setBorder(BorderFactory.createEmptyBorder()); mPrintBarCodesJPanel.setBorder(generateTitledBorder("Print Bar Codes")); mPrintOrderJPanel.setBorder(generateTitledBorder("Print Order")); mPrintFormNamesJPanel.setBorder(generateTitledBorder("Print Form Names")); @@ -699,8 +702,10 @@ } private void setHoverHelpOnItems() { - mAddlCopiesJTextField.setToolTipText(sNotImplementedString + "Additional copies"); mIsPclPrinterJCheckBox.setToolTipText(sPrinterModeHoverOverString); + mAddlCopiesJTextField.setToolTipText("Allowed values are 0 to 3 additional copies"); + mPrintAllOnLegalSizeJCheckBox.setToolTipText("Make all pages print on Legal paper"); + mPrintBarCodesYesJRadioButton.setToolTipText(sBarCodeHoverString); mPrintBarCodesNoJRadioButton.setToolTipText(sBarCodeHoverString); mPrintOrderAsDisplayedOrSelectedJRadioButton.setToolTipText("Print pages in the order shown in the tree"); @@ -710,17 +715,14 @@ mPrintFormNamesNoJRadioButton.setToolTipText("Don't print form names"); mDuplexYesJRadioButton.setToolTipText(sNotImplementedString + "Duplex pages"); mDuplexNoJRadioButton.setToolTipText("Don't duplex pages"); - mPrintAllOnLegalSizeJCheckBox.setToolTipText(sNotImplementedString + "Print all on Legal size"); } private void grayOutItemsNotImplemented() { - mAddlCopiesJTextField.setEnabled(false); mPrintBarCodesYesJRadioButton.setEnabled(false); mPrintOrderLegalFirstThenLetterJRadioButton.setEnabled(false); mPrintOrderLetterFirstThenLegalJRadioButton.setEnabled(false); mPrintFormNamesYesJRadioButton.setEnabled(false); mDuplexYesJRadioButton.setEnabled(false); - mPrintAllOnLegalSizeJCheckBox.setEnabled(false); mOpenJDKPrintDialogJButton.setEnabled(false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-07-06 20:27:55
|
Revision: 103 http://openpcl.svn.sourceforge.net/openpcl/?rev=103&view=rev Author: documentsystems Date: 2007-07-06 13:27:56 -0700 (Fri, 06 Jul 2007) Log Message: ----------- Howard Hoagland. Implemented new feature "Shrink all Legal pages to fit on Letter" that scales Legal pages by 11/14 and selectes Letter paper intead of Legal paper. On the print setup dialog, if the user unchecks the "Use Windows Print" then the "Shrink all Legal pages to fit on Letter" is automatically unselected and grayed out, because shrink Legal pages to fit on Letter isn't available for print PCL Direct. Also, when the user puts a check in "Print All Documents on Legal Size", the "Shrink all Legal pages to fit on Letter" is automatically unchecked. And visa-versa if the user puts a check in "Shrink all Legal pages to fit on Letter" then "Print All Documents on Legal Size" is automatically unchecked. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-07-06 20:27:56 UTC (rev 103) @@ -33,20 +33,22 @@ private PosTreeNode mPrintThisTreeNode = null; private AffineTransform mOrigAffineTransform = null; private AffineTransform mScaleAffineTransform = null; + private AffineTransform mShrinkLegalToLetterAffineTransform = null; private ArrayList<PosTreeNode> mPagesToPrintArrayList = null; private PosPrintSetupDialogChoices mPosPrintSetupDialogChoices = null; private JProgressBar mPrintingProgressBar = null; private static final String sProgressBarBaseString = "Generating page: "; private static final String sCantAllocate = "Can't allocate memory for temporary image used for printing."; private double mPrintScale = 72.0d / 300.0d; // making width and height using 72 / 300 scale - private int mNumberOfPrintPasses = 1; - private int mCurrentPrintPassNumber = 1; + private double mShrinkLegalToLetterScale = mPrintScale * (11.0d / 14.0d); // shrink in both directions height 14" to 11" public PosPrintBufferedImage(PosView pPosView) { super(); mPosView = pPosView; mParentFrame = mPosView.getOpenPCLViewer().getAppFrame(); mScaleAffineTransform = AffineTransform.getScaleInstance(mPrintScale, mPrintScale); + mShrinkLegalToLetterAffineTransform = + AffineTransform.getScaleInstance(mShrinkLegalToLetterScale, mShrinkLegalToLetterScale); mBufferedImageToPrintOn = createNewBufferedImageToPrintOn(); // Graphics2D for printing (is 2 color black and white with no rendering hints like anti-aliasing if (mBufferedImageToPrintOn != null) { mGraphics2DToPrintOn = mBufferedImageToPrintOn.createGraphics(); } @@ -57,7 +59,7 @@ } public void setPosPrintSetupDialogChoices(PosPrintSetupDialogChoices pPosPrintSetupDialogChoices) { - mPosPrintSetupDialogChoices = pPosPrintSetupDialogChoices; + mPosPrintSetupDialogChoices = pPosPrintSetupDialogChoices; } public void setPrintingProgressBar(JProgressBar pPrintingProgressBar) { @@ -94,10 +96,17 @@ g2D.setPaint(Color.BLACK); // Save the passed in AffineTransform (to put it back before returning) mOrigAffineTransform = g2D.getTransform(); - // Set the 72/300 = .24 AffineTransform on the current Graphics2D, to scale smaller - // to fit exactly on the printed page - g2D.transform(mScaleAffineTransform); + if (mPosPrintSetupDialogChoices.shouldShrinkLegalToFitOnLetter() && + ( !(mPosView.getOpenPCLViewer().isTreeNodePageLetterSize(mPrintThisTreeNode)) )) { + // The user has a check in the "Shrink All Legal Pages to Fit On Letter" check box so shrink to Legal to fit on Letter + g2D.transform(mShrinkLegalToLetterAffineTransform); + + } else { + // Set the 72/300 = .24 AffineTransform on the current Graphics2D, to scale smaller to fit exactly on the printed page + g2D.transform(mScaleAffineTransform); + } + // Make the BufferedImage from the tree node. // The below uses polymorphism because the method renderImageForPrintingFromTreeNode() is one of the subclassed // methods specified in the interface IPluginHooksOpenPCL Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java 2007-07-06 20:27:56 UTC (rev 103) @@ -57,12 +57,12 @@ // Letter size portrait with .2 inch margins mLetterPaperPortrait = new Paper(); mLetterPaperPortrait.setSize(8.5d * 72, 11.0d * 72); - mLetterPaperPortrait.setImageableArea(.2d * 72, .2d * 72, 8.1d * 72, 10.6d * 72); + mLetterPaperPortrait.setImageableArea(.18d * 72, .18d * 72, 8.14d * 72, 10.64d * 72); // Legal size portraint with .2 inch margins mLegalPaperPortrait = new Paper(); mLegalPaperPortrait.setSize(8.5d * 72, 14.0d * 72); - mLegalPaperPortrait.setImageableArea(.2d * 72, .2d * 72, 8.1d * 72, 13.6d * 72); + mLegalPaperPortrait.setImageableArea(.18d * 72, .18d * 72, 8.14d * 72, 13.64d * 72); } public int getNumberOfPages() { @@ -80,6 +80,12 @@ // The user has a check in the Print Setup dialog box for "Print all Documents on Legal size" // so FORCE ALL PAGES TO LEGAL SIZE no matter if LTR in the DSP values or no matter if this is a PCL file tBuiltPageFormat.setPaper(mLegalPaperPortrait); + + } else if (mPosPrintSetupDialogChoices != null && mPosPrintSetupDialogChoices.shouldShrinkLegalToFitOnLetter()) { + // The user has a check in the "Shrink All Legal Pages to Fit On Letter" check box + // so force all pages to Letter size + tBuiltPageFormat.setPaper(mLetterPaperPortrait); + } else { try { mPosTreeNode = mPagesToPrintArrayList.get(pForPageNumber); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-06 20:27:56 UTC (rev 103) @@ -255,13 +255,23 @@ StringBuffer tMsgStringBuffer = new StringBuffer(); tMsgStringBuffer.append(" to printer selected: "); tMsgStringBuffer.append(mPrintService.getName()); - tMsgStringBuffer.append("\n Additional Copies is " + mPosPrintSetupDialogChoices.getNumAdditionalCopies()); + + tMsgStringBuffer.append("\n Shrink All Legal Pages to Fit On Letter is "); + if (mPosPrintSetupDialogChoices.shouldShrinkLegalToFitOnLetter()) { + tMsgStringBuffer.append("\"True\""); + } else { + tMsgStringBuffer.append("\"False\""); + } + tMsgStringBuffer.append("\n Print all Documents on Legal Size is "); if (mPosPrintSetupDialogChoices.shouldPrintAllOnLegalSize()) { tMsgStringBuffer.append("\"True\""); } else { tMsgStringBuffer.append("\"False\""); } + + tMsgStringBuffer.append("\n Additional Copies is " + mPosPrintSetupDialogChoices.getNumAdditionalCopies()); + tMsgStringBuffer.append("\n " + mIndexNumbersStringBuffer); // Console output print type "Use Windows Print" or "Print PCL Direct" Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-06 20:27:56 UTC (rev 103) @@ -147,6 +147,8 @@ // JCheckBoxes private JCheckBox mIsPclPrinterJCheckBox = new JCheckBox("Use Windows Print (recommended)"); + private JCheckBox mShrinkLegalToFitOnLetterJCheckBox = new JCheckBox( + "Shrink All Legal Pages to Fit On Letter"); private JCheckBox mPrintAllOnLegalSizeJCheckBox = new JCheckBox("Print All Documents on Legal Size"); // JLists @@ -204,14 +206,15 @@ // Lay out tab 1 items double tloTab1GridSpec[][] = new double[][] { { mTloFill, mTloHgap, mTloFill}, // columns - { mTloFill, mTloPref, mTloPref, mTloPref}}; // rows + { mTloFill, mTloPref, mTloPref, mTloPref, mTloPref}}; // rows TableLayout tloTab1Layout = new TableLayout(tloTab1GridSpec); mTab1.setLayout(tloTab1Layout); mTab1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mTab1.add(mListOfPrintersJPanel, "0, 0, 2, 0"); mTab1.add(mWindowsPrintOrPclPrintJPanel, "0, 1, 2, 1"); - mTab1.add(mPrintAllOnLegalSizeJCheckBox, "0, 2, 2, 2"); - mTab1.add(mAddlCopiesJPanel, "0, 3, 2, 3"); + mTab1.add(mShrinkLegalToFitOnLetterJCheckBox, "0, 2, 2, 2"); + mTab1.add(mPrintAllOnLegalSizeJCheckBox, "0, 3, 2, 3"); + mTab1.add(mAddlCopiesJPanel, "0, 4, 2, 4"); // mTab1.add(mPrintBarCodesJPanel, "0, 6"); // mTab1.add(mPrintOrderJPanel, "2, 6"); @@ -284,6 +287,33 @@ } }); + mIsPclPrinterJCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (mIsPclPrinterJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(true); + } else { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(false); + } + } + }); + + mShrinkLegalToFitOnLetterJCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (mShrinkLegalToFitOnLetterJCheckBox.isSelected()) { + mPrintAllOnLegalSizeJCheckBox.setSelected(false); + } + } + }); + + mPrintAllOnLegalSizeJCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (mPrintAllOnLegalSizeJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + } + } + }); + mFontSizeDinkyJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mFontSizeDinkyJButton.setText("*D*"); @@ -388,6 +418,7 @@ putPrintChoicesOnScreen(); setHoverHelpOnItems(); grayOutItemsNotImplemented(); + grayOutShrinkToLetterOrForceLegalCheckBoxes(); // Make dialog box outer frame width and height exactly to be all item's preferred sizes pack(); } @@ -516,6 +547,23 @@ panel.add(tGridLayoutJPanel, "1, 0"); return panel; } + + private void grayOutShrinkToLetterOrForceLegalCheckBoxes() { + if (mIsPclPrinterJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(true); + } else { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(false); + } + + if (mShrinkLegalToFitOnLetterJCheckBox.isSelected()) { + mPrintAllOnLegalSizeJCheckBox.setSelected(false); + } + + if (mPrintAllOnLegalSizeJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + } + } private void putPrintChoicesOnScreen() { mAddlCopiesJTextField.setText(Integer.toString(mPrintChoices.getNumAdditionalCopies())); @@ -529,6 +577,7 @@ mPrintFormNamesNoJRadioButton.setSelected( !(mPrintChoices.shouldPrintFormNames()) ); mDuplexYesJRadioButton.setSelected(mPrintChoices.shouldDuplex()); mDuplexNoJRadioButton.setSelected( !(mPrintChoices.shouldDuplex()) ); + mShrinkLegalToFitOnLetterJCheckBox.setSelected(mPrintChoices.shouldShrinkLegalToFitOnLetter()); mPrintAllOnLegalSizeJCheckBox.setSelected(mPrintChoices.shouldPrintAllOnLegalSize()); } @@ -572,6 +621,9 @@ // Duplex mPrintChoices.setShouldDuplex(mDuplexYesJRadioButton.isSelected()); + // Shrink All Legal Pages to Fit On Letter + mPrintChoices.setShouldShrinkLegalToFitOnLetter(mShrinkLegalToFitOnLetterJCheckBox.isSelected()); + // Print all on legal size mPrintChoices.setShouldPrintAllOnLegalSize(mPrintAllOnLegalSizeJCheckBox.isSelected()); } @@ -579,6 +631,7 @@ private void makeArrayListOfDialogItems() { mItemsOnDialogBox.add(mListOfPrintersJList); mItemsOnDialogBox.add(mIsPclPrinterJCheckBox); + mItemsOnDialogBox.add(mShrinkLegalToFitOnLetterJCheckBox); mItemsOnDialogBox.add(mPrintAllOnLegalSizeJCheckBox); mItemsOnDialogBox.add(mAddlCopiesJLabel); mItemsOnDialogBox.add(mAddlCopiesJTextField); @@ -710,6 +763,8 @@ private void setHoverHelpOnItems() { mIsPclPrinterJCheckBox.setToolTipText(sPrinterModeHoverOverString); + mShrinkLegalToFitOnLetterJCheckBox.setToolTipText( + "Shrink Legal pages to Letter not available if \"Use Windows Print\" is unchecked"); mAddlCopiesJTextField.setToolTipText("Allowed values are 0 to 3 additional copies"); mPrintAllOnLegalSizeJCheckBox.setToolTipText("Make all pages print on Legal paper"); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-07-06 20:27:56 UTC (rev 103) @@ -23,6 +23,7 @@ private int mPrintOrder = mPrintOrderAsDisplayedOrSelected; private boolean mShouldPrintFormNames = false; private boolean mShouldDuplex = false; + private boolean mShouldShrinkLegalToFitOnLetter = false; private boolean mShouldPrintAllOnLegalSize = false; private boolean mUserHitOk = false; @@ -62,6 +63,9 @@ public boolean shouldDuplex() { return mShouldDuplex; } + public boolean shouldShrinkLegalToFitOnLetter() { + return mShouldShrinkLegalToFitOnLetter; + } public boolean shouldPrintAllOnLegalSize() { return mShouldPrintAllOnLegalSize; } @@ -100,6 +104,9 @@ public void setShouldDuplex(boolean yesOrNo) { mShouldDuplex = yesOrNo; } + public void setShouldShrinkLegalToFitOnLetter(boolean yesOrNo) { + mShouldShrinkLegalToFitOnLetter = yesOrNo; + } public void setShouldPrintAllOnLegalSize(boolean yesOrNo) { mShouldPrintAllOnLegalSize = yesOrNo; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-07-17 01:53:19
|
Revision: 109 http://openpcl.svn.sourceforge.net/openpcl/?rev=109&view=rev Author: documentsystems Date: 2007-07-16 18:53:21 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Howard Hoagland. Changed Print Setup Dialog to move the "Print all on Legal, Print all on Letter (Shrink Legal)" from check boxes to radio buttons that are now part of the "Paper Size" group box of 5 radio buttons instead of the "Print Order" 3 radio buttons. Added the "Print Form Names" and "Duplex" group boxes with their yes/no radio buttons. Removed the "Print Bar Codes" source code because that's for generating bar codes on the fly which we are not going to do. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-16 21:46:41 UTC (rev 108) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-17 01:53:21 UTC (rev 109) @@ -2,6 +2,7 @@ import info.clearthought.layout.TableLayout; +import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -55,6 +56,7 @@ public class PosPrintSetupDialog extends JDialog { private static final long serialVersionUID = 1L; + private PosPrintSetupDialog mThisPosPrintSetupDialog = null; private PosStartupOptions mPosStartupOptions = null; private Frame mParentFrame = null; private PosPrintSetupDialogChoices mPrintChoices = null; @@ -94,8 +96,7 @@ private JPanel mListOfPrintersJPanel = null; private JPanel mAddlCopiesJPanel = null; private JPanel mWindowsPrintOrPclPrintJPanel = null; - private JPanel mPrintBarCodesJPanel = null; - private JPanel mPrintOrderJPanel = null; + private JPanel mPaperSizeJPanel = null; private JPanel mPrintFormNamesJPanel = null; private JPanel mDuplexJPanel = null; @@ -120,11 +121,11 @@ private Font mTextAreaFont = new Font("Arial", Font.PLAIN, 12); // JRadioButtons - private JRadioButton mPrintBarCodesYesJRadioButton = new JRadioButton("Yes"); - private JRadioButton mPrintBarCodesNoJRadioButton = new JRadioButton("No"); - private JRadioButton mPrintOrderAsDisplayedOrSelectedJRadioButton = new JRadioButton("As Displayed/Selected"); - private JRadioButton mPrintOrderLegalFirstThenLetterJRadioButton = new JRadioButton("Legal First, Then Letter"); - private JRadioButton mPrintOrderLetterFirstThenLegalJRadioButton = new JRadioButton("Letter First, Then Legal"); + private JRadioButton mPrintOrderAsDisplayedOrSelectedJRadioButton = new JRadioButton("As displayed / selected"); + private JRadioButton mPrintOrderLegalFirstThenLetterJRadioButton = new JRadioButton("Legal first, then Letter"); + private JRadioButton mPrintOrderLetterFirstThenLegalJRadioButton = new JRadioButton("Letter first, then Legal"); + private JRadioButton mAllOnLegalJRadioButton = new JRadioButton("Print all on Legal paper"); + private JRadioButton mAllOnLetterShrinkLegalJRadioButton = new JRadioButton("Print all on Letter paper (shrinks Legal)"); private JRadioButton mPrintFormNamesYesJRadioButton = new JRadioButton("Yes"); private JRadioButton mPrintFormNamesNoJRadioButton = new JRadioButton("No"); private JRadioButton mDuplexYesJRadioButton = new JRadioButton("Yes (If Supported by Printer)"); @@ -144,21 +145,14 @@ // JCheckBoxes private JCheckBox mIsPclPrinterJCheckBox = new JCheckBox("Use Windows Print (recommended)"); - private JCheckBox mShrinkLegalToFitOnLetterJCheckBox = new JCheckBox( - "Shrink All Legal Pages to Fit On Letter"); - private JCheckBox mPrintAllOnLegalSizeJCheckBox = new JCheckBox("Print All Documents on Legal Size"); // JLists private JList mListOfPrintersJList = null; private ListModel mPrintersListModel = null; private ListOfPrintersSelectionListener mListOfPrintersSelectionListener = new ListOfPrintersSelectionListener(); private JScrollPane mListOfPrintersJScrollPane = null; - + // Strings - private static final String sNotImplementedString = "Not implemented: "; - private static final String sBarCodeHoverString = - "Bar codes already in the PCL are printed, but bar codes are not generated on the fly."; - private static final String sPrinterModeHoverOverString = "<html>Unselect if printer supports PCL (Example: HP LaserJet 4050)</html>"; @@ -166,6 +160,7 @@ PosPrintSetupDialogChoices pPrintChoices, PrintRequestAttributeSet pPrintRequestAttributeSet, PrinterJob pPrinterJob, String pSelectedPageNumbers) throws HeadlessException { super(pParentFrame, pTitleBarText, true); + mThisPosPrintSetupDialog = this; // needed for the ActionListeners to put up the JOptionPane info dialogs mPosStartupOptions = pPosStartupOptions; mParentFrame = pParentFrame; // Set to false the show DSML buttons even if the user said true on the command line @@ -194,31 +189,27 @@ mListOfPrintersJPanel = makeListOfPrintersPanel(); mWindowsPrintOrPclPrintJPanel = makeWindowsPrintOrPclPrintPanel(); mAddlCopiesJPanel = makeAdditionalCopiesPanel(); - mPrintBarCodesJPanel = makePrintBarCodesPanel(); - mPrintOrderJPanel = makePrintOrderPanel(); + mPaperSizeJPanel = makePaperSizePanel(); mPrintFormNamesJPanel = makePrintFormNamesPanel(); mDuplexJPanel = makeDuplexPanel(); // Lay out tab 1 items double tloTab1GridSpec[][] = new double[][] { - { mTloFill, mTloHgap, mTloFill}, // columns - { mTloFill, mTloVgap, mTloPref, mTloPref, mTloPref, mTloPref, mTloVgap, mTloPref, mTloPref}}; // rows + { mTloPref, 10, mTloFill}, // columns + { mTloFill, mTloVgap, mTloPref, mTloPref, mTloPref}}; // rows TableLayout tloTab1Layout = new TableLayout(tloTab1GridSpec); mTab1.setLayout(tloTab1Layout); mTab1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mTab1.add(mListOfPrintersJPanel, "0, 0, 2, 0"); - mTab1.add(mWindowsPrintOrPclPrintJPanel, "0, 2, 2, 2"); - mTab1.add(makeFillerOnRightPanel(mShrinkLegalToFitOnLetterJCheckBox), "0, 3, 2, 3"); - mTab1.add(makeFillerOnRightPanel(mPrintAllOnLegalSizeJCheckBox), "0, 4, 2, 4"); - mTab1.add(mAddlCopiesJPanel, "0, 5, 2, 5"); - mTab1.add(mPrintOrderJPanel, "0, 7, 2, 7"); - mTab1.add(makeFillerOnRightPanel(mOpenJDKPrintDialogJButton), "0, 8, 2, 8"); + mTab1.add(mWindowsPrintOrPclPrintJPanel, "0, 2"); + mTab1.add(mAddlCopiesJPanel, "2, 2"); + mTab1.add(mPaperSizeJPanel, "0, 3, 0, 4"); -// mTab1.add(mPrintBarCodesJPanel, "0, 6"); -// mTab1.add(mPrintOrderJPanel, "2, 6"); -// mTab1.add(mPrintFormNamesJPanel, "0, 8"); -// mTab1.add(mDuplexJPanel, "2, 8"); + mTab1.add(mPrintFormNamesJPanel, "2, 3"); + mTab1.add(mDuplexJPanel, "2, 4"); + // mTab1.add(makeFillerOnRightPanel(mOpenJDKPrintDialogJButton), "0, 8, 2, 8"); + // Lay out tab 2 items // double tloTab2GridSpec[][] = new double[][] { // { mTloPref, mTloFill }, // columns @@ -267,7 +258,7 @@ // Add the Control Panel, JTabbedPane, and buttons panel to the contentPane double tloContentPaneGridSpec[][] = new double[][] { { mTloHgap, mTloFill, mTloHgap }, // columns - { mTloFill, mTloPref, mTloVgap }}; // rows + { mTloFill, mTloPref, 10 }}; // rows TableLayout tloContentPaneLayout = new TableLayout(tloContentPaneGridSpec); setLayout(tloContentPaneLayout); // mControlJPanel = makeControlPanel(); @@ -280,7 +271,7 @@ // ActionListeners mPrintModeMoreInfoJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - JOptionPane.showMessageDialog(mParentFrame, sPrinterModeHoverOverString, + JOptionPane.showMessageDialog(mThisPosPrintSetupDialog, sPrinterModeHoverOverString, "Info for \"Use Windows Print\"", JOptionPane.INFORMATION_MESSAGE); } }); @@ -288,30 +279,16 @@ mIsPclPrinterJCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (mIsPclPrinterJCheckBox.isSelected()) { - mShrinkLegalToFitOnLetterJCheckBox.setEnabled(true); + mAllOnLetterShrinkLegalJRadioButton.setEnabled(true); } else { - mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); - mShrinkLegalToFitOnLetterJCheckBox.setEnabled(false); + if (mAllOnLetterShrinkLegalJRadioButton.isSelected()) { + mPrintOrderAsDisplayedOrSelectedJRadioButton.setSelected(true); + } + mAllOnLetterShrinkLegalJRadioButton.setEnabled(false); } } }); - mShrinkLegalToFitOnLetterJCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (mShrinkLegalToFitOnLetterJCheckBox.isSelected()) { - mPrintAllOnLegalSizeJCheckBox.setSelected(false); - } - } - }); - - mPrintAllOnLegalSizeJCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (mPrintAllOnLegalSizeJCheckBox.isSelected()) { - mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); - } - } - }); - // mFontSizeDinkyJButton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // mFontSizeDinkyJButton.setText("*D*"); @@ -415,12 +392,22 @@ adjustFontOnDialogItems(mAdjustToSmallFont); putPrintChoicesOnScreen(); setHoverHelpOnItems(); - grayOutItemsNotImplemented(); - grayOutShrinkToLetterOrForceLegalCheckBoxes(); + checkforGrayOutShrinkToLetter(); // Make dialog box outer frame width and height exactly to be all item's preferred sizes pack(); } + private void checkforGrayOutShrinkToLetter() { + if (mIsPclPrinterJCheckBox.isSelected()) { + mAllOnLetterShrinkLegalJRadioButton.setEnabled(true); + } else { + if (mAllOnLetterShrinkLegalJRadioButton.isSelected()) { + mPrintOrderAsDisplayedOrSelectedJRadioButton.setSelected(true); + } + mAllOnLetterShrinkLegalJRadioButton.setEnabled(false); + } + } + private JPanel makeListOfPrintersPanel() { JPanel panel = new JPanel(); double tloGridSpec[][] = new double[][] {{mTloHgap, mTloFill, mTloHgap }, {mTloFill, mTloVgap }}; @@ -462,57 +449,59 @@ return panel; } - private JPanel makePrintBarCodesPanel() { + private JPanel makePaperSizePanel() { JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{ mTloHgap, mTloPref, mTloFill }, { mTloPref, mTloVgap, mTloPref }}; + int tTextHeight = mPrintOrderAsDisplayedOrSelectedJRadioButton.getPreferredSize().height - 6; + double tloGridSpec[][] = new double[][] {{ mTloPref}, + { tTextHeight, tTextHeight, tTextHeight, tTextHeight, tTextHeight}}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); + ButtonGroup buttonGroup = new ButtonGroup(); - buttonGroup.add(mPrintBarCodesYesJRadioButton); - buttonGroup.add(mPrintBarCodesNoJRadioButton); - panel.add(mPrintBarCodesYesJRadioButton, "1, 0"); - panel.add(mPrintBarCodesNoJRadioButton, "1, 2"); - return panel; - } - - private JPanel makePrintOrderPanel() { - JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{ mTloHgap, mTloPref, mTloFill }, { mTloPref, mTloPref, mTloPref }}; - TableLayout tloLayout = new TableLayout(tloGridSpec); - panel.setLayout(tloLayout); - ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(mPrintOrderAsDisplayedOrSelectedJRadioButton); buttonGroup.add(mPrintOrderLegalFirstThenLetterJRadioButton); buttonGroup.add(mPrintOrderLetterFirstThenLegalJRadioButton); - panel.add(mPrintOrderAsDisplayedOrSelectedJRadioButton, "1, 0"); - panel.add(mPrintOrderLegalFirstThenLetterJRadioButton, "1, 1"); - panel.add(mPrintOrderLetterFirstThenLegalJRadioButton, "1, 2"); + buttonGroup.add(mAllOnLegalJRadioButton); + buttonGroup.add(mAllOnLetterShrinkLegalJRadioButton); + + panel.add(makeFillerOnRightPanel(mPrintOrderAsDisplayedOrSelectedJRadioButton), "0, 0"); + panel.add(makeFillerOnRightPanel(mPrintOrderLegalFirstThenLetterJRadioButton), "0, 1"); + panel.add(makeFillerOnRightPanel(mPrintOrderLetterFirstThenLegalJRadioButton), "0, 2"); + panel.add(makeFillerOnRightPanel(mAllOnLegalJRadioButton), "0, 3"); + panel.add(makeFillerOnRightPanel(mAllOnLetterShrinkLegalJRadioButton), "0, 4"); + return panel; } private JPanel makePrintFormNamesPanel() { JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{ mTloHgap, mTloPref, mTloFill }, { mTloPref, mTloVgap, mTloPref }}; + int tTextHeight = mPrintOrderAsDisplayedOrSelectedJRadioButton.getPreferredSize().height - 6; + double tloGridSpec[][] = new double[][] {{ mTloPref }, { tTextHeight, tTextHeight }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); + ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(mPrintFormNamesYesJRadioButton); buttonGroup.add(mPrintFormNamesNoJRadioButton); - panel.add(mPrintFormNamesYesJRadioButton, "1, 0"); - panel.add(mPrintFormNamesNoJRadioButton, "1, 2"); + + panel.add(makeFillerOnRightPanel(mPrintFormNamesYesJRadioButton), "0, 0"); + panel.add(makeFillerOnRightPanel(mPrintFormNamesNoJRadioButton), "0, 1"); return panel; } private JPanel makeDuplexPanel() { JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{ mTloHgap, mTloPref, mTloFill }, { mTloPref, mTloVgap, mTloPref }}; + int tTextHeight = mPrintOrderAsDisplayedOrSelectedJRadioButton.getPreferredSize().height - 6; + double tloGridSpec[][] = new double[][] {{ mTloPref }, { tTextHeight, tTextHeight }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); + ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(mDuplexYesJRadioButton); buttonGroup.add(mDuplexNoJRadioButton); - panel.add(mDuplexYesJRadioButton, "1, 0"); - panel.add(mDuplexNoJRadioButton, "1, 2"); + + panel.add(makeFillerOnRightPanel(mDuplexYesJRadioButton), "0, 0"); + panel.add(makeFillerOnRightPanel(mDuplexNoJRadioButton), "0, 1"); return panel; } @@ -547,36 +536,20 @@ } private JPanel makeFillerOnRightPanel(JComponent pJc) { - JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{mTloPref, mTloFill}, { mTloPref }}; - TableLayout tloLayout = new TableLayout(tloGridSpec); - panel.setLayout(tloLayout); - panel.add(pJc,"0,0"); - return panel; + JPanel panel1 = new JPanel(); + JPanel panel2 = new JPanel(); + panel1.setBorder(BorderFactory.createEmptyBorder()); + panel2.setBorder(BorderFactory.createEmptyBorder()); + panel2.setPreferredSize(new Dimension(0,0)); + panel1.setLayout(new BorderLayout(0,0)); + panel1.add(pJc, BorderLayout.WEST); + panel1.add(panel2, BorderLayout.CENTER); + return panel1; } - - private void grayOutShrinkToLetterOrForceLegalCheckBoxes() { - if (mIsPclPrinterJCheckBox.isSelected()) { - mShrinkLegalToFitOnLetterJCheckBox.setEnabled(true); - } else { - mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); - mShrinkLegalToFitOnLetterJCheckBox.setEnabled(false); - } - - if (mShrinkLegalToFitOnLetterJCheckBox.isSelected()) { - mPrintAllOnLegalSizeJCheckBox.setSelected(false); - } - - if (mPrintAllOnLegalSizeJCheckBox.isSelected()) { - mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); - } - } private void putPrintChoicesOnScreen() { mAddlCopiesJTextField.setText(Integer.toString(mPrintChoices.getNumAdditionalCopies())); mIsPclPrinterJCheckBox.setSelected(!(mPrintChoices.isPrintFormatPclDirect())); - mPrintBarCodesYesJRadioButton.setSelected(mPrintChoices.shouldPrintBarCodes()); - mPrintBarCodesNoJRadioButton.setSelected( !(mPrintChoices.shouldPrintBarCodes()) ); mPrintOrderAsDisplayedOrSelectedJRadioButton.setSelected(mPrintChoices.isPrintOrderAsDisplayedOrSelected()); mPrintOrderLegalFirstThenLetterJRadioButton.setSelected(mPrintChoices.isPrintOrderLegalFirstThenLetter()); mPrintOrderLetterFirstThenLegalJRadioButton.setSelected(mPrintChoices.isPrintOrderLetterFirstThenLegal()); @@ -584,8 +557,8 @@ mPrintFormNamesNoJRadioButton.setSelected( !(mPrintChoices.shouldPrintFormNames()) ); mDuplexYesJRadioButton.setSelected(mPrintChoices.shouldDuplex()); mDuplexNoJRadioButton.setSelected( !(mPrintChoices.shouldDuplex()) ); - mShrinkLegalToFitOnLetterJCheckBox.setSelected(mPrintChoices.shouldShrinkLegalToFitOnLetter()); - mPrintAllOnLegalSizeJCheckBox.setSelected(mPrintChoices.shouldPrintAllOnLegalSize()); + mAllOnLetterShrinkLegalJRadioButton.setSelected(mPrintChoices.shouldShrinkLegalToFitOnLetter()); + mAllOnLegalJRadioButton.setSelected(mPrintChoices.shouldPrintAllOnLegalSize()); } private void getPrintChoicesFromScreen() { @@ -610,9 +583,6 @@ mPrintChoices.setPrintFormatIsPclDirect(); } - // Print bar codes - mPrintChoices.setShouldPrintBarCodes(mPrintBarCodesYesJRadioButton.isSelected()); - // Print order if (mPrintOrderAsDisplayedOrSelectedJRadioButton.isSelected()) { mPrintChoices.setPrintOrderAsDisplayedOrSelected(); @@ -622,28 +592,27 @@ mPrintChoices.setPrintOrderLetterFirstThenLegal(); } + // Shrink All Legal Pages to Fit On Letter + mPrintChoices.setShouldShrinkLegalToFitOnLetter(mAllOnLetterShrinkLegalJRadioButton.isSelected()); + + // Print all on legal size + mPrintChoices.setShouldPrintAllOnLegalSize(mAllOnLegalJRadioButton.isSelected()); + // Print form names mPrintChoices.setShouldPrintFormNames(mPrintFormNamesYesJRadioButton.isSelected()); // Duplex mPrintChoices.setShouldDuplex(mDuplexYesJRadioButton.isSelected()); - // Shrink All Legal Pages to Fit On Letter - mPrintChoices.setShouldShrinkLegalToFitOnLetter(mShrinkLegalToFitOnLetterJCheckBox.isSelected()); - - // Print all on legal size - mPrintChoices.setShouldPrintAllOnLegalSize(mPrintAllOnLegalSizeJCheckBox.isSelected()); } private void makeArrayListOfDialogItems() { mItemsOnDialogBox.add(mListOfPrintersJList); mItemsOnDialogBox.add(mIsPclPrinterJCheckBox); - mItemsOnDialogBox.add(mShrinkLegalToFitOnLetterJCheckBox); - mItemsOnDialogBox.add(mPrintAllOnLegalSizeJCheckBox); + mItemsOnDialogBox.add(mAllOnLetterShrinkLegalJRadioButton); + mItemsOnDialogBox.add(mAllOnLegalJRadioButton); mItemsOnDialogBox.add(mAddlCopiesJLabel); mItemsOnDialogBox.add(mAddlCopiesJTextField); - mItemsOnDialogBox.add(mPrintBarCodesYesJRadioButton); - mItemsOnDialogBox.add(mPrintBarCodesNoJRadioButton); mItemsOnDialogBox.add(mPrintOrderAsDisplayedOrSelectedJRadioButton); mItemsOnDialogBox.add(mPrintOrderLegalFirstThenLetterJRadioButton); mItemsOnDialogBox.add(mPrintOrderLetterFirstThenLegalJRadioButton); @@ -691,8 +660,7 @@ mListOfPrintersJPanel.setBorder(generateTitledBorder("Printers")); mWindowsPrintOrPclPrintJPanel.setBorder(BorderFactory.createEmptyBorder()); mAddlCopiesJPanel.setBorder(BorderFactory.createEmptyBorder()); - mPrintBarCodesJPanel.setBorder(generateTitledBorder("Print Bar Codes")); - mPrintOrderJPanel.setBorder(generateTitledBorder("Print Order")); + mPaperSizeJPanel.setBorder(generateTitledBorder("Paper Size")); mPrintFormNamesJPanel.setBorder(generateTitledBorder("Print Form Names")); mDuplexJPanel.setBorder(generateTitledBorder("Duplex")); } @@ -770,28 +738,21 @@ private void setHoverHelpOnItems() { mIsPclPrinterJCheckBox.setToolTipText(sPrinterModeHoverOverString); - mShrinkLegalToFitOnLetterJCheckBox.setToolTipText( - "Shrink Legal pages to Letter not available if \"Use Windows Print\" is unchecked"); mAddlCopiesJTextField.setToolTipText("Allowed values are 0 to 3 additional copies"); - mPrintAllOnLegalSizeJCheckBox.setToolTipText("Make all pages print on Legal paper"); - mPrintBarCodesYesJRadioButton.setToolTipText(sBarCodeHoverString); - mPrintBarCodesNoJRadioButton.setToolTipText(sBarCodeHoverString); + mAllOnLegalJRadioButton.setToolTipText("Print all pages on Legal paper"); + mAllOnLetterShrinkLegalJRadioButton.setToolTipText( + "Print all pages on Letter paper. This is grayed out if \"Use Windows Print\" is unchecked"); mPrintOrderAsDisplayedOrSelectedJRadioButton.setToolTipText("Print pages in the order shown in the tree"); - mPrintOrderLegalFirstThenLetterJRadioButton.setToolTipText(sNotImplementedString + "Print Legal first then Letter"); - mPrintOrderLetterFirstThenLegalJRadioButton.setToolTipText(sNotImplementedString + "Print Letter first then Legal"); - mPrintFormNamesYesJRadioButton.setToolTipText(sNotImplementedString + "Print form names"); + mPrintOrderLegalFirstThenLetterJRadioButton.setToolTipText("Print Legal first then Letter"); + mPrintOrderLetterFirstThenLegalJRadioButton.setToolTipText("Print Letter first then Legal"); + + mPrintFormNamesYesJRadioButton.setToolTipText("Print form names"); mPrintFormNamesNoJRadioButton.setToolTipText("Don't print form names"); - mDuplexYesJRadioButton.setToolTipText(sNotImplementedString + "Duplex pages"); + mDuplexYesJRadioButton.setToolTipText("Duplex pages"); mDuplexNoJRadioButton.setToolTipText("Don't duplex pages"); } - private void grayOutItemsNotImplemented() { - mPrintBarCodesYesJRadioButton.setEnabled(false); - mPrintFormNamesYesJRadioButton.setEnabled(false); - mDuplexYesJRadioButton.setEnabled(false); - } - public class DialogWindowListener implements WindowListener { public void windowOpened(WindowEvent e) { } @@ -826,14 +787,14 @@ try { tAddlCopiesInt = Integer.parseInt(tAddlCopiesString); } catch (NumberFormatException nfe) { - JOptionPane.showMessageDialog(mParentFrame, tUserInputNumberRequiredString, + JOptionPane.showMessageDialog(mThisPosPrintSetupDialog, tUserInputNumberRequiredString, tUserInputTitleString, JOptionPane.INFORMATION_MESSAGE); // returning true means the screen didn't pass user input validation return true; } if (tAddlCopiesInt < 0 || tAddlCopiesInt > 3) { - JOptionPane.showMessageDialog(mParentFrame, tUserInputValidRange0to3String, + JOptionPane.showMessageDialog(mThisPosPrintSetupDialog, tUserInputValidRange0to3String, tUserInputTitleString, JOptionPane.INFORMATION_MESSAGE); // returning true means the screen didn't pass user input validation return true; Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-07-16 21:46:41 UTC (rev 108) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-07-17 01:53:21 UTC (rev 109) @@ -8,18 +8,17 @@ */ public class PosPrintSetupDialogChoices { - private final int mPrintFormatIsPclDirect = 1; - private final int mPrintFormatIsGdiDriver = 2; + public static final int mPrintFormatIsPclDirect = 1; + public static final int mPrintFormatIsGdiDriver = 2; - private final int mPrintOrderAsDisplayedOrSelected = 1; - private final int mPrintOrderLegalFirstThenLetter = 2; - private final int mPrintOrderLetterFirstThenLegal = 3; + public static final int mPrintOrderAsDisplayedOrSelected = 1; + public static final int mPrintOrderLegalFirstThenLetter = 2; + public static final int mPrintOrderLetterFirstThenLegal = 3; // TODO Add code to take the defaults from the user options in the Preferences, instead of the below initializations private PrintService mSelectedPrintService = null; private int mNumAdditionalCopies = 0; private int mPrintFormat = mPrintFormatIsGdiDriver; - private boolean mShouldPrintBarCodes = false; private int mPrintOrder = mPrintOrderAsDisplayedOrSelected; private boolean mShouldPrintFormNames = false; private boolean mShouldDuplex = false; @@ -45,9 +44,6 @@ public boolean isPrintFormatGdiDriver() { return (mPrintFormat == mPrintFormatIsGdiDriver); } - public boolean shouldPrintBarCodes() { - return mShouldPrintBarCodes; - } public boolean isPrintOrderAsDisplayedOrSelected() { return (mPrintOrder == mPrintOrderAsDisplayedOrSelected); } @@ -86,9 +82,6 @@ public void setPrintFormatIsGdiDriver() { mPrintFormat = mPrintFormatIsGdiDriver; } - public void setShouldPrintBarCodes(boolean yesOrNo) { - mShouldPrintBarCodes = yesOrNo; - } public void setPrintOrderAsDisplayedOrSelected() { mPrintOrder = mPrintOrderAsDisplayedOrSelected; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-06-21 18:43:39
|
Revision: 91 http://openpcl.svn.sourceforge.net/openpcl/?rev=91&view=rev Author: documentsystems Date: 2007-06-21 11:43:40 -0700 (Thu, 21 Jun 2007) Log Message: ----------- Howard Hoagland. On the Printer Setup dialog, commented out the lines of code that added items on the screen that were not implemented yet, but I'll add them back on the Printer Setup dialog after I implement them later: Print Bar Codes, Print Legal pages first then Letter pages, Print Letter pages first then Legal, force Duplex (front and back), Print Form Names, Print all on Legal paper even if Letter size. Moved the "Note that:" 3 items from the Printer Setup dialog to the hover help tooltip text. Changed the print mode check box from "Printer supports PCL (is an HP LaserJet XX)" changed to "Use Windows Print (recommended)". Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-18 21:35:52 UTC (rev 90) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-21 18:43:40 UTC (rev 91) @@ -2,6 +2,7 @@ import info.clearthought.layout.TableLayout; +import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -65,6 +66,8 @@ private double mTloHgap = 5; private double mTloVgap = 5; private String mSelectedPageNumbers = null; + private JDialog mAdvancedOptionsJDialog = null; + private JButton mAdvancedOptionsOkJButton = null; // Adjust to fonts private final Font mAdjustToSmallFont = getFont(); @@ -137,9 +140,10 @@ private JButton mOKJButton = new JButton("OK"); private JButton mCancelJButton = new JButton("Cancel"); private JButton mOpenJDKPrintDialogJButton = new JButton("Open JDK Print Dialog"); + private JButton mAdvancedOptionsJButton = new JButton("Advanced Options"); // JCheckBoxes - private JCheckBox mIsPclPrinterJCheckBox = new JCheckBox("Printer supports PCL (is an HP LaserJet XX)"); + private JCheckBox mIsPclPrinterJCheckBox = new JCheckBox("Use Windows Print (recommended)"); private JCheckBox mPrintAllOnLegalSizeJCheckBox = new JCheckBox("Print All Documents on Legal Size"); // JLists @@ -153,27 +157,20 @@ private static final String sBarCodeHoverString = "Bar codes already in the PCL are printed, but bar codes are not generated on the fly."; - private static final String sPrinterSupportsPclString = - "<html>Examples are:" + - "<ul>" + - "<li>HP LaserJet 1022" + - "<li>HP LaserJet P2015" + - "<li>HP LaserJet 2200" + - "<li>HP LaserJet 2400" + - "<li>HP LaserJet P3005" + - "<li>HP LaserJet 4050" + - "<li>HP LaserJet 4250" + - "<li>HP LaserJet 5000" + - "<li>HP LaserJet 5200" + - "<li>HP LaserJet 9040" + - "<li>HP LaserJet etc etc" + - "</ul></html>"; - private static final String sPrinterSupportsNotesString = - "Note that:\n" + - "1. If checked then pages print 3X faster but if not an HP LaserJet XX printer then printouts will not be correct.\n" + - "2. If pages print wrong then uncheck the box and try printing again.\n" + - "3. If the printer name doesn't say \"LaserJet\" even though it starts with \"HP\", then don't check the box."; + "<html><ul>" + + "<li>Windows print means the pages print correctly for all printers (is printer independent)." + + "<li>Unchecking the box requires that your printer be an HP LaserJet XX that supports PCL<br>" + + "and pages print 3 times faster than if checked, but if not an HP LaserJet XX printer<br>" + + "then printouts will not be correct." + + "<li>If pages print wrong then check the box and try printing again." + + "<li>If the printer name starts with \"HP\" but doesn't say \"LaserJet\", then check the box." + + "<li>Some examples of HP LaserJet printers (and you can uncheck the box) are:" + + "<table>" + + "<tr><td>HP LaserJet 1022,<td>HP LaserJet P2015,<td>HP LaserJet 2200,<td>HP LaserJet 2400,</tr>" + + "<tr><td>HP LaserJet P3005,<td>HP LaserJet 4050,<td>HP LaserJet 4250,<td>HP LaserJet 5000,</tr>" + + "<tr><td>HP LaserJet 5200,<td>HP LaserJet 9040,<td>HP LaserJet etc etc<td></tr>" + + "<table></ul></html>"; public PosPrintSetupDialog(PosView pPosView, String pTitleBarText, PosPrintSetupDialogChoices pPrintChoices, PrintRequestAttributeSet pAttributes, PrinterJob pPrinterJob, String pSelectedPageNumbers) @@ -181,6 +178,8 @@ super(pPosView.getOpenPCLViewer().getAppFrame(), pTitleBarText, true); mPosView = pPosView; mPosStartupOptions = mPosView.getOpenPCLViewer().getPosStartupOptions(); + // Set to false the show DSML buttons even if the user said true on the command line + mPosStartupOptions.setShowDSMLPrintDialogButtons(false); if (pPrintChoices == null) { mPrintChoices = new PosPrintSetupDialogChoices(); @@ -230,12 +229,12 @@ mTab1.setLayout(tloTab1Layout); mTab1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mTab1.add(mListOfPrintersJPanel, "0, 0, 2, 0"); - mTab1.add(mAddlCopiesJPanel, "0, 2, 2, 2"); +// mTab1.add(mAddlCopiesJPanel, "0, 2, 2, 2"); mTab1.add(mPrintAsPclJPanel, "0, 4, 2, 4"); - mTab1.add(mPrintBarCodesJPanel, "0, 6"); - mTab1.add(mPrintOrderJPanel, "2, 6"); - mTab1.add(mPrintFormNamesJPanel, "0, 8"); - mTab1.add(mDuplexJPanel, "2, 8"); +// mTab1.add(mPrintBarCodesJPanel, "0, 6"); +// mTab1.add(mPrintOrderJPanel, "2, 6"); +// mTab1.add(mPrintFormNamesJPanel, "0, 8"); +// mTab1.add(mDuplexJPanel, "2, 8"); // Lay out tab 2 items double tloTab2GridSpec[][] = new double[][] { @@ -247,11 +246,30 @@ mTab2.add(mPageNumbersThatWillPrintJLabel, "0, 0"); mPageNumbersThatWillPrintJTextArea.setLineWrap(true); mPageNumbersThatWillPrintJTextArea.setWrapStyleWord(true); - mPageNumbersThatWillPrintJTextArea.setText(mSelectedPageNumbers); + mPageNumbersThatWillPrintJTextArea.setText("Page numbers that will print:\n" + mSelectedPageNumbers); mPageNumbersThatWillPrintJTextArea.setEditable(false); + mPageNumbersThatWillPrintJTextArea.setPreferredSize(new Dimension(400, 200)); mPageNumbersThatWillPrintJScrollPane = new JScrollPane(mPageNumbersThatWillPrintJTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - mTab2.add(mPageNumbersThatWillPrintJScrollPane, "0, 2, 1, 2"); +// mTab2.add(mPageNumbersThatWillPrintJScrollPane, "0, 2, 1, 2"); + mAdvancedOptionsJDialog = new JDialog(mPosView.getOpenPCLViewer().getAppFrame(), "Advanced Options", true); + double tloAdvancedOptionsJDialog[][] = new double[][] { + { 10, mTloFill, mTloPref, 10}, // columns + { 10, mTloFill, 10, mTloPref, 10} // rows + }; + TableLayout tloAdvancedOptionsLayout = new TableLayout(tloAdvancedOptionsJDialog); + JPanel tJPanel = new JPanel(tloAdvancedOptionsLayout); + tJPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); + tJPanel.add("1, 1, 2, 1", mPageNumbersThatWillPrintJScrollPane); + mAdvancedOptionsOkJButton = new JButton("OK"); + mAdvancedOptionsOkJButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent pE) { + mAdvancedOptionsJDialog.setVisible(false); + } + }); + tJPanel.add("2, 3", mAdvancedOptionsOkJButton); + mAdvancedOptionsJDialog.setContentPane(tJPanel); + mAdvancedOptionsJDialog.setSize(400, 280); // Lay out tab 3 items double tloTab3GridSpec[][] = new double[][] { @@ -264,9 +282,9 @@ mTab3.add(mOpenJDKPrintDialogJButton, "0, 0"); // Add the tab panels to the JTabbedPane - mJTabbedPane.add(mTab1, "View Specific"); - mJTabbedPane.add(mTab2, "Index Numbers That Will Print"); - mJTabbedPane.add(mTab3, "Generic Properties"); +// mJTabbedPane.add(mTab1, "View Specific"); +// mJTabbedPane.add(mTab2, "Index Numbers That Will Print"); +// mJTabbedPane.add(mTab3, "Generic Properties"); // Add the Control Panel, JTabbedPane, and buttons panel to the contentPane double tloContentPaneGridSpec[][] = new double[][] { @@ -277,7 +295,8 @@ mControlJPanel = makeControlPanel(); mBottomButtonsJPanel = makeBottomButtonsPanel(); add(mControlJPanel, "1, 1"); - add(mJTabbedPane, "1, 2"); +// add(mJTabbedPane, "1, 2"); + add(mTab1, "1, 2"); add(mBottomButtonsJPanel, "1, 4"); // ActionListeners @@ -329,6 +348,13 @@ } }); + mAdvancedOptionsJButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + mAdvancedOptionsJDialog.setLocationRelativeTo(mPosView.getOpenPCLViewer().getAppFrame()); + mAdvancedOptionsJDialog.setVisible(true); + } + }); + mOKJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getPrintChoicesFromScreen(); @@ -409,7 +435,7 @@ TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); panel.add(mIsPclPrinterJCheckBox," 1, 0, 2, 0"); - panel.add(mPrinterSupportsPclJScrollPane," 2, 1"); +// panel.add(mPrinterSupportsPclJScrollPane," 2, 1"); return panel; } @@ -489,7 +515,8 @@ mTloPref, mTloFill, mTloPref, mTloHgap, mTloPref}, { mTloPref }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); - panel.add(mPrintAllOnLegalSizeJCheckBox, "0, 0"); +// panel.add(mPrintAllOnLegalSizeJCheckBox, "0, 0"); + panel.add(mAdvancedOptionsJButton, "0, 0"); panel.add(mOKJButton, "2, 0"); panel.add(mCancelJButton, "4, 0"); return panel; @@ -497,7 +524,7 @@ private void putPrintChoicesOnScreen() { mAddlCopiesJTextField.setText(Integer.toString(mPrintChoices.getNumAdditionalCopies())); - mIsPclPrinterJCheckBox.setSelected(mPrintChoices.isPrintFormatPclDirect()); + mIsPclPrinterJCheckBox.setSelected(!(mPrintChoices.isPrintFormatPclDirect())); mPrintBarCodesYesJRadioButton.setSelected(mPrintChoices.shouldPrintBarCodes()); mPrintBarCodesNoJRadioButton.setSelected( !(mPrintChoices.shouldPrintBarCodes()) ); mPrintOrderAsDisplayedOrSelectedJRadioButton.setSelected(mPrintChoices.isPrintOrderAsDisplayedOrSelected()); @@ -525,9 +552,9 @@ // Print format if (mIsPclPrinterJCheckBox.isSelected()) { + mPrintChoices.setPrintFormatIsGdiDriver(); + } else { mPrintChoices.setPrintFormatIsPclDirect(); - } else { - mPrintChoices.setPrintFormatIsGdiDriver(); } // Print bar codes @@ -586,6 +613,8 @@ mItemsOnDialogBox.add(mOKJButton); mItemsOnDialogBox.add(mCancelJButton); mItemsOnDialogBox.add(mJTabbedPane); + mItemsOnDialogBox.add(mAdvancedOptionsOkJButton); + mItemsOnDialogBox.add(mAdvancedOptionsJButton); } private void adjustFontOnDialogItems(Font pFont) { @@ -607,7 +636,8 @@ private void makePanelTitledBorders() { mListOfPrintersJPanel.setBorder(generateTitledBorder("Installed Printers")); - mPrintAsPclJPanel.setBorder(generateTitledBorder("Printer Supports PCL ?")); +// mPrintAsPclJPanel.setBorder(generateTitledBorder("Printer Supports PCL ?")); + mPrintAsPclJPanel.setBorder(BorderFactory.createEmptyBorder()); mPrintBarCodesJPanel.setBorder(generateTitledBorder("Print Bar Codes")); mPrintOrderJPanel.setBorder(generateTitledBorder("Print Order")); mPrintFormNamesJPanel.setBorder(generateTitledBorder("Print Form Names")); @@ -687,8 +717,7 @@ private void setHoverHelpOnItems() { mAddlCopiesJTextField.setToolTipText(sNotImplementedString + "Additional copies"); - mIsPclPrinterJCheckBox.setToolTipText(sPrinterSupportsPclString); - mPrinterSupportsPclJTextArea.setToolTipText(sPrinterSupportsPclString); + mIsPclPrinterJCheckBox.setToolTipText(sPrinterSupportsNotesString); mPrintBarCodesYesJRadioButton.setToolTipText(sBarCodeHoverString); mPrintBarCodesNoJRadioButton.setToolTipText(sBarCodeHoverString); mPrintOrderAsDisplayedOrSelectedJRadioButton.setToolTipText("Print pages in the order shown in the tree"); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-06-18 21:35:52 UTC (rev 90) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-06-21 18:43:40 UTC (rev 91) @@ -18,7 +18,7 @@ // TODO Add code to take the defaults from the user options in the Preferences, instead of the below initializations private PrintService mSelectedPrintService = null; private int mNumAdditionalCopies = 0; - private int mPrintFormat = mPrintFormatIsPclDirect; + private int mPrintFormat = mPrintFormatIsGdiDriver; private boolean mShouldPrintBarCodes = false; private int mPrintOrder = mPrintOrderAsDisplayedOrSelected; private boolean mShouldPrintFormNames = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-06-21 22:41:23
|
Revision: 93 http://openpcl.svn.sourceforge.net/openpcl/?rev=93&view=rev Author: documentsystems Date: 2007-06-21 15:41:24 -0700 (Thu, 21 Jun 2007) Log Message: ----------- Howard Hoagland. Changes to Printer Setup dialog. 1. Change title to say "Print" instead of "Printer Setup" and take off the title bar "Print All" or "Print Selected" or "Print Remaining" and take off the title bar how many pages will print, just say "Print" in the title bar. 2. Remove the Advanced Options button so that the user can't get the dialog that shows what pages will print. 3. Remove the "More Info" button that shows text about checking or unchecking the "Use Windows Print". 4. Center the OK and Cancel buttons on the bottom and make the buttons the same size. 5. Change the hover text on the "Use Windows Print" to say "Unselect if printer supports PCL (Example: HP LaserJet 4050)" instead of the longer instructions text that was there before. 6. Change the border title of the list of installed printers to be "Printers" instead of "Installed Printers". Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-21 19:38:33 UTC (rev 92) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-06-21 22:41:24 UTC (rev 93) @@ -205,8 +205,10 @@ mPrinterJob = PrinterJob.getPrinterJob(); // Put up our custom printer setup dialog - String tDialogTitleBarString = "Printer Setup. " + mTitleBarTextForPrintDialog[pProcessPrintType] + " (" + - tNumberOfPagesThatWillPrint + (tNumberOfPagesThatWillPrint ==1 ? " page" : " pages") + " will print)"; +// String tDialogTitleBarString = "Print" + mTitleBarTextForPrintDialog[pProcessPrintType] + " (" + +// tNumberOfPagesThatWillPrint + (tNumberOfPagesThatWillPrint ==1 ? " page" : " pages") + " will print)"; + + String tDialogTitleBarString = "Print"; mPosPrintSetupDialog = new PosPrintSetupDialog(mPosView, tDialogTitleBarString, mPosPrintSetupDialogChoices, mAttributes, mPrinterJob, tStringBuffer.toString()); @@ -444,7 +446,7 @@ mPrinterJob = PrinterJob.getPrinterJob(); // Put up our custom printer setup dialog - mPosPrintSetupDialog = new PosPrintSetupDialog(mPosView, "Printer Setup", + mPosPrintSetupDialog = new PosPrintSetupDialog(mPosView, "Print", mPosPrintSetupDialogChoices, mAttributes, mPrinterJob, "No pages will print at this time because this is Printer Setup options only. Make sure to hit OK to save your changes."); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-21 19:38:33 UTC (rev 92) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-06-21 22:41:24 UTC (rev 93) @@ -160,6 +160,9 @@ private static final String sBarCodeHoverString = "Bar codes already in the PCL are printed, but bar codes are not generated on the fly."; + private static final String sPrinterModeHoverOverString = + "<html>Unselect if printer supports PCL (Example: HP LaserJet 4050)</html>"; + private static final String sPrinterSupportsNotesString = "<html><ul>" + "<li>Windows print means the pages print correctly for all printers (is printer independent)." + @@ -447,12 +450,12 @@ private JPanel makePrintAsPclPanel() { JPanel panel = new JPanel(); - double tloGridSpec[][] = new double[][] {{ mTloPref, 5, mTloPref, mTloFill}, + double tloGridSpec[][] = new double[][] {{ mTloPref, mTloFill}, { mTloPref}}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); panel.add(mIsPclPrinterJCheckBox, " 0, 0"); - panel.add(mPrintModeMoreInfoJButton, "2,0"); +// panel.add(mPrintModeMoreInfoJButton, "2,0"); // panel.add(mPrinterSupportsPclJScrollPane," 2, 1"); return panel; } @@ -530,11 +533,13 @@ private JPanel makeBottomButtonsPanel() { JPanel panel = new JPanel(); double tloGridSpec[][] = new double[][] {{ - mTloPref, mTloFill, mTloPref, mTloHgap, mTloPref}, { mTloPref }}; + mTloHgap, mTloFill, mTloPref, mTloHgap, mTloPref, mTloFill, mTloHgap}, { mTloPref }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); // panel.add(mPrintAllOnLegalSizeJCheckBox, "0, 0"); - panel.add(mAdvancedOptionsJButton, "0, 0"); +// panel.add(mAdvancedOptionsJButton, "0, 0"); + mOKJButton.setPreferredSize(mCancelJButton.getPreferredSize()); // Make Ok button same width as Cancel button + mOKJButton.setMinimumSize(mCancelJButton.getPreferredSize()); panel.add(mOKJButton, "2, 0"); panel.add(mCancelJButton, "4, 0"); return panel; @@ -654,7 +659,8 @@ } private void makePanelTitledBorders() { - mListOfPrintersJPanel.setBorder(generateTitledBorder("Installed Printers")); +// mListOfPrintersJPanel.setBorder(generateTitledBorder("Installed Printers")); + mListOfPrintersJPanel.setBorder(generateTitledBorder("Printers")); // mPrintAsPclJPanel.setBorder(generateTitledBorder("Printer Supports PCL ?")); mPrintAsPclJPanel.setBorder(BorderFactory.createEmptyBorder()); mPrintBarCodesJPanel.setBorder(generateTitledBorder("Print Bar Codes")); @@ -736,7 +742,7 @@ private void setHoverHelpOnItems() { mAddlCopiesJTextField.setToolTipText(sNotImplementedString + "Additional copies"); - mIsPclPrinterJCheckBox.setToolTipText(sPrinterSupportsNotesString); + mIsPclPrinterJCheckBox.setToolTipText(sPrinterModeHoverOverString); mPrintBarCodesYesJRadioButton.setToolTipText(sBarCodeHoverString); mPrintBarCodesNoJRadioButton.setToolTipText(sBarCodeHoverString); mPrintOrderAsDisplayedOrSelectedJRadioButton.setToolTipText("Print pages in the order shown in the tree"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-07-04 01:45:14
|
Revision: 101 http://openpcl.svn.sourceforge.net/openpcl/?rev=101&view=rev Author: documentsystems Date: 2007-07-03 18:45:14 -0700 (Tue, 03 Jul 2007) Log Message: ----------- Howard Hoagland. Implemented "Additional Copies" with user input validation checking dialogs for must be numeric, and must be between 0 and 3, and made Additional Copies work with "Print All Documents on Legal Size" for both Windows Print and "Print PCL Direct", and tested many different combination print scenarios. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-03 21:44:07 UTC (rev 100) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-04 01:45:14 UTC (rev 101) @@ -65,12 +65,14 @@ public static final int sProcessPrintChanged = 2; public static final int sProcessPrintRemaining = 3; private int mProcessPrintType = 0; + private int mNumberOfPagesThatWillPrint = 0; private static final String[] mTitleBarTextForPrintDialog = { "Print All", "Print Selected", "Print Changed", "Print Remaining"}; public static byte sbESC = 0x1B; // Escape char public static byte sbFF = 0xC; // Form Feed ( char(12) ) private PriModifyPclBytes mPriModifyPclBytes = null; private PclParser mPclParser = null; + private StringBuffer mIndexNumbersStringBuffer = null; private int mNumberOfPrintPasses = 1; private int mCurrentPrintPassNumber = 1; @@ -131,25 +133,25 @@ // Save the parameter print type (all, selected, changed, or remaining) mProcessPrintType = pProcessPrintType; - StringBuffer tStringBuffer = new StringBuffer(); + mIndexNumbersStringBuffer = new StringBuffer(); mPagesToPrintArrayList = null; // Depending on if print all, print selected, print changed, print remaining, get which pages to print switch (mProcessPrintType) { case sProcessPrintAll: mPagesToPrintArrayList = mPosView.getPosBuildListOfPagesToPrint().makeArrayListofAllPages(); - tStringBuffer.append("\"Print all\""); + mIndexNumbersStringBuffer.append("\"Print all\""); break; case sProcessPrintSelected: mPagesToPrintArrayList = mPosView.getPosBuildListOfPagesToPrint().makeArrayListofSelectedPages(); - tStringBuffer.append("\"Print selected\""); + mIndexNumbersStringBuffer.append("\"Print selected\""); break; case sProcessPrintChanged: mPagesToPrintArrayList = mPosView.getPosBuildListOfPagesToPrint().makeArrayListofChangedPages(); - tStringBuffer.append("\"Print changed\""); + mIndexNumbersStringBuffer.append("\"Print changed\""); break; case sProcessPrintRemaining: mPagesToPrintArrayList = mPosView.getPosBuildListOfPagesToPrint().makeArrayListofRemainingPages(); - tStringBuffer.append("\"Print remaining\""); + mIndexNumbersStringBuffer.append("\"Print remaining\""); break; } @@ -184,21 +186,21 @@ return false; } - int tNumberOfPagesThatWillPrint = mPagesToPrintArrayList.size(); + mNumberOfPagesThatWillPrint = mPagesToPrintArrayList.size(); // Append all the selected page numbers to the StringBuffer - tStringBuffer.append(" " + tNumberOfPagesThatWillPrint + " page"); - if (tNumberOfPagesThatWillPrint == 1) { - tStringBuffer.append(". Index number: "); + mIndexNumbersStringBuffer.append(" " + mNumberOfPagesThatWillPrint + " page"); + if (mNumberOfPagesThatWillPrint == 1) { + mIndexNumbersStringBuffer.append(". Index number: "); } else { - tStringBuffer.append("s. Index numbers are: "); + mIndexNumbersStringBuffer.append("s. Index numbers are: "); } - for (int i = 0; i < tNumberOfPagesThatWillPrint; i++) { + for (int i = 0; i < mNumberOfPagesThatWillPrint; i++) { PosTreeNode eachNode = (PosTreeNode) mPagesToPrintArrayList.get(i); - tStringBuffer.append(eachNode.getNodeNumber()); - if (i < tNumberOfPagesThatWillPrint -1) { - tStringBuffer.append(", "); + mIndexNumbersStringBuffer.append(eachNode.getNodeNumber()); + if (i < mNumberOfPagesThatWillPrint -1) { + mIndexNumbersStringBuffer.append(", "); } } @@ -212,7 +214,7 @@ String tDialogTitleBarString = "Print"; mPosPrintSetupDialog = new PosPrintSetupDialog(mPosView, tDialogTitleBarString, - mPosPrintSetupDialogChoices, mAttributes, mPrinterJob, tStringBuffer.toString()); + mPosPrintSetupDialogChoices, mAttributes, mPrinterJob, mIndexNumbersStringBuffer.toString()); mPosPrintSetupDialog.setLocationRelativeTo(mParentFrame); mPosPrintSetupDialog.setVisible(true); @@ -234,7 +236,7 @@ return false; } - mPrintingProgressBar.setMaximum(tNumberOfPagesThatWillPrint); + mPrintingProgressBar.setMaximum(mNumberOfPagesThatWillPrint); mPrintingProgressBar.setString("Initializing..."); mPrintingProgressBar.setValue(0); mPrintingProgressJDialog.setLocationRelativeTo(mParentFrame); @@ -250,16 +252,40 @@ // Show the JDialog that has the JProgressBar threadShowProgressBar.start(); - // Depending on the choice in our custom printer setup dialog of PCL Direct or Image Print + StringBuffer tMsgStringBuffer = new StringBuffer(); + tMsgStringBuffer.append(" to printer selected: "); + tMsgStringBuffer.append(mPrintService.getName()); + tMsgStringBuffer.append("\n Additional Copies is " + mPosPrintSetupDialogChoices.getNumAdditionalCopies()); + tMsgStringBuffer.append("\n Print all Documents on Legal Size is "); + if (mPosPrintSetupDialogChoices.shouldPrintAllOnLegalSize()) { + tMsgStringBuffer.append("\"True\""); + } else { + tMsgStringBuffer.append("\"False\""); + } + tMsgStringBuffer.append("\n " + mIndexNumbersStringBuffer); + + // Console output print type "Use Windows Print" or "Print PCL Direct" if (mPosPrintSetupDialogChoices.isPrintFormatPclDirect()) { - PriDebug.releaseln("Printing Pcl Direct using printer selected: " + mPrintService.getName()); - mPrintedOkReturn = printPclDirect(mPagesToPrintArrayList, mPosPrintSetupDialogChoices, - mPrintingProgressBar, mAttributes); + PriDebug.releaseln("\"Print PCL Direct\"" + tMsgStringBuffer.toString()); } else { - PriDebug.releaseln("Image Print using printer selected: " + mPrintService.getName()); - mPrintedOkReturn = imagePrint(mPagesToPrintArrayList, mPosPrintSetupDialogChoices, - mPrintingProgressBar, mAttributes); + PriDebug.releaseln("\"Windows Print\"" + tMsgStringBuffer.toString()); } + + // The number of additional copies has already been validated and is guaranteed to be 0 to 3 at this point + mNumberOfPrintPasses = 1 + mPosPrintSetupDialogChoices.getNumAdditionalCopies(); + + // Call the print of the all/selected/remaining/changed pages "N" times depending on Additional Copies field + for (int i = 1; i <= mNumberOfPrintPasses; i++) { + // Call "Use Windows Print" or "Print PCL Direct" + if (mPosPrintSetupDialogChoices.isPrintFormatPclDirect()) { + mPrintedOkReturn = printPclDirect(mPagesToPrintArrayList, mPosPrintSetupDialogChoices, + mPrintingProgressBar, mAttributes); + } else { + mPrintedOkReturn = imagePrint(mPagesToPrintArrayList, mPosPrintSetupDialogChoices, + mPrintingProgressBar, mAttributes); + } + } + return null; } Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-03 21:44:07 UTC (rev 100) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-04 01:45:14 UTC (rev 101) @@ -5,6 +5,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Font; +import java.awt.Frame; import java.awt.GridLayout; import java.awt.HeadlessException; import java.awt.event.ActionEvent; @@ -58,6 +59,7 @@ private static final long serialVersionUID = 1L; private PosView mPosView = null; private PosStartupOptions mPosStartupOptions = null; + private Frame mParentFrame = null; private PosPrintSetupDialogChoices mPrintChoices = null; private PrintRequestAttributeSet mAttributes = null; private PrinterJob mPrinterJob = null; @@ -167,6 +169,7 @@ super(pPosView.getOpenPCLViewer().getAppFrame(), pTitleBarText, true); mPosView = pPosView; mPosStartupOptions = mPosView.getOpenPCLViewer().getPosStartupOptions(); + mParentFrame = mPosView.getOpenPCLViewer().getAppFrame(); // Set to false the show DSML buttons even if the user said true on the command line mPosStartupOptions.setShowDSMLPrintDialogButtons(false); @@ -208,7 +211,7 @@ mTab1.add(mListOfPrintersJPanel, "0, 0, 2, 0"); mTab1.add(mWindowsPrintOrPclPrintJPanel, "0, 1, 2, 1"); mTab1.add(mPrintAllOnLegalSizeJCheckBox, "0, 2, 2, 2"); -// mTab1.add(mAddlCopiesJPanel, "0, 3, 2, 3"); + mTab1.add(mAddlCopiesJPanel, "0, 3, 2, 3"); // mTab1.add(mPrintBarCodesJPanel, "0, 6"); // mTab1.add(mPrintOrderJPanel, "2, 6"); @@ -231,7 +234,7 @@ mPageNumbersThatWillPrintJScrollPane = new JScrollPane(mPageNumbersThatWillPrintJTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // mTab2.add(mPageNumbersThatWillPrintJScrollPane, "0, 2, 1, 2"); - mAdvancedOptionsJDialog = new JDialog(mPosView.getOpenPCLViewer().getAppFrame(), "Advanced Options", true); + mAdvancedOptionsJDialog = new JDialog(mParentFrame, "Advanced Options", true); double tloAdvancedOptionsJDialog[][] = new double[][] { { 10, mTloFill, mTloPref, 10}, // columns { 10, mTloFill, 10, mTloPref, 10} // rows @@ -276,7 +279,7 @@ // ActionListeners mPrintModeMoreInfoJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - JOptionPane.showMessageDialog(mPosView.getOpenPCLViewer().getAppFrame(), sPrinterModeHoverOverString, + JOptionPane.showMessageDialog(mParentFrame, sPrinterModeHoverOverString, "Info for \"Use Windows Print\"", JOptionPane.INFORMATION_MESSAGE); } }); @@ -331,7 +334,7 @@ mAdvancedOptionsJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - mAdvancedOptionsJDialog.setLocationRelativeTo(mPosView.getOpenPCLViewer().getAppFrame()); + mAdvancedOptionsJDialog.setLocationRelativeTo(mParentFrame); mAdvancedOptionsJDialog.setVisible(true); } }); @@ -344,9 +347,11 @@ mOKJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - getPrintChoicesFromScreen(); - mPrintChoices.setUserHitOk(true); - setVisible(false); + if (!hasUserInputErrors()) { + getPrintChoicesFromScreen(); + mPrintChoices.setUserHitOk(true); + setVisible(false); + } } }); @@ -534,9 +539,11 @@ // Additional copies try { - int addlCopies = Integer.parseInt(mAddlCopiesJTextField.getText()); + int addlCopies = Integer.parseInt(mAddlCopiesJTextField.getText().trim()); mPrintChoices.setNumAdditionalCopies(addlCopies); } catch (NumberFormatException e) { + // A blank field will get a NumberFormatException and below it will be set to 0. + // Previous validation in hasUserInputErrors() doesn't allow OK to continue if non numeric or not 0 to 3 is entered mPrintChoices.setNumAdditionalCopies(0); } @@ -745,6 +752,39 @@ } } + private boolean hasUserInputErrors() { + final String tUserInputNumberRequiredString = "A number is required for Additional Copies."; + final String tUserInputValidRange0to3String = "The valid range for Additional Copies is 0 to 3."; + final String tUserInputTitleString = "Problem with Additional Copies field"; + + String tAddlCopiesString = mAddlCopiesJTextField.getText(); + if (tAddlCopiesString.trim().equalsIgnoreCase("")) { + // returning false means the screen passed user input validation (blank is treated as 0) + return false; + } + + int tAddlCopiesInt = 0; + try { + tAddlCopiesInt = Integer.parseInt(tAddlCopiesString); + } catch (NumberFormatException nfe) { + JOptionPane.showMessageDialog(mParentFrame, tUserInputNumberRequiredString, + tUserInputTitleString, JOptionPane.INFORMATION_MESSAGE); + // returning true means the screen didn't pass user input validation + return true; + } + + if (tAddlCopiesInt < 0 || tAddlCopiesInt > 3) { + JOptionPane.showMessageDialog(mParentFrame, tUserInputValidRange0to3String, + tUserInputTitleString, JOptionPane.INFORMATION_MESSAGE); + // returning true means the screen didn't pass user input validation + return true; + + } else { + // returning false means the screen passed user input validation + return false; + } + } + private class ListOfPrintersSelectionListener implements ListSelectionListener { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |