Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Plug-in Developer Guide
Previous Page Home Next Page

Resource modification hooks

So far, we've assumed that resource API is being used to modify resources that are located in the user's file system.  This is indeed the fundamental structure of the workspace, but it's also possible that a plug-in adds capabilities for manipulation of resources that are managed somewhere else.  For example, the platform Team support plug-ins add the ability to work with resources that are under the management of a versioning repository.

The resource API includes capabilities that have been added specifically to enable the team support plug-ins and plug-ins that implement repository providers using the team support.  The following discussion covers the generic mechanism for registering resource hooks.  See Implementing a repository provider for a discussion of how team uses these hooks.  

Resource move/delete hooks

This hook allows the team plug-in and its providers to control how resource moves and deletes are implemented.  The hook includes the ability to prevent these operations from happening.  Implementors can provide alternate implementations for moving or deleting files, folders, and projects. 

The team plug-in uses the org.eclipse.core.resources.moveDeleteHook extension point to register its hook:

<extension point="org.eclipse.core.resources.moveDeleteHook" id="MoveDeleteHook">
	<moveDeleteHook class="org.eclipse.team.internal.core.MoveDeleteManager"/>
</extension>

The supplied class must implement IMoveDeleteHook, which is called by the platform whenever a resource is moved or deleted.  The team plug-in installs a move delete hook manager that can determine which team provider is managing a resource and invoke its specific hook.

File modification validators

It's also possible that team repository providers will need to prevent or intervene in the editing or saving of a file. The team plug-in accomplishes this by using the extension point org.eclipse.core.resources.fileModificationValidator to register a validator that is called whenever a resource is to be modified.

<extension point="org.eclipse.core.resources.fileModificationValidator" id="FileValidator">
	<fileModificationValidator class="org.eclipse.team.internal.core.FileModificationValidatorManager"/>
</extension>

The supplied class must implement FileModificationValidator, which is called by the platform whenever a resource is saved or opened. The team plug-in installs a file modification manager that can determine which team provider is managing a resource and invoke its specific validator.

General team hook

Repository providers sometimes need to hook into additional workspace operations in order to impose extra restrictions or customize workspace behavior. The org.eclipse.core.resources.teamHook extension point provides some other special functions for team providers. In particular, this hook allows a team provider to decide whether linked folders and files should be allowed for a given project. Some repository systems have strict rules about the physical layout of projects on disk, and are not able to handle resources linked to arbitrary locations.

The team hook also allows a repository provider to supply a scheduling rule factory that will be used by all workspace operations. Each time an API method is called that modifies the workspace in some way, a scheduling rule is obtained by the workspace. This scheduling rule prevents other threads from modifying those resources during the invocation of the API method. If a repository provider is performing additional work inside a file modification validator or move/delete hook, the provider must also tell the workspace what additional scheduling rules it will need. See the section on resource batching for more details on how the workspace uses scheduling rules.

The supplied class for the team hook must implement TeamHook. The team plug-in installs the single team hook that can determine which team provider is managing a resource and invoke its specific hook.

Note:  All three of these team hooks are designed specifically for use by the team core plug-in.  They are not intended for general use.  Team providers should not install hooks using these extension points, but instead implement their hooks in their Repository Provider class.   See Team resource modification hooks for more information about using these hooks.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire