我有一个用于 TreeView 的 ContentProvider。我在那里添加了一些可以对树的项目执行的操作。该方法如下所示:
private void makeActions() {
action1 = new Action() {
@Override
public void runWithEvent(Event event) {
System.out.println(event);
System.out.println(event.data.getClass());
//How can I find the caller of runWithEvent?
}
};
如何找到导致调用 Action#runWithEvent 的树对象?
最佳答案
考虑使用新的命令 API 而不是旧的操作 API。在新的 API 中,您可以轻松访问命令处理程序中的相关信息。
关于java - JFace:如何获取 Action#run() 的调用者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8562347/