/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.appogcecl.actionperformer;
import java.awt.event.ActionEvent;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
import org.geoforge.appogcecl.actioncontroller.GfrAcrSpcAppPrsPrjRunAbs;
import org.geoforge.guillc.frame.GfrFrmAbs;
import org.geoforge.guillc.menuitem.GfrMimTrsAlrDelAllObjTlos;
import org.geoforge.guillc.menuitem.GfrMimTrsAlrIdAbs;
import org.geoforge.guillc.menuitem.GfrMimTrsAlrIdDelObj;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillcogc.button.GfrBtnTransientDelAllTloGlcOgcAbs;
import org.geoforge.guillcogc.button.GfrBtnTransientDelAllTloPrcOgcAbs;
import org.geoforge.guillcogc.button.GfrBtnTransientDelAllTloProjectOgcAbs;
import org.geoforge.guillcogc.button.GfrBtnTrsDelAllTloCatOgc;
import org.geoforge.guillcogc.enumeration.GfrEnuValuesKindObjectTloSpcPrjOgc;
import org.geoforge.guillcogc.util.GfrResBundleGuiLlcOgc;
import org.geoforge.lang.enumeration.GfrEnuApplicationPropertiesImmutableKeys;
import org.geoforge.lang.util.GfrResBundleLang;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldatogc.GfrMdlDatSetTlosOgcWms;
import org.geoforge.wrpbasprssynogc.GfrWrpBasSynObjNameTloWms;
/**
*
* @author robert
*/
abstract public class ActPrfPrjDeleteOgcAbs extends ActPrfPrjDeleteAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(ActPrfPrjDeleteOgcAbs.class.getName());
static
{
ActPrfPrjDeleteOgcAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
/*
* handling secondary windows
*/
@Override
public boolean doneJob(ActionEvent evt, GfrAcrSpcAppPrsPrjRunAbs acrRun) throws Exception
{
if (super.doneJob(evt, acrRun))
return true;
if (evt.getSource() instanceof GfrBtnTrsDelAllTloCatOgc)
{
GfrBtnTrsDelAllTloCatOgc btn = (GfrBtnTrsDelAllTloCatOgc) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwnerTrickForActionController(btn);
String strBody =
GfrResBundleGuiLlcOgc.s_getInstance().getValue("sentence.confirmDeleteAllOgcServices");
if (!GfrOptionPaneAbs.s_showDialogConfirm(
frmOwner,
GfrResBundleLang.s_getInstance().getValue("sentence.deleteAll"),
strBody))
return true;
_deleteAllObjectsInProject_(acrRun);
return true;
}
if (evt.getSource() instanceof GfrBtnTransientDelAllTloProjectOgcAbs)
{
JButton btn = (JButton) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwnerTrickForActionController(btn);
String strBody = GfrResBundleLang.s_getInstance().getValue("sentence.confirmDeleteAllObjectsOfProject");
if (!GfrOptionPaneAbs.s_showDialogConfirm(
frmOwner,
GfrResBundleLang.s_getInstance().getValue("sentence.deleteAll"),
strBody))
return true; // action cancelled by user
_deleteAllObjectsInProject(acrRun);
return true;
}
if (evt.getSource() instanceof GfrBtnTransientDelAllTloGlcOgcAbs)
{
JButton btn = (JButton) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwner(btn);
String strBody = "Delete all geo-located objects";
if (!GfrOptionPaneAbs.s_showDialogConfirm(
frmOwner,
GfrResBundleLang.s_getInstance().getValue("sentence.deleteAll"),
strBody))
return true; // action cancelled by user
// !!! TEMPO
_deleteAllObjectsInProject(acrRun);
return true;
}
if (evt.getSource() instanceof GfrBtnTransientDelAllTloPrcOgcAbs)
{
JButton btn = (JButton) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwner(btn);
String strBody = "Delete all process objects";
if (!GfrOptionPaneAbs.s_showDialogConfirm(
frmOwner,
GfrResBundleLang.s_getInstance().getValue("sentence.deleteAll"),
strBody))
return true; // action cancelled by user
// !!! TEMPO
_deleteAllObjectsInProject(acrRun);
return true;
}
return false;
}
@Override
public boolean doneJob(ActionEvent evt) throws Exception
{
if (super.doneJob(evt))
return true;
if (evt.getSource() instanceof GfrMimTrsAlrIdDelObj)
{
GfrMimTrsAlrIdAbs mim = (GfrMimTrsAlrIdAbs) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwnerTrickForActionController(mim);
String strId = mim.getId();
String strValueKindObject = mim.getPropertyImmutable(
GfrEnuApplicationPropertiesImmutableKeys.KEY_KIND_OBJECT.name());
//--
if (strValueKindObject == null || strValueKindObject.length() < 1)
return false;
//--
if (strValueKindObject.compareTo(GfrEnuValuesKindObjectTloSpcPrjOgc.VALUE_TLO_WMS.name()) == 0)
{
String strName = GfrWrpBasSynObjNameTloWms.getInstance().getTitleService(strId);
String strBody =
GfrResBundleLang.s_getInstance().getValue("sentence.confirmDelete")
+ "\n"
+ " "
+ "\""
+ strName
+ "\""
+ "?";
String strTitle = GfrResBundleLang.s_getInstance().getValue("word.delete")
+ " \"" + strName + "\"";
if (!GfrOptionPaneAbs.s_showDialogConfirm(
frmOwner, strTitle, strBody))
{
return true; // action cancelled by user
}
GfrMdlDatSetTlosOgcWms.getInstance().deleteObjectWithId(strId);
return true;
}
}
if (evt.getSource() instanceof GfrMimTrsAlrDelAllObjTlos)
{
GfrMimTrsAlrDelAllObjTlos mim = (GfrMimTrsAlrDelAllObjTlos) evt.getSource();
JFrame frmOwner = GfrFrmAbs.s_getFrameOwnerTrickForActionController(mim);
String strValueKindObject = mim.getPropertyImmutable(
GfrEnuApplicationPropertiesImmutableKeys.KEY_KIND_OBJECT.name());
//--
if (strValueKindObject == null || strValueKindObject.length() < 1)
return false;
//--
if (strValueKindObject.compareTo(GfrEnuValuesKindObjectTloSpcPrjOgc.VALUE_TLO_WMS.name()) == 0)
{
String strBody =
GfrResBundleGuiLlcOgc.s_getInstance().getValue("sentence.confirmDeleteAllWmsServices");
if (!GfrOptionPaneAbs.s_showDialogConfirm(
frmOwner,
GfrResBundleLang.s_getInstance().getValue("sentence.deleteAll"),
strBody))
return true; // action cancelled by user
GfrMdlDatSetTlosOgcWms.getInstance().deleteAllObjectWithId();
return true;
}
}
// ending
return false;
}
// ---
protected ActPrfPrjDeleteOgcAbs()
{
super();
}
protected void _deleteAllObjectsInProject(GfrAcrSpcAppPrsPrjRunAbs acrRun) throws Exception
{
_deleteAllObjectsInProject_(acrRun);
}
// ---
private void _deleteAllObjectsInProject_(GfrAcrSpcAppPrsPrjRunAbs acrRun) throws Exception
{
GfrMdlDatSetTlosOgcWms.getInstance().deleteAllObjectWithId();
}
}