/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.geoforge.gfrplgimportshapesgeojson4gfr.swing.action;
import java.awt.event.ActionEvent;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.geoforge.guillc.dialog.GfrDlgCmdCancelOkEdtUrlAbs;
import org.geoforge.guillc.dialog.GfrDlgCmdCancelOkEdtUrlGeojson;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.java.lang.string.GfrUtlString;
/**
*
* @author bantchao@gmail.com
*/
public class GfrActPlgImportShapesGeojsonUrl extends GfrActPlgImportShapesGeojsonAbs
{
final static private Logger _LOGGER_ = Logger.getLogger(GfrActPlgImportShapesGeojsonUrl.class.getName());
static
{
GfrActPlgImportShapesGeojsonUrl._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// ---
public GfrActPlgImportShapesGeojsonUrl()
{
super("Import earth shapes from GeoJSON URL");
}
@Override
public void actionPerformed(ActionEvent e)
{
try
{
GfrDlgCmdCancelOkEdtUrlAbs dlg = new GfrDlgCmdCancelOkEdtUrlGeojson();
if (!dlg.init())
{
throw new Exception("! dlg.init()");
}
dlg.setVisible(true);
boolean blnCancelled = dlg.isCancelled();
String strValue = null;
if (!blnCancelled)
{
strValue = dlg.getValue();
}
dlg.destroy();
dlg = null;
if (blnCancelled)
return;
// beg handling current bug
if (strValue == null || strValue.length() < 1)
{
String str = "strUrl == null || strUrl.length()<1";
GfrActPlgImportShapesGeojsonUrl._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, "Dev coding error: " + str);
return;
}
super._doJob(strValue);
}
catch (Exception exc)
{
exc.printStackTrace();
String str = exc.getMessage();
if (str == null)
str = "Uncaught exception";
GfrActPlgImportShapesGeojsonUrl._LOGGER_.severe(str);
str = GfrUtlString.s_formatExceptionMessageForDialog(str);
JOptionPane.showMessageDialog(null, str, "Failed to import earth shapes from URL", JOptionPane.ERROR_MESSAGE);
}
}
}