20111225 补 multipage editor与 properties view无法同步

前两天csdn不稳定,所以一直没有更新。

我这里面是解决eclipse3.6.2遇到的问题,所以如果你是使用的3.7的话就不用看了。

我们的结构与之前相同在一个multipage里面嵌入gef和xml。

在我们的程序开发中遇到了一个问题:王哥用的是eclipse3.6.2 而我用的是3.7。而我们的需求中需要在properties view中显示属性,同样的写法我的能同步他的却不行但是规定的版本是3.6.2没办法哎。只能换ide找问题。


因为要想实现editor和view通信的话就必须要在editor中重写
@Override

public Object getAdapter(Class type) {
}


而IPropertySheetPage的通信已经被写入父类里面了但是我仔细看了一下3.6和3.7竟然不一样:

3.6:

public Object getAdapter(Class type) {
if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) {
return new UndoablePropertySheetPage(getCommandStack(),
getActionRegistry().getAction(ActionFactory.UNDO.getId()),
getActionRegistry().getAction(ActionFactory.REDO.getId()));
}
if (type == GraphicalViewer.class)
return getGraphicalViewer();
if (type == CommandStack.class)
return getCommandStack();
if (type == ActionRegistry.class)
return getActionRegistry();
if (type == EditPart.class && getGraphicalViewer() != null)
return getGraphicalViewer().getRootEditPart();
if (type == IFigure.class && getGraphicalViewer() != null)
return ((GraphicalEditPart) getGraphicalViewer().getRootEditPart())
.getFigure();
return super.getAdapter(type);
}

3.7:

public Object getAdapter(Class type) {
if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) {
PropertySheetPage page = new PropertySheetPage();
page.setRootEntry(new UndoablePropertySheetEntry(getCommandStack()));
return page;
}
if (type == GraphicalViewer.class)
return getGraphicalViewer();
if (type == CommandStack.class)
return getCommandStack();
if (type == ActionRegistry.class)
return getActionRegistry();
if (type == EditPart.class && getGraphicalViewer() != null)
return getGraphicalViewer().getRootEditPart();
if (type == IFigure.class && getGraphicalViewer() != null)
return ((GraphicalEditPart) getGraphicalViewer().getRootEditPart())
.getFigure();
return super.getAdapter(type);
}

既然3.7科技解决问题那么我们就用3.7的吧

@Override

public Object getAdapter(Class type) {
if (type == IContentOutlinePage.class) {
return new MyContentOutlinePage();
} else if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) {
page = new PropertySheetPage();
page.setRootEntry(new UndoablePropertySheetEntry(getCommandStack()));
return page;
}
return super.getAdapter(type);
}

但是运行了之后并不能解决问题。和没改一样。所以估计应该是没有监听到的问题。而对于监听这个问题我们以前就遇到过所以我们可以用我们自己的方法来实现:

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
super.selectionChanged(part, selection);
updateActions(getSelectionActions());
if (page != null)
page.selectionChanged(part, selection);
}

如果你看了之前的日志的话那么对这个就会很熟悉。具体的内容一看就知道。最后实现了:


@Override
@Override
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值