/*
* 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.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlTblHistoryChildrenAbs;
import org.geoforge.guillc.event.GfrEvtPanelChange;
import org.geoforge.guillc.panel.GfrPnlGrpTxfFullEditableNo;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
/**
*
* @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 GfrDlgOpenSpaceFromHistoryAbs extends GfrDlgCmdCancelOkEdtAbs
implements ListSelectionListener
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrDlgOpenSpaceFromHistoryAbs.class.getName());
static
{
GfrDlgOpenSpaceFromHistoryAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
protected GfrPnlTblHistoryChildrenAbs _pnlExistingItems;
protected GfrPnlGrpTxfFullEditableNo _pnlChildrenSelectedValue;
public String getValue()
{
return this._pnlChildrenSelectedValue.getValue();
}
protected GfrDlgOpenSpaceFromHistoryAbs(
JFrame frmOwner,
String strTitleSuffix)
{
super(
frmOwner,
strTitleSuffix);
this._pnlChildrenSelectedValue = new GfrPnlGrpTxfFullEditableNo(
"Choice");
super.addToListResizable(this._pnlChildrenSelectedValue);
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._pnlExistingItems.init())
return false;
if (!this._pnlChildrenSelectedValue.init())
return false;
this._pnlChildrenSelectedValue.setMandatoryIcon(false);
super._pnlContent.addWithSpace(this._pnlExistingItems);
super._pnlContent.addWithSpace(this._pnlChildrenSelectedValue);
this.pack();
return true;
}
@Override
public void valueChanged(ListSelectionEvent evt)
{
super.setEnabledOkCommandDialog(true);
String selectedData = null;
JTable table = _pnlExistingItems.getTable();
int[] selectedRow = table.getSelectedRows();
if (selectedRow.length > 1)
{
String str = "GfrDlgOpenSpaceFromHistoryAbs : selectedRow.length > 1, "
+ "Multi selection not supported";
GfrDlgOpenSpaceFromHistoryAbs._LOGGER_.severe(str);
GfrOptionPaneAbs.s_showDialogError(null, str);
System.exit(1);
}
if (selectedRow.length == 0)
{
this._pnlChildrenSelectedValue.setContent("");
super.setEnabledOkCommandDialog(false);
return;
}
int intRow = selectedRow[0];
selectedData = (String) table.getValueAt(intRow, 0);
this._pnlChildrenSelectedValue.setContent(selectedData);
}
@Override
protected boolean _okEnableable()
{
return true;
}
@Override
protected boolean _noErrorToDisplay()
{
return true;
}
@Override
protected void _updateModifiedFieldStatus(GfrEvtPanelChange e)
{
}
}