/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.guillcogc.treenode;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.tree.DefaultTreeModel;
import org.geoforge.guillc.tree.GfrTreAbs;
import org.geoforge.guillc.treenode.GfrNodAbs;
import org.geoforge.guillc.treenode.GfrNodCtrMovFolderAbs;
import org.geoforge.guillc.treenode.GfrSorterNodChildren;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldatogc.GfrMdlDatIdObjTloOgcWms;
import org.geoforge.mdldatogc.event.GfrEvtMdlIdDatAddedLloVarWmsLyrLeaf;
/**
*
* @author robert
*/
abstract public class GfrNodCtrMovFolderLblLyrPrjWmsAbs extends GfrNodCtrMovFolderAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrNodCtrMovFolderLblLyrPrjWmsAbs.class.getName());
static
{
GfrNodCtrMovFolderLblLyrPrjWmsAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
protected ActionListener _alrParentPanelMvc = null;
transient protected ActionListener _alrControllerPerspective = null;
abstract protected void _loadChildrenFolder(String[] strsId) throws Exception;
abstract protected void _loadChildrenLeaf(String[] strsId) throws Exception;
abstract protected void _loadChildren() throws Exception;
protected String _strIdOwner = null;
protected GfrNodCtrMovFolderLblLyrPrjWmsAbs(
ActionListener alrControllerSpcPrj,
ActionListener alrControllerPrs,
String strIdUnique,
GfrTreAbs tre,
ActionListener alrParentPanelMvc,
String strIdOwner,
String strLabel,
ImageIcon iin)
throws Exception
{
super(
alrControllerSpcPrj,
strIdUnique,
strLabel,
iin,
tre);
this._alrControllerPerspective = alrControllerPrs;
this._alrParentPanelMvc = alrParentPanelMvc;
this._strIdOwner = strIdOwner;
GfrMdlDatIdObjTloOgcWms.getInstance().addObserver((Observer) this);
}
@Override
public void update(Observable obs, Object objEvt)
{
if (objEvt instanceof GfrEvtMdlIdDatAddedLloVarWmsLyrLeaf)
return; // don't care
super.update(obs, objEvt);
}
@Override
public boolean init()
{
if (!super.init())
return false;
try
{
_loadChildren();
}
catch(Exception exc)
{
exc.printStackTrace();
GfrNodCtrMovFolderLblLyrPrjWmsAbs._LOGGER_.severe(exc.getMessage());
return false;
}
return true;
}
@Override
public void destroy()
{
GfrMdlDatIdObjTloOgcWms.getInstance().deleteObserver((Observer) this);
super.destroy();
}
protected void _addObjectVariableNode(GfrNodAbs nod) throws Exception
{
if (! nod.init())
{
GfrNodCtrMovFolderLblLyrPrjWmsAbs._LOGGER_.severe("! nod.init()");
throw new Exception("! nod.init()");
}
String strName = (String) nod.getUserObject();
int intPos = GfrSorterNodChildren.s_getPositionChildToAdd(this, strName);
DefaultTreeModel dtm = (DefaultTreeModel) super._tree.getModel();
dtm.insertNodeInto(nod, this, intPos);
// IN COMMENTS COZ OF DISPLAY TBRL, LABEL BEING TRUNCATED AT THE END !!! I.E., AT IMPORT TIME
//TreePath tphCur = new TreePath(nod.getPath());
//if (!super._tree.isVisible(tphCur))
/*{
TreePath tphThis = new TreePath(this.getPath());
super._tree.expandPath(tphThis);
}*/
}
}