/*
 * Copyright (c) 2007 Stiftung Deutsches Elektronen-Synchrotron,
 * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
 *
 * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS.
 * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND
 * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE
 * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR
 * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
 * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
 * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
 * OR MODIFICATIONS.
 * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION,
 * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS
 * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY
 * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM
 */
/*
 * $Id$
 */
package org.csstudio.utility.adlparser.fileParser.widgetParts;


//**import org.csstudio.sds.components.model.MenuButtonModel;
//**import org.csstudio.sds.components.model.PolygonModel;
//**import org.csstudio.sds.components.model.RectangleModel;
//**import org.csstudio.sds.model.AbstractWidgetModel;
//**import org.csstudio.sds.model.initializers.WidgetInitializationService;
import org.csstudio.utility.adlparser.fileParser.ADLWidget;
import org.csstudio.utility.adlparser.fileParser.WrongADLFormatException;

/**
 * @author hrickens
 * @author $Author$
 * @version $Revision$
 * @since 24.10.2007
 */
public abstract class WidgetPart {
    
    /**
     * The Widget that set the parameter from ADLWidget.
     */
//**    protected AbstractWidgetModel _widgetModel;
    
//**    protected AbstractWidgetModel _parentWidgetModel;
	protected String name = new String();
    /**
     * The default constructor.
     * 
     * @param widgetPart An ADLWidget that correspond to the Child Widget Part. 
     * @param parentWidgetModel The Widget that set the parameter from ADLWidget.
     * @throws WrongADLFormatException Wrong ADL format or untreated parameter found.
     */
    public WidgetPart(final ADLWidget widgetPart) throws WrongADLFormatException {
//**        _widgetModel = parentWidgetModel;
//**        if ((this instanceof ADLMonitor || this instanceof ADLDynamicAttribute || this instanceof ADLControl) &&!(parentWidgetModel instanceof PolygonModel || parentWidgetModel instanceof MenuButtonModel || parentWidgetModel instanceof RectangleModel)) {
//**            WidgetInitializationService instance = WidgetInitializationService.getInstance();
//**            instance.initialize(parentWidgetModel);
//**        }
        init();
        parseWidgetPart(widgetPart);
//**        generateElements();
    }

    public WidgetPart(){
    	init();
    }
    /**
     * Initialization.
     */
    abstract void init();

    /**
     * Pars the {@link ADLWidget}.
     * 
     * @param widgetPart the widget Part to pars.
     * @throws WrongADLFormatException Wrong ADL format or untreated parameter found.
     */
    abstract void parseWidgetPart(ADLWidget widgetPart) throws WrongADLFormatException;

    abstract public Object[] getChildren();

//**   /**
  //**     * Set all property's to the Parent Widget Model.
  //**     */
  //**    abstract void generateElements();
  //**
  //**    public final void setParentWidgetModel(AbstractWidgetModel parentWidgetModel) {
  //**        _widgetModel = parentWidgetModel;
  //**    }
  //**
  //**    protected void uninit() {
  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_BORDER_COLOR, null);
  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_BORDER_STYLE, null);
  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_BORDER_WIDTH, null);
  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_COLOR_BACKGROUND, null);
  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_COLOR_FOREGROUND, null);
  //**    }

    public String getName(){
    	return name;
    }
 
}

@@ -2078,123 +2078,8 @@
  */%0A
-//**    protected AbstractWidgetModel _widgetModel;%0A    %0A//**    protected AbstractWidgetModel _parentWidgetModel;%0A
 %09pro
@@ -2501,28 +2501,24 @@
 ption %7B%0A
-//**
         
 _widgetM
@@ -2513,484 +2513,249 @@
     
-_widgetModel = parentWidgetModel;%0A//**        if ((this instanceof ADLMonitor %7C%7C this instanceof ADLDynamicAttribute %7C%7C this instanceof ADLControl) &&!(parentWidgetModel instanceof PolygonModel %7C%7C parentWidgetModel instanceof MenuButtonModel %7C%7C parentWidgetModel instanceof RectangleModel)) %7B%0A//**            WidgetInitializationService instance = WidgetInitializationService.getInstance();%0A//**            instance.initialize(parentWidgetModel);%0A//**        %7D%0A        init();
+init();%0A        if (!widgetPart.getType().equals(getName()))%7B%0A        %09throw new WrongADLFormatException(%22part type does not match widget name(part type, widget name): (%22 %0A        %09%09%09+widgetPart.getType() + %22, %22 + getName() + %22)%22);%0A        %7D
 %0A   
@@ -2792,40 +2792,8 @@
 t);%0A
-//**        generateElements();%0A
     
@@ -3238,832 +3238,8 @@
 );%0A%0A
-//**   /**%0A  //**     * Set all property's to the Parent Widget Model.%0A  //**     */%0A  //**    abstract void generateElements();%0A  //**%0A  //**    public final void setParentWidgetModel(AbstractWidgetModel parentWidgetModel) %7B%0A  //**        _widgetModel = parentWidgetModel;%0A  //**    %7D%0A  //**%0A  //**    protected void uninit() %7B%0A  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_BORDER_COLOR, null);%0A  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_BORDER_STYLE, null);%0A  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_BORDER_WIDTH, null);%0A  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_COLOR_BACKGROUND, null);%0A  //**        _widgetModel.setDynamicsDescriptor(AbstractWidgetModel.PROP_COLOR_FOREGROUND, null);%0A  //**    %7D%0A
 %0A   

Add catch if widget passed to constructor is not the same as the handling class.