/*
* 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.panel;
import java.awt.BorderLayout;
import java.util.logging.Logger;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.PnlSelLblAbs;
import org.geoforge.guillc.textfield.GfrTfdAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
abstract public class PnlContentsOkAbs extends PnlContentsAbs
{
// ----
// begin: instantiate logger for this class
final static private Logger _LOGGER_ = Logger.getLogger(PnlContentsOkAbs.class.getName());
static
{
PnlContentsOkAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
protected PnlSelLblListValuesCurrentAbs _pnlSelDisplayValuesCurrent = null;
protected PnlSelEditTfdSingleValueTargetAbs _pnlSelChooserValueTarget = null;
// contains additional settings (if any) and warning label, if usable
protected PnlSouthWarning _pnlSouth = null;
@Override
protected boolean _alignLabels()
{
java.util.Set<PnlSelLblAbs> setPanels = new java.util.HashSet<PnlSelLblAbs>();PnlSelLblAbs pnlValueTarget = (PnlSelLblAbs) this._pnlSelChooserValueTarget;
setPanels.add(pnlValueTarget);
if (this._pnlSelDisplayValuesCurrent != null)
{
PnlSelLblAbs pnlList = (PnlSelLblAbs) this._pnlSelDisplayValuesCurrent;
setPanels.add(pnlList);
}
if (! PnlSelLblAbs.s_alignLabels(setPanels))
{
String str = "! PnlSelLblAbs....(setPanels)";
PnlContentsOkAbs._LOGGER_.severe(str);
return false;
}
setPanels.clear();
setPanels = null;
// ending
return true;
}
/**
*
* usage:
* if str==nil or str.length<1
* then no warning
**/
public void updateWarning(String str, boolean blnIsWrongValueTarget)
{
if (this._pnlSouth != null)
this._pnlSouth.updateMessageWarning(str);
if (blnIsWrongValueTarget)
this._pnlSelChooserValueTarget.updateWarning(str);
}
public String getValue()
{
if (this._pnlSelChooserValueTarget == null)
return null;
return this._pnlSelChooserValueTarget.getValue();
}
protected PnlContentsOkAbs()
{
super();
this._pnlSouth = new PnlSouthWarning();
}
@Override
public boolean init()
{
if (! super.init())
return false;
if (! this._pnlSelChooserValueTarget.init())
return false;
if (! this._pnlSouth.init())
return false;
super.add(this._pnlSelChooserValueTarget, BorderLayout.CENTER);
super.add(this._pnlSouth, BorderLayout.SOUTH);
if (this._pnlSelDisplayValuesCurrent != null)
{
if (! this._pnlSelDisplayValuesCurrent.init())
return false;
super.add(this._pnlSelDisplayValuesCurrent, BorderLayout.NORTH);
GfrTfdAbs tfd = (GfrTfdAbs)this._pnlSelChooserValueTarget.getTextField();
this._pnlSelDisplayValuesCurrent.setSizeWidthScrollList(tfd.getPreferredSize().width);
}
if (! _alignLabels())
{
String str = "! _alignLabels_()";
PnlContentsOkAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
return false;
}
return true;
}
@Override
public void destroy()
{
super.destroy();
if (this._pnlSelChooserValueTarget != null)
{
this._pnlSelChooserValueTarget.destroy();
this._pnlSelChooserValueTarget = null;
}
if (this._pnlSelDisplayValuesCurrent != null)
{
this._pnlSelDisplayValuesCurrent.destroy();
this._pnlSelDisplayValuesCurrent = null;
}
if (this._pnlSouth != null)
{
this._pnlSouth.destroy();
this._pnlSouth = null;
}
}
}