@NonNull public static Future<String> download( @NonNull final URL url, @NonNull final Callable<Boolean> cancel) { return RP.submit(()-> { if (cancel.call()) { return ""; //NOI18N } final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(DocDownloader.class, "LBL_DownloadingDoc")); handle.start(); try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); try(BufferedInputStream in = new BufferedInputStream(url.openStream())) { FileUtil.copy(in, out); } return cancel.call() ? "" //NOI18N : new String(out.toByteArray(),"UTF-8"); //NOI18N } finally { handle.finish(); } }); }
public TaskWorker(UserCredentialsRepository repository, Task<T> task) { this.userCredentialsRepository = repository; this.task = task; assert SwingUtilities.isEventDispatchThread(); handle = ProgressHandle.createHandle("Sonar"); handle.start(); handle.switchToIndeterminate(); try{ this.task.init(); }catch(Throwable t){ handle.finish(); handle=null; throw t; } }
@Override protected final void performAction(Node[] activatedNodes) { for (final Node node : activatedNodes) { final StatefulDockerContainer container = node.getLookup().lookup(StatefulDockerContainer.class); if (container != null) { final ProgressHandle handle = ProgressHandle.createHandle(getProgressMessage(container.getContainer())); handle.start(); Runnable task = new Runnable() { @Override public void run() { try { performAction(container.getContainer()); } catch (Exception ex) { handleException(ex); } finally { handle.finish(); } } }; requestProcessor.post(task); } } }
final DockerTag tag = node.getLookup().lookup(DockerTag.class); if (tag != null) { final ProgressHandle handle = ProgressHandle.createHandle(Bundle.MSG_RemovingTag(tag.getShortId())); handle.start(); Runnable task = new Runnable() {
ProgressHandle progress = null; if (message != null) { progress = ProgressHandle.createHandle(message); progress.start();
@Override public void run() { ProgressHandle handle = ProgressHandle.createHandle(Bundle.MSG_Commiting(container.getShortId())); handle.start(); try { DockerAction facade = new DockerAction(container.getInstance()); facade.commit(container, repository, tag, author, message, pause); } catch (DockerException ex) { LOGGER.log(Level.INFO, null, ex); String msg = ex.getLocalizedMessage(); NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(desc); } finally { handle.finish(); } } });
@Override public void run() { ProgressHandle handle = ProgressHandle.createHandle(Bundle.MSG_Tagging(source.getTag())); handle.start(); try { DockerAction facade = new DockerAction(source.getImage().getInstance()); facade.tag(source, repository, tag, force); } catch (DockerException ex) { LOGGER.log(Level.INFO, null, ex); String msg = ex.getLocalizedMessage(); NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(desc); } finally { handle.finish(); } } });
@Override public void run() { ProgressHandle handle = ProgressHandle.createHandle(Bundle.MSG_Renaming(container.getDetail().getName())); handle.start(); try { DockerAction facade = new DockerAction(container.getContainer().getInstance()); facade.rename(container.getContainer(), name); } catch (DockerException ex) { LOGGER.log(Level.INFO, null, ex); String msg = ex.getLocalizedMessage(); NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(desc); } finally { handle.finish(); } } });