メインコンテンツまでスキップ
バージョン: 20 R5 BETA

4D WritePro インターフェース

4D WritePro インターフェースは、エンドユーザーが 4D Write Proドキュメントを簡単にカスタマイズできるパレットを提供します。

4D のデベロッパーは、これらのパレットをアプリケーションに簡単に実装することができます。 それにより、エンドユーザーは、フォントやテキストの揃え方向、ブックマーク、表レイアウト、フレームなど、4D Write Pro のプロパティをすべて管理することができます。

The main 4D Write Pro Interface documentation can be found in the 4D Design Reference manual.

表ウィザードの設定に関するドキュメントは以下のとおりです。

表ウィザード

表ウィザードは、コンテキスト、データソース、およびフォーミュラを使用した、データベースのデータに基づく表組みの作成をさらに簡素化します。

エンドユーザーがアクセスできる表ウィザードは、4D デベロッパーが設定し提供するテンプレートをロードします。 これにより、デベロッパーはユーザーの特定のユースケースやビジネス要件に応じてテンプレートをカスタマイズすることができます。

表ウィザードには、デフォルトのテンプレートおよびテーマが用意されており、デベロッパーはそれらを、アプリケーションで必要とされる内容に適合させることができます。

アプリケーションに表ウィザードを実装するために、デベロッパーはテンプレートファイルを作成し、設定することができます。

WP表ウィザードのインターフェース

ユーザーは、4D Write Pro インタフェースツールバーとサイドバーの "表を挿入" メニューボタンから表ウィザードダイアログを開きます。

このインターフェースで、ユーザーは最初のドロップダウンリストからテンプレートまたはテーブルを選択し、2番目のドロップダウンリストからテーマを選択します。

列について:

テンプレートまたはテーブルの選択に応じて、テンプレートに保存されているフィールドのリストが表示されます (BLOB およびオブジェクト型は自動的に除外されます)。 表の列として表示させたいフィールドは、フィールド名の左にあるチェックボックスで選択します。また、表示する列の順序はフィールドをドラッグしてリスト内を移動させることで変更することができます。

行について:

In the Table Wizard, the user can also define the number of header rows and extra rows (0 to 5 each), set break rows (summary rows) above or below the data row, and choose to show/hide carry-over rows.

表示について:

ユーザーは、ドロップダウンリストから希望するオプションを選択することで、好みのズームレベルを調整し、ラジオボタンを使ってフォーミュラまたはデータを表示し、チェックボックスを使って水平ルーラーを表示するかどうかを選択します。

After finalizing the table creation and customization, the user can click on the Insert button to add the table to their WP document.

ドキュメントに表が統合されると、ユーザーはそのスタイルをカスタマイズできます。 ツールバーやサイドバーの書式設定ツールはすべて利用可能です。

WP表ウィザードのテンプレートの設定

テンプレートの設定には以下が含まれます:

  • Defining tables and fields as well as preparing formulas adapted to the application from the template file.
  • Translating table, field, and formula names from the translation file.
  • Designing graphic styles and customized themes from the theme file.

表ウィザードを設定するにあたって、これら 3種類のファイルにはそれぞれ明確な役割がありますが、いずれも必須ではありません。

テンプレートファイル

テンプレートファイルを使って、以下のことが定義できます:

  • 表のデータソースとして使用されるエンティティセレクションを返すフォーミュラ
  • ブレーク行のフォーミュラ (ブレーク行を挿入できる場合)
  • 表の列として使用できるデータクラス属性
  • ブレーク行、キャリーオーバー行、追加の行において、コンテキストメニューから選択可能なフォーミュラ
Limitation

現在の実装 (4D v20 R2) では、ブレーク行、データソース、コンテキストメニューに使用されるフォーミュラは、ホストデータベースのメソッドの呼び出しをサポートしていません。 この制限は次のバージョンで外される予定です。

The template file must be stored in a "Resources/4DWP_Wizard/Templates" folder within your project.

JSON形式のテンプレートファイルには、以下の属性が含まれます:

属性タイプ必須説明
tableDataSourceText表のデータソースのフォーミュラ
columnsCollection表の列のコレクション
columns.checkText表ウィザードであらかじめチェックされている場合は true。 列のチェックをあらかじめ外しておく場合は false。
columns.headerTextユーザーに提示する表示名
columns.sourceTextFormula
breaksCollectionブレークオブジェクトのコレクション。 ブレークの順番は重要です。 この順番は、ドキュメント内でブレーク行が繰り返し行の上にある場合の順番に対応します。
breaks.labelTextユーザーに提示する表示名
breaks.sourceTextFormula
breakFormulasCollectionブレーク行に適用可能なフォーミュラオブジェクトのコレクション
breakFormulas.labelTextユーザーに提示する表示名
breakFormulas.sourceTextFormula
bcorFormulasCollection下部キャリーオーバー行に適用可能なフォーミュラオブジェクトのコレクション
bcorFormulas.labelTextユーザーに提示する表示名
bcorFormulas.sourceTextFormula
extraFormulasCollection追加の行に適用可能なフォーミュラオブジェクトのコレクション
extraFormulas.labelTextユーザーに提示する表示名
extraFormulas.sourceTextFormula
French language

If your application is likely to be run on a 4D with language set to French, make sure that you use tokens in your formulas so that they are correctly interpreted no matter the user's language configuration.

例題

JSONファイルの簡単な一例を以下に示します:

