private Request () { this ( new ParserResultTask(){ @Override public int getPriority() { return 0; } @Override public Class<? extends Scheduler> getSchedulerClass() { return null; } @Override public void cancel() { } @Override public void run(Result result, SchedulerEvent event) { } }, Lookup.EMPTY); }
public void testReadAccess() throws Exception { ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class); try { Class<?> c = Class.forName("javax.help.HelpSet", true, l); } catch (ClassNotFoundException ex) { LOG.log(Level.FINE, "Can't pre-load JavaHelp", ex); } try { if (CountingSecurityManager.isEnabled()) { CountingSecurityManager.assertCounts("No reads during startup", 0); } else { System.out.println("Initialization mode, counting is disabled"); } } catch (Error e) { e.printStackTrace(getLog("file-reads-report.txt")); throw e; } assertEnabled("org.netbeans.core.windows"); }
/** * Gets IOProvider of selected name or delegates to getDefault() if none was * found. * * @param id ID of provider. * @return The instance corresponding to provided name or default instance * if not found. */ @NonNull public static IOProvider get(@NonNull String id) { Parameters.notNull("id", id); @SuppressWarnings("rawtypes") Collection<? extends InputOutputProvider> providers = Lookup.getDefault().lookupAll(InputOutputProvider.class); for (InputOutputProvider<?, ?, ?, ?> p : providers) { if (p.getId().equals(id)) { return wrapProvider(p); } } InputOutputProvider<?,?,?,?> bridgingImpl = getBridging(id); if (bridgingImpl != null) { return wrapProvider(bridgingImpl); } else { return getDefault(); } }
public ModelSource createTestModelSource(FileObject fo, boolean editable) throws CatalogModelException{ final DataObject dobj; final CatalogModel catalogModel = createCatalogModel(fo); try { dobj = DataObject.find(fo); } catch (DataObjectNotFoundException ex) { throw new CatalogModelException(ex); } Lookup lookup = Lookups.proxy(new Lookup.Provider() { public Lookup getLookup() { return Lookups.fixed(new Object[] { dobj.getPrimaryFile(), getDocument(dobj.getPrimaryFile()), dobj, catalogModel }); } } ); return new ModelSource(lookup, editable); }
public ContextBuildInstaller(Lookup actionContext) { this.actionContext = actionContext; putValue(NAME, NbBundle.getMessage(BuildInstallersAction.class, "CTL_BuildInstallers")); putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); Project project = actionContext.lookup(Project.class); if (project == null) { setEnabled(false); //#224115 } else { NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class); if (watcher == null || !NbMavenProject.TYPE_NBM_APPLICATION.equalsIgnoreCase(watcher.getPackagingType())) { setEnabled(false); } else { String version = PluginPropertyUtils.getPluginVersion(watcher.getMavenProject(), "org.codehaus.mojo", "nbm-maven-plugin"); if (version == null || new ComparableVersion(version).compareTo(new ComparableVersion("3.7-SNAPSHOT")) >= 0) { setEnabled(false); // now handled by maven.apisupport } } } }
public static void main(String[] args) throws FileNotFoundException { Lookup.getDefault().lookup(ProjectController.class).newProject(); CxfNetwork network = new CxfNetwork(); network.load(new File( "/home/ilias/workspace/sg/resources/networks/linear.cxf")); NetworkStatistics netStats = new NetworkStatistics(); netStats.execute(); System.out.println("~~~ Network Statistics Report ~~~"); System.out.println(netStats.getReport()); System.out.println("~~~~~~~~~ End of Report ~~~~~~~~"); netStats.getReportUI().setVisible(true); }
public boolean hasSnapshotsFor(Lookup.Provider project) { try { FileObject snapshotsFolder = ProfilerStorage.getProjectFolder(project, false); FileObject[] children; if (snapshotsFolder == null) { return false; } snapshotsFolder.refresh(); children = snapshotsFolder.getChildren(); for (FileObject child : children) { if (child.getExt().equalsIgnoreCase(SNAPSHOT_EXTENSION)) return true; if (checkHprofFile(FileUtil.toFile(child))) return true; } } catch (IOException e) { LOGGER.log(Level.SEVERE, Bundle.ResultsManager_ObtainSavedSnapshotsFailedMsg(e.getMessage()), e); } return false; }
@Override public boolean enabled() { for (EncryptionProvider p : Lookup.getDefault().lookupAll(EncryptionProvider.class)) { if (p.enabled()) { encryption = p; Preferences prefs = prefs(); Utils.goMinusR(prefs); p.encryptionChangingCallback(this); if (!testSampleKey(prefs)) { continue; } LOG.log(Level.FINE, "Using provider: {0}", p); return true; } } LOG.fine("No provider"); return false; }
public static BusyIcon create() { Object painter = null; ClassLoader cl = Lookup.getDefault().lookup( ClassLoader.class ); try { Class painterClass = cl.loadClass( "org.jdesktop.swingx.painter.BusyPainter" ); //NOI18N Constructor ctor = painterClass.getConstructor( int.class ); int height = getBusyIconSize(); painter = ctor.newInstance( height ); Method setFrame = painterClass.getMethod( "setFrame", int.class ); //NOI18N Method paint = painterClass.getMethod( "paint", Graphics2D.class, Object.class, int.class, int.class ); //NOI18N Method m = painterClass.getMethod( "setPoints", int.class ); //NOI18N m.invoke( painter, POINTS ); return new SwingXBusyIcon( painter, paint, setFrame, height ); } catch( Exception ex ) { Logger.getLogger( BusyIcon.class.getName() ).log( Level.FINE, null, ex ); } return null; }
public void testLookup () { final String INSTALLER_REGISTRY_FOLDER = "org-netbeans-api-java/platform/installers"; // NOI18N final Lookup lkp = Lookups.forPath(INSTALLER_REGISTRY_FOLDER); lkp.lookupAll(GeneralPlatformInstall.class); assertPlatformInstalls( lkp.lookupAll(CustomPlatformInstall.class), "org.netbeans.modules.java.j2seembedded.wizard.RemotePlatformInstall"); //NOI18N assertPlatformInstalls( lkp.lookupAll(PlatformInstall.class), "org.netbeans.modules.java.j2seplatform.J2SEInstallImpl"); //NOI18N assertPlatformInstalls( lkp.lookupAll(GeneralPlatformInstall.class), "org.netbeans.modules.java.j2seplatform.J2SEInstallImpl", //NOI18N "org.netbeans.modules.java.j2seembedded.wizard.RemotePlatformInstall"); //NOI18N }
public void testBuildWithDirtyListFirstTime() throws Exception { // #119777 J2SEProject prj = (J2SEProject) pp; EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); ep.put(ProjectProperties.TRACK_FILE_CHANGES, "true"); helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); // Use a new instance, since the old one will already have a dirty list from setUp(): actionProvider = new J2SEActionProvider(prj, prj.getUpdateHelper()); ep = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH); ep.put(ProjectProperties.DO_DEPEND, "false"); helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep); Properties p = new Properties(); MainClassChooser.unitTestingSupport_hasMainMethodResult = true; try { assertEquals("[run]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_RUN, Lookup.EMPTY, p))); assertEquals("{}", p.toString()); assertEquals("[run]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_RUN, Lookup.EMPTY, p))); assertEquals("{includes=nothing whatsoever}", p.toString()); } finally { MainClassChooser.unitTestingSupport_hasMainMethodResult = null; } }
/** Cleanup the references */ @Override public AbstractLookup.ReferenceToResult cleanUpResult(Lookup.Template<?> templ) { long now = System.currentTimeMillis(); AbstractLookup.ReferenceIterator it = new AbstractLookup.ReferenceIterator(this.results); int cnt = 0; while (it.next()) { cnt++; } long took = System.currentTimeMillis() - now; if (took > 500 && AbstractLookup.LOG != null) { AbstractLookup.LOG.log(Level.WARNING, "Too long ({0} ms and {1} references) cleanUpResult for {2}", new Object[]{took, cnt, templ != null ? templ.getType() : null} ); } return this.results = it.first(); }
/** * Implementation of the above method. * * @param activatedNodes gives array of actually activated nodes. * @return number of supported classes */ private int resolveSupported(Node[] activatedNodes) { int ret = 0; Class<?>[] cookies = getCookies(); for (Node n : activatedNodes) { for (Class<?> cookie : cookies) { // test for supported cookies @SuppressWarnings("unchecked") Lookup.Template<?> templ = new Lookup.Template(cookie); if (n.getLookup().lookupItem(templ) != null) { ret++; break; } } } return ret; }
private InstallConfig() { for( ModuleInfo mi : Lookup.getDefault().lookupAll(ModuleInfo.class) ) { ergonomics = ergonomics || isErgonomicsPack(mi); if( !isPack(mi) ) continue; if( mi.isEnabled() ) { enabledPackNames.add(mi.getCodeNameBase()); } else { somePacksDisabled = true; } availablePackNames.add(mi.getCodeNameBase()); } }
private boolean configureAttachSettings(boolean partially) { AttachSettings settings = AttachWizard.getDefault().configure(attachSettings, partially); if (settings == null) return false; // cancelled by the user attachSettings = settings; final AttachSettings as = new AttachSettings(); attachSettings.copyInto(as); final Lookup.Provider lp = session.getProject(); RequestProcessor.getDefault().post(new Runnable() { public void run() { Properties p = new Properties(); as.store(p); try { ProfilerStorage.saveProjectProperties(p, lp, "attach"); // NOI18N } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }); return true; }
@Override public FileObject[] getCurrentSelection() { Node[] nodes = TopComponent.getRegistry().getActivatedNodes(); if(nodes == null) { return null; } List<FileObject> ret = new ArrayList<FileObject>(); for(Node node : nodes) { Lookup nodeLookup = node.getLookup(); Collection<? extends Project> projects = nodeLookup.lookupAll(Project.class); if(projects != null && !projects.isEmpty()) { for (Project project : projects) { ret.add(project.getProjectDirectory()); } } else { DataObject dataObj = nodeLookup.lookup(DataObject.class); if (dataObj != null) { FileObject fileObj = dataObj.getPrimaryFile(); if (fileObj != null) { ret.add(fileObj); } } } } return ret.toArray(new FileObject[ret.size()]); }
protected void setUp() throws Exception { super.setUp(); Collection<? extends VCSSystemProvider> providers = Lookup.getDefault().lookupAll(VCSSystemProvider.class); for (VCSSystemProvider p : providers) { Collection<VCSSystemProvider.VersioningSystem> systems = p.getVersioningSystems(); for (VCSSystemProvider.VersioningSystem vs : systems) { if(vs instanceof DelegatingVCS) { DelegatingVCS dvcs = (DelegatingVCS)vs; if("TestVCSDisplay".equals(dvcs.getDisplayName())) { inteceptor = (TestVCSInterceptor) dvcs.getVCSInterceptor(); } } } } inteceptor.clearTestData(); logHandler = new FSInterceptorLogHandler(); VersioningManager.LOG.addHandler(logHandler); }
/** Creates the initial abstract lookup. */ @Override public Lookup createInstancesLookup (InstanceContent ic) { ic.attachExecutor(this); Lookup l = new AbstractLookup (ic, new InheritanceTree ()); return l; }
@Override public Action createContextAwareInstance(Lookup actionContext) { final Project project = actionContext.lookup(Project.class); if (project == null) { return this; } final ActionProvider ap = project.getLookup().lookup(ActionProvider.class); return !supportsImages(ap, actionContext) ? this : new CreateBundleAction(ap, actionContext); }
public GotoSourceRunnable(Lookup.Provider project, String className, String methodName, String signature, int line, AtomicBoolean cancelled) { this.project = project; this.className = className; this.methodName = methodName; this.signature = signature; this.line = line; this.cancelled = cancelled; }
public void testCanProxyLookupHaveWrongResults() { class L implements LookupListener { ProxyLookup pl; Lookup.Result<String> original; Lookup.Result<String> wrapped; boolean ok; public void test() { pl = new ProxyLookup(lookup); original = lookup.lookupResult(String.class); original.addLookupListener(this); wrapped = pl.lookupResult(String.class); assertEquals("Original empty", 0, original.allInstances().size()); assertEquals("Wrapped empty", 0, wrapped.allInstances().size()); ic.add("Hello!"); } public void resultChanged(LookupEvent ev) { ok = true; assertEquals("Original has hello", 1, original.allInstances().size()); assertEquals("Wrapped has hello", 1, wrapped.allInstances().size()); } } L listener = new L(); listener.test(); assertTrue("Listener called", listener.ok); }
@Override protected void setUp() throws Exception { super.setUp(); AntBridge.NO_MODULE_SYSTEM = true; System.setProperty("org.netbeans.core.startup.ModuleSystem.CULPRIT", "true"); MockServices.setServices(IFL.class, TestLogger.class); LOGGER = Lookup.getDefault().lookup(TestLogger.class); LOGGER.reset(); testdir = new File(this.getDataDir(), "antlogger"); assertTrue("have a dir " + testdir, testdir.isDirectory()); testdirFO = FileUtil.toFileObject(testdir); assertNotNull("have testdirFO", testdirFO); }
@Override protected void setUp() throws Exception { log = Logger.getLogger("[Test - " + getName() + "]"); lookup = Lookups.forPath("OptionsDialog"); // NOI18N Lookup.Result<RegisteredCategory> result = lookup.lookup(new Lookup.Template<RegisteredCategory>(RegisteredCategory.class)); all = result.allInstances(); assertTrue(all.size() > 0); }
public Lkp () { Assert.assertNull(DEFAULT); DEFAULT = this; ClassLoader l = Lkp.class.getClassLoader(); this.setLookups( new Lookup [] { Lookups.metaInfServices(l), Lookups.singleton(l), Lookups.singleton(ClassPathProviderImpl.getDefault()), }); }
public static int signalProcessSession(ExecutionEnvironment env, int psid, Signal signal) { final Collection<? extends SignalSupportImplementation> impls = Lookup.getDefault().lookupAll(SignalSupportImplementation.class); for (SignalSupportImplementation impl : impls) { if (impl.isSupported(env, SIGNAL_SCOPE.SIGNAL_SESSION)) { try { return impl.sendSignal(env, SIGNAL_SCOPE.SIGNAL_SESSION, psid, signal); } catch (UnsupportedOperationException ex) { // try next } } } throw new UnsupportedOperationException("Sending signal to a session of processes is not supported on " + env.getDisplayName()); // NOI18N }
@Override public boolean initialize(Lookup context, AtomicBoolean cancel) { FileObject file = context.lookup(FileObject.class); Project selected = null; if (file != null) { selected = FileOwnerQuery.getOwner(file); } if (selected == null) { selected = context.lookup(Project.class); if (selected == null) { SourceGroup sg = context.lookup(SourceGroup.class); if (sg != null) { selected = FileOwnerQuery.getOwner(sg.getRootFolder()); } } if (selected == null) { DataFolder df = context.lookup(DataFolder.class); if (df != null) { selected = FileOwnerQuery.getOwner(df.getPrimaryFile()); } } } if (selected == null || !OpenProjects.getDefault().isProjectOpen(selected)) { return false; } ProjectInformation pi = ProjectUtils.getInformation(selected); final SourceGroup[] sourceGroups = ProjectUtils.getSources(pi.getProject()).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); FileObject[] projectSources = new FileObject[sourceGroups.length]; for (int i = 0; i < sourceGroups.length; i++) { projectSources[i] = sourceGroups[i].getRootFolder(); } scope = Scope.create(Arrays.asList(projectSources), null, null); detail = pi.getDisplayName(); icon = pi.getIcon(); return true; }
private BuiltInDiffProvider getBuiltinProvider() { Collection<? extends DiffProvider> diffs = Lookup.getDefault().lookupAll(DiffProvider.class); for (DiffProvider diff : diffs) { if (diff instanceof BuiltInDiffProvider) { return (BuiltInDiffProvider) diff; } } throw new IllegalStateException("No builtin diff provider"); }
public void testAddToSelfClosing() throws Exception { sd = Util.getResourceAsDocument("selfClosing.xml"); Lookup lookup = Lookups.singleton(sd); ModelSource ms = new ModelSource(lookup, true); model = new XDMModel(ms); model.sync(); Document original = model.getDocument(); //Adding a brand new element for testing Node company = (Node)model.getDocument().getChildNodes().item(0); Element emp = (Element)model.getDocument().createElement("employee"); model.add(company,emp,0); model.flush(); model.sync(); company = (Node)model.getDocument().getChildNodes().item(0); emp = (Element) company.getFirstChild(); assertEquals("employee is not local name", emp.getLocalName(), "employee"); List<Token> tokens = emp.getTokens(); int endTokenCount = 0; for (Token t: tokens) { if (t.getType().equals(TokenType.TOKEN_ELEMENT_END_TAG)) { endTokenCount++; } } assertEquals("employee should be created using self-closing tag", 1, endTokenCount); }
public ToolbarPresenter(final Lookup actionContext) { assert SwingUtilities.isEventDispatchThread(); initComponents(); this.actionContext = actionContext; this.listDataListener = WeakListeners.create(ListDataListener.class, this, model); model.addListDataListener(listDataListener); }
@Override public void run() { lookupResult = Lookup.getDefault().lookupResult(PageInspector.class); lookupResult.addLookupListener(new LookupListener() { @Override public void resultChanged(LookupEvent ev) { refreshPageInspector(); } }); refreshPageInspector(); }
public static Lookup.Provider getCurrentProject() { Lookup.Provider currentProject = getMostActiveJavaProject(); if (currentProject == null) { currentProject = ProjectUtilities.getMainProject(); } return currentProject; }
private synchronized void storeProfilingPoints(ProfilingPoint[] profilingPointsArr) { if (ignoreStoreProfilingPoints) return; final Set<Lookup.Provider> projects = new HashSet(); final Set<ProfilingPointFactory> factories = new HashSet(); for (ProfilingPoint profilingPoint : profilingPointsArr) { projects.add(profilingPoint.getProject()); factories.add(profilingPoint.getFactory()); dirtyProfilingPoints.remove(profilingPoint); } processor().post(new Runnable() { public void run() { for (ProfilingPointFactory factory : factories) { if (factory == null) continue; for (Lookup.Provider project : projects) { try { factory.saveProfilingPoints(project); } catch (IOException ex) { ProfilerDialogs.displayError( Bundle.ProfilingPointsManager_CannotStorePpMsg( factory.getType(), ProjectUtilities.getDisplayName(project))); } } } } }); }
/** * Constructor for an anonymous vertex */ public Vertex() { this.internalNode = Lookup.getDefault().lookup(GraphController.class) .getModel().factory().newNode(); setId(DEFAULT_ID); setSize(DEFAULT_SIZE); setFillColor(DEFAULT_FILL_COLOR); }
/** Reset cache, for use from unit tests. */ static void reset() { cache = null; result = Lookup.getDefault().lookupResult(URLMapper.class); result.addLookupListener( new LookupListener() { public void resultChanged(LookupEvent ev) { synchronized (URLMapper.class) { cache = null; } } } ); }
/** * @return The one and only instance. */ public static EmbeddedBrowserFactory getDefault() { EmbeddedBrowserFactory res = null; for (EmbeddedBrowserFactory factory : Lookup.getDefault().lookupAll(EmbeddedBrowserFactory.class)) { if (factory.isEnabled()) { return factory; } else { res = factory; } } if( null == res ) { res = new EmbeddedBrowserFactory() { @Override public boolean isEnabled() { return false; } @Override public WebBrowser createEmbeddedBrowser() { throw new IllegalStateException(); } @Override public void addPropertyChangeListener(PropertyChangeListener l) { } @Override public void removePropertyChangeListener(PropertyChangeListener l) { } }; } return res; }
protected final Image annotateIcon(final Image img, final int type) { Image annotatedImg = img; if (files != null && files.iterator().hasNext()) { ImageDecorator imgDecorator = Lookup.getDefault().lookup(ImageDecorator.class); FileObject fo = files.iterator().next(); annotatedImg = imgDecorator.annotateIcon(img, type, files); } return annotatedImg; }
public void testContentCorrect () throws Exception { // This magic call will load modules and fill content of default file system // where xml layers live - uaah sometimes I think I just live in another world Lookup.getDefault().lookup(ModuleInfo.class); java.util.ArrayList errors = new java.util.ArrayList (); DataFolder df = DataFolder.findFolder (FileUtil.getConfigFile(rootName ())); verifyMenu (df, errors); if (!errors.isEmpty()) { fail ("Some files do not provide valid menu elements" + errors); } }
public void testFindPackageRoot() throws Exception { Lookup context = contextDO(new FileObject[] {myAppJava}); JavaActions.AntLocation loc = ja.findPackageRoot(context); assertNotNull("found a package root for " + context, loc); assertEquals("right name", "${src.dir}", loc.virtual); assertEquals("right physical", src, loc.physical); context = contextDO(new FileObject[] {myAppJava, someFileJava}); loc = ja.findPackageRoot(context); assertNotNull("found a package root for " + context, loc); assertEquals("right name", "${src.dir}", loc.virtual); assertEquals("right physical", src, loc.physical); context = contextDO(new FileObject[] {src}); loc = ja.findPackageRoot(context); assertNotNull("found a package root for " + context, loc); assertEquals("right name", "${src.dir}", loc.virtual); assertEquals("right physical", src, loc.physical); context = contextDO(new FileObject[] {myAppJava, someResourceTxt}); loc = ja.findPackageRoot(context); assertNull("found no package root for " + context + ": " + loc, loc); context = contextDO(new FileObject[] {myAppJava, specialTaskJava}); loc = ja.findPackageRoot(context); assertNull("found no package root for " + context, loc); context = contextDO(new FileObject[] {}); loc = ja.findPackageRoot(context); assertNull("found no package root for " + context, loc); context = contextDO(new FileObject[] {specialTaskJava}); loc = ja.findPackageRoot(context); assertNotNull("found a package root for " + context, loc); assertEquals("right name", "${ant.src.dir}", loc.virtual); assertEquals("right physical", antsrc, loc.physical); context = contextDO(new FileObject[] {buildProperties}); loc = ja.findPackageRoot(context); assertNull("found no package root for " + context, loc); }
private void setupDisplay(Lookup.Provider project, ProfilingSettings settings) { List<ProfilingPoint> compatibleProfilingPoints = ProfilingPointsManager.getDefault() .getCompatibleProfilingPoints(project, settings, true); listModel.removeAllElements(); if (compatibleProfilingPoints.size() == 0) { listModel.addElement(Bundle.ProfilingPointsDisplayer_NoActivePpsString()); } else { for (ProfilingPoint profilingPoint : compatibleProfilingPoints) { listModel.addElement(profilingPoint); } } }
private ShellLaunchManager getManager() { if (mgr == null) { mgr = Lookup.getDefault().lookup(ShellLaunchManager.class); if (mgr == null) { throw new IllegalStateException("Could not find launch manager"); // NOI18N } } return mgr; }