我在 CDT 中有一个自定义构建器,会将很多文件添加到项目目录中。我希望这些文件被从“项目资源管理器”中过滤掉,但是无法找出方法(文件掩码是 *.ooj)。
是否可以通过文件掩码添加自定义过滤器到“自定义视图”中?或者也许有其他方法隐藏“项目资源管理器”中的文件?
我在 CDT 中有一个自定义构建器,会将很多文件添加到项目目录中。我希望这些文件被从“项目资源管理器”中过滤掉,但是无法找出方法(文件掩码是 *.ooj)。
是否可以通过文件掩码添加自定义过滤器到“自定义视图”中?或者也许有其他方法隐藏“项目资源管理器”中的文件?
Modify the files plugin.xml
and plugin.properties
in plugins/org.eclipse.ui.navigator.resources_{version}.jar
(extract, modify and re-add the modified files).
For example, add a file only filter in plugin.xml
to the element /plugin/extension @point="org.eclipse.ui.navigator.navigatorContent"
:
<commonFilter id="org.eclipse.ui.navigator.resources.filters.{unique-id-a}" name="%filters.{unique-id-a}.name" description="%filters.{unique-id-a}.description" activeByDefault="true|false">
<filterExpression>
<and>
<instanceof value="org.eclipse.core.resources.IFile"/>
<test property="org.eclipse.core.resources.name" value="{file-wildcard-pattern-a}"/>
</and>
</filterExpression>
</commonFilter>
As another example, add a file and directory filter in plugin.xml
to the same element:
<commonFilter id="org.eclipse.ui.navigator.resources.filters.{unique-id-b}" name="%filters.{unique-id-b}.name" description="%filters.{unique-id-b}.description" activeByDefault="true|false">
<filterExpression>
<and>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="{file-wildcard-pattern-b}"/>
</adapt>
</and>
</filterExpression>
</commonFilter>
Provide filter names and descriptions for all added filters in plugin.properties
. Filter display order in Project Explorer view is by this filter name regardless of filter type:
filters.{unique-id-a}.name={file-wildcard-pattern-a} files
filters.{unique-id-a}.description=Hides files that match "{file-wildcard-pattern-a}"
filters.{unique-id-b}.name={file-wildcard-pattern-b} files and folders
filters.{unique-id-b}.description=Hides files and folders that match "{file-wildcard-pattern-b}"
Restart Eclipse and reset its caches: eclipse.exe -clean
*.orig
文件(从 hg/git 合并)的东西:这个有效: <commonFilter id="org.eclipse.ui.navigator.resources.filters.origFiles" name="%filters.origFiles.name" description="%filters.origFiles.description" activeByDefault="false"> <filterExpression> <adapt type="org.eclipse.core.resources.IFile"> <test property="org.eclipse.core.resources.name" value="*.orig" /> </adapt> </filterExpression> </commonFilter>
对于 plugin.xml
和... - Andreas Covidiotfilters.origFiles.name=*.orig resources filters.origFiles.description=隐藏以“.orig”结尾的资源,如版本控制系统合并(例如Mercurial/HG、GIT)生成的资源。
插件属性文件 plugins.properties
。在执行 eclipse -clean
后,所有内容在Eclipse Kepler中都是可用的 :) - Andreas Covidiot首先感谢 @emmzett 只是想以详细的方式解释 emmzett 答案中的内容,因为我不知道如何编辑插件文件而且我在这上面花费了2个小时。也许我可以通过这个明确的表达来节省你的时间。
plugin.xml
open with an editor(notepad,Notepad++ etc) the
plugin.xml
filepoint="org.eclipse.ui.navigator.navigatorContent"
and paste code below<commonFilter id="org.eclipse.ui.navigator.resources.filters.<i>SpecifyAnIdForYourFileType</i>"
name="%filters.<i>SpecifyAnIdForYourFileType</i>.name"
description="%filters.<i>SpecifyAnIdForYourFileType</i>.description"
activeByDefault="true">
<filterExpression>
<and>
<instanceof value="org.eclipse.core.resources.IFile"/>
<test property="org.eclipse.core.resources.name" value="<i>your specific file</i>"/>
</and>
</filterExpression>
</commonFilter>
SpecifyAnIdForYourFileType
with a unique name for id
Change "your specific file"
with your specific file suffix like *.pdf
or desktop.ini
etc.plugin.xml
and exitplugin.properties
open with an editor same as 3.step
Paste this code filters.<i>SpecifyAnIdForYourFileType</i>.name=<i>your specific file</i> files
filters.<i>SpecifyAnIdForYourFileType</i>.description=Hides files that match <i>your specific file</i>
plugin.properties
and exitProject Explorer
at
the left sideView Menu
icon at the top right cornerFilters and Customization...
Filters
menu.我想再次感谢emmzett。这就是我想表达的全部内容。
祝好。