File Size Decorator

Links: Klomp Eclipse Plugins Overview, Erwin Bolwidt's homepage

Implements a new label decorator that shows the size of each file in the Navigator and Package views. The decorator can be turned on and off in the preferences menu, and can be configured to use kilo-units of 1024 or 1000 bytes. The names of the units (single, kilo, mega, giga) and the format of the whole string can be configured, and also whether the size appears in front of or after the filename.

This is the first version publicly released version. It has been used and tested by me and the other folks at klomp.org. As well as a useful plugin, the source can also serve as an example on building label decorators or preference pages. Some interesting possible features that could serve as an excercise or as future extensions are:

Installation

To install this plugin, follow these steps:

  1. Make sure you have Eclipse 2.1 or higher. (Unfortunately, Eclipse 2.0, on which Websphere Studio Application Developer version 5 is based, does not support the necessary extension point yet.)
  2. Exit Eclipse.
  3. Download the ZIP file that contains the plugin.
  4. Extract the contents of the ZIP file into the plugins directory of your Eclipse installation.
  5. When the files have been extracted verify that the plugin configuration file can be found at .../eclipse/plugins/org.klomp.eclipse.fsize_1.0.2/plugin.xml.
  6. Start Eclipse.

Usage

To use the plugin, go to the preferences dialog (Window->Preferences). First turn on the decorator, from the Workbench->Label Decorations page. (Note: if you are using CVS, you can turn on the CVS label decorator as well from there. I find it quite handy.) When you press "Apply" or "OK", you immediately see the size of each file in any visible Navigator or Package views.

To change the kilo unit (1000 or 1024 bytes), the format, the names of the units or whether the information is prefixed or suffixed on the file name, go back to the preferences dialog. Go to the File Size Decorator preference page and change at will. If you have a directory browsing view visible behind the preferences dialog, you can preview your settings by pressing the Apply button.

Restrictions

Eclipse has its own abstraction of files in a workspace. Unfortunately, this abstraction doesn't include many attributes of a file. To retrieve the size of a file, the eclipse IFile object is first asked for its corresponding java.io.File, which can return the size of a file. This only works if there is a corresponding java.io.File, so it doesn't work when a file is derived or not real in some other sense. Perhaps eclipse will support a virtual file system in the future to directly work with remote files. In those cases, this decorator won't show a size. It also won't show the size of a directory.

License

This software is distributed under the terms of a BSD-style open source license. Please see the file LICENSE for details.

Download

Please select the version you wish to download:

Version Release date ZIP file (includes source code)
1.0.2 12 Jan 2003 org.klomp.eclipse.fsize_1.0.2.zip


Thanks to
Vincent Partington for the cascading style sheet that's used on this page.
Copyright (C) 2003 Erwin Bolwidt <erwin@klomp.org>, Last Updated: 14 Jan 2003.