/*
* 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.guillc.treenode;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlStatusBarAbs;
import org.geoforge.guillc.tree.GfrTreAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldsp.event.state.multiple.GfrEvtMdlTogMltSecRbn;
import org.geoforge.mdldsp.state.multiple.GfrMdlTogMltSecRbn;
import org.geoforge.wrpbasprsdsp.state.multiple.run.GfrWrpBasPrsDspPrjObjSecMltTogRbn;
/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com ... please remove "_AT_" from the above
* string to get the right email address
*/
abstract public class GfrNodCtrMovFolderTogSecRbnAbs extends GfrNodCtrMovFolderTogSecAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrNodCtrMovFolderTogSecRbnAbs.class.getName());
static
{
GfrNodCtrMovFolderTogSecRbnAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
protected GfrNodCtrMovFolderTogSecRbnAbs(
ActionListener alrControllerSpcPrj,
ActionListener alrControllerPrs,
String strUniqueId,
String strName,
GfrTreAbs tre,
GfrPnlStatusBarAbs pnlStatusBar,
String strIdViewer)
throws Exception
{
super(alrControllerSpcPrj,
alrControllerPrs,
strUniqueId,
strName,
tre,
pnlStatusBar,
strIdViewer,
GfrWrpBasPrsDspPrjObjSecMltTogRbn.getInstance().isEnabled(strIdViewer, strUniqueId),
(ImageIcon) null
);
GfrMdlTogMltSecRbn.getInstance().addObserver((Observer) this);
}
@Override
public void destroy()
{
super.destroy();
// for buttonGroup-like behaviour
GfrMdlTogMltSecRbn.getInstance().deleteObserver((Observer) this);
}
@Override
public void update(Observable obs, Object objEvt)
{
if (objEvt instanceof GfrEvtMdlTogMltSecRbn)
{
if (! super.isSelectedToggableNode())
return;
GfrEvtMdlTogMltSecRbn evt = (GfrEvtMdlTogMltSecRbn) objEvt;
boolean blnIsSelected = evt.getValueObject();
if (blnIsSelected)
return;
String strIdViewer = evt.getKeyViewer();
if (strIdViewer.compareTo(super._strIdViewer_) != 0)
return;
String strId = evt.getKeyObject();
if (strId.compareTo(this._strId) != 0)
return;
setSelected(false);
// x-fingers
super.getTree().validate();
super.getTree().repaint();
return;
}
super.update(obs, objEvt);
}
@Override
public void setSelected(boolean blnIsSelected)
{
super.setSelected(blnIsSelected);
try
{
if (blnIsSelected)
GfrMdlTogMltSecRbn.getInstance().doJob(this._strIdViewer_, super._strId, blnIsSelected);
}
catch (Exception exc)
{
exc.printStackTrace();
String str = exc.getMessage();
GfrNodCtrMovFolderTogSecRbnAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
}
}
}