From: <doc...@us...> - 2007-08-06 17:20:53
|
Revision: 140 http://openpcl.svn.sourceforge.net/openpcl/?rev=140&view=rev Author: documentsystems Date: 2007-08-06 10:20:55 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Howard Hoagland. New class to write all the print setup dialog options the user clicked on (Use Windows Print or print PCL Direct, Print as displayed, Legal first then Letter, Letter first then Legal, All on Legal, All on Letter (shrinks Legal), Print Form Names, Duplex), to the local persisted storage using the java.util.prefs.Preferences in a platform independent way. For Windows, it will write to the Registry at "HKEY_CURRENT_USER\Software\JavaSoft\Prefs\com\openpcl\viewer". For Macintosh, the Preferences object in the local running JVM writes the settings in a Macintosh specific way. Added Paths: ----------- openpcl/src/com/openpcl/viewer/printing/PosPersistPrintOptionsValues.java Added: openpcl/src/com/openpcl/viewer/printing/PosPersistPrintOptionsValues.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPersistPrintOptionsValues.java (rev 0) +++ openpcl/src/com/openpcl/viewer/printing/PosPersistPrintOptionsValues.java 2007-08-06 17:20:55 UTC (rev 140) @@ -0,0 +1,205 @@ +package com.openpcl.viewer.printing; + +import java.util.prefs.Preferences; + +/** + * Write the Print setup dialog options the user clicked on to persistent storage. + * @author DocMagic, Document Systems Inc, Howard H 8/3/07 + */ +public class PosPersistPrintOptionsValues { + // Keys for the get/set into Preferences object + private static final String KEY_PRINTOPTIONS_USE_WINDOWS_PRINT = "printoptions.use.windows.print"; + private static final String KEY_PRINTOPTIONS_PCL_DIRECT = "printoptions.pcl.direct"; + private static final String KEY_PRINTOPTIONS_AS_DISPLAYED = "printoptions.as.displayed"; + private static final String KEY_PRINTOPTIONS_LEGAL_THEN_LETTR = "printoptions.legal.then.letter"; + private static final String KEY_PRINTOPTIONS_LETTER_THEN_LEGAL = "printoptions.letter.then.legal"; + private static final String KEY_PRINTOPTIONS_ALL_ON_LEGAL = "printoptions.all.on.legal"; + private static final String KEY_PRINTOPTIONS_ALL_ON_LETTER = "printoptions.all.on.letter"; + private static final String KEY_PRINTOPTIONS_ADDITIONAL_COPIES = "printoptions.additional.copies"; + private static final String KEY_PRINTOPTIONS_PRINT_FORM_NAMES = "printoptions.print.form.names"; + private static final String KEY_PRINTOPTIONS_DUPLEX = "printoptions.duplex"; + + // Default if values are not currently saved in local persistence + private static final String PRINTOPTIONS_USE_WINDOWS_PRINT = "Y"; + private static final String PRINTOPTIONS_PCL_DIRECT = "N"; + private static final String PRINTOPTIONS_AS_DISPLAYED = "Y"; + private static final String PRINTOPTIONS_LEGAL_THEN_LETTR = "N"; + private static final String PRINTOPTIONS_LETTER_THEN_LEGAL = "N"; + private static final String PRINTOPTIONS_ALL_ON_LEGAL = "N"; + private static final String PRINTOPTIONS_ALL_ON_LETTER = "N"; + private static final String PRINTOPTIONS_ADDITIONAL_COPIES = "0"; + private static final String PRINTOPTIONS_PRINT_FORM_NAMES = "N"; + private static final String PRINTOPTIONS_DUPLEX = "N"; + + // Current settings to save/get. Before reading from the store, initially default to the above default values + public String mPrintOptionsUseWindowsPrint = PRINTOPTIONS_USE_WINDOWS_PRINT; + public String mPrintOptionsPclDirect = PRINTOPTIONS_PCL_DIRECT; + public String mPrintOptionsAsDisplayed = PRINTOPTIONS_AS_DISPLAYED; + public String mPrintOptionsLegalThenLetter = PRINTOPTIONS_LEGAL_THEN_LETTR; + public String mPrintOptionsLetterThenLegal = PRINTOPTIONS_LETTER_THEN_LEGAL; + public String mPrintOptionsAllOnLegal = PRINTOPTIONS_ALL_ON_LEGAL; + public String mPrintOptionsAllOnLetter = PRINTOPTIONS_ALL_ON_LETTER; + public String mPrintOptionsAdditionalCopies = PRINTOPTIONS_ADDITIONAL_COPIES; + public String mPrintOptionsPrintFormNames = PRINTOPTIONS_PRINT_FORM_NAMES; + public String mPrintOptionsDuplex = PRINTOPTIONS_DUPLEX; + + public PosPersistPrintOptionsValues() { + super(); + } + + /** + * Read print setup dialog option values from local persisted storage + * @param pPrefs + */ + public void readPrintOptionsValues(Preferences pPrefs) { + if (pPrefs == null) { + // If the passed in Preferences object is null, then set to defaults + mPrintOptionsUseWindowsPrint = PRINTOPTIONS_USE_WINDOWS_PRINT; + mPrintOptionsPclDirect = PRINTOPTIONS_PCL_DIRECT; + mPrintOptionsAsDisplayed = PRINTOPTIONS_AS_DISPLAYED; + mPrintOptionsLegalThenLetter = PRINTOPTIONS_LEGAL_THEN_LETTR; + mPrintOptionsLetterThenLegal = PRINTOPTIONS_LETTER_THEN_LEGAL; + mPrintOptionsAllOnLegal = PRINTOPTIONS_ALL_ON_LEGAL; + mPrintOptionsAllOnLetter = PRINTOPTIONS_ALL_ON_LETTER; + mPrintOptionsAdditionalCopies = PRINTOPTIONS_ADDITIONAL_COPIES; + mPrintOptionsPrintFormNames = PRINTOPTIONS_PRINT_FORM_NAMES; + mPrintOptionsDuplex = PRINTOPTIONS_DUPLEX; + + } else { + // Assign values from the Preferences object to class instance variables + mPrintOptionsUseWindowsPrint = pPrefs.get(KEY_PRINTOPTIONS_USE_WINDOWS_PRINT, mPrintOptionsUseWindowsPrint); + mPrintOptionsPclDirect = pPrefs.get(KEY_PRINTOPTIONS_PCL_DIRECT, mPrintOptionsPclDirect); + mPrintOptionsAsDisplayed = pPrefs.get(KEY_PRINTOPTIONS_AS_DISPLAYED, mPrintOptionsAsDisplayed); + mPrintOptionsLegalThenLetter = pPrefs.get(KEY_PRINTOPTIONS_LEGAL_THEN_LETTR, mPrintOptionsLegalThenLetter); + mPrintOptionsLetterThenLegal = pPrefs.get(KEY_PRINTOPTIONS_LETTER_THEN_LEGAL, mPrintOptionsLetterThenLegal); + mPrintOptionsAllOnLegal = pPrefs.get(KEY_PRINTOPTIONS_ALL_ON_LEGAL, mPrintOptionsAllOnLegal); + mPrintOptionsAllOnLetter = pPrefs.get(KEY_PRINTOPTIONS_ALL_ON_LETTER, mPrintOptionsAllOnLetter); + mPrintOptionsAdditionalCopies = pPrefs.get(KEY_PRINTOPTIONS_ADDITIONAL_COPIES, mPrintOptionsAdditionalCopies); + mPrintOptionsPrintFormNames = pPrefs.get(KEY_PRINTOPTIONS_PRINT_FORM_NAMES, mPrintOptionsPrintFormNames); + mPrintOptionsDuplex = pPrefs.get(KEY_PRINTOPTIONS_DUPLEX, mPrintOptionsDuplex); + } + } + + /** + * Save print setup dialog option values to local persisted storage + * @param pPrefs + * @param pPrintOptionsUseWindowsPrint + * @param pPrintOptionsPclDirect + * @param pPrintOptionsAsDisplayed + * @param pPrintOptionsLegalThenLetter + * @param pPrintOptionsLetterThenLegal + * @param pPrintOptionsAllOnLegal + * @param pPrintOptionsAllOnLetter + * @param pPrintOptionsAdditionalCopies + * @param pPrintOptionsPrintFormNames + * @param pPrintOptionsDuplex + */ + public void savePrintOptionsValues(Preferences pPrefs, + String pPrintOptionsUseWindowsPrint, + String pPrintOptionsPclDirect, + String pPrintOptionsAsDisplayed, + String pPrintOptionsLegalThenLetter, + String pPrintOptionsLetterThenLegal, + String pPrintOptionsAllOnLegal, + String pPrintOptionsAllOnLetter, + String pPrintOptionsAdditionalCopies, + String pPrintOptionsPrintFormNames, + String pPrintOptionsDuplex ) { + + if (pPrefs == null) { return; } + + if (pPrintOptionsUseWindowsPrint != null) { + pPrefs.put(KEY_PRINTOPTIONS_USE_WINDOWS_PRINT, pPrintOptionsUseWindowsPrint); + } + + if (pPrintOptionsPclDirect != null) { + pPrefs.put(KEY_PRINTOPTIONS_PCL_DIRECT, pPrintOptionsPclDirect); + } + + if (pPrintOptionsAsDisplayed != null) { + pPrefs.put(KEY_PRINTOPTIONS_AS_DISPLAYED, pPrintOptionsAsDisplayed); + } + + if (pPrintOptionsLegalThenLetter != null) { + pPrefs.put(KEY_PRINTOPTIONS_LEGAL_THEN_LETTR, pPrintOptionsLegalThenLetter); + } + + if (pPrintOptionsLetterThenLegal != null) { + pPrefs.put(KEY_PRINTOPTIONS_LETTER_THEN_LEGAL, pPrintOptionsLetterThenLegal); + } + + if (pPrintOptionsAllOnLegal != null) { + pPrefs.put(KEY_PRINTOPTIONS_ALL_ON_LEGAL, pPrintOptionsAllOnLegal); + } + + if (pPrintOptionsAllOnLetter != null) { + pPrefs.put(KEY_PRINTOPTIONS_ALL_ON_LETTER, pPrintOptionsAllOnLetter); + } + + if (pPrintOptionsAdditionalCopies != null) { + pPrefs.put(KEY_PRINTOPTIONS_ADDITIONAL_COPIES, pPrintOptionsAdditionalCopies); + } + + if (pPrintOptionsPrintFormNames != null) { + pPrefs.put(KEY_PRINTOPTIONS_PRINT_FORM_NAMES, pPrintOptionsPrintFormNames); + } + + if (pPrintOptionsDuplex != null) { + pPrefs.put(KEY_PRINTOPTIONS_DUPLEX, pPrintOptionsDuplex); + } + } + + // Getters + public String getPrintOptionsUseWindowsPrint() { return mPrintOptionsUseWindowsPrint; } + public String getPrintOptionsPclDirect() { return mPrintOptionsPclDirect; } + public String getPrintOptionsAsDisplayed() { return mPrintOptionsAsDisplayed; } + public String getPrintOptionsLegalThenLetter() { return mPrintOptionsLegalThenLetter; } + public String getPrintOptionsLetterThenLegal() { return mPrintOptionsLetterThenLegal; } + public String getPrintOptionsAllOnLegal() { return mPrintOptionsAllOnLegal; } + public String getPrintOptionsAllOnLetter() { return mPrintOptionsAllOnLetter; } + public String getPrintOptionsAdditionalCopies() { return mPrintOptionsAdditionalCopies; } + public String getPrintOptionsPrintFormNames() { return mPrintOptionsPrintFormNames; } + public String getPrintOptionsDuplex() { return mPrintOptionsDuplex; } + + // Setters + public void setPrintOptionsUseWindowsPrint(String pPrintOptionsUseWindowsPrint) { + mPrintOptionsUseWindowsPrint = pPrintOptionsUseWindowsPrint; + } + + public void setPrintOptionsPclDirect(String pPrintOptionsPclDirect) { + mPrintOptionsPclDirect = pPrintOptionsPclDirect; + } + + public void setPrintOptionsAsDisplayed(String pPrintOptionsAsDisplayed) { + mPrintOptionsAsDisplayed = pPrintOptionsAsDisplayed; + } + + public void setPrintOptionsLegalThenLetter(String pPrintOptionsLegalThenLetter) { + mPrintOptionsLegalThenLetter = pPrintOptionsLegalThenLetter; + } + + public void setPrintOptionsLetterThenLegal(String pPrintOptionsLetterThenLegal) { + mPrintOptionsLetterThenLegal = pPrintOptionsLetterThenLegal; + } + + public void setPrintOptionsAllOnLegal(String pPrintOptionsAllOnLegal) { + mPrintOptionsAllOnLegal = pPrintOptionsAllOnLegal; + } + + public void setPrintOptionsAllOnLetter(String pPrintOptionsAllOnLetter) { + mPrintOptionsAllOnLetter = pPrintOptionsAllOnLetter; + } + + public void setPrintOptionsAdditionalCopies(String pPrintOptionsAdditionalCopies) { + mPrintOptionsAdditionalCopies = pPrintOptionsAdditionalCopies; + } + + public void setPrintOptionsPrintFormNames(String pPrintOptionsPrintFormNames) { + mPrintOptionsPrintFormNames = pPrintOptionsPrintFormNames; + } + + public void setPrintOptionsDuplex(String pPrintOptionsDuplex) { + mPrintOptionsDuplex = pPrintOptionsDuplex; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |