2011-07-19 16 views
4

Eclipseフォームの右上隅にボタンを追加する方法はありません。Eclipse RCP - Eclipseフォームの右上隅にボタンを追加する方法

eclispe-rcp form with a button

ボタンは、フォームのタイトルのように見えるのフォーム機能やそのちょうど別の複合体の一部であり、フォームのタイトル領域の一部であるように思われますか?どのソースコードの例(ドラフトさえも)は高く評価されています。

編集:

私はセクションにボタンを追加するために管理しているが、まだフォーム自体に、私はここで見つける例を使用していない:それでも

http://svn.regilo.org/repository/regilo/trunk/org.regilo.menu/src/org/regilo/menu/editor/page/MenuPageMaster.java

private void createSectionToolbar(Section section, FormToolkit toolkit) { 
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); 
    ToolBar toolbar = toolBarManager.createControl(section); 
    final Cursor handCursor = new Cursor(Display.getCurrent(), 
      SWT.CURSOR_HAND); 
    toolbar.setCursor(handCursor); 
    // Cursor needs to be explicitly disposed 
    toolbar.addDisposeListener(new DisposeListener() { 
     public void widgetDisposed(DisposeEvent e) { 
      if ((handCursor != null) && (handCursor.isDisposed() == false)) { 
       handCursor.dispose(); 
      } 
     } 
    }); 

    // save 
    CommandContributionItemParameter saveContributionParameter = new CommandContributionItemParameter(
      editor.getSite(), null, 
      "it.wellnet.easysitebox.menu.commands.saveMenu", 
      CommandContributionItem.STYLE_PUSH); 
    saveContributionParameter.icon = RegiloCoreImages.getInstance().DESC_UPDATE; 

    CommandContributionItem saveMenu = new CommandContributionItem(
      saveContributionParameter); 

    toolBarManager.add(saveMenu); 

    toolBarManager.update(true); 

    section.setTextClient(toolbar); 
} 

をフォーム自体には運がありません。

答えて

3

次のようなtoolbarmanager得ることができます。

IManagedForm mform = formPage.getManagedForm(); 
IToolBarManager toolbar = mform.getForm().getToolBarManager(); 

今、あなたは通常通りツールバー・マネージャーAPIを使用して、ツールバーにアイテムを追加することができるはずですが。

+0

を使用して、ツールバーマネージャを取得してみてください。内部のcreatePartControl(..)メソッドとおそらくthats問題、私のフォームはScrolledForm型ですか? – Kris

+0

私はEclipse RCPでもうプレイしないので、検証する時間がありませんが、そのupvotedとして私はその真実を信じています:そして正しい答えとしてそれをマークします、thx – Kris

0

、私はそれを動作させることができない、私のEditorPartの内側に、私は、フォーム= toolkit.createScrolledForm(親)を使用して、私のフォームオブジェクトを初期化しないform.getToolBarManager()

関連する問題