#author("2019-08-23T05:37:10+00:00","","")
#topicpath
----
FormEditor (org.eclipse.ui.forms.editor.FormEditor)はEclipseプラグインのマニフェストエディタのような外観のエディタを作成するためのクラスです。[[Eclipse Forms>Eclipse/プラグイン開発のTIPS集/Forms]]を使って実装されています。これを使うことで

-plugin.xmlのマニフェストエディタのような外観
-複数タブ(ページ)を持つ

ようなエディタを作成することができます。

**クラス構成 [#i2b8ab07]
まずFormEditor は org.eclipse.ui.part.MultiPageEditorPart を継承しています。なので、FormEditor自体は複数のエディタ(やウィジェット)のまとまりと考えることができます。

通常のMultiPageEditorPart は
 protected void createPages();
メソッドをオーバーライドし、各エディタ(やウィジェット)を
 editor = new MyEditor();
 int index = addPage(editor, getEditorInput());
 setPageText(index, editor.getTitle());
としたり、
 Composite composite = new Composite(getContainer(), SWT.NONE);
 FillLayout layout = new FillLayout();
 composite.setLayout(layout);
 text = new StyledText(composite, SWT.H_SCROLL | SWT.V_SCROLL);
 text.setEditable(false);
 int index = addPage(composite);
 setPageText(index, "Preview");
などとしていきます。ようするにEditorやCompositeを各ページに追加していくような手順をとります。

それに対してFormEditor は、同じく
 protected void createPages();
ないで
 addPage(new HogePage());
と追加していくのですが、登録するクラスが org.eclipse.ui.forms.editor.IFormPageの実装クラスとなっています。このIFormPageがEclipse Formsを用いてエディタを作るための起点のインタフェースとなっています。





***TextEditorを追加したい [#c5e9957a]
FormEditorはMultiPageEditorPart なので、簡単にテキストエディタのページ(plugin.xmlのソースxmlを見るページ)を追加できると思ったけど、なぜかエラーが発生してできませんでした。http://www.koders.com/ でいろいろ探した結果、
 SourceEditorPageBridge extends TextEditor implements IFormPage
をつくって FormEditor#addPagesないで
 SourceEditorPageBridge sourcePage = new SourceEditorPageBridge(this);
 sourcePage.setInput(this.getEditorInput());
としました。

***まとめると [#af5238a4]
まとめるとクラス構成はだいたいこんな感じになっています
 FormEditor(の実装クラス) 1 -> N FormPage(の実装クラス)
 1 -> 1 MasterDetailsBlock(の実装クラス) 1 -> N  ItemDetailsPage(の実装クラス)

で、FormEditor -> FormPage は
 FormEditor#addPages(); と
 FormEditor#addPage(IEditorPart, IEditorInput);
 FormEditor#addPage(new ItemPage(this));
で関連づけられます。

FormPage と MasterDetailsBlock は
 FormPage#createFormContent(IManagedForm)
ないでMasterDetailsBlock#createContent(managedForm)を呼ぶことで処理が委譲されます。

さらにMasterDetailsBlock と ItemDetailsPage は
 MasterDetailsBlock#registerPages(DetailsPart)
ないで detailsPart.registerPage(Hoge.class, new HogeDetailsPage())を呼ぶことで、詳細画面が登録されます。




----
この記事は
#vote(おもしろかった[2],そうでもない[0])
- PZyVWdYeQx -- [[Broxx]] &new{2008-06-02 (月) 17:52:45};
- NVSSRSje -- [[jqhmpq]] &new{2008-06-03 (火) 13:51:22};
- NVSSRSje -- [[jqhmpq]] &new{2008-06-03 (火) 13:51:57};
- NVSSRSje -- [[jqhmpq]] &new{2008-06-03 (火) 13:52:34};
- WsElRLEXOb -- [[Josh]] &new{2008-06-05 (木) 11:37:39};
#vote(おもしろかった[16],そうでもない[0])

#comment

#topicpath


SIZE(10){現在のアクセス:&counter;}


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS