NetBeans basics


System Filesystem

What is it?

The System Filesystem is a tree of “files” Any file can be put in the System Filesystem Any module can make a directory in the System Filesystem and allow other modules to put files in its directory. The System Filesystem is built by merging 'all' the XML Layer files.

1. The System Filesystem is nice because it doesn't draw a distinction between actual files and “virtual” files. You can put pretty much anything into the System Filesystem, including html links, and NetBeans will treat it the same way.

2. In NetBeans, file objects and filesystem objects can fire actions when they are changed, so we can listen and find out when the System Filesystem has changed. This is part of the reason why so much stuff in NetBeans is represented as a file and is incorporated in the System Filesystem.

If you're confused about the System Filesystem

Look through it! In one of your modules, go to Important Files/XML layer/<this layer in context> and look through it for a few hours. If you're developing in NetBeans, the time is well spent. There are a lot of different folders in the System Filesystem, but as you start to open the trees you'll notice some things that make sense. As you look through it, the System Filesystem will stop seeming so mysterious.

When you explore the System Filesystem, try the following:

  1. open a directory recursively until you see the entire structure. it may make more sense at its bottom layer
  2. open files and look at them.
  3. right click on files, go to properties. some files have size 0 and under All Files there is something like :

Toolbars/Edit/org-openide-actions-CutAction.instance in C:\Documents and Settings\username\Desktop\neurospy_wc\MotionControl\Motion-API\src\motion\layer.xml this file is a shadow of the instance file which is elsewhere. (The file was /Toolbars/&Edit/Cut. Similarly, other files claim to be shadowing (linking) to /.instance/ files housed in \motion\layer.xml. This may be surprising because you probably didn't put a CutAction in any layer.xml file.

How NetBeans uses the System Filesystem

The NetBeans modules themselves use the System Filesystem to put files into its folders. These folders may seem special because they are always there.

System Filesystem folders which make sense right away

  • Menu Bar

This is the menu bar that appears at the top of NetBeans (the thing that says File, Edit, View etc). The menu bar has a tree structure, because you can open nested menus within menus. The Menu Bar folder in the system filesystem is exactly the same. If you want to change the contents of the Menu Bar, you need to write XML files which get inserted into these folders in the system filesystem

  • ProjectsTabActions

If you right click on the projects tab, you'll see that it says (New Project…, New File, Open Project etc). The ProjectsTabActions folder in the system filesystem looks exactly the same. So if you wanted to put your own functionality (aka buttons in the drop down menu that do stuff) you'd have to write an XML file that gets inserted in this folder.

  • Favorites

The Favorites folder in the System Filesystem has your actual files and directories from your computer. Go to Favorites/Cookies and you'll find your Cookies. Go to Favorites/Desktop and you'll find the files on your desktop, displayed the same way they would be in a regular filesystem browser (like “My Computer”).

  • WelcomePage

If you click on these files, you'll be taken to various websites. These are the links on the welcome page of NetBeans.

  • Toolbars

The toolbars available from View/Toolbars are the same ones found in the Toolbars folder in the System Filesystem. The Toolbars/Build directory contains (Build Main Project, Clean and Build Main Project etc). If you mouse over those, you'll notice that they are links to instances of

The System Filesystem is not static

It changes depending on what modules you have loaded in your Platform. Each module contributes its own little piece of layer.xml to the large filesystem (see XML layer) If you uninstall a module, that module's little piece is no longer part of the filesystem (similarly, when you plug a thumbdrive into your computer, it's filesystem seamlessly appears as the H: or J: directory of your computer on windows, so you don't have to think about the fact that it's actually a separate device. When you unplug the thumbdrive, that chunk of the filesystem disappears from your computer. When you talk about “plugging in” modules into the NetBeans platform, their layer.xml files are merged into the System Filesystem. If you change the system filesystem at runtime, by adding a toolbar to the display for example, your changes are recorded in the userdir, more precisely, in USERDIR/config.

What can you use the System Filesystem for?

Useful Commands

Obtain the System Filesystem

  FileSystem fs = Repository.getDefault().getDefaultFileSystem()
         


File System API

File Object API


Personal Tools