From 92994bc798c756bfa8a6ae4023ce2d36b37c0643 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Thu, 19 May 2016 18:18:17 -0500 Subject: [PATCH 1/5] Omaha #5668 Move deltaScripts from TO56 to correct directory Change-Id: I921297e0a66b9ea4732ceb399a2410e687274569 Former-commit-id: c59e6a957d9adc2d03f3c0025ee1efba839cb0f7 --- deltaScripts/{TO56 => 16.2.2}/DR5345/_update_metar_slp_values.py | 0 deltaScripts/{TO56 => 16.2.2}/DR5345/update_metar_slp_values.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename deltaScripts/{TO56 => 16.2.2}/DR5345/_update_metar_slp_values.py (100%) rename deltaScripts/{TO56 => 16.2.2}/DR5345/update_metar_slp_values.sh (100%) diff --git a/deltaScripts/TO56/DR5345/_update_metar_slp_values.py b/deltaScripts/16.2.2/DR5345/_update_metar_slp_values.py similarity index 100% rename from deltaScripts/TO56/DR5345/_update_metar_slp_values.py rename to deltaScripts/16.2.2/DR5345/_update_metar_slp_values.py diff --git a/deltaScripts/TO56/DR5345/update_metar_slp_values.sh b/deltaScripts/16.2.2/DR5345/update_metar_slp_values.sh similarity index 100% rename from deltaScripts/TO56/DR5345/update_metar_slp_values.sh rename to deltaScripts/16.2.2/DR5345/update_metar_slp_values.sh From a85a4f6a8ce5f6b411a308c65f6fd04ae92c6ebd Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Fri, 20 May 2016 10:50:32 -0500 Subject: [PATCH 2/5] Omaha #5664 Close netcdf files in pointset decoder. Former-commit-id: 1b82fbbdf5c93fe4fa7984487a02a06f31e9dcc2 --- .../pointset/netcdf/PointSetNetcdfDecoder.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java b/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java index 264d0f4867..c9773919cc 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java @@ -83,6 +83,7 @@ import com.raytheon.uf.edex.plugin.pointset.netcdf.description.TriangulationDesc * Aug 11, 2015 4709 bsteffen Initial creation * Jan 21, 2016 5208 bsteffen Decode scale, offset, units, long_name when * they are present and extra validation. + * May 20, 2016 5664 bsteffen Close files. * * * @@ -109,8 +110,9 @@ public class PointSetNetcdfDecoder { if (levelFactory == null) { levelFactory = LevelFactory.getInstance(); } + NetcdfFile netcdfFile = null; try { - NetcdfFile netcdfFile = NetcdfFile.open(file.getAbsolutePath()); + netcdfFile = NetcdfFile.open(file.getAbsolutePath()); Map locationCache = new HashMap(); List records = new ArrayList<>(); for (ProductDescription description : descriptions @@ -131,6 +133,14 @@ public class PointSetNetcdfDecoder { } catch (InvalidDescriptionException | IOException | StorageException e) { logger.error("Unable to decode pointset from file: {}", file.getName(), e); + } finally { + if (netcdfFile != null) { + try { + netcdfFile.close(); + } catch (IOException e) { + logger.warn("Error closing file: {}", file.getName()); + } + } } return EMPTY_POINTSET_ARRAY; } From 3bd561ac2e29bc2849c4fdeb972c8292599a5de2 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Tue, 24 May 2016 16:32:19 -0500 Subject: [PATCH 3/5] Omaha #5653 Workaround printer/driver issue with landscape mode printing Change-Id: I8ced511c0404b6b2a9c3249929829d3a8198d4d0 Former-commit-id: 473094783aad56e84bf6e018810cdca456e0518b --- .../uf/viz/d2d/ui/dialogs/PrintDialog.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java index e75dd0cb34..f927c9a2ef 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java @@ -20,6 +20,8 @@ package com.raytheon.uf.viz.d2d.ui.dialogs; import java.awt.Color; +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.awt.image.ComponentColorModel; import java.awt.image.IndexColorModel; @@ -688,7 +690,10 @@ public class PrintDialog extends CaveSWTDialog { printerSettings.printInGrayscale = true; } if (this.landscapeRadioButton.getSelection()) { - printerSettings.selectedPrinter.orientation = PrinterData.LANDSCAPE; + // TODO: restore this line if we ever get Landscape printing working + // on the LX workstations + // printerSettings.selectedPrinter.orientation = + // PrinterData.LANDSCAPE; printerSettings.printInLandscape = true; } @@ -705,6 +710,22 @@ public class PrintDialog extends CaveSWTDialog { private void print(PrinterSettings printerSettings) { AbstractEditor editor = (AbstractEditor) EditorUtil.getActiveEditor(); BufferedImage bi = editor.screenshot(); + + // TODO: remove this block if we ever get Landscape printing working + // on the LX workstations + if (printerSettings.printInLandscape) { + AffineTransform transform = AffineTransform + .getQuadrantRotateInstance(1); + transform.concatenate(AffineTransform.getTranslateInstance(0.0, + -bi.getHeight())); + AffineTransformOp transformOp = new AffineTransformOp(transform, + AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + bi = transformOp.filter( + bi, + new BufferedImage(bi.getHeight(), bi.getWidth(), bi + .getType())); + } + if (printerSettings.invert) { // Only invert gray pixels, not colored pixels, awt doesn't not have // a good filter for this. @@ -764,13 +785,22 @@ public class PrintDialog extends CaveSWTDialog { int scaledImageHeight = Math.round(scale * bi.getHeight() * printerDPI.y / screenDPI.y); - Point offset = new Point(0, 0); + Point initialOffset = new Point(0, 0); + int xPages = (int) Math.ceil((double) scaledImageWidth + / printArea.width); + int yPages = (int) Math.ceil((double) scaledImageHeight + / printArea.height); + + // Compute offset to center image in page(s) + initialOffset.x = ((xPages * printArea.width) - scaledImageWidth) / 2; + initialOffset.y = ((yPages * printArea.height) - scaledImageHeight) / 2; + + Point offset = new Point(initialOffset.x, initialOffset.y); Point remaining = new Point(scaledImageWidth, scaledImageHeight); if (printer.startJob("CAVE")) { while (remaining.x > 0 && remaining.y > 0) { if (printer.startPage()) { GC gc = new GC(printer); - gc.setClipping(printArea); Transform transform = new Transform(gc.getDevice()); transform.translate(offset.x, offset.y); @@ -790,7 +820,7 @@ public class PrintDialog extends CaveSWTDialog { offset.x -= printArea.width; if (remaining.x <= 0) { remaining.x = scaledImageWidth; - offset.x = 0; + offset.x = initialOffset.x; remaining.y -= printArea.height; offset.y -= printArea.height; } From 5b059253ce2dc8d2f757bf5e6e760609403f90db Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Wed, 25 May 2016 11:40:23 -0500 Subject: [PATCH 4/5] Omaha #5653 Handle empty printer list, code cleanup. Change-Id: I41b8353524c54ac91947a994370616fb00ca9b26 Former-commit-id: 9ed56de279b7d19f6a18cde083da3c29fab0cb8b --- .../uf/viz/d2d/ui/dialogs/PrintDialog.java | 211 +++++++++--------- 1 file changed, 103 insertions(+), 108 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java index f927c9a2ef..447c97df5c 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/PrintDialog.java @@ -30,7 +30,7 @@ import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; +import java.util.List; import java.util.Map; import javax.xml.bind.JAXB; @@ -99,6 +99,8 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * Oct 12, 2012 1229 rferrel Made dialog non-blocking. * Dec 09, 2014 11982 D. Friedman Fix print-to-file * May 13, 2016 5653 randerso Fixed print scaling + * Handle empty printer list + * Code cleanup * * * @@ -113,7 +115,7 @@ public class PrintDialog extends CaveSWTDialog { private final String SETTINGS_FILENAME = "printSettings"; - private ArrayList printerDataStore = null; + private List printerDataStore = null; private PrinterData printToFileData = null; @@ -164,7 +166,7 @@ public class PrintDialog extends CaveSWTDialog { public boolean magnificationAdjusted = false; - public Map magnificationStore = new HashMap(); + public Map magnificationStore = new HashMap<>(); } private class DensityInformationStorage { @@ -172,7 +174,7 @@ public class PrintDialog extends CaveSWTDialog { public boolean densityAdjusted = false; - public Map densityStore = new HashMap(); + public Map densityStore = new HashMap<>(); } private class PrinterSettings { @@ -222,7 +224,7 @@ public class PrintDialog extends CaveSWTDialog { } private void createPrintToGroup() { - ArrayList availablePrinters = this.getAvailablePrinters(); + List availablePrinters = this.getAvailablePrinters(); Group group = new Group(this.shell, SWT.SHADOW_ETCHED_IN); GridData gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); @@ -233,73 +235,72 @@ public class PrintDialog extends CaveSWTDialog { group.setLayout(gridLayout); group.setText("Print To"); - Button button = new Button(group, SWT.RADIO); - button.setText("Printer"); - button.setSelection(true); - button.addSelectionListener(new SelectionAdapter() { + printerRadioButton = new Button(group, SWT.RADIO); + printerRadioButton.setText("Printer"); + printerRadioButton.setSelection(true); + printerRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (printerRadioButton.getSelection()) { selectedPrinterCombo.setEnabled(true); destinationFileText.setEnabled(false); - destinationFileText.setText(""); - destinationFileText.setToolTipText("~ NO FILE SELECTED ~"); browseButton.setEnabled(false); + okButton.setEnabled(selectedPrinterCombo + .getSelectionIndex() >= 0); } } }); - this.printerRadioButton = button; - Combo combo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); + selectedPrinterCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - combo.setLayoutData(gridData); + selectedPrinterCombo.setLayoutData(gridData); - if (availablePrinters != null) { - Iterator printerIterator = availablePrinters.iterator(); - while (printerIterator.hasNext()) { - combo.add(printerIterator.next()); - } - combo.select(0); + for (String printer : availablePrinters) { + selectedPrinterCombo.add(printer); } - this.selectedPrinterCombo = combo; + selectedPrinterCombo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + okButton.setEnabled(selectedPrinterCombo.getSelectionIndex() >= 0); + } + }); // filler new Label(group, SWT.NONE); - button = new Button(group, SWT.RADIO); - button.setText("File"); - button.addSelectionListener(new SelectionAdapter() { + fileRadioButton = new Button(group, SWT.RADIO); + fileRadioButton.setText("File"); + fileRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (fileRadioButton.getSelection()) { selectedPrinterCombo.setEnabled(false); destinationFileText.setEnabled(true); browseButton.setEnabled(true); + okButton.setEnabled(!destinationFileText.getText() + .isEmpty()); } } }); - this.fileRadioButton = button; - Text text = new Text(group, SWT.BORDER); + destinationFileText = new Text(group, SWT.BORDER | SWT.READ_ONLY); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - GC gc = new GC(text); + GC gc = new GC(destinationFileText); int textWidth = gc.getFontMetrics().getAverageCharWidth() * 30; gc.dispose(); gridData.minimumWidth = textWidth; - text.setLayoutData(gridData); - text.setEnabled(false); - this.destinationFileText = text; + destinationFileText.setLayoutData(gridData); + destinationFileText.setEnabled(false); - button = new Button(group, SWT.PUSH); - button.setText("Browse ..."); - button.addSelectionListener(new SelectionAdapter() { + browseButton = new Button(group, SWT.PUSH); + browseButton.setText("Browse ..."); + browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { selectDestinationFile(destinationFileText.getText()); } }); - button.setEnabled(false); - this.browseButton = button; + browseButton.setEnabled(false); } private void createPrintInAndOrientationGroups() { @@ -312,28 +313,24 @@ public class PrintDialog extends CaveSWTDialog { group.setLayout(new GridLayout(1, true)); group.setText("Print In"); - Button button = new Button(group, SWT.RADIO); - button.setText("Color"); - button.setSelection(true); - colorRadioButton = button; + colorRadioButton = new Button(group, SWT.RADIO); + colorRadioButton.setText("Color"); + colorRadioButton.setSelection(true); - button = new Button(group, SWT.RADIO); - button.setText("Grayscale"); - this.grayscaleRadioButton = button; + grayscaleRadioButton = new Button(group, SWT.RADIO); + grayscaleRadioButton.setText("Grayscale"); group = new Group(this.shell, SWT.SHADOW_ETCHED_IN); group.setLayoutData(gridData); group.setLayout(new GridLayout(1, true)); group.setText("Orientation"); - button = new Button(group, SWT.RADIO); - button.setText("Portrait"); - button.setSelection(true); - portraitRadioButton = button; + portraitRadioButton = new Button(group, SWT.RADIO); + portraitRadioButton.setText("Portrait"); + portraitRadioButton.setSelection(true); - button = new Button(group, SWT.RADIO); - button.setText("Landscape"); - this.landscapeRadioButton = button; + landscapeRadioButton = new Button(group, SWT.RADIO); + landscapeRadioButton.setText("Landscape"); } private void createRemainingPrintingSettingsSection() { @@ -354,14 +351,10 @@ public class PrintDialog extends CaveSWTDialog { label.setLayoutData(gridData); label.setText("Scale %:"); - Spinner spinner = new Spinner(leftComp, SWT.READ_ONLY | SWT.BORDER); + scaleSpinner = new Spinner(leftComp, SWT.READ_ONLY | SWT.BORDER); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - spinner.setLayoutData(gridData); - spinner.setMinimum(0); - spinner.setMaximum(9999); - spinner.setSelection(100); - spinner.setIncrement(1); - this.scaleSpinner = spinner; + scaleSpinner.setLayoutData(gridData); + scaleSpinner.setValues(100, 0, 999, 0, 1, 10); this.fitToPageBtn = new Button(leftComp, SWT.CHECK); gridData = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false); @@ -382,15 +375,10 @@ public class PrintDialog extends CaveSWTDialog { label.setLayoutData(gridData); label.setText("Copies:"); - spinner = new Spinner(leftComp, SWT.READ_ONLY | SWT.BORDER); + copiesSpinner = new Spinner(leftComp, SWT.READ_ONLY | SWT.BORDER); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - spinner.setLayoutData(gridData); - - spinner.setMinimum(1); - spinner.setMaximum(9999); - spinner.setSelection(0); - spinner.setIncrement(1); - this.copiesSpinner = spinner; + copiesSpinner.setLayoutData(gridData); + copiesSpinner.setValues(1, 1, 9999, 0, 1, 10); Composite rightComp = new Composite(comp, SWT.NONE); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); @@ -402,22 +390,23 @@ public class PrintDialog extends CaveSWTDialog { label.setLayoutData(gridData); label.setText("Mag:"); - Combo combo = new Combo(rightComp, SWT.READ_ONLY | SWT.DROP_DOWN); + magnificationCombo = new Combo(rightComp, SWT.READ_ONLY | SWT.DROP_DOWN); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - combo.setLayoutData(gridData); + magnificationCombo.setLayoutData(gridData); /* Get The Magnification Values. */ for (int i = 0; i < MagnificationPopulator.getMagnifications().length; i++) { - combo.add(MagnificationPopulator.getMagnifications()[i]); + magnificationCombo + .add(MagnificationPopulator.getMagnifications()[i]); } String currentMagnification = this.getCurrentMagnification(); for (int i = 0; i < MagnificationPopulator.getMagnifications().length; i++) { if (currentMagnification.equals(MagnificationPopulator .getMagnifications()[i])) { - combo.select(i); + magnificationCombo.select(i); break; } } - combo.addSelectionListener(new SelectionAdapter() { + magnificationCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { okButton.setEnabled(false); @@ -427,27 +416,26 @@ public class PrintDialog extends CaveSWTDialog { cancelButton.setEnabled(true); } }); - this.magnificationCombo = combo; label = new Label(rightComp, SWT.NONE); gridData = new GridData(SWT.RIGHT, SWT.CENTER, true, false); label.setLayoutData(gridData); label.setText("Density:"); - combo = new Combo(rightComp, SWT.READ_ONLY | SWT.DROP_DOWN); + densityCombo = new Combo(rightComp, SWT.READ_ONLY | SWT.DROP_DOWN); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - combo.setLayoutData(gridData); + densityCombo.setLayoutData(gridData); for (int i = 0; i < DensityPopulator.getDensityLabels().length; i++) { - combo.add(DensityPopulator.getDensityLabels()[i]); + densityCombo.add(DensityPopulator.getDensityLabels()[i]); } String currentDensity = this.getCurrentDensity(); for (int i = 0; i < DensityPopulator.getDensityLabels().length; i++) { if (currentDensity.equals(DensityPopulator.getDensityLabels()[i])) { - combo.select(i); + densityCombo.select(i); break; } } - combo.addSelectionListener(new SelectionAdapter() { + densityCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { okButton.setEnabled(false); @@ -457,7 +445,6 @@ public class PrintDialog extends CaveSWTDialog { cancelButton.setEnabled(true); } }); - this.densityCombo = combo; rightComp = new Composite(comp, SWT.NONE); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); @@ -467,28 +454,27 @@ public class PrintDialog extends CaveSWTDialog { label = new Label(rightComp, SWT.NONE); label.setText("Paper:"); - combo = new Combo(rightComp, SWT.READ_ONLY | SWT.DROP_DOWN); + Combo paperCombo = new Combo(rightComp, SWT.READ_ONLY | SWT.DROP_DOWN); gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - combo.setLayoutData(gridData); - combo.add("DEFAULT"); - combo.setEnabled(false); - combo.select(0); + paperCombo.setLayoutData(gridData); + paperCombo.add("DEFAULT"); + paperCombo.setEnabled(false); + paperCombo.select(0); // TODO: implement paper settings + invertCheckbox = new Button(comp, SWT.CHECK); gridData = new GridData(); gridData.horizontalAlignment = SWT.CENTER; - Button button = new Button(comp, SWT.CHECK); - button.setLayoutData(gridData); - button.setText("Invert Black/White"); - button.setSelection(true); - this.invertCheckbox = button; + invertCheckbox.setLayoutData(gridData); + invertCheckbox.setText("Invert Black/White"); + invertCheckbox.setSelection(true); gridData = new GridData(); gridData.horizontalAlignment = SWT.CENTER; - button = new Button(comp, SWT.CHECK); - button.setLayoutData(gridData); - button.setText("Manual Feed"); - button.setEnabled(false); + Button manualFeedCheckbox = new Button(comp, SWT.CHECK); + manualFeedCheckbox.setLayoutData(gridData); + manualFeedCheckbox.setText("Manual Feed"); + manualFeedCheckbox.setEnabled(false); // TODO: implement manual feed } @@ -497,10 +483,10 @@ public class PrintDialog extends CaveSWTDialog { GridData gridData = new GridData(); gridData.horizontalAlignment = SWT.CENTER; gridData.widthHint = buttonWidth; - Button button = new Button(this.shell, SWT.PUSH); - button.setLayoutData(gridData); - button.setText("OK"); - button.addSelectionListener(new SelectionAdapter() { + okButton = new Button(this.shell, SWT.PUSH); + okButton.setLayoutData(gridData); + okButton.setText("OK"); + okButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { okButton.setEnabled(false); @@ -512,15 +498,15 @@ public class PrintDialog extends CaveSWTDialog { close(); } }); - this.okButton = button; + okButton.setEnabled(false); gridData = new GridData(); gridData.horizontalAlignment = SWT.CENTER; gridData.widthHint = buttonWidth; - button = new Button(this.shell, SWT.PUSH); - button.setLayoutData(gridData); - button.setText("Cancel"); - button.addSelectionListener(new SelectionAdapter() { + cancelButton = new Button(this.shell, SWT.PUSH); + cancelButton.setLayoutData(gridData); + cancelButton.setText("Cancel"); + cancelButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { okButton.setEnabled(false); @@ -529,7 +515,6 @@ public class PrintDialog extends CaveSWTDialog { close(); } }); - this.cancelButton = button; } private void selectDestinationFile(String fileName) { @@ -564,6 +549,7 @@ public class PrintDialog extends CaveSWTDialog { String destinationFile = filterPath + selectedFile; this.destinationFileText.setText(destinationFile); this.destinationFileText.setToolTipText(destinationFile); + this.okButton.setEnabled(true); } private void updateMagnification() { @@ -853,14 +839,11 @@ public class PrintDialog extends CaveSWTDialog { return currentDensity.toString(); } - private ArrayList getAvailablePrinters() { + private List getAvailablePrinters() { PrinterData[] printers = Printer.getPrinterList(); - if (printers == null || printers.length <= 0) { - return null; - } - ArrayList availablePrinters = new ArrayList(); - this.printerDataStore = new ArrayList(); + List availablePrinters = new ArrayList<>(printers.length); + this.printerDataStore = new ArrayList<>(printers.length); for (int i = 0; i < printers.length; i++) { /* Do Not Include "Print to File" In The Printer List. */ if (printers[i].name.equalsIgnoreCase("print to file")) { @@ -1053,10 +1036,22 @@ public class PrintDialog extends CaveSWTDialog { } if (idx > -1) { selectedPrinterCombo.select(idx); + } else { + selectedPrinterCombo.deselectAll(); + } + } + + if (settings.isUsePrinterFile()) { + printerRadioButton.setSelection(false); + fileRadioButton.setSelection(true); + } else { + printerRadioButton.setSelection(true); + fileRadioButton.setSelection(false); + + if (selectedPrinterCombo.getSelectionIndex() >= 0) { + okButton.setEnabled(true); } } - printerRadioButton.setSelection(!settings.isUsePrinterFile()); - fileRadioButton.setSelection(settings.isUsePrinterFile()); } } } From dc55dde5d5a01bccefa40af5473204ca7084bb93 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Tue, 31 May 2016 17:01:18 -0500 Subject: [PATCH 5/5] Omaha #5513 Fix NPE when AlarmAlertDlg is opened the second time. Change-Id: Iba0cfd1ed74d4ab045064abdf4768bd0fa3f1db4 Former-commit-id: 430701c960d301cfae54b65dc9c6a0187352a760 --- .../alarmalert/dialogs/AlarmAlertDlg.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java index 1c5f10ebef..4c779c6436 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java @@ -203,13 +203,14 @@ public class AlarmAlertDlg extends CaveSWTDialog { * Sets the shell location. */ private void setLocation() { - int shellSizeX = getShell().getSize().x; - int shellSizeY = getShell().getSize().y; - Rectangle bounds = getParent().getMonitor().getBounds(); - int locationX = bounds.x + bounds.width - shellSizeX; - int locationY = bounds.y + bounds.height - shellSizeY; - shell.setLocation(locationX, locationY); - return; + if (shell != null) { + int shellSizeX = getShell().getSize().x; + int shellSizeY = getShell().getSize().y; + Rectangle bounds = getParent().getMonitor().getBounds(); + int locationX = bounds.x + bounds.width - shellSizeX; + int locationY = bounds.y + bounds.height - shellSizeY; + shell.setLocation(locationX, locationY); + } } @Override