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種類のファイルにはそれぞれ明確な役割がありますが、いずれも必須ではありません。
テンプレートファイル
テンプレートファイルを使って、以下のことが定義できます:
- 表のデータソースとして使用されるエンティティセレクションを返すフォーミュラ
- ブレーク行のフォーミュラ (ブレーク行を挿入できる場合)
- 表の列として使用できるデータクラス属性
- ブレーク行、キャリーオーバー行、追加の行において、コンテキストメニューから選択可能なフォーミュラ
現在の実装 (4D v20 R2) では、ブレーク行、データソース、コンテキストメニューに使用されるフォーミュラは、ホストデータベースのメソッドの呼び出しをサポートしていません。 この制限は次のバージョンで外される予定です。
The template file must be stored in a "Resources
/4DWP_Wizard/Templates" folder within your project.
JSON形式のテンプレートファイルには、以下の属性が含まれます:
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
tableDataSource | Text | ○ | 表のデータソースのフォーミュラ |
columns | Collection | ○ | 表の列のコレクション |
columns.check | Text | ○ | 表ウィザードであらかじめチェックされている場合は true。 列のチェックをあらかじめ外しておく場合は false。 |
columns.header | Text | ○ | ユーザーに提示する表示名 |
columns.source | Text | ○ | Formula |
breaks | Collection | ブレークオブジェクトのコレクション。 ブレークの順番は重要です。 この順番は、ドキュメント内でブレーク行が繰り返し行の上にある場合の順番に対応します。 | |
breaks.label | Text | ○ | ユーザーに提示する表示名 |
breaks.source | Text | ○ | Formula |
breakFormulas | Collection | ブレーク行に適用可能なフォーミュラオブジェクトのコレクション | |
breakFormulas.label | Text | ○ | ユーザーに提示する表示名 |
breakFormulas.source | Text | ○ | Formula |
bcorFormulas | Collection | 下部キャリーオーバー行に適用可能なフォーミュラオブジェクトのコレクション | |
bcorFormulas.label | Text | ○ | ユーザーに提示する表示名 |
bcorFormulas.source | Text | ○ | Formula |
extraFormulas | Collection | 追加の行に適用可能なフォーミュラオブジェクトのコレクション | |
extraFormulas.label | Text | ○ | ユーザーに提示する表示名 |
extraFormulas.source | Text | ○ | Formula |
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形式のトランスレーションファイルには、以下の属性が含まれます:
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
tables | Collection | 翻訳されたテーブルオブジェクトのコレクション | |
fields | Collection | 翻訳されたフィールドオブジェクトのコレクション | |
formulas | Collection | 翻訳されたフォーミュラオブジェクトのコレクション | |
fileNames | Collection | 翻訳された fileNameオブジェクトのコレクション (テーマとテンプレート名に適用) |
これら属性に含まれるコレクションの各オブジェクト要素は以下の属性を含みます:
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
original | Text | ○ | 翻訳の対象となる原文 |
translation | Text | ○ | 原文を翻訳したもの |
これらの属性を定義することで、原文と翻訳されたコンテンツ間の適切な対応が確保されます。
テンプレート名やフォーミュラ名 (ブレーク行、キャリーオーバー行、追加の行) がトランスレーションファイルに存在する場合、表ウィザードではその翻訳が表示されます。 また、トランスレーションファイル内で定義されたテーブルだけが表ウィザードに (翻訳されて) 表示されます。
ユーザーがインターフェースでテーブルを選択したときには、トランスレーションファイルは追加の役割を果たします。 具体的には、ユーザーに提案されるテーブルやフィールドをフィルターします。 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形式のテーマファイルには、以下の属性が含まれます:
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
default | Object | すべての行に適用されるデフォルトスタイルを格納したオブジェクト。 | |
table | Object | 表組みに適用されるスタイル定義を格納したオブジェクト。 | |
rows | Object | すべての行に適用されるスタイル定義を格納したオブジェクト。 | |
cells | Object | すべてのセルに適用されるスタイル定義を格納したオブジェクト。 | |
header1 | Object | 先頭のヘッダー行に適用されるスタイル定義を格納したオブジェクト。 | |
header2 | Object | 2つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。 | |
header3 | Object | 3つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。 | |
header4 | Object | 4つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。 | |
header5 | Object | 5つ目のヘッダー行に適用されるスタイル定義を格納したオブジェクト。 | |
headers | Object | Object containing the style definition applicable to the header rows, if a specific header (like header1, header2...) is not defined. | |
data | Object | 繰り返し行に適用されるスタイル定義を格納したオブジェクト。 | |
break1 | Object | 1つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。 | |
break2 | Object | 2つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。 | |
break3 | Object | 3つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。 | |
break4 | Object | 4つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。 | |
break5 | Object | 5つ目のブレーク行に適用されるスタイル定義を格納したオブジェクト。 | |
breaks | Object | Object containing the style definition applicable to the break rows, if a specific break (like break1, break2...) is not defined. | |
bcor | Object | 下部キャリーオーバー行に適用されるスタイル定義を格納したオブジェクト。 |
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定数 |
---|---|
textAlign | wk text align |
backgroundColor | wk background color |
borderColor | wk border color |
borderStyle | wk border style |
borderWidth | wk border width |
font | wk font |
color | wk font color |
fontFamily | wk font family |
fontSize | wk font size |
padding | wk 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"
}
}