开发者

Eclipse RCP get elements by ID

I don't know RCP very well yet, but I've been r开发者_运维问答eading a lot of the docs. I don't know if my question makes sense; I apologize if not and beg that you try to work out what I mean and come up with some kind of answer.

I have a tree view element, which has a double click listener on it. In another part of the window there is a layout folder which contains views that are supposed to be inspectors for the items double-clicked on.

The only way I know to make another inspector appear is:

getActivePage().showView(Inspector.ID). 

showView() doesn't give any opportunity to pass extra information to the view, so can it know which element to inspect?

Pointers in different directions appreciated. The Vogel tutorial doesn't seem to cover this, or I don't understand it.


You could check if the article "Link to Editor" can help you here.
That is, instead of trying to access the right view, define a Listener for the Editors:

private IPartListener2 partListener2 = new IPartListener2() {
  public void partActivated(IWorkbenchPartReference ref) {
    if (ref.getPart(true) instanceof IEditorPart)
      editorActivated(getViewSite().getPage().getActiveEditor());
}

That way, you can get back the right Editor, and ask that Editor all you need for your View to update accordingly.


You can use the SelectionService. The Inspector view should register as a SelectionListener. And the other view with the tree should register a SelectionProvider. This view should listen for the double click in the tree and then update the selection

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