org.openide.filesystems.FileStateInvalidException Java Examples
The following examples show how to use
org.openide.filesystems.FileStateInvalidException.
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: I18nOptions.java From netbeans with Apache License 2.0 | 6 votes |
private static FileObject findFileObject(DataObject srcDataObject, String path) { FileObject pfo = srcDataObject.getPrimaryFile(); ClassPath cp = ClassPath.getClassPath(pfo, ClassPath.EXECUTE); // #167334 if(cp == null) { LOG.info("Unable to find FileObject due to ClassPath is null"); return null; } for(FileObject fo : getRoots(cp)) { try { FileSystem fs = fo.getFileSystem(); if (fs != null) { FileObject retval = fs.findResource(path); if (retval != null) { return retval; } } } catch (FileStateInvalidException ex) { LOG.log(Level.INFO, null, ex); } } return null; }
Example #2
Source File: FileSearchUtility.java From netbeans with Apache License 2.0 | 6 votes |
public static FileObject guessConfigFilesPath(final FileObject dir, final String configFileName) { if (null == dir) { return null; } Enumeration<FileObject> ch = FileSearchUtility.getChildrenToDepth(dir, 3, true); //getChildren(true); try { while (ch.hasMoreElements()) { FileObject f = ch.nextElement(); if (f.getNameExt().equals(configFileName)) { String rootName = f.getParent().getPath(); return f.getFileSystem().findResource(rootName); } } } catch (FileStateInvalidException fsie) { Logger.getLogger("global").log(Level.INFO, null, fsie); } return null; }
Example #3
Source File: MetroConfigLoader.java From netbeans with Apache License 2.0 | 6 votes |
/** * Loads the default definition from metro-default.xml file from the metro jars. * @param project * @return */ public MetroConfig loadDefaultMetroConfig(Project project) { SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); ClassPath classPath = ClassPath.getClassPath(sgs[0].getRootFolder(),ClassPath.COMPILE); if ( classPath == null ){ return null; } FileObject defFO = classPath.findResource("META-INF/metro-default.xml"); // NOI18N try { if (defFO != null) { return loadMetroConfig(defFO.getURL()); } } catch (FileStateInvalidException ex) { Exceptions.printStackTrace(ex); } return null; }
Example #4
Source File: JaxWsClientNode.java From netbeans with Apache License 2.0 | 6 votes |
WsdlModeler getWsdlModeler() { if (getLocalWsdl()!=null) { try { WsdlModeler modeler = WsdlModelerFactory.getDefault().getWsdlModeler(wsdlFileObject.getURL()); if (modeler!=null) { // String packageName = client.getPackageName(); // if (packageName!=null && client.isPackageNameForceReplace()) { // // set the package name for the modeler // modeler.setPackageName(packageName); // } else { // modeler.setPackageName(null); // } modeler.setCatalog(jaxWsSupport.getCatalog()); // setBindings(modeler); return modeler; } } catch (FileStateInvalidException ex) { ErrorManager.getDefault().log(ex.getLocalizedMessage()); } } else { ErrorManager.getDefault().log(ErrorManager.ERROR, NbBundle.getMessage(JaxWsNode.class,"ERR_missingLocalWsdl")); } return null; }
Example #5
Source File: ProjectClassLoader.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected Enumeration<URL> findResources(String name) throws IOException { Set<URL> urls = new HashSet<URL>(); List<FileObject> fos = sources.findAllResources(name); for (FileObject fo : fos) { try { urls.add(fo.getURL()); } catch (FileStateInvalidException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } Enumeration<URL> e = projectClassLoaderDelegate.getResources(name); while (e.hasMoreElements()) { urls.add(e.nextElement()); } return Collections.enumeration(urls); }
Example #6
Source File: PageFlowController.java From netbeans with Apache License 2.0 | 6 votes |
/** * Unregister any listeners. */ public void unregisterListeners() { if (pcl != null) { if (configModel != null) { configModel.removePropertyChangeListener(pcl); } pcl = null; } FileObject myWebFolder = getWebFolder(); if (fcl != null && myWebFolder != null) { try { FileSystem fileSystem = myWebFolder.getFileSystem(); fileSystem.removeFileChangeListener(fcl); fcl = null; } catch (FileStateInvalidException ex) { Exceptions.printStackTrace(ex); } } }
Example #7
Source File: J2SELibrarySourceForBinaryQuery.java From netbeans with Apache License 2.0 | 6 votes |
private URL getNormalizedURL (URL url) throws MalformedURLException { //URL is already nornalized, return it if (isNormalizedURL(url)) { return url; } //Todo: Should listen on the LibrariesManager and cleanup cache // in this case the search can use the cache onle and can be faster // from O(n) to O(ln(n)) URL normalizedURL = normalizedURLCache.get(url); if (normalizedURL == null) { FileObject fo = URLMapper.findFileObject(url); if (fo != null) { try { normalizedURL = fo.getURL(); this.normalizedURLCache.put (url, normalizedURL); } catch (FileStateInvalidException e) { Exceptions.printStackTrace(e); } } } return normalizedURL; }
Example #8
Source File: ImportFormatTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testAddFirstImport() throws IOException, FileStateInvalidException { System.err.println("testAddFirstImport"); JavaSource src = getJavaSource(testFile); Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(Phase.RESOLVED); CompilationUnitTree cut = workingCopy.getCompilationUnit(); TreeMaker make = workingCopy.getTreeMaker(); List<ImportTree> imports = new ArrayList<ImportTree>(cut.getImports()); imports.add(0, make.Import(make.Identifier("java.util.AbstractList"), false)); CompilationUnitTree unit = make.CompilationUnit( cut.getPackageName(), imports, cut.getTypeDecls(), cut.getSourceFile() ); workingCopy.rewrite(cut, unit); } }; src.runModificationTask(task).commit(); String res = TestUtilities.copyFileToString(testFile); //System.err.println(res); assertFiles("testAddFirstImport_ImportFormatTest.pass"); }
Example #9
Source File: ImportFormatTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testRemoveInnerImport() throws IOException, FileStateInvalidException { JavaSource src = getJavaSource(testFile); Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(Phase.RESOLVED); CompilationUnitTree cut = workingCopy.getCompilationUnit(); TreeMaker make = workingCopy.getTreeMaker(); List<ImportTree> imports = new ArrayList<ImportTree>(cut.getImports()); imports.remove(1); CompilationUnitTree unit = make.CompilationUnit( cut.getPackageName(), imports, cut.getTypeDecls(), cut.getSourceFile() ); workingCopy.rewrite(cut, unit); } }; src.runModificationTask(task).commit(); String res = TestUtilities.copyFileToString(testFile); //System.err.println(res); assertFiles("testRemoveInnerImport_ImportFormatTest.pass"); }
Example #10
Source File: ImportFormatTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testRemoveFirstImport() throws IOException, FileStateInvalidException { JavaSource src = getJavaSource(testFile); Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(Phase.RESOLVED); CompilationUnitTree cut = workingCopy.getCompilationUnit(); TreeMaker make = workingCopy.getTreeMaker(); List<ImportTree> imports = new ArrayList<ImportTree>(cut.getImports()); imports.remove(0); CompilationUnitTree unit = make.CompilationUnit( cut.getPackageName(), imports, cut.getTypeDecls(), cut.getSourceFile() ); workingCopy.rewrite(cut, unit); } }; src.runModificationTask(task).commit(); String res = TestUtilities.copyFileToString(testFile); //System.err.println(res); assertFiles("testRemoveFirstImport_ImportFormatTest.pass"); }
Example #11
Source File: ImportFormatTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testRemoveLastImport() throws IOException, FileStateInvalidException { JavaSource src = getJavaSource(testFile); Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(Phase.RESOLVED); TreeMaker make = workingCopy.getTreeMaker(); CompilationUnitTree cut = workingCopy.getCompilationUnit(); List<ImportTree> imports = new ArrayList<ImportTree>(cut.getImports()); imports.remove(1); CompilationUnitTree unit = make.CompilationUnit( cut.getPackageName(), imports, cut.getTypeDecls(), cut.getSourceFile() ); workingCopy.rewrite(cut, unit); } }; src.runModificationTask(task).commit(); String res = TestUtilities.copyFileToString(testFile); //System.err.println(res); assertFiles("testRemoveLastImport_ImportFormatTest.pass"); }
Example #12
Source File: ImportFormatTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testRemoveInside() throws IOException, FileStateInvalidException { JavaSource src = getJavaSource(testFile); Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(Phase.RESOLVED); CompilationUnitTree cut = workingCopy.getCompilationUnit(); TreeMaker make = workingCopy.getTreeMaker(); List<ImportTree> imports = new ArrayList<ImportTree>(cut.getImports()); imports.remove(4); CompilationUnitTree unit = make.CompilationUnit( cut.getPackageName(), imports, cut.getTypeDecls(), cut.getSourceFile() ); workingCopy.rewrite(cut, unit); } }; src.runModificationTask(task).commit(); String res = TestUtilities.copyFileToString(testFile); //System.err.println(res); assertFiles("testRemoveInside_ImportFormatTest.pass"); }
Example #13
Source File: SpringBinaryIndexer.java From netbeans with Apache License 2.0 | 6 votes |
private String findVersion(FileObject classpathRoot) { ClassPath cp = ClassPath.getClassPath(classpathRoot, ClassPath.COMPILE); if (cp == null) { return null; } String classRelativePath = SpringUtilities.SPRING_CLASS_NAME.replace('.', '/') + ".class"; //NOI18N try { FileObject resource = cp.findResource(classRelativePath); //NOI18N if (resource==null) { return null; } FileObject ownerRoot = cp.findOwnerRoot(resource); if (ownerRoot !=null) { //NOI18N if (ownerRoot.getFileSystem() instanceof JarFileSystem) { JarFileSystem jarFileSystem = (JarFileSystem) ownerRoot.getFileSystem(); return SpringUtilities.getImplementationVersion(jarFileSystem); } } } catch (FileStateInvalidException e) { Exceptions.printStackTrace(e); } return null; }
Example #14
Source File: J2eePlatformSourceForBinaryQuery.java From netbeans with Apache License 2.0 | 6 votes |
private URL getNormalizedURL (URL url) { //URL is already nornalized, return it if (isNormalizedURL(url)) { return url; } //Todo: Should listen on the LibrariesManager and cleanup cache // in this case the search can use the cache onle and can be faster // from O(n) to O(ln(n)) URL normalizedURL = (URL) this.normalizedURLCache.get (url); if (normalizedURL == null) { FileObject fo = URLMapper.findFileObject(url); if (fo != null) { try { normalizedURL = fo.getURL(); this.normalizedURLCache.put (url, normalizedURL); } catch (FileStateInvalidException e) { Exceptions.printStackTrace(e); } } } return normalizedURL; }
Example #15
Source File: EjbJarProject.java From netbeans with Apache License 2.0 | 6 votes |
public void initialize() throws FileStateInvalidException { EjbJarProject.this.evaluator().addPropertyChangeListener(this); if (!isCopyOnSaveEnabled()) { return; } metaBase = getEjbModule().getMetaInf(); metaBaseValue = evaluator().getProperty(EjbJarProjectProperties.META_INF); if (resources != null) { FileUtil.removeFileChangeListener(this, resources); } resources = getEjbModule().getResourceDirectory(); buildClasses = evaluator().getProperty(ProjectProperties.BUILD_CLASSES_DIR); if (metaBase != null) { metaBase.getFileSystem().addFileChangeListener(this); } if (resources != null) { FileUtil.addFileChangeListener(this, resources); } LOGGER.log(Level.FINE, "Meta directory is {0}", metaBaseValue); }
Example #16
Source File: ClassSourceResolver.java From netbeans with Apache License 2.0 | 6 votes |
@Override public List<URL> getClasspath() { Sources sources = ProjectUtils.getSources(project); SourceGroup[] sgs = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); List<URL> list = new ArrayList<URL>(); for (SourceGroup sg : sgs) { try { ClassPath cp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE); if (cp != null) { for (FileObject fob : cp.getRoots()) { URL[] urls = UnitTestForSourceQuery.findSources(fob); if (urls.length == 0) { BinaryForSourceQuery.Result result = BinaryForSourceQuery.findBinaryRoots(fob.getURL()); list.addAll(Arrays.asList(result.getRoots())); } } } } catch (FileStateInvalidException fsiex) { FormUtils.LOGGER.log(Level.INFO, fsiex.getMessage(), fsiex); } } return list; }
Example #17
Source File: JPDAReload.java From netbeans with Apache License 2.0 | 6 votes |
private String classToSourceURL (FileObject fo) { try { ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE); FileObject root = cp.findOwnerRoot (fo); String resourceName = cp.getResourceName (fo, '/', false); if (resourceName == null) { getProject().log("Can not find classpath resource for "+fo+", skipping...", Project.MSG_ERR); return null; } int i = resourceName.indexOf ('$'); if (i > 0) resourceName = resourceName.substring (0, i); FileObject[] sRoots = SourceForBinaryQuery.findSourceRoots (root.getURL ()).getRoots (); ClassPath sourcePath = ClassPathSupport.createClassPath (sRoots); FileObject rfo = sourcePath.findResource (resourceName + ".java"); if (rfo == null) return null; return rfo.getURL ().toExternalForm (); } catch (FileStateInvalidException ex) { ex.printStackTrace (); return null; } }
Example #18
Source File: ProjectEar.java From netbeans with Apache License 2.0 | 6 votes |
public void initialize() throws FileStateInvalidException { ProjectEar.this.project.evaluator().addPropertyChangeListener(this); if (!isCopyOnSaveEnabled()) { return; } if (resources != null) { FileUtil.removeFileChangeListener(this, resources); } resources = getResourceDirectory(); if (resources != null) { FileUtil.addFileChangeListener(this, resources); } // Add deployed resources notification listener ProjectEar.this.getConfigSupport().addDeployOnSaveListener(this); }
Example #19
Source File: BrokenDataShadow.java From netbeans with Apache License 2.0 | 6 votes |
/** * Check if validity of broken data shadows can be checked for this file. * * See bug 43315 and bug 247812. The OS sometimes asked to insert floppy * disk or CD-ROM. * * @param file The file that may be referenced by broken data shadow. * @return True if validity of passed file can be checked. */ private static boolean canCheckValidity(FileObject file) { if (CHECK_ONLY_DEFAULT) { // #43315 hotfix: disable validity checking for non-SFS filesystem try { return file.getFileSystem().isDefault(); } catch (FileStateInvalidException e) { // something wrong, exit DataObject.LOG.log(Level.WARNING, e.toString(), e); return false; } } else { return true; } }
Example #20
Source File: ToDoCustomizer.java From netbeans with Apache License 2.0 | 6 votes |
private static String getLoaderDisplayName(String mimeType) { FileSystem filesystem = null; try { filesystem = FileUtil.getConfigRoot().getFileSystem(); } catch (FileStateInvalidException ex) { Exceptions.printStackTrace(ex); } FileObject factoriesFO = FileUtil.getConfigFile("Loaders/" + mimeType + "/Factories"); //NOI18N if (factoriesFO != null) { FileObject[] children = factoriesFO.getChildren(); for (FileObject child : children) { String childName = child.getNameExt(); String displayName = filesystem.getDecorator().annotateName(childName, Collections.singleton(child)); if (!childName.equals(displayName)) { return displayName; } } } return null; }
Example #21
Source File: SiteDocsNode.java From netbeans with Apache License 2.0 | 6 votes |
@Override public String getHtmlDisplayName() { if (!isTopLevelNode) { return getOriginal().getHtmlDisplayName(); } try { DataObject dob = getOriginal().getLookup().lookup(DataObject.class); FileObject file = dob.getPrimaryFile(); String s = LBL_Site_Pages(); String result = file.getFileSystem().getDecorator().annotateNameHtml ( s, Collections.singleton(file)); //Make sure the super string was really modified if (result != null && !s.equals(result)) { return result; } } catch (FileStateInvalidException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } return super.getHtmlDisplayName(); }
Example #22
Source File: CompileData.java From netbeans with Apache License 2.0 | 6 votes |
public FileObject getServletFileObject() { FileObject root = getServletJavaRoot(); if (root == null) { return null; } File servlet = getServletFile(); if ((servlet == null) || !servlet.exists()) { return null; } FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(servlet)); if (fo != null) { return fo; } try { root.getFileSystem().refresh(false); return root.getFileObject(getServletResourceName()); } catch (FileStateInvalidException e) { Logger.getLogger("global").log(Level.INFO, null, e); } return null; }
Example #23
Source File: NewSpringXMLConfigWizardIterator.java From netbeans with Apache License 2.0 | 6 votes |
private String findSpringVersion(FileObject ownerRoot) { try { if (ownerRoot !=null) { //NOI18N if (ownerRoot.getFileSystem() instanceof JarFileSystem) { JarFileSystem jarFileSystem = (JarFileSystem) ownerRoot.getFileSystem(); String implementationVersion = SpringUtilities.getImplementationVersion(jarFileSystem); if (implementationVersion != null) { String[] splitedVersion = implementationVersion.split("[.]"); //NOI18N if (splitedVersion.length < 2) { LOG.log(Level.SEVERE, "Unknown syntax of implementation version={0}", implementationVersion); return null; } return splitedVersion[0] + "." + splitedVersion[1]; } } } } catch (FileStateInvalidException e) { Exceptions.printStackTrace(e); } return null; }
Example #24
Source File: SettingChildren.java From netbeans with Apache License 2.0 | 6 votes |
protected Node copyNode (Node node) { boolean filter = false; try { DataObject d = (DataObject) node.getCookie (DataObject.class); if (d != null) { InstanceCookie.Of inst = (InstanceCookie.Of)d.getCookie(InstanceCookie.Of.class); if (inst != null && (inst.instanceOf(Node.class) || inst.instanceOf(Node.Handle.class))) { // This is just a node, not a real setting. E.g. ModuleNode, LoaderPoolNode. As such, // it itself should not display any origin information, it would make no sense. However // its children might have a legitimate DataObject cookie from the SFS. d = null; } } DataFolder folder = (DataFolder) node.getCookie (DataFolder.class); FileSystem fs = d == null || folder != null ? null : d.getPrimaryFile ().getFileSystem (); filter = fs == null ? false : fs.isDefault(); } catch (FileStateInvalidException e) { // ignore } return filter ? new SettingFilterNode (node) : node.isLeaf() ? node.cloneNode() : new TrivialFilterNode(node); }
Example #25
Source File: OpenSupport.java From netbeans with Apache License 2.0 | 5 votes |
private void init() { obj.addPropertyChangeListener(org.openide.util.WeakListeners.propertyChange(this, obj)); // XXX #25400. Ugly patch for being able to react // on change of root directory of filesystem, see more in the issue. final FileSystem fs; try { fs = obj.getPrimaryFile().getFileSystem(); } catch(FileStateInvalidException fsie) { throw (IllegalStateException) new IllegalStateException("FileSystem is invalid for " + obj.getPrimaryFile() + "!").initCause(fsie); // NOI18N } FileSystemNameListener fsListener; boolean initListening = false; synchronized(fsListenerMap) { Reference<FileSystemNameListener> fsListenerRef = fsListenerMap.get(fs); fsListener = fsListenerRef == null ? null : fsListenerRef.get(); if(fsListener == null) { // Create listener for that filesystem. fsListener = new FileSystemNameListener(); fsListenerMap.put(fs, new WeakReference<FileSystemNameListener>(fsListener)); initListening = true; } } if(initListening) { fs.addPropertyChangeListener(fsListener); fs.addVetoableChangeListener(fsListener); } fsListener.add(this); // End of patch #25400. }
Example #26
Source File: AnnotationProviderTest.java From netbeans with Apache License 2.0 | 5 votes |
/** Check whether a file is recognized. * It will be if the extension matches, or if it is marked to be a text file. */ protected FileObject findPrimaryFile (FileObject fo) { boolean isSysFile; try { isSysFile = fo.getFileSystem ().isDefault(); } catch (FileStateInvalidException fsie) { // Never mind. isSysFile = false; } if (! isSysFile && Boolean.TRUE.equals (fo.getAttribute (ATTR_IS_TEXT_FILE))) return fo; return super.findPrimaryFile (fo); }
Example #27
Source File: EjbJarMultiViewDataObject.java From netbeans with Apache License 2.0 | 5 votes |
private void refreshSourceFolders() { SourceGroup[] groups; Project project = getProject(); if (project != null) { Sources sources = ProjectUtils.getSources(project); groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); } else { groups = null; } if (groups != null) { synchronized(srcRoots) { srcRoots.clear(); for (int i = 0; i < groups.length; i++) { org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(groups[i].getRootFolder()); if ((ejbModule != null) && (ejbModule.getDeploymentDescriptor() != null)) { try { FileObject fo = groups[i].getRootFolder(); srcRoots.add(fo); FileSystem fs = fo.getFileSystem(); fs.removeFileChangeListener(this); //avoid being added multiple times fs.addFileChangeListener(this); } catch (FileStateInvalidException ex) { Exceptions.printStackTrace(ex); } } } initialized = true; } } }
Example #28
Source File: GeneratorTestBase.java From netbeans with Apache License 2.0 | 5 votes |
void assertFiles(final String aGoldenFile) throws IOException, FileStateInvalidException { assertFile("File is not correctly generated.", getTestFile(), getFile(getGoldenDir(), getGoldenPckg() + aGoldenFile), getWorkDir() ); }
Example #29
Source File: OthersRootNode.java From netbeans with Apache License 2.0 | 5 votes |
@Override public String getDisplayName () { String s = super.getDisplayName (); try { s = file.getFileSystem ().getDecorator ().annotateName (s, Collections.singleton(file)); } catch (FileStateInvalidException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } return s; }
Example #30
Source File: PackageRootNode.java From netbeans with Apache License 2.0 | 5 votes |
public @Override String getHtmlDisplayName() { try { String result = file.getFileSystem().getDecorator().annotateNameHtml ( super.getDisplayName(), files); //Make sure the super string was really modified if (result != null && !super.getDisplayName().equals(result)) { return result; } } catch (FileStateInvalidException e) { Exceptions.printStackTrace(e); } return super.getHtmlDisplayName(); }