Java Code Examples for org.openide.util.Lookup#Provider

The following examples show how to use org.openide.util.Lookup#Provider . 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: ObjectsFeature.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private ObjectsFeatureUI getUI() {
    if (ui == null) ui = new ObjectsFeatureUI() {
        Set<ClientUtils.SourceCodeSelection> getSelection() {
            return selectedClassesMode.getSelection();
        }
        void selectForProfiling(ClientUtils.SourceCodeSelection value) {
            ObjectsFeature.this.selectForProfiling(value);
        }
        Lookup.Provider getProject() {
            return ObjectsFeature.this.getSession().getProject();
        }
        ProfilerClient getProfilerClient() {
            Profiler profiler = ObjectsFeature.this.getSession().getProfiler();
            return profiler.getTargetAppRunner().getProfilerClient();
        }
        int getSessionState() {
            return ObjectsFeature.this.getSessionState();
        }
        void refreshResults() {
            ObjectsFeature.this.refreshResults();
        }
    };
    return ui;
}
 
Example 2
Source File: MethodsFeatureModes.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
void configureSettings(ProfilingSettings settings) {
    super.configureSettings(settings);
    
    StringBuilder filter = new StringBuilder();
    
    for (Lookup.Provider project : selectedProjects) {
        ProjectContentsSupport pcs = ProjectContentsSupport.get(project);
        filter.append(pcs.getInstrumentationFilter(false));
        filter.append(" "); // NOI18N
        pcs.reset();
    }
    
    String s  = filter.toString().replace(". ", ".* ").replace(".,", ".*,").trim(); // NOI18N
    JavaTypeFilter f = new JavaTypeFilter(s, JavaTypeFilter.TYPE_INCLUSIVE);
    settings.setInstrumentationFilter(f);
}
 
Example 3
Source File: ObjectsFeatureModes.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
ProjectClassesMode() {
    selectedProjects = new HashSet();
    
    Collection<File> files = createFilesFromStorage();
    if (files.isEmpty()) {
        selectedProjects.add(getProject());
    } else {
        for (File file : files) if (file.exists()) {
            FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(file));
            Lookup.Provider project = fo == null ? null : ProjectUtilities.getProject(fo);
            if (fo != null) selectedProjects.add(project);
        }
        verifySelectedProjects(false);
    }
}
 
Example 4
Source File: NbEditorKit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Lookup getContextLookup(java.awt.Component component){
    Lookup lookup = null;
    for (java.awt.Component c = component; c != null; c = c.getParent()) {
        if (c instanceof Lookup.Provider) {
            lookup = ((Lookup.Provider)c).getLookup ();
            if (lookup != null) {
                break;
            }
        }
    }
    return lookup;
}
 
Example 5
Source File: ProfilingPointsManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public List<ProfilingPoint> getCompatibleProfilingPoints(Lookup.Provider project, ProfilingSettings profilingSettings, boolean sorted) {

       List<ProfilingPoint> projectProfilingPoints = sorted ? getSortedProfilingPoints(project, 1, false)
                                                            : getProfilingPoints(project, ProfilerIDESettings.
                                                              getInstance().getIncludeProfilingPointsDependencies(), false); // TODO: define default sorting (current sorting of Profiling Points window?)
       List<ProfilingPoint> compatibleProfilingPoints = new ArrayList();

       for (ProfilingPoint profilingPoint : projectProfilingPoints) {
           if (profilingPoint.supportsProfilingSettings(profilingSettings)) {
               compatibleProfilingPoints.add(profilingPoint);
           }
       }

       return compatibleProfilingPoints;
   }
 
Example 6
Source File: ClassMethodSelector.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static Collection<SourcePackageInfo> getProjectPackages(Lookup.Provider project, boolean sources, boolean dependencies) {
    Set<SourcePackageInfo> packages = new HashSet();
    if (sources) packages.addAll(ProfilerTypeUtils.getPackages(false, SourcePackageInfo.Scope.SOURCE, project));
    if (dependencies) packages.addAll(ProfilerTypeUtils.getPackages(false, SourcePackageInfo.Scope.DEPENDENCIES, project));

    Set<SourcePackageInfo> sortedPackages = new TreeSet<SourcePackageInfo>(
        new Comparator<SourcePackageInfo>() {
            public int compare(SourcePackageInfo p1, SourcePackageInfo p2) {
                return p1.getBinaryName().compareTo(p2.getBinaryName());
            }
        }
    );
    sortedPackages.addAll(packages);
    return sortedPackages;
}
 
Example 7
Source File: TriggeredTakeSnapshotProfilingPointFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TriggeredTakeSnapshotProfilingPoint create(Lookup.Provider project) {
    if (project == null) {
        project = Utils.getCurrentProject(); // project not defined, will be detected from most active Editor or Main Project will be used
    }

    String name = Utils.getUniqueName(getType(),
                                      Bundle.TriggeredTakeSnapshotProfilingPointFactory_PpDefaultName(
                                            "", ProjectUtilities.getDisplayName(project)), // NOI18N
                                      project);

    return new TriggeredTakeSnapshotProfilingPoint(name, project, this);
}
 
