Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modernizes the progress listener for shapefiles
- Loading branch information
1 parent
d1ba5bd
commit 93941a9
Showing
2 changed files
with
127 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package msi.gama.util.file; | ||
|
||
import org.geotools.util.SimpleInternationalString; | ||
import org.opengis.util.InternationalString; | ||
import org.opengis.util.ProgressListener; | ||
|
||
import msi.gama.common.interfaces.IStatusDisplayer; | ||
import msi.gama.runtime.GAMA; | ||
import msi.gama.runtime.IScope; | ||
import msi.gama.runtime.exceptions.GamaRuntimeException; | ||
|
||
class ProgressCounter implements ProgressListener { | ||
|
||
final IScope scope; | ||
final String name; | ||
float progress; | ||
|
||
ProgressCounter(final IScope scope, final String name) { | ||
this.scope = scope; | ||
this.name = name; | ||
} | ||
|
||
IStatusDisplayer getDisplayer() { | ||
return scope.getGui().getStatus(scope); | ||
} | ||
|
||
@Override | ||
public void complete() { | ||
getDisplayer().setSubStatusCompletion(1d); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
getDisplayer().endSubStatus(name.toString()); | ||
} | ||
|
||
@Override | ||
public void exceptionOccurred(final Throwable arg0) { | ||
GAMA.reportAndThrowIfNeeded(scope, GamaRuntimeException.create(arg0, scope), true); | ||
} | ||
|
||
@Override | ||
public float getProgress() { | ||
return progress; | ||
} | ||
|
||
@Override | ||
public InternationalString getTask() { | ||
return new SimpleInternationalString(name); | ||
} | ||
|
||
@Override | ||
public boolean isCanceled() { | ||
return scope.interrupted(); | ||
} | ||
|
||
@Override | ||
public void progress(final float p) { | ||
progress = p; | ||
getDisplayer().setSubStatusCompletion(progress); | ||
} | ||
|
||
@Override | ||
public void setCanceled(final boolean cancel) { | ||
getDisplayer().endSubStatus(name.toString()); | ||
} | ||
|
||
@Override | ||
public void setTask(final InternationalString n) {} | ||
|
||
@Override | ||
public void started() { | ||
getDisplayer().beginSubStatus(name.toString()); | ||
} | ||
|
||
@Override | ||
public void warningOccurred(final String source, final String location, final String warning) { | ||
GAMA.reportAndThrowIfNeeded(scope, GamaRuntimeException.warning(warning, scope), false); | ||
} | ||
|
||
} |