ZIETrans Toolkit のカスタム・コンポーネントおよびウィジェットの設定に対するサポート

カスタム・コンポーネントおよびカスタム・ウィジェットの設定の変更に GUI サポートを提供できます。この GUI は、作成したカスタム・コンポーネントまたはカスタム・ウィジェットを他の開発者が使用する場合か、または ZIETrans Toolkit で使用可能なプレビュー機能を使用して、設定の異なる組み合わせのテストを簡単に行う場合に役立ちます。基本コンポーネントおよびウィジェット・クラスにより、ICustomPropertySupplier インターフェースがインプリメントされます。このインターフェースを使用すれば、コンポーネントまたはウィジェットによる ZIETrans Toolkit への設定情報の提供ができます。この情報は、コンポーネントまたはウィジェットの設定を変更できるパネルのレンダリングに使用されます。すべての設定をこの GUI で公開する必要はありません。

getCustomProperties() メソッドは、HCustomProperty でカスタマイズ可能なプロパティー・オブジェクトのベクトルを戻します。各 HCustomProperty オブジェクトは、コンポーネントまたはウィジェットの設定を表します。ZIETrans Toolkit は、各 HCustomProperty オブジェクトをそのタイプに基づいてレンダリングします。例えば、HCustomProperty.TYPE_BOOLEAN タイプのオブジェクトは、GUI のチェック・ボックスとしてレンダリングされます。

以下のサンプル・コードは、ウィジェットがその 3 つの設定 (mySetting1、mySetting2、および mySetting3) に対してどのように GUI サポートを提供できるかを示しています。

// Returns the number of settings panels (property pages) to be contributed 
//by this widget.  The returned value must be greater than or equal to 1 if 
//custom properties will be supplied via the getCustomProperties() method.  
public int getPropertyPageCount() {
         return 1;     
}

// Returns a Vector (list) of custom properties to be displayed in the GUI 
//panel for this component or widget.     
public Vector getCustomProperties(int iPageNumber, Properties properties, 
         ResourceBundle bundle) {
         Vector props = new Vector();          

// Constructs a boolean property that will be rendered as a checkbox         
HCustomProperty prop1 = HCustomProperty.new_Boolean("mySetting1", 
                "Enable some boolean setting", false, null, null);         
props.add(prop1); 

// Constructs a string property that will be rendered as a text field         
HCustomProperty prop2 = HCustomProperty.new_String("mySetting2", 
                "Some string value setting", false, null,
                 null, null, null);         
props.add(prop2);          

// Constructs an enumeration property that will be rendered as a drop-down         
HCustomProperty prop3 = HCustomProperty.new_Enumeration("mySetting3", 
                 "Some enumerated value setting", false,
                 new String[] { "A", "B", "C" }, new String[] 
                 { "Option A", "Option B", "Option C" }, null, null, null);
props.add(prop3);          

return props;     }
ウィジェット GUI

カスタム・コンポーネントまたはウィジェットのユーザーによって指定された値が、コンポーネントの recognize() メソッドに渡された componentSettingsプロパティー・オブジェクト、またはウィジェットのコンストラクターに渡された widgetSettings プロパティー・オブジェクト内で使用可能になります。getCustomProperties() メソッドは、設定用のデフォルト値を収集するために実行時に呼び出される可能性があります。

このメソッドの引数および使用法については、「ZIETrans API リファレンス (Javadoc)」で HCustomProperty クラスの説明を参照してください。API 資料の使用 (Javadoc)を参照してください。