List of usage examples for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress
IRunnableWithProgress
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.wizards.ReviewTypeSelectionPage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().margins(5, 5).create()); new Label(composite, SWT.NONE).setText("Select how you want to add files to the review:"); Composite buttonComp = new Composite(composite, SWT.NONE); buttonComp.setLayout(GridLayoutFactory.fillDefaults().margins(10, 5).create()); changesetReview = new Button(buttonComp, SWT.CHECK); changesetReview.setText("From a Changeset"); changesetReview.setSelection(plugin.getPreviousChangesetReviewSelection()); changesetReview.addSelectionListener(new SelectionAdapter() { @Override/* w ww.jav a 2 s.c o m*/ public void widgetSelected(SelectionEvent e) { plugin.setPreviousChangesetReviewSelection(changesetReview.getSelection()); } }); patchReview = new Button(buttonComp, SWT.CHECK); patchReview.setText("From a Patch"); patchReview.setSelection(plugin.getPreviousPatchReviewSelection()); patchReview.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { plugin.setPreviousPatchReviewSelection(patchReview.getSelection()); } }); workspacePatchReview = new Button(buttonComp, SWT.CHECK); workspacePatchReview.setText("From Workspace Changes"); workspacePatchReview.setSelection(plugin.getPreviousWorkspacePatchReviewSelection()); workspacePatchReview.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { plugin.setPreviousWorkspacePatchReviewSelection(workspacePatchReview.getSelection()); } }); Set<ITeamUiResourceConnector> teamConnectors = AtlassianTeamUiPlugin.getDefault().getTeamResourceManager() .getTeamConnectors(); if (teamConnectors.size() == 0) { disablePreCommits(); showScmRelatedWarning(buttonComp, "You don't have any SCM integration installed for Atlassian Connector for Eclipse. " + "You need to install at least Subversion or Perforce integration to be able to create reviews. " + "<A href=\"http://confluence.atlassian.com/display/IDEPLUGIN/Installing+the+Eclipse+Connector\">" + "Check installation guide for details</A>. " + "\n\nIf you need <A href=\"https://studio.atlassian.com/browse/PLE-728\">CVS</A>" + " integration help us prioritize our backlog by voting for it."); } else { final int[] repoCount = { 0 }; final IRunnableWithProgress getRepositories = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { repoCount[0] = TeamUiUtils.getRepositories(monitor).size(); } }; try { getContainer().run(true, true, getRepositories); } catch (InvocationTargetException e) { StatusHandler.log(new Status(IStatus.WARNING, CrucibleUiPlugin.PLUGIN_ID, "Failed to retrieve repositories", e)); } catch (InterruptedException e) { StatusHandler.log(new Status(IStatus.WARNING, CrucibleUiPlugin.PLUGIN_ID, "Failed to retrieve repositories", e)); } if (repoCount[0] == 0) { disablePreCommits(); showScmRelatedWarning(buttonComp, "In order to create regular pre- or post-commit review you need to have at least one " + "supported SCM repository configured in your Eclipse workspace.\n" + "If you use SVN, make sure that your \"SVN Repositories\" View contain at least one entry."); } } GridDataFactory.fillDefaults().grab(true, true).applyTo(buttonComp); setControl(composite); setSelectedNode(new IWizardNode() { private ReviewWizard wizard; public boolean isContentCreated() { // re-create this wizard every time return false; } public IWizard getWizard() { dispose(); wizard = new ReviewWizard(taskRepository, getTypes()); return wizard; } public Point getExtent() { return null; } public void dispose() { if (wizard != null) { wizard.dispose(); } } }); }
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.wizards.SelectScmChangesetsPage.java
License:Open Source License
private void updateRepositories() { final MultiStatus status = new MultiStatus(CrucibleUiPlugin.PLUGIN_ID, IStatus.WARNING, "Error while retrieving repositories", null); IRunnableWithProgress getRepositories = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { Collection<ScmRepository> repositories = TeamUiUtils.getRepositories(monitor); if (repositories != null) { for (ScmRepository repository : repositories) { availableLogEntries.put(repository, null); }//from w ww . j a v a 2s . c o m } } }; try { setErrorMessage(null); getContainer().run(true, true, getRepositories); // blocking operation } catch (Exception e) { status.add( new Status(IStatus.WARNING, CrucibleUiPlugin.PLUGIN_ID, "Failed to retrieve repositories", e)); } if (availableLogEntries != null) { availableTreeViewer.setInput(availableLogEntries); } if (status.getChildren().length > 0 && status.getSeverity() == IStatus.ERROR) { //only log errors, swallow warnings setErrorMessage("Error while retrieving repositories. See Error Log for details."); StatusHandler.log(status); } }
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.wizards.SelectScmChangesetsPage.java
License:Open Source License
private void updateChangesets(final ScmRepository repository, final int numberToRetrieve) { final IStatus[] status = { Status.OK_STATUS }; IRunnableWithProgress getChangesets = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { ITeamUiResourceConnector tc = repository.getTeamResourceConnector(); if (tc instanceof ITeamUiResourceConnector2) { SortedSet<ICustomChangesetLogEntry> retrieved = ((ITeamUiResourceConnector2) tc) .getLatestChangesets(repository.getScmPath(), numberToRetrieve, monitor); if (availableLogEntries.containsKey(repository) && availableLogEntries.get(repository) != null) { availableLogEntries.get(repository).addAll(retrieved); } else { availableLogEntries.put(repository, retrieved); }//from ww w. jav a2s . c o m } else { status[0] = new Status(IStatus.ERROR, CrucibleUiPlugin.PLUGIN_ID, "This repository is managed by SCM integration that's compatible only with Crucible 2.x"); } } catch (CoreException e) { status[0] = e.getStatus(); } } }; try { setErrorMessage(null); getContainer().run(false, true, getChangesets); // blocking operation } catch (Exception e) { status[0] = new Status(IStatus.WARNING, CrucibleUiPlugin.PLUGIN_ID, "Failed to retrieve changesets", e); } if (availableLogEntries != null && availableLogEntries.get(repository) != null) { availableTreeViewer.setInput(availableLogEntries); } if (status[0].getSeverity() == IStatus.ERROR) { //only log errors, swallow warnings setErrorMessage(String.format("Error while retrieving changesets (%s). See Error Log for details.", status[0].getMessage())); StatusHandler.log(status[0]); } }
From source file:com.bdaum.zoom.core.internal.CoreActivator.java
License:Open Source License
public void deleteTrashCan() { if (dbManager.hasTrash()) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { List<Trash> set = dbManager.obtainTrashToDelete(true); monitor.beginTask(Messages.CoreActivator_Cleaning_up, set.size() + 1); for (Trash t : set) { t.deleteFiles();//from w ww . j a v a 2 s .c o m monitor.worked(1); } dbManager.closeTrash(); monitor.done(); } }; try { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (workbenchWindow != null) new ProgressMonitorDialog(workbenchWindow.getShell()).run(false, true, runnable); else runnable.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { // ignore } catch (InterruptedException e) { // ignore } } }
From source file:com.bdaum.zoom.core.internal.CoreActivator.java
License:Open Source License
private void convertDatabase(final Meta meta) { final IDbManager db = getDbManager(); int catVersion = meta.getVersion(); int supportedVersion = db.getVersion(); if (catVersion > supportedVersion) Core.getCore().getDbFactory().getErrorHandler().fatalError(Messages.CoreActivator_unsupported_version, NLS.bind(Messages.CoreActivator_use_newer_version, Constants.APPLICATION_NAME, db.getFileName()), (IAdaptable) db);//from ww w .j a v a 2 s. c o m else if (catVersion < supportedVersion) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { monitor.beginTask(Messages.CoreActivator_converting_cat, IProgressMonitor.UNKNOWN); monitor.subTask(Messages.CoreActivator_backing_up_cat); db.performBackup(0L, -1L, true); monitor.subTask(Messages.CoreActivator_converting_to_new_version); CatalogConverter.convert(db, monitor); logInfo(NLS.bind(Messages.CoreActivator_catalog_converted, db.getVersion())); monitor.done(); } }; IWorkbench workbench = PlatformUI.getWorkbench(); Shell shell = workbench.getWorkbenchWindowCount() > 0 ? workbench.getWorkbenchWindows()[0].getShell() : null; if (shell != null) { shell.getDisplay().syncExec(() -> { try { new ProgressMonitorDialog(shell).run(true, false, runnable); } catch (InvocationTargetException e1) { logError(NLS.bind(Messages.CoreActivator_error_when_updating_to_version_n, db.getVersion()), e1); } catch (InterruptedException e2) { // should never happen } }); } else try { runnable.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { logError(NLS.bind(Messages.CoreActivator_error_when_updating_to_version_n, db.getVersion()), e); } catch (InterruptedException e) { // should never happen } } }
From source file:com.bdaum.zoom.db.internal.DbManager.java
License:Open Source License
public void checkDbSanity(final boolean force) { // MessageDialog.openInformation(null, "", systemInfo.freespaceSize() // + ", " + systemInfo.totalSize() + "; " // + systemInfo.freespaceEntryCount()); if (!emergency) try {//from w w w . j a va 2 s . com if (force || needsDefragmentation()) { Meta meta1 = getMeta(false); boolean hasBackups = meta1 == null || meta1.getBackupLocation() != null && !meta1.getBackupLocation().isEmpty(); if (force || hasBackups || factory.getErrorHandler().question(Messages.DbManager_Catalog_maintenance, Messages.DbManager_The_cat_seems_to_be_fragmented, this)) { SystemInfo systemInfo = getSystemInfo(); long totalSize = systemInfo.totalSize(); long freespaceSize = systemInfo.freespaceSize(); long occupiedspaceSize = totalSize - freespaceSize; final long reserve = isReadOnly() ? occupiedspaceSize / 100 : occupiedspaceSize / 20; final long defragSpaceSize = occupiedspaceSize + reserve; long requiredSpace = defragSpaceSize + (force ? 0 : totalSize); long availableSpace = file.getUsableSpace(); if (availableSpace < requiredSpace) { factory.getErrorHandler().showError(Messages.DbManager_Catalog_maintenance, NLS.bind( Messages.DbManager_not_enough_disc_space, requiredSpace, availableSpace), this); return; } final String backupPath = fileName + ".defrag"; //$NON-NLS-1$ File backup = new File(backupPath); ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); try { dialog.run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { monitor.beginTask(NLS.bind(Messages.DbManager_Defragmenting_, fileName), IProgressMonitor.UNKNOWN); if (!force) { monitor.subTask(Messages.DbManager_backing_up_cat); performBackup(0L, -1L, true); } db.close(); db = null; monitor.subTask(Messages.DbManager_defragmenting_cat); DefragmentConfig config = new DefragmentConfig(fileName, backupPath); boolean fileNeedsUpgrade = config.fileNeedsUpgrade(); EmbeddedConfiguration ef = createDatabaseConfiguration(fileNeedsUpgrade, fileName, defragSpaceSize); try { defragment(fileName, backupPath, ef); ef = createDatabaseConfiguration(false, fileName, -1L); db = Db4oEmbedded.openFile(ef, fileName); SystemInfo systemInfo = getSystemInfo(); long newFreespaceSize = systemInfo.freespaceSize(); long newTotalSize = systemInfo.totalSize(); db.close(); db = null; if (newFreespaceSize > 3 * reserve) { monitor.subTask(Messages.DbManager_defrag_cat_2); long newOccupiedspaceSize = newTotalSize - newFreespaceSize; long newReserve = isReadOnly() ? newOccupiedspaceSize / 100 : newOccupiedspaceSize / 20; long newDefragSpaceSize = newOccupiedspaceSize + newReserve; ef = createDatabaseConfiguration(fileNeedsUpgrade, fileName, newDefragSpaceSize); defragment(fileName, backupPath, ef); } } catch (Exception e) { File target = new File(fileName); target.delete(); new File(backupPath).renameTo(target); throw new InvocationTargetException(e); } if (fileNeedsUpgrade) { monitor.subTask(Messages.DbManager_updating_database_version); db = Db4oEmbedded.openFile(ef, fileName); db.close(); db = null; DbActivator.getDefault() .logInfo(NLS.bind( Messages.DbManager_database_converted_to_version_n, Db4o.version())); } } finally { if (db == null) db = createDatabase(fileName, false); } } }); } catch (InvocationTargetException e1) { factory.getErrorHandler().showError(Messages.DbManager_Defrag_error, NLS.bind(Messages.DbManager_Defrag_failed, e1.getCause()), this); DbActivator.getDefault().logError(Messages.DbManager_Defrag_error, e1); return; } catch (InterruptedException e1) { // should never happen } finally { if (!file.exists()) { if (backup.exists()) backup.renameTo(file); DbActivator.getDefault().logError(Messages.DbManager_defragmentation_failed, null); return; } } backup.delete(); DbActivator.getDefault().logInfo(Messages.DbManager_defragmentation_successfiul); } } } catch (Throwable e) { DbActivator.getDefault().logError(Messages.DbManager_error_checking_sanity, e); } }
From source file:com.bdaum.zoom.db.internal.DbManager.java
License:Open Source License
public void pruneEmptySystemCollections() { if (!readOnly && hasDirtyCollection()) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pruneEmptySystemCollections(monitor, false); }/*from w ww. j ava 2s . com*/ }; try { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (workbenchWindow != null) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(workbenchWindow.getShell()); dialog.create(); dialog.getShell().setText(Constants.APPLICATION_NAME); dialog.run(false, true, runnable); } else runnable.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { // ignore } catch (InterruptedException e) { // ignore } } }
From source file:com.bdaum.zoom.ui.internal.commands.ArchiveCommand.java
License:Open Source License
@Override public void run() { boolean result = AcousticMessageDialog.openQuestion(getShell(), Messages.ArchiveAction_archive, Messages.ArchiveAction_archive_message); if (result) { ZProgressMonitorDialog dialog = new ZProgressMonitorDialog(getShell()); try {//from w ww.j a va 2s. c om dialog.run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { imageSize = 0; catSize = 0; remoteImages = 0; externalImages = 0; localImages = 0; voiceFiles = 0; recipes = 0; IDbManager dbManager = Core.getCore().getDbManager(); IVolumeManager volumeManager = Core.getCore().getVolumeManager(); List<IRecipeDetector> recipeDetectors = CoreActivator.getDefault().getRecipeDetectors(); List<AssetImpl> assets = dbManager.obtainAssets(); assetCount = assets.size(); monitor.beginTask(Messages.ArchiveAction_calculationg_space, assetCount + 2); monitor.subTask(Messages.ArchiveAction_calculationg_image_space); for (AssetImpl asset : assets) { if (volumeManager.isRemote(asset)) ++remoteImages; else { URI uri = volumeManager.findExistingFile(asset, true); if (uri == null) ++externalImages; else { ++localImages; File file = new File(uri); imageSize += file.length() + 4096; URI voiceUri = volumeManager.findVoiceFile(asset); if (voiceUri != null) { ++voiceFiles; imageSize += new File(voiceUri).length() + 4096; } for (IRecipeDetector recipeDetector : recipeDetectors) { File[] metafiles = recipeDetector.getMetafiles(asset.getUri()); if (metafiles != null) for (File metafile : metafiles) { ++recipes; imageSize += metafile.length() + 4096; } } } } if (monitor.isCanceled()) return; monitor.worked(1); } monitor.subTask(Messages.ArchiveAction_calculationg_catalog_space); catSize = dbManager.getFile().length(); monitor.worked(1); File indexPath = dbManager.getIndexPath(); if (indexPath != null) { catSize += indexPath.length(); File[] list = indexPath.listFiles(); if (list != null) for (File file : list) catSize += file.length(); } monitor.done(); } }); } catch (InvocationTargetException e) { AcousticMessageDialog.openError(getShell(), Messages.ArchiveAction_error_during_space_calc, e.getCause().getMessage()); return; } catch (InterruptedException e) { AcousticMessageDialog.openInformation(getShell(), Constants.APPLICATION_NAME, Messages.ArchiveAction_archiving_aborted); return; } SpaceDialog spaceDialog = new SpaceDialog(getShell(), remoteImages, externalImages, localImages, voiceFiles, recipes, imageSize, catSize); if (spaceDialog.open() == SpaceDialog.OK) { final File output = spaceDialog.getTargetFile(); final boolean catReadOnly = spaceDialog.isCatReadonly(); final boolean fileReadOnly = spaceDialog.isFileReadonly(); ZProgressMonitorDialog runDialog = new ZProgressMonitorDialog(getShell()); try { runDialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { CoreActivator coreActivator = CoreActivator.getDefault(); IDbFactory dbFactory = coreActivator.getDbFactory(); IDbErrorHandler errorHandler = dbFactory.getErrorHandler(); IDbManager dbManager = coreActivator.getDbManager(); IVolumeManager volumeManager = coreActivator.getVolumeManager(); monitor.beginTask(Messages.ArchiveAction_archiving, assetCount + 105); monitor.subTask(Messages.ArchiveAction_archiving_cat); File catFile = dbManager.getFile(); File indexPath = dbManager.getIndexPath(); File catBackupFile = new File(output, catFile.getName()); dbManager.backup(catBackupFile.getAbsolutePath()); monitor.worked(100); if (indexPath != null) { monitor.subTask(Messages.ArchiveAction_archiving_index); try { BatchUtilities.copyFolder(indexPath, new File(output, indexPath.getName()), monitor); } catch (IOException e1) { errorHandler.showError(Messages.ArchiveAction_error_during_archiving, e1.getMessage(), ArchiveCommand.this); return; } catch (DiskFullException e1) { errorHandler.showError(Messages.ArchiveAction_error_during_archiving, Messages.ArchiveAction_disk_full, ArchiveCommand.this); return; } if (monitor.isCanceled()) { errorHandler.showInformation(Messages.ArchiveAction_operation_cancelled, Messages.ArchiveAction_incomplete_archive, ArchiveCommand.this); return; } } monitor.worked(5); final IDbManager newDbManager = dbFactory .createDbManager(catBackupFile.getAbsolutePath(), false, false, false); try { List<IRecipeDetector> recipeDetectors = coreActivator.getRecipeDetectors(); monitor.subTask(Messages.ArchiveAction_archiving_images); List<AssetImpl> assets = newDbManager.obtainAssets(); int i = 0; long start = System.currentTimeMillis(); for (AssetImpl asset : assets) { URI uri = volumeManager.findExistingFile(asset, true); if (uri != null) { try { String name = Core.getFileName(uri, false); File targetFile = BatchUtilities.makeUniqueFile(output, name, Core.getFileName(uri, true).substring(name.length())); BatchUtilities.copyFile(new File(uri), targetFile, null); if (fileReadOnly) targetFile.setReadOnly(); asset.setUri(targetFile.toURI().toString()); String volume = volumeManager.getVolumeForFile(targetFile); asset.setVolume(volume); URI voiceUri = volumeManager.findVoiceFile(asset); if (voiceUri != null) { String voiceName = Core.getFileName(uri, false); File voiceTargetFile = BatchUtilities.makeUniqueFile(output, name, Core.getFileName(voiceUri, true) .substring(voiceName.length())); BatchUtilities.copyFile(new File(voiceUri), voiceTargetFile, null); if (fileReadOnly) voiceTargetFile.setReadOnly(); AssetEnsemble.insertVoiceNote(asset, volume, voiceTargetFile.toURI().toString()); } else AssetEnsemble.insertVoiceNote(asset, null, null); for (IRecipeDetector recipeDetector : recipeDetectors) recipeDetector.archiveRecipes(output, uri.toString(), asset.getUri(), fileReadOnly); newDbManager.storeAndCommit(asset); } catch (IOException e) { errorHandler.showError(Messages.ArchiveAction_error_during_archiving, e.getMessage(), ArchiveCommand.this); newDbManager.close(CatalogListener.EMERGENCY); return; } catch (DiskFullException e) { errorHandler.showError(Messages.ArchiveAction_error_during_archiving, Messages.ArchiveAction_disk_full, ArchiveCommand.this); newDbManager.close(CatalogListener.EMERGENCY); return; } if (++i % 10 == 0) { int remainingImages = localImages - i; if (remainingImages > 0) { long elapsed = System.currentTimeMillis() - start; long estimated = elapsed / i * remainingImages; monitor.subTask(NLS.bind(Messages.ArchiveAction_elapsed_time, Format.timeFormatter .toString((int) ((elapsed + 30000) / 60000)), Format.timeFormatter .toString((int) ((estimated + 30000) / 60000)))); } } } if (monitor.isCanceled()) { errorHandler.showInformation(Messages.ArchiveAction_operation_cancelled, Messages.ArchiveAction_incomplete_archive, ArchiveCommand.this); return; } monitor.worked(1); } if (catReadOnly) { Meta meta = newDbManager.getMeta(false); if (meta != null) { meta.setReadonly(true); newDbManager.storeAndCommit(meta); } } } finally { newDbManager.close(CatalogListener.NORMAL); monitor.done(); } } }); } catch (InvocationTargetException e) { AcousticMessageDialog.openError(getShell(), Messages.ArchiveAction_error_during_archiving, e.getCause().getMessage()); } catch (InterruptedException e) { AcousticMessageDialog.openInformation(getShell(), Constants.APPLICATION_NAME, Messages.ArchiveAction_incomplete_archive); } } } }
From source file:com.bdaum.zoom.ui.internal.commands.BackupCommand.java
License:Open Source License
@Override public void run() { ZProgressMonitorDialog dialog = new ZProgressMonitorDialog(getShell()); try {/* w w w .ja v a 2s.c o m*/ dialog.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { CoreActivator activator = CoreActivator.getDefault(); monitor.beginTask(Messages.BackupAction_creating_backup, IProgressMonitor.UNKNOWN); activator.getDbManager().performBackup(0L, -1L, false, activator.getBackupGenerations()); monitor.done(); } }); } catch (InvocationTargetException e) { AcousticMessageDialog.openError(getShell(), Messages.BackupAction_error_during_backup, e.getCause().getMessage()); return; } catch (InterruptedException e) { // should not happen } }
From source file:com.bdaum.zoom.ui.internal.commands.ImportAnalogCommand.java
License:Open Source License
private List<File> extractDigitalFiles(String filterPath, String[] fileNames) throws InvocationTargetException, InterruptedException { List<File> digitalFiles = new ArrayList<>(fileNames.length); final ZProgressMonitorDialog dialog = new ZProgressMonitorDialog(getShell()); dialog.create();// w ww .j ava 2 s . co m dialog.getShell().setText(Constants.APPLICATION_NAME + " - " + Messages.ImportAnalogCommand_analog_import); //$NON-NLS-1$ dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.ImportAnalogCommand_checking_files, fileNames.length); try (ExifTool exifTool = new ExifTool(null, false)) { exifTool.setFast(3); for (String fileName : fileNames) { File f = new File(filterPath, fileName); exifTool.reset(f); Map<String, String> metadata = exifTool.getMetadata(); if (metadata.containsKey(QueryField.EXIF_MAKE.getExifToolKey())) digitalFiles.add(f); monitor.worked(1); if (monitor.isCanceled()) throw new InterruptedException(); } } } }); return digitalFiles; }