Java Code Examples for org.openide.filesystems.FileStateInvalidException#printStackTrace()

The following examples show how to use org.openide.filesystems.FileStateInvalidException#printStackTrace() . 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: JPDAReload.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 2
Source File: FormEditorSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** This is called by the multiview elements whenever they are created
 * (and given a observer knowing their multiview TopComponent). It is
 * important during deserialization and cloning the multiview - i.e. during
 * the operations we have no control over. But anytime a multiview is
 * created, this method gets called.
 */
void setTopComponent(TopComponent topComp) {
    multiviewTC = (CloneableTopComponent)topComp;
    String[] titles = getMVTCDisplayName(formDataObject);
    multiviewTC.setDisplayName(titles[0]);
    multiviewTC.setHtmlDisplayName(titles[1]);
    multiviewTC.setToolTipText(getMVTCToolTipText(formDataObject));
    opened.add(this);
    registerNodeListener();
    attachTopComponentsListener();
    try {
        addStatusListener(formDataObject.getPrimaryFile().getFileSystem());
    } catch (FileStateInvalidException fsiex) {
        fsiex.printStackTrace();
    }
}
 
Example 3
Source File: IDEInitializer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Set the global default lookup with the specified content.
 *
 * @param layers xml-layer URLs to be present in the system filesystem.
 * @param instances object instances to be present in the default lookup.
 */
public static void setup (
    String[] layers, 
    Object[] instances
) {
    ClassLoader classLoader = IDEInitializer.class.getClassLoader ();
    File workDir = new File (Manager.getWorkDirPath ());
    URL[] urls = new URL [layers.length];
    int i, k = urls.length;
    for (i = 0; i < k; i++)
        urls [i] = classLoader.getResource (layers [i]);

    // 1) create repository
    XMLFileSystem systemFS = new XMLFileSystem ();
    lfs = FileUtil.createMemoryFileSystem();
    try {
        systemFS.setXmlUrls (urls);
    } catch (Exception ex) {
        ex.printStackTrace ();
    }
    MyFileSystem myFileSystem = new MyFileSystem (
        new FileSystem [] {lfs, systemFS}
    );
    Repository repository = new Repository (myFileSystem);

    Object[] lookupContent = new Object [instances.length + 1];
    lookupContent [0] = repository;
    System.arraycopy (instances, 0, lookupContent, 1, instances.length);
    
    DEFAULT_LOOKUP.setLookups (new Lookup[] {
        Lookups.fixed (lookupContent),
        Lookups.metaInfServices (classLoader),
        Lookups.singleton (classLoader),
    });
    try {
        Assert.assertEquals (myFileSystem, FileUtil.getConfigRoot().getFileSystem());
    } catch (FileStateInvalidException e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: GradleDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public Image getIcon(int type) {
    Image image = GRADLE_ICON.getImage();
    try {
        image = FileUIUtils.getImageDecorator(getPrimaryFile().getFileSystem()).annotateIcon(image, type, new HashSet<>());
    } catch (FileStateInvalidException ex) {
        ex.printStackTrace();
    }
    return image;
}