/*
* 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.guillcogc.panel;
import org.geoforge.guillc.event.GfrEvtPanelChange;
import org.geoforge.guillc.panel.GfrPnlGrpLbl;
import org.geoforge.guillc.handler.IGfrHandlerListenerPanelDialog;
import org.geoforge.guillc.panel.GfrPnlSelEdt;
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
*/
public class GfrPnlSelEdtServerSelect extends GfrPnlSelEdt implements IGfrHandlerListenerPanelDialog
{
//--
//--beg private fields
private GfrPnlSelDefaultWmsServer _pnlSelectServer_;
private GfrPnlGrpLbl _pnlShowUrlServerWms_;
private GfrPnlShowUrlServerWms _pnlShowUrlHomePage_;
private GfrPnlGrpLbl _pnlShowWhat_;
private GfrPnlGrpLbl _pnlShowWho_;
private String[] _strsDefaultUrlServer_;
private String[] _strsDefaultUrlHomepage_;
private String[] _strsDefaultWho_;
private String[] _strsDefaultWhat_;
//--end private fields
//--
//--
//--beg public methods
public GfrPnlSelEdtServerSelect(
String[] strsItemList,
String strLabelWhat,
String[] strsDefaultServerUrl,
String[] strsDefaultWho,
String[] strsDefaultWhat,
String[] strsDefaultUrlHomePage,
IGfrHandlerListenerPanelDialog pnr)
{
super();
this._strsDefaultUrlServer_ = strsDefaultServerUrl;
this._strsDefaultWho_ = strsDefaultWho;
this._strsDefaultWhat_ = strsDefaultWhat;
this._strsDefaultUrlHomepage_ = strsDefaultUrlHomePage;
this._pnlSelectServer_ = new GfrPnlSelDefaultWmsServer(
strsItemList,
strLabelWhat);
this._pnlSelectServer_.addPanelListener((IGfrHandlerListenerPanelDialog) this);
this._pnlSelectServer_.addPanelListener(pnr);
this._pnlShowUrlServerWms_ = new GfrPnlGrpLbl(
GfrResBundleLang.s_getInstance().getValue("sentence.webMapService"), "");
this._pnlShowUrlHomePage_ = new GfrPnlShowUrlServerWms(
GfrResBundleLang.s_getInstance().getValue("sentence.homePage"), "");
this._pnlShowWhat_ = new GfrPnlGrpLbl(GfrResBundleLang.s_getInstance().getValue("word.what"), "");
this._pnlShowWho_ = new GfrPnlGrpLbl(GfrResBundleLang.s_getInstance().getValue("word.who"), "");
super.addToListResizable(this._pnlShowUrlServerWms_);
super.addToListResizable(this._pnlShowUrlHomePage_);
super.addToListResizable(this._pnlShowWhat_);
super.addToListResizable(this._pnlShowWho_);
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._pnlSelectServer_.init())
return false;
if (!this._pnlShowWho_.init())
return false;
if (!this._pnlShowWhat_.init())
return false;
if (!this._pnlShowUrlServerWms_.init())
return false;
if (!this._pnlShowUrlHomePage_.init())
return false;
this._pnlShowUrlHomePage_.setButtonEnabled(false);
super.addWithSpace(this._pnlSelectServer_);
super.addWithSpace(this._pnlShowUrlServerWms_);
super.addWithSpace(this._pnlShowWhat_);
super.addWithSpace(this._pnlShowWho_);
super.addWithSpace(this._pnlShowUrlHomePage_);
return true;
}
@Override
public void somethingHasHappened(GfrEvtPanelChange e)
{
if (e.getSource() instanceof GfrPnlSelDefaultWmsServer)
{
GfrPnlSelDefaultWmsServer pnl = (GfrPnlSelDefaultWmsServer) e.getSource();
int idx = pnl.getSelectedIndex();
if (idx == 0)
{
this._pnlShowUrlServerWms_.setText("");
this._pnlShowUrlHomePage_.setText("");
this._pnlShowWho_.setText("");
this._pnlShowWhat_.setText("");
this._pnlShowUrlHomePage_.setButtonEnabled(false);
return;
}
this._pnlShowUrlServerWms_.setText(this._strsDefaultUrlServer_[idx - 1]);
this._pnlShowUrlHomePage_.setText(this._strsDefaultUrlHomepage_[idx - 1]);
this._pnlShowUrlHomePage_.setUrl(this._strsDefaultUrlHomepage_[idx - 1]);
this._pnlShowWho_.setText(this._strsDefaultWho_[idx - 1]);
this._pnlShowWhat_.setText(this._strsDefaultWhat_[idx - 1]);
this._pnlShowUrlHomePage_.setButtonEnabled(true);
return;
}
}
public String getWho()
{
return this._pnlShowWho_.getText();
}
public String getValueUrl()
{
return this._pnlShowUrlHomePage_.getText();
}
public String getValueDescShort()
{
return this._pnlShowWhat_.getText();
}
public String getValue()
{
return this._pnlShowUrlServerWms_.getText();
}
public void setCorrectInput(boolean bln)
{
this._pnlSelectServer_.setValueIsOk(bln);
}
public Object getUrlObject()
{
return this._pnlSelectServer_;
}
//--end public methods
//--
}