From: <doc...@us...> - 2007-07-07 01:01:09
|
Revision: 104 http://openpcl.svn.sourceforge.net/openpcl/?rev=104&view=rev Author: documentsystems Date: 2007-07-06 18:01:10 -0700 (Fri, 06 Jul 2007) Log Message: ----------- Howard Hoagland. Changed 4 files: OpenPCLViewer, PosUserOptionsDialog, PosPrintPages, PosPrintSetupDialog to implement share user options for the "Print Setup Defaults" dialog user choices with per print settings on the Print dialog. User choices made on the "Print Setup Defaults" dialog didn't take effect on the per each print "Print" dialog, and it wasn't possible to show the "Print Setup Defaults" dialog until the user opened a PCL file or a Blockument. Fixed both problems by moving the instantiation of the PosPrintSetupOptions object from the PosView object for each open file, higher up in the conatainment hierarchy to the OpenPCLviewer class, then for showing both the Print Setup Defaults dialog from the User Options dialog, and for each printout, passed in the same PosPrintSetupOptions, so changing any print option in either place effects the other one bidirectionally. Fixing this problem needed to be done before the Print Setup Defaults can be persisted in a platform independent way (the running platform's JVM writes to the Windows registry when running on Windows, or does it the Macintosh way when running on a Macintosh) so that the data flow between persistent local storage on the client PC/Macintosh is the same data that gets set on the Print Setup Defaults dialog via the User Options dialog, and also the same settings on the Print dialog for each printout, then saved back to persistent storage. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/OpenPCLViewer.java openpcl/src/com/openpcl/viewer/options/PosUserOptionsDialog.java openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java Modified: openpcl/src/com/openpcl/viewer/OpenPCLViewer.java =================================================================== --- openpcl/src/com/openpcl/viewer/OpenPCLViewer.java 2007-07-06 20:27:56 UTC (rev 103) +++ openpcl/src/com/openpcl/viewer/OpenPCLViewer.java 2007-07-07 01:01:10 UTC (rev 104) @@ -169,12 +169,12 @@ private PosHtmlViewerButtonChoicesDialog mHelpAboutDialog = null; private PosHtmlViewerButtonChoicesDialog mLicenseInfoDialog = null; private PosUserOptionsDialog mPosUserOptionsDialog = null; - private PosPrintSetupDialogChoices mPosUserOptionsPosPrintSetupDialogChoices = null; private ComponentListener mFrameComponentListener = null; private String mFilePathAndFileName = "C:\\"; private Preferences mPackagePreferences = null; private PosPersistViewValues mPosPersistViewValues = null; private PosStartupOptions mPosStartupOptions = null; + private PosPrintSetupDialogChoices mPosPrintSetupDialogChoices = null; private int mViewframeX = 0; private int mViewframeY = 0; private int mViewframeWidth = 100; @@ -644,6 +644,10 @@ mHelpAboutDialog.pack(); } + //----- Print Setup Defaults dialog and Print dialog (same dialog for both defaults and per print) + mPosPrintSetupDialogChoices = new PosPrintSetupDialogChoices(); + mPosUserOptionsDialog = new PosUserOptionsDialog(mPosPrintSetupDialogChoices, this, "Options Dialog", true); + //----- Print choices list mPosPrintChoicesList = new PosPrintChoicesList(createPrintChoicesListSelectionListener()); // Popup dialog for print choices list @@ -781,6 +785,7 @@ public PosView getPosViewSelected() { return mPosViewSelected; } public String getFilePathAndFileName() { return mFilePathAndFileName; } public PosStartupOptions getPosStartupOptions() { return mPosStartupOptions; } + public PosPrintSetupDialogChoices getPosPrintSetupDialogChoices() { return mPosPrintSetupDialogChoices; } // One line setters public void setIsDrawingForPrinting(boolean pIsDrawingForPrinting) { mIsDrawingForPrinting = pIsDrawingForPrinting; } @@ -943,6 +948,7 @@ SwingUtilities.updateComponentTreeUI(mPosHelpChoicesPopupDialog); SwingUtilities.updateComponentTreeUI(mLicenseInfoDialog); SwingUtilities.updateComponentTreeUI(mHelpAboutDialog); + SwingUtilities.updateComponentTreeUI(mPosUserOptionsDialog); if (mPosViewArray != null && mPosViewArray.length > 0) { for (PosView tPosView : mPosViewArray) { @@ -2259,14 +2265,8 @@ /** Show the Options dialog */ public void actionShowOptionsDialog() { - if (mPosUserOptionsDialog == null) { - mPosUserOptionsPosPrintSetupDialogChoices = new PosPrintSetupDialogChoices(); - } - mPosUserOptionsDialog = new PosUserOptionsDialog( - mPosUserOptionsPosPrintSetupDialogChoices, this, "Options Dialog", true); mPosUserOptionsDialog.setLocationRelativeTo(getAppFrame()); mPosUserOptionsDialog.setVisible(true); - // TODO read the values that were set in the user options dialog and handle the different settings } Modified: openpcl/src/com/openpcl/viewer/options/PosUserOptionsDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/options/PosUserOptionsDialog.java 2007-07-06 20:27:56 UTC (rev 103) +++ openpcl/src/com/openpcl/viewer/options/PosUserOptionsDialog.java 2007-07-07 01:01:10 UTC (rev 104) @@ -26,6 +26,7 @@ import com.openpcl.viewer.OpenPCLViewer; import com.openpcl.viewer.panels.PosView; +import com.openpcl.viewer.printing.PosPrintSetupDialog; import com.openpcl.viewer.printing.PosPrintSetupDialogChoices; import com.openpcl.viewer.util.PosReadImageIcon; @@ -37,6 +38,9 @@ private OpenPCLViewer mOpenPCLViewer = null; private Frame mParentFrame = null; + // Dialogs + private PosPrintSetupDialog mPosPrintSetupDialog = null; + // Values for laying out panels, buttons, labels, textfields private double mTloPref = TableLayout.PREFERRED; private double mTloFill = TableLayout.FILL; @@ -69,7 +73,7 @@ // Buttons private JButton mCreateShortcutJButton = new JButton(PosReadImageIcon.read("pclIcon_32x32.png")); private JButton mRegisterFileTypeJButton = new JButton(PosReadImageIcon.read("PageNewBig.gif")); - private JButton mPrinterSetupDefaultsJButton = new JButton("Printer Setup dialog"); + private JButton mPrinterSetupDefaultsJButton = new JButton("Print Setup Defaults"); private JButton mEMailAdvancedSettingsJButton = new JButton("Advanced Settings for EMail"); private JButton mScanningSetupJButton = new JButton("Scanning Setup"); private JButton mCheckForUpdatesJButton = new JButton("Check for Updates Now"); @@ -123,7 +127,6 @@ private static final String sNotImplementedString = "Not implemented: "; // Constructor - public PosUserOptionsDialog(PosPrintSetupDialogChoices pPosPrintSetupDialogChoices, OpenPCLViewer pOpenPCLViewer, String pTitleString, boolean pIsModal) { @@ -180,14 +183,7 @@ private void addActionListeners() { mPrinterSetupDefaultsJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - PosView tPosView = mOpenPCLViewer.getPosViewSelected(); - if (tPosView != null) { - tPosView.getPosPrintPages().showPrintDialog(); - } else { - JOptionPane.showMessageDialog(mParentFrame, "To show the Print Setup dialog, a file needs to be opened", - "To show the Print Setup dialog", - JOptionPane.WARNING_MESSAGE); - } + showPrintSetupDefaultsDialog(); } }); @@ -207,6 +203,15 @@ }); } + private void showPrintSetupDefaultsDialog() { + mPosPrintSetupDialog = new PosPrintSetupDialog(mParentFrame, "Print Setup Defaults", + mOpenPCLViewer.getPosStartupOptions(), mPosPrintSetupDialogChoices, + null, null, "No pages will print at this time because this is Printer Setup Defaluts."); + + mPosPrintSetupDialog.setLocationRelativeTo(mParentFrame); + mPosPrintSetupDialog.setVisible(true); + } + private void makePanelTitledBorders() { mPrintingOptionsJPanel.setBorder(generateTitledBorder(mPrintingGroupBoxString)); mEMailJPanel.setBorder(generateTitledBorder(mEMailGroupBoxString)); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-06 20:27:56 UTC (rev 103) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-07 01:01:10 UTC (rev 104) @@ -85,11 +85,11 @@ super(); mPosView = pPosView; mParentFrame = mPosView.getOpenPCLViewer().getAppFrame(); + mPosPrintSetupDialogChoices = mPosView.getOpenPCLViewer().getPosPrintSetupDialogChoices(); mPosPrintBufferedImage = new PosPrintBufferedImage(mPosView); mPosPrintPageableInterface = new PosPrintPageableInterface(mPosView); mPriModifyPclBytes = new PriModifyPclBytes(); mAttributes = new HashPrintRequestAttributeSet(); - mPosPrintSetupDialogChoices = new PosPrintSetupDialogChoices(); mPrintingProgressBar = new JProgressBar(); mPrintingProgressBar.setStringPainted(true); mPrintingProgressBar.setIndeterminate(false); @@ -113,7 +113,7 @@ mAttributes.add(PrintQuality.HIGH); mAttributes.add(MediaSize.findMedia(8.5f, 14.0f, Size2DSyntax.INCH)); mAttributes.add(Sides.ONE_SIDED); - mAttributes.add(new JobName("OpenPCL OpenPCLViewer print", Locale.getDefault())); + mAttributes.add(new JobName(mPosView.getOpenPCLViewer().getAppName() + " print", Locale.getDefault())); mAttributes.add(new MediaPrintableArea(0.20f, 0.20f, 8.1f, 13.6f, MediaPrintableArea.INCH)); } @@ -210,11 +210,11 @@ // Put up our custom printer setup dialog // String tDialogTitleBarString = "Print" + mTitleBarTextForPrintDialog[pProcessPrintType] + " (" + // tNumberOfPagesThatWillPrint + (tNumberOfPagesThatWillPrint ==1 ? " page" : " pages") + " will print)"; - String tDialogTitleBarString = "Print"; - mPosPrintSetupDialog = new PosPrintSetupDialog(mPosView, tDialogTitleBarString, - mPosPrintSetupDialogChoices, mAttributes, mPrinterJob, mIndexNumbersStringBuffer.toString()); + mPosPrintSetupDialog = new PosPrintSetupDialog(mParentFrame, tDialogTitleBarString, + mPosView.getOpenPCLViewer().getPosStartupOptions(), mPosPrintSetupDialogChoices, + mAttributes, mPrinterJob, mIndexNumbersStringBuffer.toString()); mPosPrintSetupDialog.setLocationRelativeTo(mParentFrame); mPosPrintSetupDialog.setVisible(true); @@ -480,24 +480,4 @@ return true; } - public boolean showPrintDialog() { - // Get a new PrinterJob using its static method - mPrinterJob = PrinterJob.getPrinterJob(); - - // Put up our custom printer setup dialog - 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."); - - mPosPrintSetupDialog.setLocationRelativeTo(mParentFrame); - mPosPrintSetupDialog.setVisible(true); - - boolean userHitOk = mPosPrintSetupDialogChoices.getDidUserHitOk(); - - if (userHitOk) { - return true; - } else { - return false; - } - } } Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-06 20:27:56 UTC (rev 103) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-07 01:01:10 UTC (rev 104) @@ -165,13 +165,12 @@ private static final String sPrinterModeHoverOverString = "<html>Unselect if printer supports PCL (Example: HP LaserJet 4050)</html>"; - public PosPrintSetupDialog(PosView pPosView, String pTitleBarText, PosPrintSetupDialogChoices pPrintChoices, - PrintRequestAttributeSet pAttributes, PrinterJob pPrinterJob, String pSelectedPageNumbers) - throws HeadlessException { - super(pPosView.getOpenPCLViewer().getAppFrame(), pTitleBarText, true); - mPosView = pPosView; - mPosStartupOptions = mPosView.getOpenPCLViewer().getPosStartupOptions(); - mParentFrame = mPosView.getOpenPCLViewer().getAppFrame(); + public PosPrintSetupDialog(Frame pParentFrame, String pTitleBarText, PosStartupOptions pPosStartupOptions, + PosPrintSetupDialogChoices pPrintChoices, PrintRequestAttributeSet pAttributes, + PrinterJob pPrinterJob, String pSelectedPageNumbers) throws HeadlessException { + super(pParentFrame, pTitleBarText, true); + mPosStartupOptions = pPosStartupOptions; + mParentFrame = pParentFrame; // Set to false the show DSML buttons even if the user said true on the command line mPosStartupOptions.setShowDSMLPrintDialogButtons(false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |