Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    *
    * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    *
    * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    * Other names may be trademarks of their respective owners.
    *
    * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common
   * Development and Distribution License("CDDL") (collectively, the
   * "License"). You may not use this file except in compliance with the
   * License. You can obtain a copy of the License at
   * http://www.netbeans.org/cddl-gplv2.html
   * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   * specific language governing permissions and limitations under the
   * License.  When distributing the software, include this License Header
   * Notice in each file and include the License file at
   * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Oracle in the GPL Version 2 section of the License file that
   * accompanied this code. If applicable, add the following below the
   * License Header, with the fields enclosed by brackets [] replaced by
   * your own identifying information:
   * "Portions Copyrighted [year] [name of copyright owner]"
   *
   * Contributor(s):
   * The Original Software is NetBeans. The Initial Developer of the Original
   * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   * Microsystems, Inc. All Rights Reserved.
   *
   * If you wish your version of this file to be governed by only the CDDL
   * or only the GPL Version 2, indicate your decision by adding
   * "[Contributor] elects to include this software in this distribution
   * under the [CDDL or GPL Version 2] license." If you do not indicate a
   * single choice of license, a recipient has the option to distribute
   * your version of this file under either the CDDL, the GPL Version 2 or
   * to extend the choice of license to its licensees as provided above.
   * However, if you add GPL Version 2 code and therefore, elected the GPL
   * Version 2 license, then the option applies only if the new code is
   * made subject to such option by the copyright holder.
   */
  
  package org.netbeans.modules.profiler.ppoints;
  
  import java.util.Arrays;
  import java.awt.Dialog;
  import java.awt.Point;
  import java.io.File;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;

