我正在尝试更新 GEF 的模型并在我创建的视图中显示更改。目前我所做的任何更改都没有反映在视图中,我正在使用以下方法来更新模型,并且想知道它是否是正确的方法:
Display.getDefault().asyncExec(new Runnable() {
public void run() {
String viewId = "beat.views.BeatView";
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow mainWindow = workbench
.getActiveWorkbenchWindow();
try {
BeatView view = (BeatView) mainWindow.getActivePage()
.showView(viewId);
BeatEditPart beatEditPart = (BeatEditPart)view.getGraphicalViewer().getContents();
BeatModel beatModel = (BeatModel)beatEditPart.getModel();
beatModel.setObjects(model);
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});