Chinaunix首页 | 论坛 | 博客
  • 博客访问: 508093
  • 博文数量: 95
  • 博客积分: 5168
  • 博客等级: 大校
  • 技术积分: 1271
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-28 23:31
文章分类

全部博文(95)

文章存档

2013年(2)

2012年(3)

2011年(1)

2010年(8)

2009年(81)

分类:

2009-10-11 18:24:59

-----------------------------------------------------------
本文系本站原创,欢迎转载!

转载请注明出处:http://sjj0412.cublog.cn/

--------------------------------------------------

1.首先是workbench:

      一个workbench可以管理多个window,在eclipseWorkbenchWindow,通过windowmanger管理,windowanager功能很简单,如下。

 

2.workbenchwindow:

 

 

 

  上面的window就相当于我们swtcontrol(创建shell).

Window通过createContent创建类似的control.

ApplicationWindow多了菜单,coolbar等东西的管理。

Create(是否有shell即父控件,如没有则创建shell)->CreateContent(这个会调用windowadvisorcreateWindowContents)->

WWinActionBars就是actionbars

 

 

Class WorkbenchWindow

 

public WWinActionBars getActionBars() {

       if (actionBars == null) {

           actionBars = new WWinActionBars(this);

       }

       return actionBars;

    }

 

 

Class WWinActionBars

 

public class WWinActionBars implements IActionBars2 {

    private WorkbenchWindow window;

 

    /**

     * PerspActionBars constructor comment.

     */

    public WWinActionBars(WorkbenchWindow window) {

        super();

        this.window = window;

    }

 

 

    public ICoolBarManager getCoolBarManager() {

        return window.getCoolBarManager2();

    }

  

    public IMenuManager getMenuManager() {

        return window.getMenuManager();

    }

 

    public void updateActionBars() {

        window.updateActionBars();

    }

}

可见windowactionBar是顶级actionbars,可以获menumanger,coolbarmanager.

1action对应一个actioncontributionItem.

Menumanger对应menu,一个action对应一个contributionItem.

1item对应一个button,是在itemfill里创建的,而这个button的单击处理函数会调用action对应的runwithevent->run函数。

Submenemanager.addmenemanger.add差别是:

Submenumanger生成的SubContributionItem

public void add(IContributionItem item) {

        item.setParent(this);

        SubContributionItem wrap = wrap(item);

        wrap.setVisible(visible);

        parentMgr.add(wrap);

        itemAdded(item, wrap);

}

subcontributeitemfill有个特点就是要判断是否为visible

public void fill(Composite parent) {

        if (visible) {

           innerItem.fill(parent);

// innerItem就是IContributionItem

       }

}

也就是说submenumanger本身不包括一个menu.只是一个中间桥梁,并用于管理器其下面的所有特性,故其能够实现全部显示功能。

菜单是通过调用递归调用fill来实现显示的。

 

2.下面说下perspectivepage的区别:

What is the difference between a perspective and a workbench page?

The workbench page is the main body of a workbench window: between the toolbar and the status line, the area that contains views and editors. In Eclipse 1.0, each workbench window could have multiple pages, but this has not been the case since Eclipse 2.0. The workbench page can have one or more perspectives associated with it that define the layout of the views and editors in the page. Each workbench page has at most one instance of each kind of view and one editor per unique editor input. When the perspective is changed, the position and visibility of views and editors change, but the set of open views and editors does not change.

从上面这段文字我们可以看出,page大于perspectiveperspective只是布局,而page还包含editor,view等。

( w,  input) 
          Constructs a page.

( w,  layoutID,  input) 
          Constructs a new page with a given perspective and input.

 

/**

     * Changes the visible views, their layout, and the visible action sets

     * within the page to match the given perspective descriptor. This is a

     * rearrangement of components and not a replacement. The contents of the

     * old perspective descriptor are unaffected.

     *

     * When a perspective change occurs the old perspective is deactivated

     * (hidden) and cached for future reference. Then the new perspective is

     * activated (shown). The views within the page are shared by all existing

     * perspectives to make it easy for the user to switch between one

     * perspective and another quickly without loss of context.

     *

     *

     * During activation the action sets are modified. If an action set is

     * specified in the new perspective which is not visible in the old one it

     * will be created. If an old action set is not specified in the new

     * perspective it will be disposed.

     *

     *

     * The visible views and their layout within the page also change. If a view

     * is specified in the new perspective which is not visible in the old one a

     * new instance of the view will be created. If an old view is not specified

     * in the new perspective it will be hidden. This view may reappear if the

     * user selects it from the View menu or if they switch to a perspective

     * (which may be the old one) where the view is visible.

     *

     *

     * The open editors are not modified by this method.

     *

     *

     * @param perspective

     *            the perspective descriptor

     */

    public void setPerspective(IPerspectiveDescriptor perspective);

从上面可以看出大小关系:

 Workbench>workbenchwindow>page>perspective,viewpart,editorpart

3.各种site的作用:

        如果说workbench,workbenchwindow这些都是和显示有关,那么site相关的类就是管理和相互联系的集合。

    

 

4.各种part,其实part可以是显示和事件传递的集合,他是比page更小的单元,主要就是viewparteditorpart,这些构成了elipse显示的基础,而上面的partsite就是管理和相互联系的集合,比如可以由editorpart得到site然后由site得到更多其他内容,如getWorkbenchWindow,activepagegetActionBars,getshell,getPluginId,所以如果我们想要在part中获得上层的东西,可以先获得其partsite

  一般一个part有自己独立的actionbars,这个actionbar其实是subActionBars,其获得menumangeToolBarManager也是submenumange,subToolBarManager.

     viewPartEditorPart有什么区别呢,其实也没有什么区别,都是显示东西的,不过EditorPart还有管理文档,如打开文档,保存文档相关的操作,EditorPart可以说比view要多一些功能吧,他们显示的功能都是通过createPartControl函数添加控件来实现的

阅读(1475) | 评论(0) | 转发(0) |
0

上一篇:点滴积累

下一篇:eclipse RetargetAction机制

给主人留下些什么吧!~~