• <legend id='9UHrf'><style id='9UHrf'><dir id='9UHrf'><q id='9UHrf'></q></dir></style></legend>

      <small id='9UHrf'></small><noframes id='9UHrf'>

        <bdo id='9UHrf'></bdo><ul id='9UHrf'></ul>

      1. <i id='9UHrf'><tr id='9UHrf'><dt id='9UHrf'><q id='9UHrf'><span id='9UHrf'><b id='9UHrf'><form id='9UHrf'><ins id='9UHrf'></ins><ul id='9UHrf'></ul><sub id='9UHrf'></sub></form><legend id='9UHrf'></legend><bdo id='9UHrf'><pre id='9UHrf'><center id='9UHrf'></center></pre></bdo></b><th id='9UHrf'></th></span></q></dt></tr></i><div id='9UHrf'><tfoot id='9UHrf'></tfoot><dl id='9UHrf'><fieldset id='9UHrf'></fieldset></dl></div>
        <tfoot id='9UHrf'></tfoot>

        如何使用 IResourceChangeListener 检测文件重命名并动态设置 EditorPart 名称?

        时间:2023-08-22
        <i id='2Pft6'><tr id='2Pft6'><dt id='2Pft6'><q id='2Pft6'><span id='2Pft6'><b id='2Pft6'><form id='2Pft6'><ins id='2Pft6'></ins><ul id='2Pft6'></ul><sub id='2Pft6'></sub></form><legend id='2Pft6'></legend><bdo id='2Pft6'><pre id='2Pft6'><center id='2Pft6'></center></pre></bdo></b><th id='2Pft6'></th></span></q></dt></tr></i><div id='2Pft6'><tfoot id='2Pft6'></tfoot><dl id='2Pft6'><fieldset id='2Pft6'></fieldset></dl></div>

        <small id='2Pft6'></small><noframes id='2Pft6'>

            <tbody id='2Pft6'></tbody>
            <bdo id='2Pft6'></bdo><ul id='2Pft6'></ul>
          • <legend id='2Pft6'><style id='2Pft6'><dir id='2Pft6'><q id='2Pft6'></q></dir></style></legend>

                <tfoot id='2Pft6'></tfoot>

                  本文介绍了如何使用 IResourceChangeListener 检测文件重命名并动态设置 EditorPart 名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  IResourceChangeListener 侦听项目工作区中的更改,例如,如果编辑器部件文件名已更改.

                  IResourceChangeListener listens to changes in project workspace for example if the editor part file name has changed.

                  我想知道如何访问特定的 EditorPart 并相应地更改其标题名称(例如使用 .setPartName),或者可能刷新编辑器以使其显示新名称自动.

                  I want to know how to access that particular EditorPart and change its title name accordingly (e.g. with .setPartName), or maybe the refresh the editor so that it shows the new name automatically.

                  理想的情况是 IResourceChangeListener 具有 Rename 事件类型但似乎不是 案例.

                  Ideal would be if the IResourceChangeListener has a Rename event type but does not seem to be the case.

                  参考问题.

                  推荐答案

                  IResourceChangeListener 使用 REMOVED 类型和 MOVED_TO 标志).您可以在 IResourceDelta 中使用

                  The IResourceChangeListener does fire for rename/move events using a combination of the REMOVED kind and a MOVED_TO flag). You can test for that in the IResourceDelta with

                  @Override
                  public void resourceChanged(final IResourceChangeEvent event)
                  {
                    IResourceDelta delta = event.getDelta();
                  
                    // Look for change to our file
                  
                    delta = delta.findMember(IPath of file being edited);
                    if (delta == null)
                      return;
                  
                    if delta.getKind() == IResourceDelta.REMOVED
                     {
                       if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0)
                        {
                          IPath newPath = delta.getMovedToPath();
                  
                          ... handle new path
                        }
                     }
                  }
                  

                  处理新路径的代码可能类似于:

                  The code to handle the new path might be something like:

                  IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(newPath);
                  if (file != null)
                   {
                     setInput(new FileEditorInput(file));
                  
                     setPartName(newPath.lastSegment());
                  
                     ... anything else required 
                   }
                  

                  这篇关于如何使用 IResourceChangeListener 检测文件重命名并动态设置 EditorPart 名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Eclipse Juno WindowBuilder 调色板为空 下一篇:如何在 Eclipse 插件中添加 IResourceChangeListener?

                  相关文章

                    <i id='7WbIn'><tr id='7WbIn'><dt id='7WbIn'><q id='7WbIn'><span id='7WbIn'><b id='7WbIn'><form id='7WbIn'><ins id='7WbIn'></ins><ul id='7WbIn'></ul><sub id='7WbIn'></sub></form><legend id='7WbIn'></legend><bdo id='7WbIn'><pre id='7WbIn'><center id='7WbIn'></center></pre></bdo></b><th id='7WbIn'></th></span></q></dt></tr></i><div id='7WbIn'><tfoot id='7WbIn'></tfoot><dl id='7WbIn'><fieldset id='7WbIn'></fieldset></dl></div>
                    • <bdo id='7WbIn'></bdo><ul id='7WbIn'></ul>
                      <tfoot id='7WbIn'></tfoot>

                      <small id='7WbIn'></small><noframes id='7WbIn'>

                      <legend id='7WbIn'><style id='7WbIn'><dir id='7WbIn'><q id='7WbIn'></q></dir></style></legend>