Example 8
Source File: GoToSource.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
@NbBundle.Messages({
    "OpeningSourceMsg=Opening source for class {0}",
    "NoSourceFoundMessage=No source found for class {0}"
})
private static void openSourceImpl(Lookup.Provider project, String className, String methodName, String signature, int line) {
    int idx = methodName == null ? -1 : methodName.indexOf("[native]"); // NOI18N
    if (idx > -1) methodName = methodName.substring(0, idx);
    
    // *** logging stuff ***
    ProfilerLogger.debug("Open Source: Project: " + project); // NOI18N
    ProfilerLogger.debug("Open Source: Class name: " + className); // NOI18N
    ProfilerLogger.debug("Open Source: Method name: " + methodName); // NOI18N
    ProfilerLogger.debug("Open Source: Method sig: " + signature); // NOI18N
    
    Collection<? extends GoToSourceProvider> implementations = Lookup.getDefault().lookupAll(GoToSourceProvider.class);
    
    String st = Bundle.OpeningSourceMsg(className);
    final String finalStatusText = st + " ..."; // NOI18N
    StatusDisplayer.getDefault().setStatusText(finalStatusText);
    
    for(GoToSourceProvider impl : implementations) {
        try {
            if (impl.openSource(project, className, methodName, signature, line)) return;
        } catch (Exception e) {
            ProfilerLogger.log(e);
        }
    }
    
    ProfilerDialogs.displayError(Bundle.NoSourceFoundMessage(className));
}
 
Example 9
Source File: IOColors.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static IOColors find(InputOutput io) {
    if (io instanceof Lookup.Provider) {
        Lookup.Provider p = (Lookup.Provider) io;
        return p.getLookup().lookup(IOColors.class);
    }
    return null;
}
 
Example 10
Source File: ContextManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Checks whether a type is enabled.
 */
public <T> boolean runEnabled(Class<T> type, ContextSelection selectMode,  BiFunction<List<? extends T>, Lookup.Provider, Boolean> callback) {
    Lookup.Result<T> result = findResult(type);
    
    boolean e = isEnabledOnData(result, type, selectMode);
    if (e) {
        List<? extends T> all = listFromResult(result);
        e = callback.apply(all, new LkpAE(all, type));
    }
    
    return e;
}
 
Example 11
Source File: ProfilerStorage.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public static void deleteProjectProperties(Lookup.Provider project, String filename) throws IOException {
    if (project == null) {
        deleteGlobalProperties(filename);
    } else {
        ProfilerStorageProvider p = provider();
        if (p != null) p.deleteProjectProperties(project, filename);
    }
}
 
Example 12
Source File: ToolsAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Tells if there is any action that is willing to provide
 * Presenter.Popup
 */
private boolean isPopupEnabled(Action toolsAction) {
    boolean en = false;
    Action[] copy = actions;

    // Get action conext.
    Lookup lookup;

    if (toolsAction instanceof Lookup.Provider) {
        lookup = ((Lookup.Provider) toolsAction).getLookup();
    } else {
        lookup = null;
    }

    for (int i = 0; i < copy.length; i++) {
        if (copy[i] == null) {
            continue;
        }
        // Get context aware action instance if needed.
        Action act;

        // Retrieve context aware action instance if possible.
        if ((lookup != null) && copy[i] instanceof ContextAwareAction) {
            act = ((ContextAwareAction) copy[i]).createContextAwareInstance(lookup);
            if (act == null) {
                throw new IllegalStateException("createContextAwareInstance for " + copy[i] + " returned null!");
            }
        } else {
            act = copy[i];
        }

        if (act.isEnabled()) {
            en = true;

            break;
        }
    }

    return en;
}
 
Example 13
Source File: LoadGeneratorCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setProject(Lookup.Provider aProject) {
    project = aProject;
}
 
Example 14
Source File: ProfilerProject.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected ProfilerProject(Lookup.Provider project) {
    this.provider = project;
}
 
Example 15
Source File: MainClassWarning.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates new form LibrariesChooser
 */
public MainClassWarning(String message, Lookup.Provider project) {
    this.project = project;
    this.message = message;
    initComponents();
}
 
Example 16
Source File: ProfilingResultsSupport.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public Lookup.Provider getProjectFromFolder(FileObject settingsFolder) {
    return null;
}
 
Example 17
Source File: ProjectSelector.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public final Lookup.Provider getProject() {
    Lookup.Provider project = (Lookup.Provider)getSelectedItem();
    return project == EXTERNAL_PROCESS ? null : project;
}
 
Example 18
Source File: SessionStorage.java    From netbeans with Apache License 2.0 4 votes vote down vote up
SessionStorage(Lookup.Provider project) {
    this.project = project;
}
 
Example 19
Source File: ProfilingPointsManager.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public List<ProfilingPoint> getProfilingPoints(Lookup.Provider project,
                                               boolean inclSubprojects,
                                               boolean inclUnavailable) {
    return getProfilingPoints(ProfilingPoint.class, project,
                              inclSubprojects, inclUnavailable);
}
 
Example 20
Source File: ProfilerTypeUtils.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves project's packages
 * @param subprojects Flag indicating whether subprojects should be taken into account
 * @param scope A {@linkplain SourcePackageInfo.Scope} - SOURCE or DEPENDENCIES
 * @param project A project to get the packages for
 * @return Returns a list of project's packages
 */
public static Collection<SourcePackageInfo> getPackages(boolean subprojects, SourcePackageInfo.Scope scope, Lookup.Provider project) {
    ProfilerTypeUtilsProvider p = getProvider(project);
    
    return p != null ? p.getPackages(subprojects, scope) : Collections.EMPTY_LIST;
}