Java Code Examples for org.netbeans.api.progress.ProgressHandle#setInitialDelay()
The following examples show how to use
org.netbeans.api.progress.ProgressHandle#setInitialDelay() .
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: ExecutionService.java From netbeans with Apache License 2.0 | 6 votes |
private ProgressHandle createProgressHandle(InputOutput inputOutput, String displayName, Cancellable cancellable) { if (!descriptor.showProgress() && !descriptor.showSuspended()) { return null; } ProgressHandle handle = ProgressHandleFactory.createHandle(displayName, cancellable, new ProgressAction(inputOutput)); handle.setInitialDelay(0); handle.start(); handle.switchToIndeterminate(); if (descriptor.showSuspended()) { handle.suspend(NbBundle.getMessage(ExecutionService.class, "Running")); } return handle; }
Example 2
Source File: InstanceNode.java From visualvm with GNU General Public License v2.0 | 6 votes |
protected List getReferences() { if (hasInstance()) { ProgressHandle pHandle = null; ChangeListener cl = null; try { pHandle = ProgressHandle.createHandle(Bundle.InstanceNode_References()); pHandle.setInitialDelay(200); pHandle.start(HeapProgress.PROGRESS_MAX); cl = setProgress(pHandle); return getInstance().getReferences(); } finally { if (pHandle != null) { pHandle.finish(); } if (cl != null) { HeapProgress.getProgress().removeChangeListener(cl); } } } return Collections.EMPTY_LIST; }
Example 3
Source File: InstanceNode.java From netbeans with Apache License 2.0 | 6 votes |
protected List getReferences() { if (hasInstance()) { ProgressHandle pHandle = null; ChangeListener cl = null; try { pHandle = ProgressHandle.createHandle(Bundle.InstanceNode_References()); pHandle.setInitialDelay(200); pHandle.start(HeapProgress.PROGRESS_MAX); cl = setProgress(pHandle); return getInstance().getReferences(); } finally { if (pHandle != null) { pHandle.finish(); } if (cl != null) { HeapProgress.getProgress().removeChangeListener(cl); } } } return Collections.EMPTY_LIST; }
Example 4
Source File: HeapWalker.java From netbeans with Apache License 2.0 | 6 votes |
private static Heap createHeap(File heapFile) throws FileNotFoundException, IOException { ProgressHandle pHandle = null; try { pHandle = ProgressHandle.createHandle(Bundle.ClassesListController_LoadingDumpMsg()); pHandle.setInitialDelay(0); pHandle.start(HeapProgress.PROGRESS_MAX*2); setProgress(pHandle,0); Heap heap = HeapFactory.createHeap(heapFile); setProgress(pHandle,HeapProgress.PROGRESS_MAX); heap.getSummary(); // Precompute HeapSummary within progress return heap; } finally { if (pHandle != null) { pHandle.finish(); } } }
Example 5
Source File: HeapWalker.java From visualvm with GNU General Public License v2.0 | 6 votes |
private static Heap createHeap(File heapFile) throws FileNotFoundException, IOException { ProgressHandle pHandle = null; try { pHandle = ProgressHandle.createHandle(Bundle.ClassesListController_LoadingDumpMsg()); pHandle.setInitialDelay(0); pHandle.start(HeapProgress.PROGRESS_MAX*2); setProgress(pHandle,0); Heap heap = HeapFactory.createHeap(heapFile); setProgress(pHandle,HeapProgress.PROGRESS_MAX); heap.getSummary(); // Precompute HeapSummary within progress return heap; } finally { if (pHandle != null) { pHandle.finish(); } } }
Example 6
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 7
Source File: TruffleLanguageHeapFragment.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void computeStatistics(Progress progress) { if (statisticsProgress == null) { synchronized (statisticsProgressLock) { if (progress != null) { statisticsProgress = progress; } else { ownProgress = true; statisticsProgress = new Progress(); statisticsProgress.setupUnknownSteps(); } } } int verIdx = getDescription().indexOf(" ("); // NOI18N String langName = verIdx != -1 ? getDescription().substring(0, verIdx) : Bundle.TruffleLanguageHeapFragment_Language(); ProgressHandle pHandle = ProgressHandle.createHandle(Bundle.TruffleLanguageHeapFragment_InitializingLanguageModel(langName)); pHandle.setInitialDelay(1000); pHandle.start(); TruffleType.TypesComputer<O, T> computer = new TruffleType.TypesComputer(language, heap) { @Override protected void addingObject(long size, long retained, String type) { objectsCount++; heapSize += size; } }; Iterator<O> objects = getObjectsIterator(); try { while (objects.hasNext()) { computer.addObject(objects.next()); if (statisticsProgress != null) statisticsProgress.step(); } } finally { if (statisticsProgress != null && ownProgress) statisticsProgress.finish(); pHandle.finish(); } types = computer.getTypes(); }
Example 8
Source File: ClassesListController.java From visualvm with GNU General Public License v2.0 | 5 votes |
@NbBundle.Messages("ClassesListController_AnalyzingClassesMsg=Analyzing classes...") private static Collection getContextSubclasses(Heap heap, String className, Lookup.Provider project) { ProgressHandle pHandle = null; try { pHandle = ProgressHandle.createHandle(Bundle.ClassesListController_AnalyzingClassesMsg()); pHandle.setInitialDelay(0); pHandle.start(); HashSet subclasses = new HashSet(); SourceClassInfo sci = ProfilerTypeUtils.resolveClass(className, project); Collection<SourceClassInfo> impls = sci != null ? sci.getSubclasses() : Collections.EMPTY_LIST; for (SourceClassInfo ci : impls) { JavaClass jClass = heap.getJavaClassByName(ci.getQualifiedName()); if ((jClass != null) && subclasses.add(jClass)) { // instanceof approach rather than subclassof subclasses.addAll(jClass.getSubClasses()); } } return subclasses; } finally { if (pHandle != null) { pHandle.finish(); } } }
Example 9
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 10
Source File: ClassesListController.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages("ClassesListController_AnalyzingClassesMsg=Analyzing classes...") private static Collection getContextSubclasses(Heap heap, String className, Lookup.Provider project) { ProgressHandle pHandle = null; try { pHandle = ProgressHandle.createHandle(Bundle.ClassesListController_AnalyzingClassesMsg()); pHandle.setInitialDelay(0); pHandle.start(); HashSet subclasses = new HashSet(); SourceClassInfo sci = ProfilerTypeUtils.resolveClass(className, project); Collection<SourceClassInfo> impls = sci != null ? sci.getSubclasses() : Collections.EMPTY_LIST; for (SourceClassInfo ci : impls) { JavaClass jClass = heap.getJavaClassByName(ci.getQualifiedName()); if ((jClass != null) && subclasses.add(jClass)) { // instanceof approach rather than subclassof subclasses.addAll(jClass.getSubClasses()); } } return subclasses; } finally { if (pHandle != null) { pHandle.finish(); } } }
Example 11
Source File: ResultsManager.java From netbeans with Apache License 2.0 | 4 votes |
public void exportSnapshots(final FileObject[] selectedSnapshots) { assert (selectedSnapshots != null); assert (selectedSnapshots.length > 0); final String[] fileName = new String[1], fileExt = new String[1]; final FileObject[] dir = new FileObject[1]; if (selectedSnapshots.length == 1) { SelectedFile sf = selectSnapshotTargetFile(selectedSnapshots[0].getName(), selectedSnapshots[0].getExt().equals(HEAPDUMP_EXTENSION)); if ((sf != null) && checkFileExists(sf)) { fileName[0] = sf.fileName; fileExt[0] = sf.fileExt; dir[0] = sf.folder; } else { // dialog cancelled by the user return; } } else { JFileChooser chooser = new JFileChooser(); if (exportDir != null) { chooser.setCurrentDirectory(exportDir); } chooser.setDialogTitle(Bundle.ResultsManager_SelectDirDialogCaption()); chooser.setApproveButtonText(Bundle.ResultsManager_SaveButtonName()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); if (chooser.showSaveDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (!file.exists()) { if (!ProfilerDialogs.displayConfirmation( Bundle.ResultsManager_DirectoryDoesntExistMsg(), Bundle.ResultsManager_DirectoryDoesntExistCaption())) { return; // cancelled by the user } file.mkdir(); } exportDir = file; dir[0] = FileUtil.toFileObject(FileUtil.normalizeFile(file)); } else { // dialog cancelled return; } } final ProgressHandle ph = ProgressHandle.createHandle(Bundle.MSG_SavingSnapshots()); ph.setInitialDelay(500); ph.start(); ProfilerUtils.runInProfilerRequestProcessor(new Runnable() { @Override public void run() { try { for (int i = 0; i < selectedSnapshots.length; i++) { exportSnapshot(selectedSnapshots[i], dir[0], fileName[0] != null ? fileName[0] : selectedSnapshots[i].getName(), fileExt[0] != null ? fileExt[0] : selectedSnapshots[i].getExt()); } } finally { ph.finish(); } } }); }
Example 12
Source File: TakeScreenshotActionProvider.java From netbeans with Apache License 2.0 | 4 votes |
private ProgressHandle createProgress() { ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(TakeScreenshotActionProvider.class, "MSG_TakingApplicationScreenshot")); ph.setInitialDelay(500); ph.start(); return ph; }
Example 13
Source File: ModuleOptions.java From netbeans with Apache License 2.0 | 4 votes |
@NbBundle.Messages({ "# {0} - module name", "# {1} - module version", "MSG_Installing=Installing {0}@{1}", "# {0} - paterns", "MSG_InstallNoMatch=Cannot install. No match for {0}." }) private void install(final Env env, String... pattern) throws CommandException { if (! initialized()) { refresh(env); } Pattern[] pats = findMatcher(env, pattern); List<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits(); OperationContainer<InstallSupport> operate = OperationContainer.createForInstall(); for (UpdateUnit uu : units) { if (uu.getInstalled() != null) { continue; } if (!matches(uu.getCodeName(), pats)) { continue; } if (uu.getAvailableUpdates().isEmpty()) { continue; } UpdateElement ue = uu.getAvailableUpdates().get(0); env.getOutputStream().println( Bundle.MSG_Installing(uu.getCodeName(), ue.getSpecificationVersion())); operate.add(ue); } final InstallSupport support = operate.getSupport(); if (support == null) { env.getOutputStream().println(Bundle.MSG_InstallNoMatch(Arrays.asList(pats))); return; } try { env.getOutputStream().println("modules=" + operate.listAll().size()); // NOI18N ProgressHandle downloadHandle = new CLIInternalHandle("downloading-modules", env).createProgressHandle(); // NOI18N downloadHandle.setInitialDelay(0); final Validator res1 = support.doDownload(downloadHandle, null, false); Installer res2 = support.doValidate(res1, null); ProgressHandle installHandle = new CLIInternalHandle("installing-modules", env).createProgressHandle(); // NOI18N installHandle.setInitialDelay(0); Restarter res3 = support.doInstall(res2, installHandle); if (res3 != null) { support.doRestart(res3, null); } } catch (OperationException ex) { // a hack if (OperationException.ERROR_TYPE.INSTALL.equals(ex.getErrorType())) { // probably timeout of loading env.getErrorStream().println(ex.getLocalizedMessage()); throw (CommandException) new CommandException(34, ex.getMessage()).initCause(ex); } else { try { support.doCancel(); throw (CommandException) new CommandException(32, ex.getMessage()).initCause(ex); } catch (OperationException ex1) { throw (CommandException) new CommandException(32, ex1.getMessage()).initCause(ex1); } } } }
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: ResultsManager.java From visualvm with GNU General Public License v2.0 | 4 votes |
public void exportSnapshots(final FileObject[] selectedSnapshots) { assert (selectedSnapshots != null); assert (selectedSnapshots.length > 0); final String[] fileName = new String[1], fileExt = new String[1]; final FileObject[] dir = new FileObject[1]; if (selectedSnapshots.length == 1) { SelectedFile sf = selectSnapshotTargetFile(selectedSnapshots[0].getName(), selectedSnapshots[0].getExt().equals(HEAPDUMP_EXTENSION)); if ((sf != null) && checkFileExists(sf)) { fileName[0] = sf.fileName; fileExt[0] = sf.fileExt; dir[0] = sf.folder; } else { // dialog cancelled by the user return; } } else { JFileChooser chooser = new JFileChooser(); if (exportDir != null) { chooser.setCurrentDirectory(exportDir); } chooser.setDialogTitle(Bundle.ResultsManager_SelectDirDialogCaption()); chooser.setApproveButtonText(Bundle.ResultsManager_SaveButtonName()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); if (chooser.showSaveDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (!file.exists()) { if (!ProfilerDialogs.displayConfirmation( Bundle.ResultsManager_DirectoryDoesntExistMsg(), Bundle.ResultsManager_DirectoryDoesntExistCaption())) { return; // cancelled by the user } file.mkdir(); } exportDir = file; dir[0] = FileUtil.toFileObject(FileUtil.normalizeFile(file)); } else { // dialog cancelled return; } } final ProgressHandle ph = ProgressHandle.createHandle(Bundle.MSG_SavingSnapshots()); ph.setInitialDelay(500); ph.start(); ProfilerUtils.runInProfilerRequestProcessor(new Runnable() { @Override public void run() { try { for (int i = 0; i < selectedSnapshots.length; i++) { exportSnapshot(selectedSnapshots[i], dir[0], fileName[0] != null ? fileName[0] : selectedSnapshots[i].getName(), fileExt[0] != null ? fileExt[0] : selectedSnapshots[i].getExt()); } } finally { ph.finish(); } } }); }
Example 16
Source File: Utilities.java From netbeans with Apache License 2.0 | 4 votes |
private static boolean tryRefreshProviders (Collection<UpdateUnitProvider> providers, PluginManagerUI manager, boolean force) { ProgressHandle handle = ProgressHandleFactory.createHandle (NbBundle.getMessage(SettingsTableModel.class, ("Utilities_CheckingForUpdates"))); JComponent progressComp = ProgressHandleFactory.createProgressComponent (handle); JLabel detailLabel = ProgressHandleFactory.createDetailLabelComponent (handle); detailLabel.setHorizontalAlignment (SwingConstants.LEFT); try { manager.setProgressComponent (detailLabel, progressComp); handle.setInitialDelay (0); handle.start (); if (providers == null) { providers = UpdateUnitProviderFactory.getDefault ().getUpdateUnitProviders (true); } for (UpdateUnitProvider p : providers) { try { p.refresh (handle, force); showProviderNotification(p); } catch (IOException ioe) { logger.log (Level.INFO, ioe.getMessage (), ioe); JButton cancel = new JButton (); Mnemonics.setLocalizedText (cancel, getBundle ("Utilities_NetworkProblem_Cancel")); // NOI18N JButton skip = new JButton (); Mnemonics.setLocalizedText (skip, getBundle ("Utilities_NetworkProblem_Skip")); // NOI18N skip.setEnabled (providers.size() > 1); JButton tryAgain = new JButton (); Mnemonics.setLocalizedText (tryAgain, getBundle ("Utilities_NetworkProblem_Continue")); // NOI18N ProblemPanel problem = new ProblemPanel ( getBundle ("Utilities_NetworkProblem_Text", p.getDisplayName (), ioe.getLocalizedMessage ()), // NOI18N new JButton [] { tryAgain, skip, cancel }); Object ret = problem.showNetworkProblemDialog (); if (skip.equals (ret)) { // skip UpdateUnitProvider and try next one continue; } else if (tryAgain.equals (ret)) { // try again return false; } return true; } } } finally { if (handle != null) { handle.finish (); } // XXX: Avoid NPE when called refresh providers on selected units // #101836: OperationContainer.contains() sometimes fails Containers.initNotify (); manager.unsetProgressComponent (detailLabel, progressComp); } return true; }
Example 17
Source File: UnitTab.java From netbeans with Apache License 2.0 | 4 votes |
private Task reloadTask (final boolean force) { final Runnable checkUpdates = new Runnable (){ @Override public void run () { ProgressHandle handle = ProgressHandleFactory.createHandle (NbBundle.getMessage (UnitTab.class, ("UnitTab_ReloadAction"))); JComponent progressComp = ProgressHandleFactory.createProgressComponent (handle); JLabel detailLabel = new JLabel (NbBundle.getMessage (UnitTab.class, "UnitTab_PrepareReloadAction")); manager.setProgressComponent (detailLabel, progressComp); handle.setInitialDelay (0); handle.start (); manager.initTask.waitFinished (); setWaitingState (true); if (getDownloadSizeTask != null && ! getDownloadSizeTask.isFinished ()) { if (getDownloadSizeTask.getDelay () > 0) { getDownloadSizeTask.cancel (); } else { getDownloadSizeTask.waitFinished (); } } final int row = getSelectedRow (); final Map<String, Boolean> state = UnitCategoryTableModel.captureState (model.getUnits ()); if (model instanceof LocallyDownloadedTableModel) { ((LocallyDownloadedTableModel) model).removeInstalledUnits (); ((LocallyDownloadedTableModel) model).setUnits (null); } manager.unsetProgressComponent (detailLabel, progressComp); Utilities.presentRefreshProviders (manager, force); SwingUtilities.invokeLater (new Runnable () { @Override public void run () { fireUpdataUnitChange (); UnitCategoryTableModel.restoreState (model.getUnits (), state, model.isMarkedAsDefault ()); restoreSelectedRow (row); refreshState (); setWaitingState (false); } }); } }; return Utilities.startAsWorkerThread (checkUpdates); }
Example 18
Source File: JFRSnapshotProvider.java From visualvm with GNU General Public License v2.0 | 4 votes |
private static void createJFRSnapshotImpl(String jfrSnapshotFile, final String displayName, boolean deleteJFRSnapshot) { // TODO: check if the same JFR snapshot isn't already imported (can happen for moved coredumps) final JFRSnapshotImpl knownJFRSnapshot = getJFRSnapshotByFile(new File(jfrSnapshotFile)); if (knownJFRSnapshot != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { ExplorerSupport.sharedInstance().selectDataSource(knownJFRSnapshot); DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor. Message(NbBundle.getMessage(JFRSnapshotProvider.class, "MSG_Core_dump_already_added", new Object[] {displayName, // NOI18N DataSourceDescriptorFactory.getDescriptor(knownJFRSnapshot). getName()}), NotifyDescriptor.ERROR_MESSAGE)); } }); return; } if (deleteJFRSnapshot) { ProgressHandle pHandle = null; try { pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(JFRSnapshotProvider.class, "MSG_Adding", displayName)); // NOI18N pHandle.setInitialDelay(0); pHandle.start(); File file = new File(jfrSnapshotFile); File copy = Utils.getUniqueFile(JFRSnapshotSupport.getStorageDirectory(), file.getName()); if (Utils.copyFile(file, copy)) { jfrSnapshotFile = copy.getAbsolutePath(); if (!file.delete()) file.deleteOnExit(); } } finally { final ProgressHandle pHandleF = pHandle; SwingUtilities.invokeLater(new Runnable() { public void run() { if (pHandleF != null) pHandleF.finish(); } }); } } final String[] propNames = new String[] { SNAPSHOT_VERSION, Snapshot.PROPERTY_FILE, DataSourceDescriptor.PROPERTY_NAME }; final String[] propValues = new String[] { CURRENT_SNAPSHOT_VERSION, jfrSnapshotFile, displayName }; File customPropertiesStorage = Utils.getUniqueFile(JFRSnapshotSupport.getStorageDirectory(), new File(jfrSnapshotFile).getName(), Storage.DEFAULT_PROPERTIES_EXT); Storage storage = new Storage(customPropertiesStorage.getParentFile(), customPropertiesStorage.getName()); try { JFRSnapshotImpl newJFRSnapshot = new JFRSnapshotImpl(new File(jfrSnapshotFile), storage); if (newJFRSnapshot != null) new SnapshotAdder(newJFRSnapshot, storage, propNames, propValues).execute(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error creating JFR snapshot", e); // NOI18N } }
Example 19
Source File: CoreDumpProvider.java From visualvm with GNU General Public License v2.0 | 4 votes |
private static void createCoreDumpImpl(String coreDumpFile, final String displayName, String jdkHome, boolean deleteCoreDump) { // TODO: check if the same coredump isn't already imported (can happen for moved coredumps) final CoreDumpImpl knownCoreDump = getCoreDumpByFile(new File(coreDumpFile)); if (knownCoreDump != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { ExplorerSupport.sharedInstance().selectDataSource(knownCoreDump); DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor. Message(NbBundle.getMessage(CoreDumpProvider.class, "MSG_Core_dump_already_added", new Object[] {displayName, // NOI18N DataSourceDescriptorFactory.getDescriptor(knownCoreDump). getName()}), NotifyDescriptor.ERROR_MESSAGE)); } }); return; } if (deleteCoreDump) { ProgressHandle pHandle = null; try { pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CoreDumpProvider.class, "MSG_Adding", displayName)); // NOI18N pHandle.setInitialDelay(0); pHandle.start(); File file = new File(coreDumpFile); File copy = Utils.getUniqueFile(CoreDumpSupport.getStorageDirectory(), file.getName()); if (Utils.copyFile(file, copy)) { coreDumpFile = copy.getAbsolutePath(); if (!file.delete()) file.deleteOnExit(); } } finally { final ProgressHandle pHandleF = pHandle; SwingUtilities.invokeLater(new Runnable() { public void run() { if (pHandleF != null) pHandleF.finish(); } }); } } final String[] propNames = new String[] { SNAPSHOT_VERSION, Snapshot.PROPERTY_FILE, DataSourceDescriptor.PROPERTY_NAME, PROPERTY_JAVA_HOME }; final String[] propValues = new String[] { CURRENT_SNAPSHOT_VERSION, coreDumpFile, displayName, jdkHome }; File customPropertiesStorage = Utils.getUniqueFile(CoreDumpSupport.getStorageDirectory(), new File(coreDumpFile).getName(), Storage.DEFAULT_PROPERTIES_EXT); Storage storage = new Storage(customPropertiesStorage.getParentFile(), customPropertiesStorage.getName()); try { CoreDumpImpl newCoreDump = new CoreDumpImpl(new File(coreDumpFile), new File(jdkHome), storage); if (newCoreDump != null) { new CoreDumpAdder(newCoreDump, storage, propNames, propValues).execute(); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error creating coredump", e); // NOI18N return; } }
Example 20
Source File: NetBeansProfiler.java From visualvm with GNU General Public License v2.0 | 4 votes |
/** * Connects to an application started using the specified sessionSettings, and will start its profiling * with the provided profilingSettings. * * @param profilingSettings Settings to use for profiling * @param sessionSettings Session settings for profiling * @param cancel shared cancel flag * @return true if connected successfully, false otherwise */ public boolean connectToStartedApp(final ProfilingSettings profilingSettings, final SessionSettings sessionSettings, final AtomicBoolean cancel) { profilingMode = MODE_PROFILE; lastProfilingSettings = profilingSettings; lastSessionSettings = sessionSettings; lastMode = MODE_PROFILE; ProgressHandle ph = ProgressHandle.createHandle(Bundle.NetBeansProfiler_StartingSession()); try { ph.setInitialDelay(500); ph.start(); if (getTargetAppRunner().targetJVMIsAlive()) { getTargetAppRunner().terminateTargetJVM(); } final ProfilerEngineSettings sSettings = getTargetAppRunner().getProfilerEngineSettings(); sessionSettings.applySettings(sSettings); profilingSettings.applySettings(sSettings); // can override the session settings sSettings.setInstrumentObjectInit(false); // clear instrument object.<init> //sSettings.setRemoteHost(""); // NOI18N // clear remote profiling host //getThreadsManager().setSupportsSleepingStateMonitoring( // Platform.supportsThreadSleepingStateMonitoring(sharedSettings.getTargetJDKVersionString())); logActionConfig("connectToStartedApp", profilingSettings, sessionSettings, null, sSettings.getInstrumentationFilter()); // NOI18N if (prepareProfilingSession(profilingSettings, sessionSettings)) { RequestProcessor.getDefault().post(new Runnable() { @Override public void run() { // should propagate the result of the following operation somehow; current workflow doesn't allow it if (tryInitiateSession(sessionSettings, cancel)) { connectToApp(); } } }); return true; } return false; } finally { ph.finish(); } }