/**
 * 
 */
package org.csstudio.opibuilder.adl2boy.utilities;

import org.csstudio.opibuilder.adl2boy.translator.TranslatorUtils;
import org.csstudio.opibuilder.util.OPIFont;
import org.csstudio.opibuilder.widgets.model.LabelModel;
import org.csstudio.opibuilder.widgets.model.TextIndicatorModel;
import org.csstudio.utility.adlparser.fileParser.widgets.ADLAbstractWidget;
import org.eclipse.swt.graphics.FontData;

/**
 * @author hammonds
 *
 */
public class TextUtilities {

	/**
	 * 
	 */
	public static void setWidgetFont(LabelModel textModel) {
		OPIFont font = textModel.getFont();
		int fontSize = TranslatorUtils.convertTextHeightToFontSize(textModel.getHeight());
		FontData fontData = font.getFontData();
		FontData newFontData = new FontData(fontData.getName(), fontData.getHeight(), fontData.getStyle());
		newFontData.setHeight(fontSize);
		textModel.setPropertyValue(LabelModel.PROP_FONT, newFontData);
	}

	/**
	 * @param textModel TODO
	 * @param adlTextWidget TODO
	 * 
	 */
	public static void setAlignment(LabelModel textModel, ADLAbstractWidget adlTextWidget) {
		//TODO Add Alignment to TextUpdate2Model
		TranslatorUtils.printNotHandledWarning("TextUtilites", "Text alingnment" );
	}

	/**
	 * @param textModel TODO
	 * @param adlTextWidget TODO
	 * 
	 */
	public static void setFormat(TextIndicatorModel textModel, ADLAbstractWidget adlTextWidget) {
		//TODO Add format to TextEntry2Model
		TranslatorUtils.printNotHandledWarning("", "format" );
	}

}

@@ -373,24 +373,95 @@
 actWidget;%0D%0A
+import org.csstudio.utility.adlparser.fileParser.widgets.ITextWidget;%0D%0A
 import org.e
@@ -521,16 +521,17 @@
 onds%0D%0A *
+ 
 %0D%0A */%0D%0Ap
@@ -743,24 +743,30 @@
 ze(textModel
+%0D%0A%09%09%09%09
 .getHeight()
@@ -869,17 +869,22 @@
 tName(),
- 
+%0D%0A%09%09%09%09
 fontData
@@ -1058,44 +1058,142 @@
 odel
- TODO%0D%0A%09 * @param adlTextWidget TODO
+%0D%0A%09 *            Model of BOY widget to be modified%0D%0A%09 * @param adlTextWidget%0D%0A%09 *            Model of ADL widget.  Sourve of the data
 %0D%0A%09 
@@ -1248,33 +1248,37 @@
 Model textModel,
- 
+%0D%0A%09%09%09
 ADLAbstractWidge
@@ -1303,127 +1303,560 @@
 %0D%0A%09%09
-//TODO Add Alignment to TextUpdate2Model
+if (adlTextWidget.getName().equals(%22text%22)%0D%0A%09%09%09%09%7C%7C adlTextWidget.getName().equals(%22text update%22)) %7B%0D%0A%09%09%09String alignment = ((ITextWidget)adlTextWidget).getAlignment();
 %0D%0A%09%09
+%09
-TranslatorUtils.printNotHandledWarning(%22TextUtilites%22, %22Text 
+if (alignment.equals(%22%22)%7C%7C%0D%0A%09%09%09%09%09alignment.equals(%22horiz. left%22))%7B%0D%0A%09%09%09%09textModel.setPropertyValue(LabelModel.PROP_ALIGN_H, 0);%0D%0A%09%09%09%7D%0D%0A%09%09%09else if (alignment.equals(%22horiz. centered%22))%7B%0D%0A%09%09%09%09textModel.setPropertyValue(LabelModel.PROP_ALIGN_H, 1);%0D%0A%09%09%09%09%0D%0A%09%09%09%7D%0D%0A%09%09%09else if (
 ali
-n
 gnment
-%22 );
+.equals(%22horiz.right%22))%7B%0D%0A%09%09%09%09textModel.setPropertyValue(LabelModel.PROP_ALIGN_H, 2);%0D%0A%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A
 %0D%0A%09%7D
@@ -1885,16 +1885,32 @@
 extModel
+%0D%0A%09 *           
  TODO%0D%0A%09
@@ -1932,16 +1932,32 @@
 xtWidget
+%0D%0A%09 *           
  TODO%0D%0A%09
@@ -2026,17 +2026,21 @@
 xtModel,
- 
+%0D%0A%09%09%09
 ADLAbstr
@@ -2071,16 +2071,17 @@
  %7B%0D%0A%09%09//
+ 
 TODO Add
@@ -2161,17 +2161,16 @@
 %22format%22
- 
 );%0D%0A%09%7D%0D%0A

Add handling of text alignment