Interface ThreadedPlugIn
- All Superinterfaces:
PlugIn
- All Known Implementing Classes:
AbstractAddDatastoreLayerPlugIn, AbstractLinearReferencingPlugIn, AbstractLoadDatasetPlugIn, AbstractLoadSaveDatasetPlugIn, AbstractSaveDatasetAsPlugIn, AbstractThreadedUiPlugIn, AbstractWizardPlugin, Add3DGeometryAttributesPlugIn, AddDatastoreLayerPlugIn, AddGeometryAttributesPlugIn, AffineTransformationPlugIn, AttributeQueryPlugIn, BeanshellAttributeCalculatorPlugIn, BufferPlugIn, CalculateDistancesPlugIn, CalcVarianceAndMeanPerClassPlugIn, ChangeNoDataValuePlugIn, ChangeRangeValuesToNoDataPlugIn, ChangeValueToNoDataPlugIn, ClassifyAttributesPlugIn, ClipToFencePlugIn, ConvexHullPlugIn, CoverageSimplifierPlugIn, CreateBarPlotPlugIn, CreateGridPlugIn, CreateHistogramPlugIn, CreateLatticeFromSelectedImageLayerPlugIn, CreatePolygonGridFromSelectedImageLayerPlugIn, CreateScatterPlotPlugIn, CreateThiessenPolygonsPlugIn, CropWarpPlugIn, CTSPlugIn, DeleteDuplicateGeometriesPlugIn, DEMStatisticsPlugIn, DiffGeometryPlugIn, Dissolve2PlugIn, DissolvePlugIn, EditDataStoreQueryPlugIn, EraseLayerAWithLayerBPlugIn, ExtensionManagerPlugIn, ExtractCommonBoundaryBetweenPolysPlugIn, ExtractLayersByGeometry, ExtractPointsPlugIn, ExtractSegmentsPlugIn, GeometryFunctionPlugIn, GeometrySnapperPlugIn, HistogramPlugIn, IntersectPolygonLayersPlugIn, IntersectPolygonsOneLayerPlugIn, JoinAttributesSpatiallyPlugIn, JoinTableFromExistingLayerPlugIn, JoinTablePlugIn, KernelAnalysisPlugIn, LinearReferencingOnLayerPlugIn, LinearReferencingOnSelectionPlugIn, LineNoderPlugIn, LoadDatasetPlugIn, LoadStylePlugIn, MainButtonPlugIn, MakeValidPlugIn, ManageDataPlugIn, MergePolygonsWithNeighbourPlugIn, MergeSelectedPolygonsWithNeighbourPlugIn, MultiRingBufferSelectedPlugIn, NodeFeaturesPlugIn, NodeLinesPlugIn, NodePolygonsPlugIn, NoderPlugIn, OffsetCurvePlugIn, OpenFilePlugIn, OpenProjectPlugIn, OpenProjectPlugIn, OpenWizardPlugIn, OverlayPlugIn, PlanarGraphPlugIn, PointLayerFromAttributeTablePlugIn, PointsToPathsPlugIn, PolygonizerPlugIn, PrecisionReducerPlugIn, ProfileGraphPlugIn, ProgressReportingPlugIn, RasterizePlugIn, RasterLegendPlugIn, RasterStylesPlugIn, RefreshDataStoreQueryPlugIn, RemoveSpikePlugIn, ReplaceValuePlugIn, ReplicateSelectedItemsPlugIn, RunDatastoreQueryPlugIn, RunMacroPlugIn, SaveDatasetAsFilePlugIn, SaveDatasetAsPlugIn, SaveImageAsSVGPlugIn, SaveStylePlugIn, SaveWizardPlugIn, SimplifyPolygonCoveragePlugIn, SimplifyWithJTSAlgorithmPlugIn, SpatialJoinPlugIn, SpatialJoinPlugIn, SpatialQueryPlugIn, SplitFeaturesPlugIn, SplitLinesNodePolygonsPlugIn, SplitPolygonPlugIn, SplitPolygonsNodeLinesPlugIn, ThreadedBasePlugIn, TriangulationPlugIn, UnionByAttributePlugIn, UnionPlugIn, UpdateWithJoinPlugIn, ValidateSelectedLayersPlugIn, VectorizeToContoursPlugIn, VectorizeToPolygonsPlugIn, VoronoiDiagramPlugIn
A long-running PlugIn that keeps the GUI responsive (but only partially so,
as a modal progress dialog will be in the way).
First, #execute is called on the AWT event dispatch thread (the "GUI thread"). Here, the user can be prompted with a dialog.
Then, #run(TaskMonitor) is called, on a new thread. Here, a long operation can be performed. The TaskMonitor can be used to report progress (messages will appear on a modal progress dialog). Because the thread is not the GUI thread, the GUI will remain responsive.
Thus, to run a PlugIn on a separate thread with progress reporting:
- implement ThreadedPlugIn
- put any GUI prompting in #execute. If the user chooses to cancel, return false.
- put the time-consuming task in #run(TaskMonitor)
- add the ThreadedPlugIn using FeatureInstaller
-
Method Summary
Modifier and TypeMethodDescriptionvoidrun(TaskMonitor monitor, PlugInContext context) Runs the task.Methods inherited from interface PlugIn
execute, getName, initialize
-
Method Details
-
run
Runs the task. This method will be executed in a separate thread, so that the GUI remains responsive (but only partially so, as a modal progress dialog will be in the way). Don't call GUI classes in this method as it is not executed on the GUI thread.- Parameters:
monitor- context to which this task can report its progress and check whether a party has requested its cancellationcontext- context of this PlugIn- Throws:
Exception- if an Exception occurs during the run
-