Java Code Examples for org.netbeans.api.progress.ProgressHandle#createHandle()
The following examples show how to use
org.netbeans.api.progress.ProgressHandle#createHandle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractContainerAction.java From netbeans with Apache License 2.0 | 6 votes |
@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); } } }
Example 2
Source File: MissingModuleProblemsProvider.java From netbeans with Apache License 2.0 | 6 votes |
private static InstallationResult installUpdate(@NonNull final UpdateElement update) { final ProgressHandle installHandle = ProgressHandle.createHandle(NbBundle.getMessage( MissingModuleProblemsProvider.class, "TXT_InstallModule", update.getDisplayName())); installHandle.start(); try { final OperationContainer<InstallSupport> container = OperationContainer.createForInstall(); container.add(Collections.singleton(update)); final InstallSupport support = container.getSupport(); try { final InstallSupport.Validator v = support.doDownload(installHandle, true, true); final InstallSupport.Installer i = support.doValidate(v, installHandle); final Restarter r = support.doInstall(i, installHandle); return InstallationResult.success(support, r); } catch (OperationException ex) { Exceptions.printStackTrace(ex); } } finally { installHandle.finish(); } return InstallationResult.failure(); }
Example 3
Source File: RepositoryIndexerListener.java From netbeans with Apache License 2.0 | 6 votes |
@Messages({ "# {0} - repo name", "LBL_indexing_repo=Indexing Maven repository: {0}", "LBL_findIndexableDirs=Counting indexable directories..." }) @Override public void scanningStarted(IndexingContext ctx) { if (handle != null) { handle.finish(); } expectedDirs.clear(); encounteredDirs.clear(); handle = ProgressHandle.createHandle(Bundle.LBL_indexing_repo(ri != null ? ri.getName() : indexingContext.getId()), this); handle.start(); handle.progress(Bundle.LBL_findIndexableDirs()); findIndexableDirs(ctx.getRepository()); handle.switchToDeterminate(expectedDirs.size()); }
Example 4
Source File: RemotePackExporter.java From visualvm with GNU General Public License v2.0 | 5 votes |
public String export(final String exportPath, final String hostOS, final String jvm) throws IOException { if (impl == null) { throw new IOException(); } ProgressHandle ph = ProgressHandle.createHandle( Bundle.RemotePackExporter_GeneratingRemotePack(impl.getRemotePackPath(exportPath, hostOS))); ph.setInitialDelay(500); ph.start(); try { return impl.export(exportPath, hostOS, jvm); } finally { ph.finish(); } }
Example 5
Source File: RemotePackExporter.java From netbeans with Apache License 2.0 | 5 votes |
public String export(final String exportPath, final String hostOS, final String jvm) throws IOException { if (impl == null) { throw new IOException(); } ProgressHandle ph = ProgressHandle.createHandle( Bundle.RemotePackExporter_GeneratingRemotePack(impl.getRemotePackPath(exportPath, hostOS))); ph.setInitialDelay(500); ph.start(); try { return impl.export(exportPath, hostOS, jvm); } finally { ph.finish(); } }
Example 6
Source File: HeapFragmentWalker.java From visualvm with GNU General Public License v2.0 | 5 votes |
public final int computeRetainedSizes(boolean masterAction, boolean interactive) { synchronized(this) { if (retainedSizesStatus == RETAINED_SIZES_UNSUPPORTED || retainedSizesStatus == RETAINED_SIZES_COMPUTED) return retainedSizesStatus; } if (interactive && !ProfilerDialogs.displayConfirmationDNSA( Bundle.HeapFragmentWalker_ComputeRetainedMsg(), Bundle.HeapFragmentWalker_ComputeRetainedCaption(), null, "HeapFragmentWalker.computeRetainedSizes", false)) { //NOI18N return changeState(RETAINED_SIZES_CANCELLED, masterAction); } else { changeState(RETAINED_SIZES_COMPUTING, masterAction); List<JavaClass> classes = heapFragment.getAllClasses(); if (classes.size() > 0) { ProgressHandle pd = interactive ? ProgressHandle.createHandle(Bundle.HeapFragmentWalker_ComputingRetainedMsg()) : null; if (pd != null) { pd.start(); } classes.get(0).getRetainedSizeByClass(); if (pd != null) pd.finish(); } return changeState(RETAINED_SIZES_COMPUTED, masterAction); } }
Example 7
Source File: ExportSnapshotAction.java From visualvm with GNU General Public License v2.0 | 5 votes |
private static void export(final FileObject sourceFO, final File targetFile) { final ProgressHandle progress = ProgressHandle.createHandle( Bundle.ExportSnapshotAction_ProgressMsg()); progress.setInitialDelay(500); RequestProcessor.getDefault().post(new Runnable() { public void run() { progress.start(); try { if (targetFile.exists() && !targetFile.delete()) { ProfilerDialogs.displayError( Bundle.ExportSnapshotAction_CannotReplaceMsg(targetFile.getName())); } else { targetFile.toPath(); File targetParent = FileUtil.normalizeFile(targetFile.getParentFile()); FileObject targetFO = FileUtil.toFileObject(targetParent); String targetName = targetFile.getName(); FileUtil.copyFile(sourceFO, targetFO, targetName, null); } } catch (Throwable t) { ProfilerLogger.log("Failed to export NPSS snapshot: " + t.getMessage()); // NOI18N String msg = t.getLocalizedMessage().replace("<", "<").replace(">", ">"); // NOI18N ProfilerDialogs.displayError("<html><b>" + Bundle.ExportSnapshotAction_ExportFailedMsg() + // NOI18N "</b><br><br>" + msg + "</html>"); // NOI18N } finally { progress.finish(); } } }); }
Example 8
Source File: HeapFragmentWalker.java From netbeans with Apache License 2.0 | 5 votes |
public final int computeRetainedSizes(boolean masterAction, boolean interactive) { synchronized(this) { if (retainedSizesStatus == RETAINED_SIZES_UNSUPPORTED || retainedSizesStatus == RETAINED_SIZES_COMPUTED) return retainedSizesStatus; } if (interactive && !ProfilerDialogs.displayConfirmationDNSA( Bundle.HeapFragmentWalker_ComputeRetainedMsg(), Bundle.HeapFragmentWalker_ComputeRetainedCaption(), null, "HeapFragmentWalker.computeRetainedSizes", false)) { //NOI18N return changeState(RETAINED_SIZES_CANCELLED, masterAction); } else { changeState(RETAINED_SIZES_COMPUTING, masterAction); List<JavaClass> classes = heapFragment.getAllClasses(); if (classes.size() > 0) { ProgressHandle pd = interactive ? ProgressHandle.createHandle(Bundle.HeapFragmentWalker_ComputingRetainedMsg()) : null; if (pd != null) { pd.start(); } classes.get(0).getRetainedSizeByClass(); if (pd != null) pd.finish(); } return changeState(RETAINED_SIZES_COMPUTED, masterAction); } }
Example 9
Source File: UploadCommand.java From netbeans with Apache License 2.0 | 5 votes |
private Set<TransferFile> prepareUpload(FileObject sources, FileObject[] filesToUpload, FileObject[] preselectedFiles, RemoteClient remoteClient) { Set<TransferFile> forUpload = Collections.emptySet(); ProgressHandle progressHandle = ProgressHandle.createHandle(NbBundle.getMessage(UploadCommand.class, "MSG_UploadingFiles", getProject().getName()), remoteClient); try { progressHandle.start(); forUpload = remoteClient.prepareUpload(sources, filesToUpload); RemoteUtils.fetchAllFiles(false, forUpload, sources, filesToUpload); // manage preselected files - it is just enough to touch the file if (preselectedFiles != null && preselectedFiles.length > 0) { File baseLocalDir = FileUtil.toFile(sources); String baseLocalAbsolutePath = baseLocalDir.getAbsolutePath(); for (FileObject fo : preselectedFiles) { // we need to touch the _original_ transfer file because of its parent! TransferFile transferFile = TransferFile.fromFileObject(remoteClient.createRemoteClientImplementation(baseLocalAbsolutePath), null, fo); for (TransferFile file : forUpload) { if (transferFile.equals(file)) { file.touch(); break; } } } } boolean showDialog = true; if (forUpload.size() == 1 && forUpload.iterator().next().isFile()) { // do not show transfer dialog for exactly one file (not folder!) showDialog = false; } if (showDialog) { forUpload = TransferFilesChooser.forUpload(forUpload, RemoteUtils.getLastTimestamp(true, getProject())).showDialog(); } } finally { progressHandle.finish(); } return forUpload; }
Example 10
Source File: RemoteIndexTransferListener.java From netbeans with Apache License 2.0 | 5 votes |
@SuppressWarnings("LeakingThisInConstructor") @Messages({"# {0} - repo name", "LBL_Transfer=Transferring Maven repository index: {0}"}) public RemoteIndexTransferListener(RepositoryInfo info) { this.info = info; Cancellation.register(this); handle = ProgressHandle.createHandle(Bundle.LBL_Transfer(info.getName()), this); handle.start(); }
Example 11
Source File: RemoveTagAction.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages({ "# {0} - image id", "MSG_RemovingTag=Removing image {0}" }) @Override protected void performAction(Node[] activatedNodes) { for (final Node node : activatedNodes) { 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() { @Override public void run() { try { DockerInstance instance = tag.getImage().getInstance(); DockerAction facade = new DockerAction(instance); facade.remove(tag); } catch (Exception ex) { // FIXME offer force remove ? 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(); } } }; requestProcessor.post(task); } } }
Example 12
Source File: UndeployModuleCookieImpl.java From netbeans with Apache License 2.0 | 4 votes |
@Override public Task undeploy() { final WildflyDeploymentManager dm = (WildflyDeploymentManager) lookup.lookup(WildflyDeploymentManager.class); final String nameWoExt; if(fileName.indexOf('.') > 0) { nameWoExt = fileName.substring(0, fileName.lastIndexOf('.')); } else { nameWoExt = fileName; } final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(UndeployModuleCookieImpl.class, "LBL_UndeployProgress", nameWoExt)); Runnable r = new Runnable() { public void run() { isRunning = true; try { switch(type) { case EJB: case EAR: case CAR: case RAR: case WAR: dm.getClient().undeploy(fileName); break; case QUEUE: dm.getClient().removeMessageDestination(new WildflyMessageDestination(fileName, MessageDestination.Type.QUEUE)); break; case TOPIC: dm.getClient().removeMessageDestination(new WildflyMessageDestination(fileName, MessageDestination.Type.TOPIC)); break; case DATASOURCE: dm.getClient().removeDatasource(fileName); break; } } catch (IOException ex) { Logger.getLogger(UndeployModuleCookieImpl.class.getName()).log(Level.INFO, null, ex); } handle.finish(); isRunning = false; } }; handle.start(); return PROCESSOR.post(r); }
Example 13
Source File: ProgressDisplayer.java From visualvm with GNU General Public License v2.0 | 4 votes |
public synchronized ProgressDisplayer showProgress(String message) { ph = ProgressHandle.createHandle(message); ph.start(); return DEFAULT; }
Example 14
Source File: CopySupport.java From netbeans with Apache License 2.0 | 4 votes |
private Boolean callRemote() { Boolean remoteRetval = null; Exception remoteExc = null; if (remoteHandler != null) { LOGGER.log(Level.FINE, "Processing REMOTE copying handler for project {0}", project.getName()); ProgressHandle progress = ProgressHandle.createHandle(NbBundle.getMessage(CopySupport.class, "LBL_RemoteSynchronization")); progress.setInitialDelay(PROGRESS_INITIAL_DELAY); try { progress.start(); remoteRetval = remoteHandler.call(); } catch (Exception exc) { LOGGER.log(Level.INFO, "REMOTE copying fail: ", exc); remoteRetval = false; remoteExc = exc; } finally { progress.finish(); } if (remoteRetval != null && !remoteRetval) { String pathInfo = getPathInfo(source); if (pathInfo != null) { remoteFailedFiles.add(pathInfo); } if (!userAskedRemoteCopying) { userAskedRemoteCopying = true; // disconnect remote client remoteFactory.reset(); if (askUser(NbBundle.getMessage(CopySupport.class, "LBL_Remote_On_Save_Fail", project.getName()))) { // invalidate factory remoteFactory.invalidate(); remoteFailedFiles.clear(); LOGGER.log(Level.INFO, String.format("REMOTE copying for project %s disabled by user", project.getName()), remoteExc); } else { LOGGER.log(Level.INFO, String.format("REMOTE copying for project %s failed but not disabled by user => resetting", project.getName()), remoteExc); } } } } return remoteRetval; }
Example 15
Source File: ProgressDisplayer.java From netbeans with Apache License 2.0 | 4 votes |
public synchronized ProgressDisplayer showProgress(String caption, String message, ProgressController controller) { ph = ProgressHandle.createHandle(message, controller); ph.start(); return DEFAULT; }
Example 16
Source File: ProgressDisplayer.java From visualvm with GNU General Public License v2.0 | 4 votes |
public synchronized ProgressDisplayer showProgress(String caption, String message, ProgressController controller) { ph = ProgressHandle.createHandle(message, controller); ph.start(); return DEFAULT; }
Example 17
Source File: SessionProgress.java From netbeans with Apache License 2.0 | 4 votes |
private SessionProgress(Session session) { this.session = session; String displayName = NbBundle.getMessage(SessionProgress.class, "LBL_Progress_Connecting", session.getName()); h = ProgressHandle.createHandle(displayName, this); }
Example 18
Source File: ProgressDisplayer.java From visualvm with GNU General Public License v2.0 | 4 votes |
public synchronized ProgressDisplayer showProgress(String message, ProgressController controller) { ph = ProgressHandle.createHandle(message, controller); ph.start(); return DEFAULT; }
Example 19
Source File: ServerStateMonitor.java From netbeans with Apache License 2.0 | 4 votes |
private void updateProgress() { boolean display = profiler.getProfilingState() != Profiler.PROFILING_INACTIVE && profiler.getServerState() != CommonConstants.SERVER_RUNNING; if (display) { int serverProgress = profiler.getServerProgress(); int serverState = profiler.getServerState(); if (progressHandle == null) { progressHandle = ProgressHandle.createHandle(Bundle.ServerStateMonitor_ProfilerBusy()); if (serverProgress == CommonConstants.SERVER_PROGRESS_INDETERMINATE) { progressHandle.start(); } else { progressHandle.start(CommonConstants.SERVER_PROGRESS_WORKUNITS); } activeServerState = -1; activeServerProgress = serverProgress; } if (serverProgress != activeServerProgress) { if (activeServerProgress == CommonConstants.SERVER_PROGRESS_INDETERMINATE) { progressHandle.switchToDeterminate(CommonConstants.SERVER_PROGRESS_WORKUNITS); progressHandle.progress(serverProgress); activeServerProgressValue = serverProgress; } else if (serverProgress == CommonConstants.SERVER_PROGRESS_INDETERMINATE) { progressHandle.switchToIndeterminate(); } else { if (serverProgress > activeServerProgressValue) { progressHandle.progress(serverProgress); activeServerProgressValue = serverProgress; } } activeServerProgress = serverProgress; } if (serverState != activeServerState) { activeServerState = serverState; switch (activeServerState) { case CommonConstants.SERVER_INITIALIZING: progressHandle.progress(Bundle.ServerStateMonitor_ServerInitializing()); break; case CommonConstants.SERVER_INSTRUMENTING: progressHandle.progress(Bundle.ServerStateMonitor_ServerInstrumenting()); break; case CommonConstants.SERVER_PREPARING: progressHandle.progress(Bundle.ServerStateMonitor_ServerPreparing()); break; default: progressHandle.progress(""); // NOI18N break; } } } else { closeProgress(); } }
Example 20
Source File: HandleIoProgress.java From constellation with Apache License 2.0 | 4 votes |
public HandleIoProgress(final String message) { progress = ProgressHandle.createHandle(message); }