private static void addProducts(final FileTableModel tableModel, final File[] files) { final ProgressHandleMonitor pm = ProgressHandleMonitor.create("Populating table"); Runnable operation = () -> { pm.beginTask("Populating table...", files.length); for (File file : files) { if (ProductFunctions.isValidProduct(file)) { tableModel.addFile(file); } pm.worked(1); } pm.done(); }; ProgressUtils.runOffEventThreadWithProgressDialog(operation, "Adding Products", pm.getProgressHandle(), true, 50, 1000); }
public static ProgressHandleMonitor create(String displayName, Cancellable cancellable) { ProgressHandleMonitor progressMonitor = new ProgressHandleMonitor(cancellable); ProgressHandle progressHandle = ProgressHandleFactory.createHandle(displayName, progressMonitor); progressMonitor.setProgressHandle(progressHandle); return progressMonitor; }
@Override public void worked(int work) { internalWorked(work); }
@Override public boolean cancel() { if (cancellable != null) { setCanceled(cancellable.cancel()); } else { setCanceled(true); } return isCanceled(); }
@Override protected void onApply() { BenchmarkExecutor executor = new BenchmarkExecutor(); //launch processing with a progress bar ProgressHandleMonitor pm = ProgressHandleMonitor.create("Running benchmark", executor); executor.setProgressHandleMonitor(pm); ProgressUtils.runOffEventThreadWithProgressDialog(executor, "Benchmarking....", pm.getProgressHandle(), true, 50, 1000); }
progressHandleMonitor.beginTask("Benchmark running... ", benchmarkModel.getBenchmarkCalculus().size() * 100); progressHandleMonitor.getProgressHandle().progress( String.format("Benchmarking ( cache size:%d , nb threads:%d )", benchmarkSingleCalcul.getCacheSize(), progressHandleMonitor.done();
public static ProgressHandleMonitor create(String displayName) { return create(displayName, null); }
public ProgressHandle getProgressHandle() { return pm.getProgressHandle(); }
private static void updateImages(RasterDataNode rasterDataNode, boolean validMaskPropertyChanged) { if (rasterDataNode instanceof VirtualBand) { VirtualBand virtualBand = (VirtualBand) rasterDataNode; if (virtualBand.hasRasterData()) { String title = "Recomputing Raster Data"; ProgressHandleMonitor pm = ProgressHandleMonitor.create(title); Runnable operation = () -> { try { virtualBand.readRasterDataFully(pm); } catch (IOException e) { Dialogs.showError(e.getMessage()); } }; ProgressUtils.runOffEventThreadWithProgressDialog(operation, title, pm.getProgressHandle(), true, 50, // time in ms after which wait cursor is shown 1000); // time in ms after which dialog with "Cancel" button is shown } } OpenImageViewAction.updateProductSceneViewImages(new RasterDataNode[]{rasterDataNode}, view -> { if (validMaskPropertyChanged) { view.updateNoDataImage(); } view.updateImage(); }); }
public WriteProductOperation(Product product, File fileLocation, String formatName, Boolean incremental) { Assert.notNull(product, "product"); Assert.notNull(fileLocation, "fileLocation"); Assert.notNull(formatName, "formatName"); this.product = product; this.fileLocation = fileLocation; this.formatName = formatName; if (incremental != null) { this.incremental = incremental; } else { this.incremental = SnapApp.getDefault().getPreferences().getBoolean(PREFERENCE_KEY_SAVE_INCREMENTAL, DEFAULT_VALUE_SAVE_INCREMENTAL); } this.pm = ProgressHandleMonitor.create(Bundle.CTL_WriteProductOperationName(), this); }
private static void addAllOpenProducts(final FileTableModel tableModel) { final ProgressHandleMonitor pm = ProgressHandleMonitor.create("Populating table"); Runnable operation = () -> { final Product[] products = SnapApp.getDefault().getProductManager().getProducts(); pm.beginTask("Populating table...", products.length); for (Product prod : products) { final File file = prod.getFileLocation(); if (file != null && file.exists()) { tableModel.addFile(file); } pm.worked(1); } pm.done(); }; ProgressUtils.runOffEventThreadWithProgressDialog(operation, "Adding Products", pm.getProgressHandle(), true, 50, 1000); }