/*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.guillc.dialog;
import javax.swing.JFrame;
import org.geoforge.guillc.event.GfrEvtValidityChanged;
import org.geoforge.guillc.handler.IGfrHandlerDisplayableObjectsSet;
import org.geoforge.guillc.handler.IGfrHandlerListenerPanelDialog;
import org.geoforge.guillc.panel.GfrPnlGrpTxfAbs;
import org.geoforge.guillc.panel.GfrPnlGrpTxfFullEditableYes;
import org.geoforge.java.net.GfrValidatorUrlHttp;
import org.geoforge.lang.util.GfrResBundleLang;
/**
*
* @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 GfrDlgNewSettingsTloNamAbsUrlAbs extends GfrDlgNewSettingsTloNamAbsAbs
{
private GfrPnlGrpTxfAbs _pnlUrl_;
public String getValueUrl()
{
return this._pnlUrl_.getValue();
}
protected GfrDlgNewSettingsTloNamAbsUrlAbs(
JFrame frmOwner,
IGfrHandlerDisplayableObjectsSet enuValueTlo,
String[] strsExistingItems)
{
super(
frmOwner,
enuValueTlo,
strsExistingItems);
this._pnlUrl_ = new GfrPnlGrpTxfFullEditableYes(
GfrResBundleLang.s_getInstance().getValue("word.url"));
super.addToListResizable(this._pnlUrl_);
this._pnlUrl_.addPanelListener((IGfrHandlerListenerPanelDialog) this);
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._pnlUrl_.init())
return false;
super._pnlGeneral.addWithSpace(this._pnlUrl_, 2);
return true;
}
@Override
public void destroy()
{
super.destroy();
if (this._pnlUrl_ != null)
{
this._pnlUrl_.destroy();
this._pnlUrl_ = null;
}
}
@Override
protected boolean _okEnableable()
{
if (!super._okEnableable())
return false;
//--Not mandatory field
String strUrl = this._pnlUrl_.getValue();
if (strUrl == null || strUrl.length() < 1)
return true;
if (!GfrValidatorUrlHttp.s_isOk(strUrl))
return false;
return true;
}
@Override
protected boolean _noErrorToDisplay()
{
if (!super._noErrorToDisplay())
return false;
//--Url
String strUrl = this._pnlUrl_.getValue();
if (strUrl != null && strUrl.compareTo("") != 0)
{
if (!GfrValidatorUrlHttp.s_isOk(strUrl))
{
validityChanged(new GfrEvtValidityChanged(
false,
"Provide a valid URL"));
return false;
}
}
return true;
}
}