package com.interpress_project.modernshare.client.view.preference;

import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;

import com.interpress_project.modernshare.AppKeys;

public class PreferenceBasic extends FieldEditorPreferencePage {
	/**
	 * @stereotype uses
	 */
	/*#com.interpress_project.modernshare.client.view.preference.LabelFieldEditor Dependency20*/

	/**
	 * @stereotype uses
	 */
	/*#com.interpress_project.modernshare.client.view.preference.UsernameEditor Dependency201*/

	/**
	 * @stereotype uses
	 */

	/*#com.interpress_project.modernshare.client.view.preference.PasswordEditor Dependency202*/

	/**
	 * PrefrenceBasic
	 */
	protected PreferenceBasic() {
		super(GRID);

		setTitle("データセンタ設定");
		setDescription("HotShotデータセンタに関する情報を設定します。");
	}

	/**
	 * createFieldEditors
	 */
	@Override
	protected void createFieldEditors() {
		LabelFieldEditor sp0 = new LabelFieldEditor("", getFieldEditorParent());
		addField(sp0);
		LabelFieldEditor l0 = new LabelFieldEditor("データセンタへのユーザ認証情報を設定します。\n" + "不明の場合は、システム管理者にお尋ねください。",
		  getFieldEditorParent());
		addField(l0);

		StringFieldEditor sfeUsername = new UsernameEditor(AppKeys.USERNAME, "アカウント名: ", getFieldEditorParent());
		sfeUsername.setTextLimit(32);
		sfeUsername.setEmptyStringAllowed(false);
		addField(sfeUsername);

		StringFieldEditor sfePassword = new PasswordEditor(AppKeys.PASSWORD, "パスワード: ", getFieldEditorParent());
		sfePassword.setEmptyStringAllowed(false);
		sfePassword.setTextLimit(32);
		sfePassword.getTextControl(getFieldEditorParent()).setEchoChar('*');
		sfePassword.setEmptyStringAllowed(false);
		addField(sfePassword);

		LabelFieldEditor sp1 = new LabelFieldEditor("", getFieldEditorParent());
		addField(sp1);
		LabelFieldEditor l1 = new LabelFieldEditor("データセンタのホスト名/ポート番号を設定します。\n" + "不明の場合は、システム管理者にお尋ねください。",
		  getFieldEditorParent());
		addField(l1);

		StringFieldEditor sfeHost = new StringFieldEditor(AppKeys.ADMIN_HOST, "ホスト名:", getFieldEditorParent());
		sfeHost.setEmptyStringAllowed(false);
		addField(sfeHost);

		IntegerFieldEditor ifePort = new IntegerFieldEditor(AppKeys.ADMIN_PORT, "ポート:", getFieldEditorParent());
		ifePort.setValidRange(1, 65535);
		ifePort.setEmptyStringAllowed(false);
		addField(ifePort);
	}
}
