Merge "Issue #1229 Changes for non-blocking PrintDialog." into development
Former-commit-id:552224976e
[formerly 17b7e3bbae7230bfa40490b84b7b13cf41881649] Former-commit-id:143ba131d0
This commit is contained in:
commit
e59ff7722a
2 changed files with 76 additions and 60 deletions
|
@ -36,6 +36,7 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.PrintDialog;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Feb 15, 2011 bkowal Initial creation
|
* Feb 15, 2011 bkowal Initial creation
|
||||||
|
* Oct 15, 2012 1229 rferrel Changes to work with non-blocking PrintDialog.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -44,6 +45,7 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.PrintDialog;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ShowPrintDialog extends AbstractHandler {
|
public class ShowPrintDialog extends AbstractHandler {
|
||||||
|
PrintDialog printDialog;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
@ -54,9 +56,13 @@ public class ShowPrintDialog extends AbstractHandler {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
PrintDialog printDialog = new PrintDialog(
|
if (printDialog == null || printDialog.getShell() == null
|
||||||
HandlerUtil.getActiveShell(event));
|
|| printDialog.isDisposed()) {
|
||||||
|
printDialog = new PrintDialog(HandlerUtil.getActiveShell(event));
|
||||||
printDialog.open();
|
printDialog.open();
|
||||||
|
} else {
|
||||||
|
printDialog.bringToTop();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||||
* AWIPS2 DR Work
|
* AWIPS2 DR Work
|
||||||
* 08/15/2012 1053 jkorman Added capability to save/restore user
|
* 08/15/2012 1053 jkorman Added capability to save/restore user
|
||||||
* print settings.
|
* print settings.
|
||||||
|
* 10/12/2012 1229 rferrel Made dialog non-blocking.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -107,9 +108,10 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||||
|
|
||||||
public class PrintDialog extends CaveSWTDialog {
|
public class PrintDialog extends CaveSWTDialog {
|
||||||
|
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(PrintDialog.class);
|
private final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(PrintDialog.class);
|
||||||
|
|
||||||
private static final String SETTINGS_FILENAME = "printSettings";
|
private final String SETTINGS_FILENAME = "printSettings";
|
||||||
|
|
||||||
private ArrayList<PrinterData> printerDataStore = null;
|
private ArrayList<PrinterData> printerDataStore = null;
|
||||||
|
|
||||||
|
@ -136,7 +138,6 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
|
|
||||||
private Button portraitRadioButton = null;
|
private Button portraitRadioButton = null;
|
||||||
|
|
||||||
|
|
||||||
/* Remaining Settings */
|
/* Remaining Settings */
|
||||||
private Spinner scaleSpinner = null;
|
private Spinner scaleSpinner = null;
|
||||||
|
|
||||||
|
@ -189,7 +190,7 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintDialog(Shell shell) {
|
public PrintDialog(Shell shell) {
|
||||||
super(shell, SWT.DIALOG_TRIM);
|
super(shell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||||
this.setText("Print");
|
this.setText("Print");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,8 +711,8 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printerSettings.invert) {
|
if (printerSettings.invert) {
|
||||||
// Only invert gray pixels, not colored pixels, awt doesn't not have a
|
// Only invert gray pixels, not colored pixels, awt doesn't not have
|
||||||
// good filter for this.
|
// a good filter for this.
|
||||||
for (int x = 0; x < bi.getWidth(); x += 1) {
|
for (int x = 0; x < bi.getWidth(); x += 1) {
|
||||||
for (int y = 0; y < bi.getHeight(); y += 1) {
|
for (int y = 0; y < bi.getHeight(); y += 1) {
|
||||||
Color color = new Color(bi.getRGB(x, y));
|
Color color = new Color(bi.getRGB(x, y));
|
||||||
|
@ -887,7 +888,8 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
|
|
||||||
settings.setInvertBlackWhite(invertCheckbox.getSelection());
|
settings.setInvertBlackWhite(invertCheckbox.getSelection());
|
||||||
settings.setPrintGrayScale(grayscaleRadioButton.getSelection());
|
settings.setPrintGrayScale(grayscaleRadioButton.getSelection());
|
||||||
settings.setOrientation(PRINT_ORIENTATION.getPrintOrientation(landscapeRadioButton.getSelection()));
|
settings.setOrientation(PRINT_ORIENTATION
|
||||||
|
.getPrintOrientation(landscapeRadioButton.getSelection()));
|
||||||
|
|
||||||
settings.setCopies(copiesSpinner.getSelection());
|
settings.setCopies(copiesSpinner.getSelection());
|
||||||
settings.setScale(scaleSpinner.getSelection());
|
settings.setScale(scaleSpinner.getSelection());
|
||||||
|
@ -907,7 +909,8 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
LocalizationContext ctx = initUserLocalization();
|
LocalizationContext ctx = initUserLocalization();
|
||||||
|
|
||||||
// Get a list of localization files!
|
// Get a list of localization files!
|
||||||
LocalizationFile f = PathManagerFactory.getPathManager().getLocalizationFile(ctx, SETTINGS_FILENAME);
|
LocalizationFile f = PathManagerFactory.getPathManager()
|
||||||
|
.getLocalizationFile(ctx, SETTINGS_FILENAME);
|
||||||
OutputStream strm = null;
|
OutputStream strm = null;
|
||||||
try {
|
try {
|
||||||
strm = f.openOutputStream();
|
strm = f.openOutputStream();
|
||||||
|
@ -921,7 +924,8 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
try {
|
try {
|
||||||
strm.close();
|
strm.close();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
statusHandler.error("Could not close user print settings", ioe);
|
statusHandler.error("Could not close user print settings",
|
||||||
|
ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -935,35 +939,43 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
LocalizationContext ctx = initUserLocalization();
|
LocalizationContext ctx = initUserLocalization();
|
||||||
|
|
||||||
// Get a list of localization files!
|
// Get a list of localization files!
|
||||||
LocalizationFile f = PathManagerFactory.getPathManager().getLocalizationFile(ctx, SETTINGS_FILENAME);
|
LocalizationFile f = PathManagerFactory.getPathManager()
|
||||||
|
.getLocalizationFile(ctx, SETTINGS_FILENAME);
|
||||||
// If its not there, no previous settings have been saved. Just exit.
|
// If its not there, no previous settings have been saved. Just exit.
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
UserPrintSettings settings = null;
|
UserPrintSettings settings = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
settings = (UserPrintSettings) JAXB.unmarshal(f.openInputStream(),UserPrintSettings.class);
|
settings = (UserPrintSettings) JAXB.unmarshal(
|
||||||
|
f.openInputStream(), UserPrintSettings.class);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.error("Could not read user print settings-using defaults", e);
|
statusHandler.error(
|
||||||
|
"Could not read user print settings-using defaults", e);
|
||||||
}
|
}
|
||||||
if (settings != null) {
|
if (settings != null) {
|
||||||
invertCheckbox.setSelection(settings.getInvertBlackWhite());
|
invertCheckbox.setSelection(settings.getInvertBlackWhite());
|
||||||
grayscaleRadioButton.setSelection(settings.isPrintGrayScale());
|
grayscaleRadioButton.setSelection(settings.isPrintGrayScale());
|
||||||
colorRadioButton.setSelection(!grayscaleRadioButton.getSelection());
|
colorRadioButton.setSelection(!grayscaleRadioButton
|
||||||
|
.getSelection());
|
||||||
|
|
||||||
landscapeRadioButton.setSelection(settings.getOrientation().isPrintLandscape());
|
landscapeRadioButton.setSelection(settings.getOrientation()
|
||||||
portraitRadioButton.setSelection(!landscapeRadioButton.getSelection());
|
.isPrintLandscape());
|
||||||
|
portraitRadioButton.setSelection(!landscapeRadioButton
|
||||||
|
.getSelection());
|
||||||
|
|
||||||
Integer n = settings.getCopies();
|
Integer n = settings.getCopies();
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
if(n >= copiesSpinner.getMinimum() && n <= copiesSpinner.getMaximum()) {
|
if (n >= copiesSpinner.getMinimum()
|
||||||
|
&& n <= copiesSpinner.getMaximum()) {
|
||||||
copiesSpinner.setSelection(n);
|
copiesSpinner.setSelection(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = settings.getScale();
|
n = settings.getScale();
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
if(n >= scaleSpinner.getMinimum() && n <= scaleSpinner.getMaximum()) {
|
if (n >= scaleSpinner.getMinimum()
|
||||||
|
&& n <= scaleSpinner.getMaximum()) {
|
||||||
scaleSpinner.setSelection(settings.getScale());
|
scaleSpinner.setSelection(settings.getScale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1007,8 +1019,6 @@ public class PrintDialog extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize the localization for user with the save/load functions
|
* initialize the localization for user with the save/load functions
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue