/*
* 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 java.util.ArrayList;
import javax.swing.JFrame;
import org.geoforge.guillc.event.GfrEvtValidityChanged;
import org.geoforge.guillc.handler.IGfrHandlerListenerPanelDialog;
import org.geoforge.guillc.panel.GfrPnlGrpSngCmbNotEditableStr;
import org.geoforge.guillc.panel.GfrPnlSelColumn;
import org.geoforge.io.header.GfrIoSheetColIdxXlosNamGeometry;
import org.geoforge.io.header.GfrIoSheetColNamTlosPointGeometryAbs;
/**
*
* @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 GfrDlgSelImpSheetTlosPointGeometryAbs extends GfrDlgSelImpSheetXlosNamAbs
{
final static private int _INT_NB_COLUMNS_MIN_ = 1;
protected int getIndexGeometry()
{
return this._pnlGeometry.getSelectedIndex() - 1;
}
@Override
public GfrIoSheetColIdxXlosNamGeometry getUserChoices()
{
return new GfrIoSheetColIdxXlosNamGeometry(
super.isSkipFirstLine(),
super._getIndexName(),
this.getIndexGeometry());
}
protected GfrPnlGrpSngCmbNotEditableStr _pnlGeometry = null;
protected GfrDlgSelImpSheetTlosPointGeometryAbs(
JFrame frmOwner,
int intNbColumn,
ArrayList<Object[]> alt,
String strSentence,
String strUniqueName,
int intNbColumnMin)
throws Exception
{
super(
frmOwner,
intNbColumn,
alt,
strSentence,
strUniqueName,
_INT_NB_COLUMNS_MIN_ + intNbColumnMin);
this._pnlGeometry = new GfrPnlSelColumn(super._strsItemList, "Coordinates");
super.addToListResizable(this._pnlGeometry);
this._pnlGeometry.addPanelListener((IGfrHandlerListenerPanelDialog) this);
}
@Override
protected boolean _noErrorToDisplay()
{
if (!super._noErrorToDisplay())
return false;
int intGeometry = this._pnlGeometry.getSelectedIndex();
int intUniqueName = this._pnlName.getSelectedIndex();
// ----
if (intGeometry != 0)
{
if (intGeometry == intUniqueName)
{
boolean blnResult = false;
String str = "Geometry and " + super.getUniqueName() + " are sharing the same column";
validityChanged(new GfrEvtValidityChanged(blnResult, str));
return blnResult;
}
}
return true;
}
@Override
protected boolean _okEnableable()
{
//--
if (!super._okEnableable())
return false;
int intId = this._pnlName.getSelectedIndex();
//--
int intGeometry = this._pnlGeometry.getSelectedIndex();
if (intGeometry == 0)
return false;
// ---
if (intGeometry == intId)
return false;
return true;
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._pnlGeometry.init())
return false;
super._initChoicePanel(this._pnlGeometry, GfrIoSheetColNamTlosPointGeometryAbs.STR_GEOMETRY, true);
super._pnlSelect.addWithSpace(this._pnlGeometry);
return true;
}
@Override
public void destroy()
{
super.destroy();
if (this._pnlGeometry != null)
{
this._pnlGeometry.destroy();
this._pnlGeometry = null;
}
}
}