Eclipse:重构重命名 GWT uibinder java bean 不会重命名模板 ui.xml 文件
使用 Eclipse Google 插件时,当您创建 gwt uibinder 对时,您将获得一个 java bean 文件及其相应的 .ui.xml 模板文件。
我相信我曾经能够在 Eclipse Helios 中做到这一点: 右键单击 uibinder 集的 java bean,重构以重命名它,我可以配置重构对话框以也重命名 .ui.xml 模板文件。
最近,我一直在使用Eclipse 3.7.0和最新的GPE。我不能再这样做了。可能是我忘记了怎么做。请有人提醒我如何 - 谢谢。
例如,将 uibinder 对重命名
Hello.java, Hello.ui.xml
为
Bello.java, Bello.ui.xml
Maybe,这从一开始就是不可能的,而且我记错了。
When using Eclipse Google plugin, when you create a gwt uibinder pair, you get a java bean file and its corresponding .ui.xml template file.
I believe I used to be able to do this in Eclipse Helios:
Right-click on the java bean of a uibinder set, refactor to rename it, I could config the refactor dialog to also rename the .ui.xml template file.
Recently, I have been using Eclipse 3.7.0 and latest GPE. I am no longer able to do that. May be I forgot how to do it. Somebody please remind me how - thanks.
e.g. rename the uibinder pair
Hello.java, Hello.ui.xml
to
Bello.java, Bello.ui.xml
Perhaps, it had never been possible in the first place and I had remembered wrongly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有注意到该功能,我只是尝试了一下,重命名 java 或 ui.xml 会给您带来错误,直到您重命名其他文件为止。请注意,file.java 代码不会映射到 file.ui.xml,因为设计可以使用 @UiTemplate 将 file.java 链接到其他内容.ui.xml。这可能是这不起作用的原因。像这样自动更改 ui.xml 文件名可能会导致大量的更改。
但有一些重构。
重构能够跟踪 @UiField 名称的更改。如果我重命名(使用 Alt-R) file.java 文件中已使用 @UiField 注释的字段,则 ui.xml 文件中的 ui:field 也会更改。
现在有一点棘手。假设我有 foo.java、foo.ui.xml 和 foo2.java,其中 foo2.java 使用 foo.ui.xml UI 模板(通过 @UiTemplate 注释)。 ui.xml 文件有一个 Button 调用栏,因此 foo.java 和 foo2.java 都有 @UiField("bar") Button bar。到目前为止还关注我吗?
在 Eclipse 中,我打开 foo.java,并使用 Alt-R 将 bar 更改为 baz。 ui.xml 文件的 ui:field="bar" 更改为 ui:field="baz",并且 foo.java 中引用 bar 的所有注释(例如 @UiField 和 @UiHandler)都更新为引用 baz。但是 foo2.java 中的代码没有更改,现在有一个错误需要修复。 foo2.java 仍然希望在 foo.ui.xml 中看到一个名为 bar 的按钮。
同样,如果我打开 foo2.java,并使用 Alt-R 将 bar 更改为 baz,则 foo.ui.xml 中的 ui:field="bar" 不会发生更改,并且您现在拥有一个错误。
不确定是否有任何记录在某处。也许你依稀记得这次重构。
I've not noticed that capability, and I just tried it out, and renaming either the java or the ui.xml leaves you with an error until you rename the other file. Note that it isn't a given that the file.java code is mapped to file.ui.xml, since the design could use @UiTemplate to link file.java to somethingelse.ui.xml. That might be the reason for this not to work. Changing a ui.xml file name automatically like that could cause a big cascade of changes.
But there is some refactoring.
What the refactoring is capable of doing it tracking changes to @UiField names. If I rename (using Alt-R) a field in my file.java file that has been annotated with @UiField, the ui:field in the ui.xml file is changed as well.
Now here's a tricky bit. Let's say I have foo.java, foo.ui.xml, and foo2.java, with foo2.java using the foo.ui.xml UI template (via the @UiTemplate annotation). The ui.xml file has a Button call bar, so each of foo.java and foo2.java have @UiField("bar") Button bar. Follow me so far?
In Eclipse, I open foo.java, and using Alt-R I change bar to baz. The ui.xml file has its ui:field="bar" changed to ui:field="baz", and all annotations within foo.java that reference bar (such as @UiField and @UiHandler) are updated to reference baz. But the code in foo2.java is not changed, and there is now an error I need to fix. foo2.java still expects to see a button called bar inside of foo.ui.xml.
Similarly, if I open foo2.java, and using Alt-R I change bar to baz, the ui:field="bar" in foo.ui.xml is not changed, and you now have an error.
Not sure if any of this is documented somewhere. Maybe you vaguely remembered this refactoring.