package org.csstudio.utility.adlparser.fileParser.widgets;

import org.csstudio.utility.adlparser.fileParser.ADLWidget;
import org.csstudio.utility.adlparser.fileParser.FileLine;
import org.csstudio.utility.adlparser.fileParser.WrongADLFormatException;
import org.csstudio.utility.adlparser.fileParser.widgetParts.ADLControl;
import org.csstudio.utility.adlparser.fileParser.widgetParts.ADLObject;
import org.csstudio.utility.adlparser.internationalization.Messages;

public class MessageButton extends ADLAbstractWidget {
	private String label = new String();;
	private String press_msg = new String();
	private String release_msg = new String();

	public MessageButton(ADLWidget adlWidget) {
		super(adlWidget);
		try {
			for (ADLWidget childWidget : adlWidget.getObjects()) {
	        	
	        	if (childWidget.getType().equals("object")){
	        		_adlObject = new ADLObject(childWidget);
	        		if (_adlObject != null){
	        			_hasObject = true;
	        		}
	        		
	        	}
	        	else if (childWidget.getType().equals("control")){
	        		_adlControl = new ADLControl(childWidget);
	        		if (_adlControl != null){
	        			_hasControl = true;
	        		}
	        	}
			}
			for (FileLine fileLine : adlWidget.getBody()){
				String bodyPart = fileLine.getLine();
				String[] row = bodyPart.trim().split("=");
				if (row.length < 2){
					throw new WrongADLFormatException(Messages.Label_WrongADLFormatException_Parameter_Begin + bodyPart + Messages.Label_WrongADLFormatException_Parameter_End);
				}
				if (FileLine.argEquals(row[0], "label")){
					setLabel(FileLine.getTrimmedValue(row[1]));
				}
				else if (FileLine.argEquals(row[0], "press_msg")){
					setPress_msg(FileLine.getTrimmedValue(row[1]));
				}
				else if (FileLine.argEquals(row[0], "release_msg")){
					setRelease_msg(FileLine.getTrimmedValue(row[1]));
				}
			}
		}
		catch (WrongADLFormatException ex) {
			
		}
		//TODO Add Color mode to MessageButton
	}

	/**
	 * @param label the label to set
	 */
	public void setLabel(String label) {
		this.label = label;
	}

	/**
	 * @return the label
	 */
	public String getLabel() {
		return label;
	}

	/**
	 * @param press_msg the press_msg to set
	 */
	public void setPress_msg(String press_msg) {
		this.press_msg = press_msg;
	}

	/**
	 * @return the press_msg
	 */
	public String getPress_msg() {
		return press_msg;
	}

	/**
	 * @param release_msg the release_msg to set
	 */
	public void setRelease_msg(String release_msg) {
		this.release_msg = release_msg;
	}

	/**
	 * @return the release_msg
	 */
	public String getRelease_msg() {
		return release_msg;
	}

}

@@ -641,16 +641,68 @@
 ring();%0A
+%09private String color_mode = new String(%22static%22);%0A%09
 %0A%09public
@@ -1926,16 +1926,132 @@
 ;%0A%09%09%09%09%7D%0A
+%09%09%09%09else if (FileLine.argEquals(row%5B0%5D, %22color mode%22))%7B%0A%09%09%09%09%09setColor_mode(FileLine.getTrimmedValue(row%5B1%5D));%0A%09%09%09%09%7D%0A
 %09%09%09%7D%0A%09%09%7D
@@ -2102,49 +2102,8 @@
 %09%09%7D%0A
-%09%09//TODO Add Color mode to MessageButton%0A
 %09%7D%0A%0A
@@ -2756,10 +2756,244 @@
 sg;%0A%09%7D%0A%0A
+%09/**%0A%09 * @param color_mode the color_mode to set%0A%09 */%0A%09private void setColor_mode(String color_mode) %7B%0A%09%09this.color_mode = color_mode;%0A%09%7D%0A%0A%09/**%0A%09 * @return the color_mode%0A%09 */%0A%09public String getColor_mode() %7B%0A%09%09return color_mode;%0A%09%7D%0A%0A
 %7D%0A

Add code to get the color mode.