*链接的含义
---代表一个资源,但是这个资源存在的地方,是在其他地方,非当前显示位置.这和软链接的概念一致,可以说是EFS的软链接.
*相关API
---哪些元素能创建link
IFolder,IFile,org.eclipse.core.internal.resources.Resource
---验证是否为link
IResource.isLinked(int options),options=IResource.CHECK_ANCESTORS,则自己或父资源任一为link,则方法返回true.
IResource.isLinked() == isLinked(IResource.NONE)
一般以createLink方式创建的为link,其下的内容就不属于link.所以CHECK_ANCESTORS区分了这2中情况.
*Broken Link
---含义,link定义的path不存在或未定义的情况
---resource对Broken link的处理协议,
* The copy and move methods will fail when called on broken links.
* Calling refreshLocal on a broken link will not cause the resource to be removed from the workspace, as it does for normal resources that are missing from the file system.
* The method getLocation will return null for linked resources whose locations are relative to undefined path variables.
* You can still use delete to remove broken links from the workspace.
*禁用link的方式
---org.eclipse.core.resources.natures扩展点中设置"<options allowLinking="false"/>"
---org.eclipse.core.resources.teamHook,可参考TeamHook
---设置禁用属性ResourcesPlugin.PREF_DISABLE_LINKING
1.在首选项中配置,Preferences->Workspace->Linked Resources
2.Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE)
.node(ResourcesPlugin.PI_RESOURCES).putBoolean(ResourcesPlugin.PREF_DISABLE_LINKING, true);
3.ResourcesPlugin.getPlugin().getPluginPreferences().setValue(ResourcesPlugin.PREF_DISABLE_LINKING, "false");//@deprecated
*创建link
Linked Resource示例
*记录link
---对于包含link的Project,在Project的".project"文件中会记录下link的信息
"When a user creates a linked resource in a project, a description of the linked resource is added to the project description file (".project") in the project's location. "
项目对link的记录
*参考
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/resAdv_events.htm
http://www.eclipse.org/eclipse/platform-core/documents/user_settings/faq.html