/*
* 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.thread;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.swing.JLabel;
import org.geoforge.guillc.progressbar.GfrProgressBar;
import org.geoforge.io.util.eventobject.GfrEventObjectDoneWriteObjects;
import org.geoforge.lang.util.eventobject.GfrEventObjectAbs;
import org.geoforge.lang.handler.IGfrHandlerEventListenerThreadJobProgress;
import org.geoforge.lang.thread.GfrPgsThrAbs;
/**
*
* @author bantchao
*/
abstract public class GfrPgsThrIdsBldAbs extends GfrPgsThrAbs
{
protected JLabel _lblItems = null;
protected GfrProgressBar _pbrItems = null;
protected Set<String> _setCreatedIds = null;
protected boolean _blnDoneJob = false;
public boolean isDoneJob() { return this._blnDoneJob; }
public Set<String> getCreatedIds() { return this._setCreatedIds; }
protected GfrPgsThrIdsBldAbs(
IGfrHandlerEventListenerThreadJobProgress lst,
GfrProgressBar pbrItems,
JLabel lblItems)
throws Exception
{
super(lst);
this._setCreatedIds = new HashSet<String>();
this._pbrItems = pbrItems;
this._lblItems = lblItems;
super._thr.start();
}
@Override
protected synchronized void _fireEvent() throws Exception
{
if (super._blnCanceled)
return;
GfrEventObjectAbs event = new GfrEventObjectDoneWriteObjects(this, super._strError);
Iterator itr = super._listeners.iterator();
while (itr.hasNext())
{
if (super._blnCanceled)
return;
((IGfrHandlerEventListenerThreadJobProgress) itr.next()).handleEventThreadJobDone(event);
}
}
}