I am developing an eclipse plugin where you can mark an IFolder with some meta data and this meta data is used to validate the content of that fodler. This meta data is stored in a model somewhere, and you can change the type of the folder with a Command that is set on popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu.
An example of the Project Explorere:
+ MyProject
+ FolderType1 (should have a type1 icon)
- file1.json
- file2.json
+ FolderType2 (should have a type2 icon)
- file1.json
- file2.json
There needs to be an special icon for the folder to inform the user that this folder uses a special validation step. How can I change the folder icon in my AbstractHandler.execute method?
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Get workbench window
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
// Set selection service
ISelectionService service = window.getSelectionService();
// Set structured selection
IStructuredSelection structured = (IStructuredSelection) service.getSelection();
Object first = structured.getFirstElement();
if (first instanceof IFolder) {
IFolder folder = (IFolder) first;
// Change icon ...
}
return null;
}
Addionaly I want to know what the best place is to store this meta data persistently (.settings file?) and what api to use?
To pre-empt the suggestion that I should create a custom project instead of one project with multiple folders, I played with the idea but that does not fit the way my plugin is going to be used.
I've never used them, but I think you are looking for the Decorators feature. From the Platform Plugin Developers Guide:
Quote:
Your plug-in can use decorators to annotate the images for resources and other objects that appear in the workbench views. Decorators are useful when your plug-in adds functionality for existing resource types. Many of the standard workbench views participate in showing decorations.
For example, PDE contributes decorators that allow you to distinguish between binary and source projects.
Decorators are discussed in the Advanced Workbench concepts section of the guide.