[309606] Develop Script Editor (Lang support for old branch)
diff --git a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/internal/ui/scripteditor/EditPanelTab.java b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/internal/ui/scripteditor/EditPanelTab.java
index ae4a56c..a68e44c 100644
--- a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/internal/ui/scripteditor/EditPanelTab.java
+++ b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/internal/ui/scripteditor/EditPanelTab.java
@@ -19,6 +19,7 @@
 import org.eclipse.actf.ai.internal.ui.scripteditor.event.SyncTimeEventListener;
 import org.eclipse.actf.ai.scripteditor.data.ScriptData;
 import org.eclipse.actf.ai.scripteditor.preferences.CSVRulePreferenceUtil;
+import org.eclipse.actf.ai.tts.ITTSEngine;
 import org.eclipse.actf.ai.ui.scripteditor.views.EditPanelView;
 import org.eclipse.actf.ai.ui.scripteditor.views.IUNIT;
 import org.eclipse.actf.ai.ui.scripteditor.views.ScriptListView;
@@ -56,6 +57,10 @@
 	 */
 	Composite ownComposite;
 
+	private String[] langList = ITTSEngine.LANGSET
+			.toArray(new String[ITTSEngine.LANGSET.size()]);
+
+	
 	// Own instance
 	static private EditPanelTab ownInst = null;
 
@@ -90,7 +95,7 @@
 	private int updateScriptStartTime = 0;
 
 	// Language of description
-	private int currentDescLang = DESC_LANG_EN;
+	private String currentDescLang = "en-US";
 
 	// Edit Panel part
 	private Label labelVPitch;
@@ -471,14 +476,23 @@
 			comboLangLData.top = new FormAttachment(labelLang, 2);
 			comboLang = new Combo(ownComposite, SWT.DROP_DOWN);
 			comboLang.setLayoutData(comboLangLData);
-			comboLang.setItems(itemLang);
+			comboLang.setItems(langList);
 			if (Locale.getDefault().toString().startsWith("ja")) {
-				currentDescLang = DESC_LANG_JA;
+				for (int i = 0; i < langList.length; i++) {
+					if ("ja-JP".equals(langList[i])) {
+						comboLang.select(i);
+						break;
+					}
+				}
 			} else {
-				// Default : English selected
-				currentDescLang = DESC_LANG_EN;
-			}
-			comboLang.select(currentDescLang);
+				// TODO
+				for (int i = 0; i < langList.length; i++) {
+					if ("en-US".equals(langList[i])) {
+						comboLang.select(i);
+						break;
+					}
+				}
+			}			
 			// Add EventListener
 			comboLang.addListener(SWT.Selection, new DescLangListener());
 
@@ -672,20 +686,6 @@
 	}
 
 	/**
-	 * Getter method : Get current Language of Description
-	 */
-	public int getLangDescription() {
-		return (currentDescLang);
-	}
-
-	/**
-	 * Setter method : Set current Language of Description
-	 */
-	public void setLangDescription(int lindex) {
-		currentDescLang = lindex;
-	}
-
-	/**
 	 * Local method : setVisible button Delete
 	 */
 	private void setVisibleDelete(boolean stat) {
@@ -802,8 +802,13 @@
 
 		// Set Language of Description
 		currentDescLang = instScriptData.getExtendLang(index);
-		comboLang.select(currentDescLang);
-
+		for (int i = 0; i < langList.length; i++) {
+			if (langList[i].equals(currentDescLang)) {
+				comboLang.select(i);
+			}
+		}// TODO set default
+		
+		
 		// Set visible button
 		setVisibleAppend(true, true);
 		setVisibleDelete(true);
@@ -929,7 +934,7 @@
 					.getScriptStartTime(0));
 			boolean extended = instScriptData.getExtendExtended(index);
 			boolean gender = instScriptData.getExtendGender(index);
-			int lang = instScriptData.getExtendLang(index);
+			String lang = instScriptData.getExtendLang(index);
 			int speed = instScriptData.getExtendSpeed(index);
 			int pitch = instScriptData.getExtendPitch(index);
 			int volume = instScriptData.getExtendVolume(index);
@@ -974,7 +979,11 @@
 				comboLang.setBackground(PlatformUI.getWorkbench().getDisplay()
 						.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
 			}