{
"tableDataSource": "ds.People.all().orderBy(\"toCompany.name asc, continent asc, country asc, city asc\")",
"columns": [{
"check": true,
"header": "Firstname",
"source": "This.item.firstname"
}, {
"check": true,
"header": "Lastname",
"source": "This.item.lastname"
}, {
"check": true,
"header": "Salary",
"source": "String(This.item.salary;\"###,###.00\")"
}
],
"breaks": [{
"label": "Company",
"source": "This.item.toCompany.name"
}
],
"breakFormulas": [{
"label": "Company",
"source": "This.item.toCompany.name"
}, {
"label": "Sum of salaries",
"source": "String(This.breakItems.sum(\"salary\"); \"###,###.00\")"
}
],
"bcorFormulas": [{
"label": "Sum of salaries",
"source": "String(This.tableData.sum(\"salary\"); \"###,###.00\")"
}
],
"extraFormulas": [{
"label": "Sum of salaries",
"source": "String(This.tableData.sum(\"salary\"); \"###,###.00\")"
}
]
}

トランスレーションファイル

トランスレーションファイルは、テンプレート、テーマ、テーブル、フィールド、およびフォーミュラの翻訳名を指定します。 These files are added to the "Resources/4DWP_Wizard/Translations" folder in your project.

各トランスレーションファイルには、対応する言語コード (英語なら "en"、日本語なら "ja" など) のファイル名を付けます。

JSON形式のトランスレーションファイルには、以下の属性が含まれます:

属性タイプ必須説明
tablesCollection翻訳されたテーブルオブジェクトのコレクション
fieldsCollection翻訳されたフィールドオブジェクトのコレクション
formulasCollection翻訳されたフォーミュラオブジェクトのコレクション
fileNamesCollection翻訳された fileNameオブジェクトのコレクション (テーマとテンプレート名に適用)

これら属性に含まれるコレクションの各オブジェクト要素は以下の属性を含みます:

属性タイプ必須説明
originalText翻訳の対象となる原文
translationText原文を翻訳したもの

これらの属性を定義することで、原文と翻訳されたコンテンツ間の適切な対応が確保されます。

テンプレート名やフォーミュラ名 (ブレーク行、キャリーオーバー行、追加の行) がトランスレーションファイルに存在する場合、表ウィザードではその翻訳が表示されます。 また、トランスレーションファイル内で定義されたテーブルだけが表ウィザードに (翻訳されて) 表示されます。

ユーザーがインターフェースでテーブルを選択したときには、トランスレーションファイルは追加の役割を果たします。 具体的には、ユーザーに提案されるテーブルやフィールドをフィルターします。 For example, to hide table IDs, this behavior is similar to the SET TABLE TITLES and SET FIELD TITLES commands.

例題
{
"tables": [{
"original": "People",
"translation": "Personne"
}
],
"fields": [{
"original": "lastname",
"translation": "Nom"
}, {
"original": "firstname",
"translation": "Prénom"
}, {
"original": "salary",
"translation": "Salaire"
}, {
"original": "company",
"translation": "Société"
}
],
"formulas": [{
"original": "Sum of salary",
"translation": "Somme des salaires"
}
]
}

テーマファイル

4D WritePro Interface コンポーネントには、"Arial"、"CourierNew"、"YuGothic" などのテーマがデフォルトで用意されており、"Blue" や "Green" など複数のバリエーションが用意されています。 However, you can create your own theme by placing it in the "Resources/4DWP_Wizard/Themes" folder within your project.

JSON形式のテーマファイルには、以下の属性が含まれます:

属性タイプ必須説明
defaultObjectすべての行に適用されるデフォルトスタイルを格納したオブジェクト。
tableObject表組みに適用されるスタイル定義を格納したオブジェクト。
rowsObjectすべての行に適用されるスタイル定義を格納したオブジェクト。
cellsObjectすべてのセルに適用されるスタイル定義を格納したオブジェクト。
header1Object先頭のヘッダー行に適用されるスタイル定義を格納したオブジェクト。
header2Object2つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。
header3Object3つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。
header4Object4つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。
header5Object5つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。
headersObjectObject containing the style definition applicable to the header rows, if a specific header (like header1, header2...) is not defined.
dataObject繰り返し行に適用されるスタイル定義を格納したオブジェクト。
break1Object1つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。
break2Object2つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。
break3Object3つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。
break4Object4つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。
break5Object5つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。
breaksObjectObject containing the style definition applicable to the break rows, if a specific break (like break1, break2...) is not defined.
bcorObject下部キャリーオーバー行に適用されるスタイル定義を格納したオブジェクト。

For every attribute used in your JSON file (header, data, carry-over, summary, and extra rows), you can define the following WP attributes, mentionned with their corresponding WP constant:

WP 属性対応する WP定数
textAlignwk text align
backgroundColorwk background color
borderColorwk border color
borderStylewk border style
borderWidthwk border width
fontwk font
colorwk font color
fontFamilywk font family
fontSizewk font size
paddingwk padding
例題
{
"default": {
"backgroundColor": "#F0F0F0",
"borderColor": "#101010",
"borderStyle": 1,
"borderWidth": "0.5pt",
"font": "Times New Roman",
"color": "#101010",
"fontFamily": "Times New Roman",
"fontSize": "7pt",
"padding": "2pt"
},
"table": {
"backgroundColor": "#E1EAF3"
},
"header1": {
"textAlign": 2,
"borderColor": "#41548F",
"borderWidth": "1.5pt",
"backgroundColor": "#979BA9",
"color": "#F4F4FF",
"font": "Times New Roman Bold"
},
"data": {
"fontSize": "13pt",
"textAlign": 0
},
"break1": {
"textAlign": 2,
"fontSize": "15pt"
}
}

参照

4D Write Pro - Table Wizard (tutorial video)