How to Refresh Eclipse View Plugin(如何刷新 Eclipse 视图插件)
问题描述
我根据 Eclipse 插件视图教程创建了一个简单的视图.我添加了允许我的插件监听调试器更改的功能.我的问题是,每次调试器发生某些事情时,我都希望我的视图能够刷新并使用新信息进行更新.这是我所拥有的/我正在尝试的:
I created a simple view based off of the eclipse plugin view tutorial. I added functionality that allows my plugin to listen to changes on the debugger. My problem is, every time something on the debugger happens, I want my view to be refreshed and be updated with new information. Here is what I have/what I'm trying:
public void createPartControl(Composite parent) {
listener = new DebugContextListener(this);
DebugUITools.getDebugContextManager().addDebugContextListener(listener);
// Check if there is an already started debug context
IAdaptable dc = DebugUITools.getDebugContext();
if (dc != null) {
dataCollection.add(new ProxyScope("hi")); // manually injecting data
Object o = dc.getAdapter(IStackFrame.class);
if (o instanceof IStackFrame)
setStackFrame((IStackFrame) o);
viewer.refresh(); // this doesn't work
}
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
// Set column lines visible, and create two columns
Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
column1.setText("Name");
column1.setWidth(400);
TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
column2.setText("Value");
column2.setWidth(200);
drillDownAdapter = new DrillDownAdapter(viewer);
viewer.setContentProvider(new VariableViewContentProvider());
viewer.setLabelProvider(new VariableViewLabelProvider());
viewer.setSorter(new ViewerSorter());
viewer.setInput(getViewSite());
....
}
所以基本上,我在顶部有所有这些调试监听逻辑,这发生在 if 语句中.我知道我的程序进入了那里.每次发生某些变化时,我都想刷新我的视图,并且我尝试过 viewer.refresh,但它不起作用.我的视图显示的信息基于 dataCollection 对象,因此与 dataCollection.add... 的那一行是我只是手动添加数据,就好像调试器做了什么一样.如果我将该行放在 if 语句之外,那么我的视图可以工作(我猜这只是我第一次启动插件时视图的原始构造),但是当我将它放在 if 语句中时它不起作用,这意味着我的视图永远不会刷新.
So basically, I have all this debug listening logic at the top, which happens inside that if statement. I know for a fact that my program gets in there. Everytime somethign changes I want to refresh my view, and I've tried doing viewer.refresh, which doesnt work. The information my view displays is based off of the dataCollection object, so that line with the dataCollection.add... is me just adding data manually as if the debugger did something. If I put that line outside the if statement, then my view works (I'm guessing this is just the original construction of the view when I first start the plugin), but when I put it inside the if statement it doesn't work, meaning my view never refreshes.
感谢您的帮助.
推荐答案
createPartControls
是视图生命周期的时间,它包含的小部件被创建(当视图最初变得可见时).此代码仅在视图生命周期中执行一次,因此您不能直接在此处添加任何内容来刷新视图.
createPartControls
is that time of the life cycle of a view, where its contained widgets are created (when the view becomes visible initially). This code is only executed once during the view life cycle, therefore you cannot add anything here directly to refresh your view.
Eclipse 部件通常会更新其内容作为对工作台内更改选择的反应(例如,用户可能会单击调试视图中的另一个堆栈框架).我不确定这是否已经完全满足您的需求,但这肯定是一个好的开始,并且在 Eclipse 常见问题解答.
Eclipse parts typically update their content as a reaction to a changed selection inside of the workbench (e.g. the user might click on another stack frame in the debug view). I'm not sure if that already completely fulfills your needs, but it's a good start for sure and described well in the Eclipse FAQ.
这篇关于如何刷新 Eclipse 视图插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何刷新 Eclipse 视图插件
基础教程推荐
- Java:带有char数组的println给出乱码 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01