From 59e20e1f022c13cfa0c631da3e667598af002dd4 Mon Sep 17 00:00:00 2001 From: Nathan Bowler Date: Thu, 4 Dec 2014 13:24:04 -0500 Subject: [PATCH] Omaha #3848 Fix cancelling geotiff import. Change-Id: I1af55a1ba866fc08814fbb8362334a430b0f7463 Former-commit-id: e1af24d84e28fad729aaeda6c7ee030c67a90b18 [formerly 3e7a1993e32940ec76c110b9cd9608dd4172a087 [formerly 4c64044de959e709cd00da40826b916a579c44fe]] Former-commit-id: 3e7a1993e32940ec76c110b9cd9608dd4172a087 Former-commit-id: a5bc553461f9abd9e96f7c3ea7fe4a52197deb77 --- .../viz/geotiff/ui/OpenImageAction.java | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/cave/com.raytheon.viz.geotiff/src/com/raytheon/viz/geotiff/ui/OpenImageAction.java b/cave/com.raytheon.viz.geotiff/src/com/raytheon/viz/geotiff/ui/OpenImageAction.java index 65e3536a52..1a428c8476 100644 --- a/cave/com.raytheon.viz.geotiff/src/com/raytheon/viz/geotiff/ui/OpenImageAction.java +++ b/cave/com.raytheon.viz.geotiff/src/com/raytheon/viz/geotiff/ui/OpenImageAction.java @@ -1,27 +1,25 @@ /** * This software was developed and / or modified by Raytheon Company, * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * + * * U.S. EXPORT CONTROLLED TECHNICAL DATA * This software product contains export-restricted data whose * export/transfer/disclosure is restricted by U.S. law. Dissemination * to non-U.S. persons whether in the United States or abroad requires * an export license or other authorization. - * + * * Contractor Name: Raytheon Company * Contractor Address: 6825 Pine Street, Suite 340 * Mail Stop B8 * Omaha, NE 68106 * 402.291.0100 - * + * * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ package com.raytheon.viz.geotiff.ui; -import java.io.File; - import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.Status; @@ -44,15 +42,16 @@ import com.raytheon.viz.ui.EditorUtil; /** * Open an GeoTIFF image - * + * *
  * SOFTWARE HISTORY
  * Date         Ticket#     Engineer    Description
  * ------------ ----------  ----------- --------------------------
  * 7/1/06                   chammack    Initial Creation.
- * 
+ * Dec 04, 2014 3848        nabowle     Fix file dialog being cancelled.
+ *
  * 
- * + * * @author chammack * @version 1 */ @@ -70,43 +69,44 @@ public class OpenImageAction extends AbstractMapHandler { FileDialog fd = new FileDialog(shell, SWT.OPEN); fd.setFilterExtensions(new String[] { "*.tif;*.tiff" }); - fd.open(); - final String fileName = fd.getFilterPath() + File.separator - + fd.getFileName(); + final String fileName = fd.open(); - VizApp.runAsync(new Runnable() { - @Override - public void run() { - try { - IDescriptor mapDesc = container.getActiveDisplayPane() - .getRenderableDisplay().getDescriptor(); + if (fileName != null) { + VizApp.runAsync(new Runnable() { + @Override + public void run() { + try { + IDescriptor mapDesc = container.getActiveDisplayPane() + .getRenderableDisplay().getDescriptor(); - if (mapDesc == null) { - Activator - .getDefault() - .getLog() - .log(new Status(Status.ERROR, - Activator.PLUGIN_ID, - "Map does not support GeoTIFFs", null)); + if (mapDesc == null) { + Activator + .getDefault() + .getLog() + .log(new Status(Status.ERROR, + Activator.PLUGIN_ID, + "Map does not support GeoTIFFs", + null)); + } + GeoTiffResourceData data = new GeoTiffResourceData( + fileName); + LoadProperties lProps = new LoadProperties(); + GeoTiffResource gtiff = data.construct(lProps, mapDesc); + + ResourceProperties rProps = new ResourceProperties(); + + rProps.setMapLayer(true); + rProps.setVisible(true); + rProps.setPdProps(new ProgressiveDisclosureProperties()); + + mapDesc.getResourceList().add(gtiff); + } catch (Exception e) { + e.printStackTrace(); } - GeoTiffResourceData data = new GeoTiffResourceData(fileName); - LoadProperties lProps = new LoadProperties(); - GeoTiffResource gtiff = data.construct(lProps, mapDesc); - - ResourceProperties rProps = new ResourceProperties(); - - rProps.setMapLayer(true); - rProps.setVisible(true); - rProps.setPdProps(new ProgressiveDisclosureProperties()); - - mapDesc.getResourceList().add(gtiff); - } catch (Exception e) { - e.printStackTrace(); } - } - }); - + }); + } return null; } }