Author(s):
Tomas Hurka
Jiri Sedlacek
 
     "ProfilingPointsManager_AnotherPpEditedMsg=Another Profiling Point is currently being edited!",
     "ProfilingPointsManager_PpCustomizerCaption=Customize Profiling Point",
     "ProfilingPointsManager_CannotStorePpMsg=Cannot store {0} Profiling Points to {1}",
     "ProfilingPointsManager_ShowingFirstNItemsTxt=Showing first {0} items",
     "ProfilingPointsManager_OkButtonText=OK"
 })
 public final class ProfilingPointsManager extends ProfilingPointsProcessor 
                                           implements ChangeListener,
                                                      PropertyChangeListener {
     //~ Inner Classes ------------------------------------------------------------------------------------------------------------
 
     private static class ProfilingPointsComparator implements Comparator {
         //~ Instance fields ------------------------------------------------------------------------------------------------------
 
         private boolean sortOrder;
         private int sortBy;
 
         //~ Constructors ---------------------------------------------------------------------------------------------------------
 
         public ProfilingPointsComparator(int sortByboolean sortOrder) {
             this. = sortBy;
             this. = sortOrder;
         }
 
         //~ Methods --------------------------------------------------------------------------------------------------------------
 
         public int compare(Object o1Object o2) {
             ProfilingPoint pp1 =  ? (ProfilingPointo1 : (ProfilingPointo2;
             ProfilingPoint pp2 =  ? (ProfilingPointo2 : (ProfilingPointo1;
 
             switch () {
                 case .:
                 case :
                     return ProjectUtilities.getDisplayName(pp1.getProject())
                                        .compareTo(ProjectUtilities.getDisplayName(pp2.getProject()));
                 case :
 
                     int v1 = pp1.getFactory().getScope();
                     int v2 = pp2.getFactory().getScope();
 
                     return ((v1 < v2) ? (-1) : ((v1 == v2) ? 0 : 1));
                 case :
                     return pp1.getName().compareTo(pp2.getName());
                 case :
                     return pp1.getResultsText().compareTo(pp2.getResultsText());
                 default:
                     throw new RuntimeException("Unsupported compare operation for " + o1 + ", " + o2); // NOI18N
             }
         }
     }
 
     private static class CustomizerButton extends JButton implements ValidityListener {
         //~ Constructors ---------------------------------------------------------------------------------------------------------
 
         public CustomizerButton() {
             super(Bundle.ProfilingPointsManager_OkButtonText());
         }
 
         //~ Methods --------------------------------------------------------------------------------------------------------------
 
         public void validityChanged(boolean isValid) {
             setEnabled(isValid);
         }
     }
 
     private class CustomizerListener extends WindowAdapter {
         //~ Instance fields ------------------------------------------------------------------------------------------------------
 
         private Dialog d;
         private DialogDescriptor dd;
         private Runnable updater;
 
         //~ Constructors ---------------------------------------------------------------------------------------------------------
 
         public CustomizerListener(Dialog dDialogDescriptor ddRunnable updater) {
             super();
             this. = d;
             this. = dd;
             this. = updater;
         }
 
         //~ Methods --------------------------------------------------------------------------------------------------------------
 
         public void windowClosed(WindowEvent e) {
             if (.getValue() == getCustomizerButton()) {
                 .run();
             }
 
             .removeWindowListener(this);
              = null;
              = null;
              = null;
         }
 
         public void windowOpened(WindowEvent e) {
             .requestFocus();
         }
     }
 
     private static class RuntimeProfilingPointMapper {
         //~ Instance fields ------------------------------------------------------------------------------------------------------
 
         private final CodeProfilingPoint owner;
         private final int index;
 
         //~ Constructors ---------------------------------------------------------------------------------------------------------
 
         public RuntimeProfilingPointMapper(CodeProfilingPoint ownerint index) {
             this. = owner;
             this. = index;
         }
 
         //~ Methods --------------------------------------------------------------------------------------------------------------
 
         public int getIndex() {
             return ;
         }
 
         public CodeProfilingPoint getOwner() {
             return ;
         }
     }
     
     private static class FileWatch {
         private int references = 0;
         private LocationFileListener listener;
         
         public FileWatch(LocationFileListener listener) { this. = listener; }
         
         public boolean hasReferences() { return  > 0; }
         public LocationFileListener getListener() { return ; }
         
         public void increaseReferences() { ++; }
         public void decreaseReferences() { --; }
     }
     
     private class LocationFileListener implements FileChangeListener {
         
         private File file;
         
         public LocationFileListener(File file) { this. = file; }
 
         public void fileDeleted(final FileEvent fe) {
             Runnable worker = new Runnable() {
                 public void run() { deleteProfilingPointsForFile(); }
             };
             
             if (SwingUtilities.isEventDispatchThread()) {
                 processor().post(worker);
             } else {
                 worker.run();
             }
         }
 
         public void fileRenamed(final FileRenameEvent fe) {
             Runnable worker = new Runnable() {
                 public void run() { 
                     FileObject renamedFileO = fe.getFile();
                     File renamedFile = FileUtil.toFile(renamedFileO);
                     if (renamedFile != null && renamedFile.exists() && renamedFile.isFile()) {
                         updateProfilingPointsFile(renamedFile);
                     } else {
                         deleteProfilingPointsForFile();
                     }
                 }
             };
             
             if (SwingUtilities.isEventDispatchThread()) {
                 processor().post(worker);
             } else {
                 worker.run();
             }
         }
         
         public void fileFolderCreated(FileEvent fe) {}
         public void fileDataCreated(FileEvent fe) {}
         public void fileChanged(FileEvent fe) {}
         public void fileAttributeChanged(FileAttributeEvent fe) {}
         
     }
 
     //~ Static fields/initializers -----------------------------------------------------------------------------------------------
     
     private static final int MAX_HITS = Integer.getInteger("nbprofiler.ppoints.maxhits", 1000); // NOI18N
 
     public static final String PROPERTY_PROJECTS_CHANGED = "p_projects_changed"// NOI18N
     public static final String PROPERTY_PROFILING_POINTS_CHANGED = "p_profiling_points_changed"// NOI18N
     public static final int SORT_BY_PROJECT = 1;
     public static final int SORT_BY_SCOPE = 2;
     public static final int SORT_BY_NAME = 3;
     public static final int SORT_BY_RESULTS = 4;
 
     //~ Instance fields ----------------------------------------------------------------------------------------------------------
 
     private PropertyChangeListener pcl = new PropertyChangeListener() {
         public void propertyChange(PropertyChangeEvent evt) {
             if (evt.getPropertyName().equals(.)) {
                 refreshProfilingPointFactories();
                 firePropertyChanged(); // notify the profiling points list displayer about the change
             }
         }
     };
 
     private Set<ProfilingPointdirtyProfilingPoints = Collections.synchronizedSet(new HashSet());
     private List<ValidityAwarePanelcustomizers = new ArrayList();
     private final Collection<Lookup.ProvideropenedProjects = new ArrayList();
     private List<ProfilingPointprofilingPoints = new ArrayList();
     private boolean profilingInProgress = false// collecting data
     private boolean profilingSessionInProgress = false// session started and not yet finished
     private int nextUniqueRPPIdentificator;
     
     private Map<FileFileWatchprofilingPointsFiles = new HashMap<FileFileWatch>();
     private boolean ignoreStoreProfilingPoints = false;
     
     private boolean processesProfilingPoints;
     final private Object pointsLock = new Object();
     // @GuardedBy pointsLock
     private RuntimeProfilingPoint[] points = null;
     
     private final Object _processorLock = new Object();
 
     //~ Constructors -------------------------------------------------------------------------------------------------------------
 
     public ProfilingPointsManager() {
         final ProfilingStateListener listener = new ProfilingStateAdapter() {
             public void profilingStateChanged(final ProfilingStateEvent profilingStateEvent) {
                 processor().post(new Runnable() {
                     public void run() {
                         boolean wasProfilingInProgress = ;
                         boolean wasProfilingSessionInProgres = ;
 
                         synchronized (ProfilingPointsManager.this) {
                             switch (profilingStateEvent.getNewState()) {
                                 case .:
                                 case .:
                                      = false;
                                      = false;
 
                                     break;
                                 case .:
                                 case .:
                                      = false;
                                      = true;
 
                                     break;
                                 default:
                                      = true;
                                      = true;
                             }
                         }
 
                         if ((wasProfilingInProgress != ) || (wasProfilingSessionInProgres != )) {
                             GlobalProfilingPointsProcessor.getDefault().notifyProfilingStateChanged();
                             CommonUtils.runInEventDispatchThread(new Runnable() {
                                 public void run() {
                                     ProfilingPointsWindow.getDefault().notifyProfilingStateChanged(); // this needs to be called on EDT
                                     ProfilingPointReport.refreshOpenReports();
                                 }
                             });
                         }
                     }
                 });
             }
         };
         processor().post(new Runnable() {
                 public void run() {
                     ProjectUtilities.addOpenProjectsListener(ProfilingPointsManager.this);
                     processOpenedProjectsChanged(); // will subsequently invoke projectOpened on all open projects
                     Profiler.getDefault().addProfilingStateListener(listener);
                 }
             });
     }
 
     //~ Methods ------------------------------------------------------------------------------------------------------------------
 
     public static ProfilingPointsManager getDefault() {
         return Lookup.getDefault().lookup(ProfilingPointsManager.class);
     }
 
     public List<ProfilingPointgetCompatibleProfilingPoints(Lookup.Provider projectProfilingSettings profilingSettingsboolean sorted) {
  
         List<ProfilingPointprojectProfilingPoints = sorted ? getSortedProfilingPoints(project, 1, false)
                                                              : getProfilingPoints(project, ProfilerIDESettings.
                                                                getInstance().getIncludeProfilingPointsDependencies(), false); // TODO: define default sorting (current sorting of Profiling Points window?)
         List<ProfilingPointcompatibleProfilingPoints = new ArrayList();
 
         for (ProfilingPoint profilingPoint : projectProfilingPoints) {
             if (profilingPoint.supportsProfilingSettings(profilingSettings)) {
                 compatibleProfilingPoints.add(profilingPoint);
             }
         }
 
         return compatibleProfilingPoints;
     }
 
     // Currently profiling, data are being collected
     public boolean isProfilingInProgress() {
         synchronized (this) {
             return ;
         }
     }
 
         return ;
     }
 
                                                    boolean inclSubprojects,
                                                    boolean inclUnavailable) {
         return getProfilingPoints(ProfilingPoint.classproject,
                                   inclSubprojectsinclUnavailable);
     }
 
     public <T extends ProfilingPointList<T> getProfilingPoints(Class<T> ppClass,
                                                                  Lookup.Provider project,
                                                                  boolean inclSubprojects) {
         return getProfilingPoints(ppClassprojectinclSubprojectstrue);
     }
 
     public <T extends ProfilingPointList<T> getProfilingPoints(Class<T> ppClass,
                                                                  Lookup.Provider project,
                                                                  boolean inclSubprojects,
                                                                  boolean inclUnavailable) {
         Set<Lookup.Providerprojects = new HashSet();
 
         if (project == null) {
             synchronized () { projects.addAll(); }
         } else {
             projects.add(project);
             if (inclSubprojectsprojects.addAll(getOpenSubprojects(project));
         }        
 
         ArrayList<T> filteredProfilingPoints = new ArrayList();
         Iterator<ProfilingPointiterator = .iterator();
         
         Set<FileObjectprojectsLoc = locations(projects);
         while (iterator.hasNext()) {
             ProfilingPoint profilingPoint = iterator.next();
             ProfilingPointFactory factory = profilingPoint.getFactory();
 
             // Bugfix #162132, the factory may already be unloaded
             if (factory != null) {
                 if (ppClass.isInstance(profilingPoint) && (inclUnavailable || factory.isAvailable())) {
                     Lookup.Provider ppProject = profilingPoint.getProject();
                     if (matchesScope(ppProjectprojectprojects) ||
                             containsProject(projectsLocppProject))
                         filteredProfilingPoints.add((T) profilingPoint);
                 }
             } else {
                 // TODO: profiling points without factories should be cleaned up somehow
             }
         }
 
         return filteredProfilingPoints;
     }
 
     // Profiling session started and not yet finished
     public boolean isProfilingSessionInProgress() {
         synchronized (this) {
             return ;
         }
     }
 
     public List<ProfilingPointgetSortedProfilingPoints(Lookup.Provider projectint sortByboolean sortOrder) {
         List<ProfilingPointsortedProfilingPoints = getProfilingPoints(project, ProfilerIDESettings.getInstance().
                                                                         getIncludeProfilingPointsDependencies(), false);
         Collections.sort(sortedProfilingPointsnew ProfilingPointsComparator(sortBysortOrder));
 
         return sortedProfilingPoints;
     }
 
     public void addProfilingPoint(ProfilingPoint profilingPoint) {
         addProfilingPoints(new ProfilingPoint[] { profilingPoint });
     }
 
     public void addProfilingPoints(ProfilingPoint[] profilingPointsArr) {
         addProfilingPoints(profilingPointsArrfalse);
     }
 
     public void addPropertyChangeListener(PropertyChangeListener listener) {
     }
 
     public void addPropertyChangeListener(String propertyNamePropertyChangeListener listener) {
         .addPropertyChangeListener(propertyNamelistener);
     }
 
     // TODO: should optionally support also subprojects/project references
     public RuntimeProfilingPoint[] createCodeProfilingConfiguration(Lookup.Provider projectProfilingSettings profilingSettings) {
         
         checkProfilingPoints(); // NOTE: Probably not neccessary but we need to be sure here
         
          = 0;
 
         List<RuntimeProfilingPointruntimeProfilingPoints = new ArrayList();
         List<ProfilingPointcompatibleProfilingPoints = getCompatibleProfilingPoints(projectprofilingSettingsfalse);
 
         for (ProfilingPoint compatibleProfilingPoint : compatibleProfilingPoints) {
             if (compatibleProfilingPoint.isEnabled() && compatibleProfilingPoint instanceof CodeProfilingPoint) {
                 CodeProfilingPoint compatibleCodeProfilingPoint = (CodeProfilingPointcompatibleProfilingPoint;
                 RuntimeProfilingPoint[] rpps = compatibleCodeProfilingPoint.createRuntimeProfilingPoints();
                 
                 if (rpps.length == 0) ErrorManager.getDefault().log(."Cannot resolve RuntimeProfilingPoint(s) for " + compatibleCodeProfilingPoint.getName() + ", check location"); // NOI18N
 
                 for (int i = 0; i < rpps.lengthi++) {
                     runtimeProfilingPoints.add(rpps[i]);
                     .put(rpps[i].getId(),
                                                   new RuntimeProfilingPointMapper(compatibleCodeProfilingPointi)); // Note that profiled project may be closed but it's active Profiling Points are still referenced by this map => will be processed
                 }
             }
         }
 
         return runtimeProfilingPoints.toArray(new RuntimeProfilingPoint[runtimeProfilingPoints.size()]);
     }
 
     // TODO: should optionally support also subprojects/project references
     public GlobalProfilingPoint[] createGlobalProfilingConfiguration(Lookup.Provider projectProfilingSettings profilingSettings) {
         
         checkProfilingPoints(); // NOTE: Probably not neccessary but we need to be sure here
         
         List<ProfilingPointcompatibleProfilingPoints = getCompatibleProfilingPoints(projectprofilingSettingsfalse);
 
         for (ProfilingPoint compatibleProfilingPoint : compatibleProfilingPoints) {
             if (compatibleProfilingPoint.isEnabled() && compatibleProfilingPoint instanceof GlobalProfilingPoint) {
                 .add((GlobalProfilingPointcompatibleProfilingPoint);
             }
         }
 
     }
 
     public synchronized int createUniqueRuntimeProfilingPointIdentificator() {
         return ++;
     }
 
     public void firePropertyChanged(String property) {
         .firePropertyChange(propertyfalsetrue);
     }
 
     public void ideClosing() {
         // TODO: dirty profiling points should be persisted on document save!
         processor().post(new Runnable() {
             public void run() {
                 storeDirtyProfilingPoints();
             }
         });
     }
 
     public void profilingPointHit(RuntimeProfilingPoint.HitEvent hitEvent) {
         RuntimeProfilingPointMapper mapper = .get(hitEvent.getId());
 
         if (mapper != null) {
             mapper.getOwner().hit(hitEventmapper.getIndex());
         } else {
             ErrorManager.getDefault().log(."Cannot resolve ProfilingPoint for event: " + hitEvent); // NOI18N
         }
     }
 
     @Override
     public void init(Object project) {
         reset();
         
         ProfilingSettings ps = Profiler.getDefault().getLastProfilingSettings();
         TargetAppRunner tar = Profiler.getDefault().getTargetAppRunner();
         
         if (ps.useProfilingPoints() && (project != null)) {
             synchronized() {
                  = createCodeProfilingConfiguration((Lookup.Provider)projectps);
                  = . > 0;
                 tar.getProfilerEngineSettings().setRuntimeProfilingPoints();
             }
             //      targetAppRunner.getProfilingSessionStatus().startProfilingPointsActive = profilingSettings.useProfilingPoints();
         } else {
             synchronized() {
                  = new RuntimeProfilingPoint[0];
             }
              = false;
         }
 
         // TODO: should be moved to openWindowsOnProfilingStart()
         if () {
             SwingUtilities.invokeLater(new Runnable() {
                     public void run() {
                         if (!ProfilingPointsWindow.getDefault().isOpened()) {
                             ProfilingPointsWindow.getDefault().open();
                             ProfilingPointsWindow.getDefault().requestVisible();
                         }
                     }
                 });
         }
     }
 
     @Override
         return  != null ?  : new RuntimeProfilingPoint[0];
     }
     
     // Required for JDev implementation
     public void updateLocation(CodeProfilingPoint cppint oldLineint newLine) {
         if (cpp instanceof CodeProfilingPoint.Single) {
             CodeProfilingPoint.Single cpps = (CodeProfilingPoint.Single)cpp;
             CodeProfilingPoint.Location loc = cpps.getLocation();
             if (loc.getLine() == oldLine)
                 updateLocation(cppsnewLinecpps.getAnnotation());
                 
         } else if (cpp instanceof CodeProfilingPoint.Paired) {
             CodeProfilingPoint.Paired cppp = (CodeProfilingPoint.Paired)cpp;
             CodeProfilingPoint.Annotation ann = null;
             CodeProfilingPoint.Location loc = cppp.getStartLocation();
             if (loc.getLine() == oldLine) {
                 ann = cppp.getStartAnnotation();
             } else {
                 loc = cppp.getEndLocation();
                 if (loc.getLine() == oldLine)
                     ann = cppp.getEndAnnotation();
             }
             if (ann != nullupdateLocation(cpppnewLineann);
         }
     }
     
     private void updateLocation(CodeProfilingPoint cppint lineCodeProfilingPoint.Annotation cppa) {
         cpp.internalUpdateLocation(cppaline);
         .add(cpp);
     }
 
     public void propertyChange(PropertyChangeEvent evt) {
         if (evt.getSource() instanceof Line && ..equals(evt.getPropertyName())) {
             final Line line = (Lineevt.getSource();
             processor().post(new Runnable() {
                     public void run() {
                         for (ProfilingPoint pp : ) {
                             if (pp instanceof CodeProfilingPoint) {
                                 CodeProfilingPoint cpp = (CodeProfilingPointpp;
 
                                 for (CodeProfilingPoint.Annotation cppa : cpp.getAnnotations()) {
                                     if (line.equals(cppa.getAttachedAnnotatable())) {
                                         cpp.internalUpdateLocation(cppaline.getLineNumber() + 1); // Line is 0-based, needs to be 1-based for CodeProfilingPoint.Location
                                     }
                                 }
 
                                 .add(cpp);
                             }
                         }
                     }
                 });
         } else if (evt.getSource() instanceof ProfilingPoint) {
             ProfilingPoint profilingPoint = (ProfilingPointevt.getSource();
             if (!evt.getPropertyName().equals(.))
                 storeProfilingPoints(new ProfilingPoint[] { profilingPoint });
 
             if (isAnnotationChange(evt)) {
                 ProfilingPointAnnotator.get().annotationChanged(evt);
             }
 
             if (isLocationChange(evt)) {
                 ProfilingPointAnnotator.get().locationChanged(evt);
                 
                 CodeProfilingPoint.Location oldLocation = (CodeProfilingPoint.Location)evt.getOldValue();
                 if (oldLocation != null && !...equals(oldLocation))
                     removeFileWatch(new File(oldLocation.getFile()));
                 
                 CodeProfilingPoint.Location newLocation = (CodeProfilingPoint.Location)evt.getNewValue();
                 if (newLocation != null && !...equals(newLocation))
                     addFileWatch(new File(newLocation.getFile()));
             }
                 
             if (isAppearanceChange(evt)) {
                 ProfilingPointAnnotator.get().appearanceChanged(evt);
                 firePropertyChanged();
             }
 //        } else if (OpenProjects.PROPERTY_OPEN_PROJECTS.equals(evt.getPropertyName())) {
 //            processor().post(new Runnable() {
 //                    public void run() {
 //                        processOpenedProjectsChanged();
 //                    }
 //                });
 
             // --- Code for saving dirty profiling points on document save instead of IDE closing ----------------
             //    } else if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
             //      System.err.println(">>> Changed " + evt.getPropertyName() + " from " + evt.getOldValue() + " to " + evt.getNewValue() + ", origin: "+ evt.getSource());
             // ---------------------------------------------------------------------------------------------------
         }
     }
     
     public void stateChanged(ChangeEvent e) {
         processor().post(new Runnable() {
             public void run() {
                 processOpenedProjectsChanged();
             }
         });
     }
 
     public void removeProfilingPoint(ProfilingPoint profilingPoint) {
         removeProfilingPoints(new ProfilingPoint[] { profilingPoint });
     }
 
     public synchronized void removeProfilingPoints(ProfilingPoint[] profilingPointsArr) {
         removeProfilingPoints(profilingPointsArrfalse);
     }
 
     public void removePropertyChangeListener(PropertyChangeListener listener) {
     }
 
     public void removePropertyChangeListener(String propertyNamePropertyChangeListener listener) {
         .addPropertyChangeListener(propertyNamelistener);
     }
 
     public void reset() {
         // TODO: currently only last used profiling points are reset, check if all profiling points need to be reset
         List<ProfilingPointprofilingPointsToReset = new LinkedList();
 
         // reset CodeProfilingPoints
 
         for (RuntimeProfilingPointMapper mapper : mappersToReset) {
             profilingPointsToReset.add(mapper.getOwner());
         }
 
         .clear();
 
         // reset GlobalProfilingPoints
         profilingPointsToReset.addAll();
 
         for (ProfilingPoint ppoint : profilingPointsToReset) {
             ppoint.reset();
         }
 
         profilingPointsToReset.clear();
     }
 
     public void timeAdjust(final int threadIdfinal long timeDiff0final long timeDiff1) {
         Set uniqueSet = new HashSet();
 
         while (it.hasNext()) {
             CodeProfilingPoint cpp = it.next().getOwner();
 
             if (cpp instanceof CodeProfilingPoint.Paired) {
                 if (uniqueSet.add(cpp)) {
                     ((CodeProfilingPoint.Pairedcpp).timeAdjust(threadIdtimeDiff0timeDiff1);
                 }
             }
         }
     }
     
     public boolean belowMaxHits(int hitsCount) {
         return hitsCount < ;
     }
     
     public String getTruncatedResultsText() {
         return "<br>&nbsp;" + Bundle.ProfilingPointsManager_ShowingFirstNItemsTxt(); // NOI18N
     }
 
     boolean isAnyCustomizerShowing() {
         return getShowingCustomizer() != null;
     }
 
         Iterator<ValidityAwarePaneliterator = .iterator();
 
         while (iterator.hasNext()) {
             ValidityAwarePanel vaPanel = iterator.next();
 
             if (vaPanel.isShowing()) {
                 return vaPanel;
             }
         }
 
         return null;
     }
 
     // Returns true if customizer was opened and then submitted by OK button
     boolean customize(final ValidityAwarePanel customizerRunnable updaterboolean focusToEditor) {
         ValidityAwarePanel showingCustomizer = getShowingCustomizer();
 
         if (showingCustomizer != null) {
             ProfilerDialogs.displayWarning(
                     Bundle.ProfilingPointsManager_AnotherPpEditedMsg());
             SwingUtilities.getWindowAncestor(showingCustomizer).requestFocus();
             showingCustomizer.requestFocusInWindow();
         } else {
             CustomizerButton cb = getCustomizerButton();
             customizer.addValidityListener(cb);
             cb.setEnabled(customizer.areSettingsValid()); // In fact customizer should be valid but just to be sure...
 
             JPanel customizerContainer = new JPanel(new BorderLayout());
             JPanel customizerSpacer = new JPanel(new BorderLayout());
             customizerSpacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0));
             customizerSpacer.add(customizer.);
             customizerContainer.add(customizerSpacer.);
             customizerContainer.add(new JSeparator(), .);
 
             HelpCtx helpCtx = null;
 
             if (customizer instanceof HelpCtx.Provider) {
                 helpCtx = ((HelpCtx.Providercustomizer).getHelpCtx();
             }
 
             DialogDescriptor dd = new DialogDescriptor(customizerContainer, Bundle.ProfilingPointsManager_PpCustomizerCaption(), false,
                                                        new Object[] { cb. },
                                                        cb, 0, helpCtxnull);
             final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
             d.addWindowListener(new CustomizerListener(dddupdater));
             d.setModal(true);
             // give focus to the initial focus target
             d.addFocusListener(new FocusAdapter() {
                 @Override
                 public void focusGained(FocusEvent e) {
                     if (customizer.getInitialFocusTarget() != null) {
                         customizer.getInitialFocusTarget().requestFocusInWindow();
                     }
                 }
             });
             
             if (focusToEditor) {
                 Dimension dim = d.getPreferredSize();
                 Component masterComponent = WindowManager.getDefault().getRegistry().getActivated();
                 if (masterComponent != null) {
                     Rectangle b = masterComponent.getBounds();
                     Point location = new Point((b.x + (b.width / 2)) - (dim.width / 2),
                                                (b.y + (b.height / 2)) - (dim.height / 2));
                     SwingUtilities.convertPointToScreen(locationmasterComponent);
                     d.setLocation(location);
                 }
             }
             
             d.setVisible(true);
             
             if (dd.getValue() == cb) {
                 return true;
             }
         }
         return false;
     }
 
     void documentOpened(Line.Set lineSetFileObject fileObject) {
         for (ProfilingPoint profilingPoint : ) {
             if (profilingPoint instanceof CodeProfilingPoint) {
                 CodeProfilingPoint cpp = (CodeProfilingPointprofilingPoint;
 
                 for (CodeProfilingPoint.Annotation cppa : cpp.getAnnotations()) {
                     File annotationFile = new File(cpp.getLocation(cppa).getFile());
 
                     if ((annotationFile == null) || (fileObject == null)) {
                         continue// see #98535
                     }
 
                     File adeptFile = FileUtil.toFile(fileObject);
 
                     if (adeptFile == null) {
                         continue// see #98535
                     }
 
                     if (adeptFile.equals(annotationFile)) {
                         deannotateProfilingPoint(cpp);
                         annotateProfilingPoint(cpp);
 
                         break;
                     }
                 }
             }
         }
     }
 
         if (!.contains(customizer)) {
             .add(customizer);
         }
 
         return isAnyCustomizerShowing() ? null : customizer;
     }
 
     private boolean isAnnotationChange(PropertyChangeEvent evt) {
         String propertyName = evt.getPropertyName();
 
         return propertyName.equals(.);
     }
     
     private boolean isLocationChange(PropertyChangeEvent evt) {
         String propertyName = evt.getPropertyName();
 
         return propertyName.equals(.);
     }
     
     private boolean isAppearanceChange(PropertyChangeEvent evt) {
         String propertyName = evt.getPropertyName();
 
         return propertyName.equals(.) || propertyName.equals(.)
                || propertyName.equals(.) || propertyName.equals(.);
     }
     
     private static Set<FileObjectlocations(Collection<Lookup.Providerprojects) {
         if (projects == null || projects.isEmpty()) return .;
         Set<FileObjectlocations = new HashSet();
         for (Lookup.Provider project : projects)
             locations.add(ProjectUtilities.getProjectDirectory(project));
         return locations;
     }
 
     private static boolean containsProject(Set<FileObjectlocationsLookup.Provider p) {
         if (p != null && !locations.isEmpty()) {
             FileObject projectDir = ProjectUtilities.getProjectDirectory(p);
             return locations.contains(projectDir);
         }
         return false;
     }
 
     private Set<Lookup.ProvidergetOpenSubprojects(Lookup.Provider project) {
         Set<Lookup.Providersubprojects = new HashSet();
         ProjectUtilities.fetchSubprojects(projectsubprojects);
 
         if (subprojects.isEmpty()) return subprojects;
 
         Set<Lookup.ProvideropenSubprojects = new HashSet();
         Set<FileObjectsubprojectsLoc = locations(subprojects);
         synchronized() {
             for (Lookup.Provider openProject : )
                 if (containsProject(subprojectsLocopenProject))
                     openSubprojects.add(openProject);
         }
 
         return openSubprojects;
     }
     
     // Returns only valid profiling points (currently all GlobalProfilingPoints and CodeProfilingPoints with all locations pointing to a valid java file)
     private ProfilingPoint[] getValidProfilingPoints(ProfilingPoint[] profilingPointsArr) {
         ArrayList<ProfilingPointvalidProfilingPoints = new ArrayList<ProfilingPoint>();
         for (ProfilingPoint profilingPoint : profilingPointsArrif(profilingPoint.isValid()) validProfilingPoints.add(profilingPoint);
         return validProfilingPoints.toArray(new