From e5ace6936b6407d3eb6efa0f4bd7e7d2881c773f Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Thu, 6 Jun 2013 16:10:54 -0500 Subject: [PATCH] Issue #2074 fix null capabilities when loading procedures having to do with non-existent plugins Change-Id: I83b62fbdc4688b9b330a4485111fe77c0a12beff Former-commit-id: d51e3f2e949394fe4e31299698ac1856bfa853f0 [formerly 3411b8df93d6ec8fcc88bd2c85b94c3edceecfc9 [formerly 7124abddfa9f066e6c7424992d84b403fd1f6d4c]] Former-commit-id: 3411b8df93d6ec8fcc88bd2c85b94c3edceecfc9 Former-commit-id: 1be3d925744f721c73a8b46e80696f90be01d210 --- .../core/rsc/capabilities/Capabilities.java | 5 ++- .../d2d/ui/actions/OpenAWIPSProcedure.java | 12 ++++--- .../ui/dialogs/procedures/ProcedureDlg.java | 34 +++++++++++++------ 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/Capabilities.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/Capabilities.java index 73b2f0f2f6..fb32a90add 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/Capabilities.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/Capabilities.java @@ -52,6 +52,7 @@ import com.raytheon.uf.viz.core.rsc.AbstractResourceData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Feb 2, 2009 chammack Initial creation + * Jun 7, 2013 2074 mnash Fix for null capabilities trying to be added * * * @@ -191,7 +192,9 @@ public class Capabilities implements Iterable { collection).iterator(); while (collectionIterator.hasNext()) { AbstractCapability cap = collectionIterator.next(); - this.backingMap.put(cap.getClass(), cap); + if (cap != null) { + this.backingMap.put(cap.getClass(), cap); + } } } diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java index 306883f180..5d743cc132 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java @@ -47,7 +47,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Sep 13, 2007 chammack Initial Creation. * Oct 16, 2012 1229 rferrel Change to use ProcedureDlg.displayDialog. * Oct 16, 2012 1229 rferrel Changes for non-blocking ProcedureListDlg. - * + * Jun 7, 2013 2074 mnash Don't open the dialog if no procedures are deserialized * * * @author chammack @@ -77,10 +77,12 @@ public class OpenAWIPSProcedure extends AbstractHandler { File f = selectedFile.getFile(); Procedure p = (Procedure) LoadSerializedXml .deserialize(f); - ProcedureDlg.displayDialog(LocalizationUtil - .extractName(selectedFile.getName()), p, - VizWorkbenchManager.getInstance() - .getCurrentWindow().getShell()); + if (p != null) { + ProcedureDlg.displayDialog(LocalizationUtil + .extractName(selectedFile.getName()), p, + VizWorkbenchManager.getInstance() + .getCurrentWindow().getShell()); + } } dialog = null; } diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java index 120c7fe66e..f50665e65d 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java @@ -75,6 +75,7 @@ import com.raytheon.uf.viz.core.procedures.Procedure; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractResourceData; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureComm.BundlePair; import com.raytheon.viz.ui.HistoryList; import com.raytheon.viz.ui.UiUtil; @@ -100,7 +101,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * Jan 15, 2013 DR 15699 D. Friedman Prompt for save when close button clicked. * Jan 16, 2013 DR 15367 D. Friedman Enable save button for Up/Down changes. * Feb 25, 2013 1640 bsteffen Dispose old display in BundleLoader - * + * Jun 7, 2013 2074 mnash Remove resource if doesn't instantiate correctly * * * @author unknown @@ -193,15 +194,26 @@ public class ProcedureDlg extends CaveSWTDialog { if (p != null && p.getBundles() != null) { Bundle[] bund = p.getBundles(); for (Bundle b : bund) { + // remove any bad resource pairs from each display + for (AbstractRenderableDisplay display : b.getDisplays()) { + ResourceList rList = display.getDescriptor() + .getResourceList(); + // modify the resource list so that we remove any null + // resource datas + for (ResourcePair rp : rList) { + if (rp.getResourceData() == null) { + rList.remove(rp); + } + } + } // Check to see if frozen for (AbstractRenderableDisplay display : b.getDisplays()) { - for (ResourcePair rp : display.getDescriptor() - .getResourceList()) { - if (rp.getResourceData() != null) { - if (rp.getResourceData().isFrozen()) { - frozen = true; - break; - } + ResourceList rList = display.getDescriptor() + .getResourceList(); + for (ResourcePair rp : rList) { + if (rp.getResourceData().isFrozen()) { + frozen = true; + break; } } if (frozen) { @@ -958,8 +970,7 @@ public class ProcedureDlg extends CaveSWTDialog { } } - private void handleCloseRequest() - { + private void handleCloseRequest() { if (saved) { close(); } else { @@ -972,7 +983,8 @@ public class ProcedureDlg extends CaveSWTDialog { * to close it */ private void showConfirmSaveDlg() { - CaveSWTDialog dlg = new CaveSWTDialog(shell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.DO_NOT_BLOCK) { + CaveSWTDialog dlg = new CaveSWTDialog(shell, SWT.DIALOG_TRIM + | SWT.PRIMARY_MODAL, CAVE.DO_NOT_BLOCK) { @Override protected void initializeComponents(Shell shell) {