-			comboLang.select(lang);
+			for (int i = 0; i < langList.length; i++) {
+				if (langList[i].equals(lang)) {
+					comboLang.select(i);
+				}
+			}// TODO set default			
 		} else {
 			// Reset grayed color setting
 			chkBoxExtended.setGrayed(false);
@@ -1051,7 +1060,7 @@
 
 	private boolean isDiffLang() {
 		boolean result = false;
-		int firstData;
+		String firstData;
 
 		// PickUP 1st data
 		ScriptData wrkData = (ScriptData) storeObjs[0];
@@ -1065,9 +1074,9 @@
 			wrkData = (ScriptData) storeObjs[i];
 			index = instScriptData.getIndexScriptData(wrkData
 					.getScriptStartTime(0));
-			int nextData = instScriptData.getExtendLang(index);
+			String nextData = instScriptData.getExtendLang(index);
 			// Check value
-			if (firstData != nextData) {
+			if (!firstData.equals(nextData)) {
 				// detect different value
 				result = true;
 				break;
@@ -1182,7 +1191,7 @@
 			return;
 		}
 		int extendSpeed = scaleVoiceSpeed.getSelection();
-		int extendLang = currentDescLang;
+		String extendLang = currentDescLang;
 		String currentDesc = textAreaDescription.getText();
 		// PickUP EndTime of current description
 		int newEndTime = TimeLineView.getInstance().setEndTimeVolumeLevel(
@@ -1326,9 +1335,10 @@
 			int speed = scaleVoiceSpeed.getSelection();
 			int pitch = scaleVoicePitch.getSelection();
 			int volume = scaleVoiceVolume.getSelection();
+			String lang = langList[comboLang.getSelectionIndex()];
 
 			// SetUP Voice Manage
-			TimeLineView.getInstance().reqSetupScriptAudio(strGender, speed,
+			TimeLineView.getInstance().reqSetupScriptAudio(lang, strGender, speed,
 					pitch, volume);
 			// Play voice(Script Audio)
 			TimeLineView.getInstance().reqPlayScriptAudio(currentScriptText);
@@ -1349,9 +1359,9 @@
 		public void widgetSelected(SelectionEvent e) {
 			// Get current Script text from Text Area
 			String currentScriptText = new String(textAreaDescription.getText());
-
+			
 			// Check length of String
-			if (!currentScriptText.isEmpty()) {
+			if (!currentScriptText.isEmpty()) {				
 				// Preview Voice
 				playPreviewDescription(currentScriptText);
 			}
@@ -1404,7 +1414,7 @@
 			int extendSpeed = scaleVoiceSpeed.getSelection();
 			int extendPitch = scaleVoicePitch.getSelection();
 			int extendVolume = scaleVoiceVolume.getSelection();
-			int extendLang = currentDescLang;
+			String extendLang = currentDescLang;
 
 			// Check Update button mode
 			if (currentModeAppend && (startTime != updateScriptStartTime)) {
@@ -1561,7 +1571,7 @@
 				int extendSpeed = scaleVoiceSpeed.getSelection();
 				int extendPitch = scaleVoicePitch.getSelection();
 				int extendVolume = scaleVoiceVolume.getSelection();
-				int extendLang = currentDescLang;
+				String extendLang = currentDescLang;
 
 				// Start delete multiple data
 				for (int i = 0; i < storeObjs.length; i++) {
@@ -1708,13 +1718,11 @@
 				int extendSpeed = Integer.parseInt(extSpeed);
 				int extendPitch = Integer.parseInt(extPitch);
 				int extendVolume = Integer.parseInt(extVolume);
-				int extendLang = "ja".equals(extLang) ? DESC_LANG_JA
-						: DESC_LANG_EN;
 
 				// update Extended data
 				instScriptData.appendExtendData(index, startTime,
 						extendExtended, extendSex, extendSpeed, extendPitch,
-						extendVolume, extendLang);
+						extendVolume, extLang);
 			}
 		}
 	}
@@ -1726,7 +1734,7 @@
 	 * @return result process : TRUE:success process, FALSE:faile process
 	 */
 	public boolean appendScriptData(int startTime, String strDescription,
-			boolean extended, boolean gender, int lang, int speed, int pitch,
+			boolean extended, boolean gender, String lang, int speed, int pitch,
 			int volume) {
 
 		// Extended parameters
@@ -1735,7 +1743,7 @@
 		int extendSpeed = speed;
 		int extendPitch = pitch;
 		int extendVolume = volume;
-		int extendLang = lang;
+		String extendLang = lang;
 		int index = -1;
 
 		// Check preference setting of CSV save rule
@@ -1899,7 +1907,7 @@
 			int currentSpeed = instScriptData.getExtendSpeed(index);
 			int currentPitch = instScriptData.getExtendPitch(index);
 			int currentVolume = instScriptData.getExtendVolume(index);
-			int currentLang = instScriptData.getExtendLang(index);
+			String currentLang = instScriptData.getExtendLang(index);
 
 			// Delete target ScriptData from List
 			instScriptData.deleteScriptData(index);
@@ -2240,8 +2248,8 @@
 		public void handleEvent(Event e) {
 			// PickUP selection item index of Language of Description
 			Combo combo = (Combo) e.widget;
-			currentDescLang = combo.getSelectionIndex();
-
+			currentDescLang = langList[combo.getSelectionIndex()];
+			
 			// SetUP enabled status for multiple selection mode
 			if (currentMultiSelection) {
 				modifyMultiLang = true;
diff --git a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/data/ScriptData.java b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/data/ScriptData.java
index 42dcd50..4686d7c 100644
--- a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/data/ScriptData.java
+++ b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/data/ScriptData.java
@@ -42,14 +42,14 @@
 		// 5)Extend : Volume of Machine Voice
 		private int Volume;
 
-		// Special)Extend : Language of Description
-		private int Lang;
+		// Language of Description
+		private String Lang;
 
 		/**
 		 * Constructor
 		 */
 		public StructExtendData(int starttime, boolean extended,
-				boolean gender, int speed, int pitch, int volume, int lang) {
+				boolean gender, int speed, int pitch, int volume, String lang) {
 			// Store index(Start Time)
 			StartTime = starttime;
 			// Store Extended data
@@ -112,7 +112,7 @@
 		/**
 		 * Getter method : Get Language of Description
 		 */
-		public int getLang() {
+		public String getLang() {
 			// return current Language of Description
 			return (Lang);
 		}
@@ -168,7 +168,7 @@
 		/**
 		 * Setter method : Set Language of Description
 		 */
-		public void setLang(int lang) {
+		public void setLang(String lang) {
 			// update current Language of Description
 			Lang = lang;
 		}
@@ -796,7 +796,7 @@
 	 * @param index
 	 * @return Index of Language
 	 */
-	public int getExtendLang(int index) {
+	public String getExtendLang(int index) {
 		// Get Structure of target Extended data
 		StructExtendData currentExtendData = (StructExtendData) ExtendList
 				.get(index);
@@ -806,7 +806,7 @@
 
 	public void appendExtendData(int index, int starttime,
 			Boolean extendExtended, Boolean extendSex, int extendSpeed,
-			int extendPitch, int extendVolume, int extendLang) {
+			int extendPitch, int extendVolume, String extendLang) {
 
 		// Create target Struct(Extended data)
 		StructExtendData newExtendData = new StructExtendData(starttime,
@@ -1062,7 +1062,6 @@
 			String strGender = new String((gender ? "male" : "female"));
 			String strExtended = new String(
 					(getExtendExtended(i) ? " extended=\"true\"" : ""));
-			String strLang = new String(((getExtendLang(i) == 1) ? "ja" : "en"));
 
 			// for WAV information
 			String strServerUri = "";
@@ -1082,7 +1081,7 @@
 					+ "</start>" + LINE_SEP);
 			tmpSB.append("\t  <duration>" + strDuration + "</duration>"
 					+ LINE_SEP);
-			tmpSB.append("\t  <description xml:lang=\"" + strLang + "\" "
+			tmpSB.append("\t  <description xml:lang=\"" + getExtendLang(i) + "\" "
 					+ "speed=\"" + strSpeed + "\" " + "gender=\"" + strGender
 					+ "\"" + strExtended + ">" + strDesc + "</description>"
 					+ LINE_SEP);
@@ -1169,9 +1168,6 @@
 			String strExtended = (getExtendExtended(index) ? "1" : "0");
 			// Get gender
 			String strGender = (getExtendGender(index) ? "male" : "female");
-			// Get language of description
-			String strLang = ((getExtendLang(index) == DESC_LANG_JA) ? "ja"
-					: "en");
 			// Get play voice speed
 			String strSpeed = String.valueOf(getExtendSpeed(index));
 			// Get play voice pitch
@@ -1192,7 +1188,7 @@
 			tmpSB.append(wavLocalPath + COLUMN_SEP);
 			tmpSB.append(strExtended + COLUMN_SEP);
 			tmpSB.append(strGender + COLUMN_SEP);
-			tmpSB.append(strLang + COLUMN_SEP);
+			tmpSB.append(getExtendLang(index) + COLUMN_SEP);
 			tmpSB.append(strSpeed + COLUMN_SEP);
 			tmpSB.append(strPitch + COLUMN_SEP);
 			tmpSB.append(strVolume + COLUMN_SEP);
diff --git a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/reader/CSVReader.java b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/reader/CSVReader.java
index c1b7b39..baf6fe3 100644
--- a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/reader/CSVReader.java
+++ b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/scripteditor/reader/CSVReader.java
@@ -101,7 +101,7 @@
 	// variables for extended information
 	private boolean bkup_ext_extended = false;
 	private boolean bkup_ext_gender = true;
-	private int bkup_ext_lang = 0;
+	private String bkup_ext_lang = "en-US";
 	private int bkup_ext_speed = 50;
 	private int bkup_ext_pitch = 50;
 	private int bkup_ext_volume = 50;
@@ -117,7 +117,7 @@
 	// variables for extend information
 	private ArrayList<Boolean> list_ext_extended;
 	private ArrayList<Boolean> list_ext_gender;
-	private ArrayList<Integer> list_ext_lang;
+	private ArrayList<String> list_ext_lang;
 	private ArrayList<Integer> list_ext_speed;
 	private ArrayList<Integer> list_ext_pitch;
 	private ArrayList<Integer> list_ext_volume;
@@ -153,7 +153,7 @@
 		// Allocate array list for extend information
 		list_ext_extended = new ArrayList<Boolean>();
 		list_ext_gender = new ArrayList<Boolean>();
-		list_ext_lang = new ArrayList<Integer>();
+		list_ext_lang = new ArrayList<String>();
 		list_ext_speed = new ArrayList<Integer>();
 		list_ext_pitch = new ArrayList<Integer>();
 		list_ext_volume = new ArrayList<Integer>();
@@ -232,7 +232,7 @@
 			// reset all extend variables
 			bkup_ext_extended = false;
 			bkup_ext_gender = true;
-			bkup_ext_lang = 0;
+			bkup_ext_lang = "en-US";
 			bkup_ext_speed = 50;
 			bkup_ext_pitch = 50;
 			bkup_ext_volume = 50;
@@ -415,8 +415,7 @@
 				// Initialize Extended area for next start time
 				bkup_ext_extended = false;
 				bkup_ext_gender = true;
-				bkup_ext_lang = EditPanelView.getInstance()
-						.getInstanceTabEditPanel().getLangDescription();
+				bkup_ext_lang = "en-US";
 				bkup_ext_speed = 50;
 				bkup_ext_pitch = 50;
 				bkup_ext_volume = 50;
@@ -527,14 +526,15 @@
 		}
 		// Status 6 : PickUP language of Extend
 		else if (currentStatus == CSV_ANA_EXT_GEN) {
-			bkup_ext_lang = EditPanelView.getInstance()
-					.getInstanceTabEditPanel().getLangDescription();
+			bkup_ext_lang = "en-US";
 			if (nowStr != null) {
 				// Check limit
+				// Check limit
 				if ("ja".equals(nowStr) || "en".equals(nowStr)) {
 					// Set language
-					bkup_ext_lang = ("ja".equals(nowStr) ? DESC_LANG_JA
-							: DESC_LANG_EN);
+					bkup_ext_lang = ("ja".equals(nowStr) ? "ja-JP" : "en-US");
+				} else {
+					bkup_ext_lang = nowStr;
 				}
 			}
 			// Change mode to own process
@@ -953,7 +953,7 @@
 			// PickUP current Extend data from temporary list
 			boolean extended = list_ext_extended.get(i);
 			boolean gender = list_ext_gender.get(i);
-			int lang = list_ext_lang.get(i);
+			String lang = list_ext_lang.get(i);
 			int speed = list_ext_speed.get(i);
 			int pitch = list_ext_pitch.get(i);
 			int volume = list_ext_volume.get(i);
diff --git a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/IUNIT.java b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/IUNIT.java
index df49004..57511f9 100644
--- a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/IUNIT.java
+++ b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/IUNIT.java
@@ -143,11 +143,6 @@
 	static final float SM_CAP_RATE_LATE = 11025; // 11025Hz : Sampling rate of
 													// capture voice (late mode)
 
-	// Language of Description
-	static final String[] itemLang = { "English", "Japanese" };
-	static final int DESC_LANG_EN = 0;
-	static final int DESC_LANG_JA = 1;
-
 	// temporary file interface
 	static final String DIR_TEMP_VOLLVL = "VOLLVL";
 	static final String FILE_TEMP_VOLLVL_PREFIX = "temp";
diff --git a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/TimeLineView.java b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/TimeLineView.java
index b2dd522..beed759 100644
--- a/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/TimeLineView.java
+++ b/plugins/org.eclipse.actf.examples.scripteditor/src/org/eclipse/actf/ai/ui/scripteditor/views/TimeLineView.java
@@ -1397,9 +1397,11 @@
 	/**
 	 * Setter method : Request Play voice(Script Audio) by ProTalker
 	 */
-	public void reqSetupScriptAudio(String strGender, int speed, int pitch,
+	public void reqSetupScriptAudio(String lang, String strGender, int speed, int pitch,
 			int volume) {
 		// SetUP extended parameters
+		voicePlayer.setLang(lang);
+
 		voicePlayer.setGender(strGender);
 		voicePlayer.setSpeed(speed);
 		voicePlayer.setPitch(pitch);
@@ -1468,21 +1470,13 @@
 		SoundMixer.getInstance().dispose();
 	}
 
-	/**
-	 * Request Start VoicePlayer
-	 */
-	public void reqStartVoicePlayer(String nowScriptText) {
-		// Start ProTalker
-		voicePlayer.speak(nowScriptText);
-	}
-
 	public void reqStartVoicePlayer(int index) {
-		// SetUP current Script
-		reqSetupScriptAudio((instScriptData.getExtendGender(index) ? "male"
+		// SetUP current Script		
+		reqSetupScriptAudio(instScriptData.getExtendLang(index),(instScriptData.getExtendGender(index) ? "male"
 				: "female"), instScriptData.getExtendSpeed(index),
 				instScriptData.getExtendPitch(index),
 				instScriptData.getExtendVolume(index));
-
+		
 		// Start ProTalker
 		voicePlayer.speak(instScriptData.getScriptData(index));
 	}
@@ -1547,7 +1541,7 @@
 	 * Update End Time of sampling data for Time Line
 	 */
 	public int setEndTimeVolumeLevel(String currentScript, int currentSpeed,
-			int currentLang) {
+			String currentLang) {
 
 		// get current Script data length (as Preview action)
 		int lengthSample = VolumeLevelCanvas.getInstance()
@@ -1633,7 +1627,7 @@
 	 *            : string of description
 	 * @return MORA counter
 	 */
-	public int sumMoraCount(String strDesc, int speed, int lang) {
+	public int sumMoraCount(String strDesc, int speed, String lang) {
 		int duration = 0;
 
 		// Calculate current pitch(speed)
@@ -1641,12 +1635,12 @@
 				: (VE_TIME_MORA_EN + (4 * (50 - speed)));
 
 		// Count character
-		if (lang == DESC_LANG_JA) {
+		if ("ja-JP".equalsIgnoreCase(lang)) {
 			// Japanese
 			duration = (int) ((float) nowPitch * voicePlayer
 					.sumMoraCountJp(strDesc));
 		} else {
-			// English
+			// English or other
 			duration = (int) ((float) nowPitch * (int) voicePlayer
 					.sumMoraCountEn(strDesc));
 		}