<commit_before>/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.eclipse.birt.report.designer.internal.ui.editors.parts.event.IModelEventProcessor;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.AbstractModelEventProcessor.IModelEventFactory;
import org.eclipse.birt.report.model.api.activity.NotificationEvent;
import org.eclipse.gef.EditPart;

/**
 * For the report topo edit part to process the model event through the GraphicsViewModelEventProcessor.
 */

public abstract class AbstractReportEditPart extends ReportElementEditPart implements
		IAdvanceModelEventFactory
{

	public final static String MODEL_EVENT_DISPATCH = "model event dipatch";//$NON-NLS-1$
	public final static String START = "start";//$NON-NLS-1$
	public final static String END = "end";//$NON-NLS-1$
	private boolean isDispatch = false;
	/**
	 * @param model
	 */
	public AbstractReportEditPart( Object model )
	{
		super( model );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
	 */
	public Object getAdapter( Class key )
	{
		if ( key == IModelEventProcessor.class )
		{
			return new GraphicsViewModelEventProcessor( this );
		}
		return super.getAdapter( key );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.GraphicsViewModelEventProcessor.IModelEventFactory#createModelEventRunnable(java.lang.Object, int, java.util.Map)
	 */
	public Runnable createModelEventRunnable( Object focus, int type,
			Map args )
	{
		switch ( type )
		{
			case NotificationEvent.CONTENT_REPLACE_EVENT :
			case NotificationEvent.TEMPLATE_TRANSFORM_EVENT :
			case NotificationEvent.CONTENT_EVENT :
			{
				return new EditpartReportEventRunnable( focus, type, args ) {

					public void runModelChange( )
					{
						contentChange( getFocus( ), getArgs( ) );
					}
				};
			}
			case NotificationEvent.NAME_EVENT :
			case NotificationEvent.STYLE_EVENT :
			case NotificationEvent.EXTENSION_PROPERTY_DEFINITION_EVENT :
			case NotificationEvent.THEME_EVENT :
			case NotificationEvent.LIBRARY_EVENT :
			case NotificationEvent.ELEMENT_LOCALIZE_EVENT :
			
			case NotificationEvent.PROPERTY_EVENT :
			{
				return new EditpartReportEventRunnable( focus, type, args ) {

					public void runModelChange( )
					{
						propertyChange( getFocus( ), getArgs() );
					}
				};
			}
			case NotificationEvent.LIBRARY_RELOADED_EVENT :
			{
				return new EditpartReportEventRunnable( focus, type, args ) {

					public void runModelChange( )
					{
						reloadTheChildren( );
					}
				};

			}

			default :
				break;
		}
		return null;
	}

	/**
	 * @param focus
	 * @param info
	 */
	protected void propertyChange( Object focus, Map info )
	{
		if (getViewer( )==null)
		{
			return;
		}
		Object obj = getViewer( ).getEditPartRegistry( ).get( focus );
		if ( obj instanceof ReportElementEditPart && !((ReportElementEditPart)obj).isDelete( ))
		{
			( (ReportElementEditPart) obj ).propertyChange( info );
			return;<commit_msg>- Summary:Fix bug 181678,181541,181542,181438,177455<commit_after>/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.eclipse.birt.report.designer.internal.ui.editors.parts.event.IModelEventProcessor;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.AbstractModelEventProcessor.IModelEventFactory;
import org.eclipse.birt.report.model.api.activity.NotificationEvent;
import org.eclipse.gef.EditPart;

/**
 * For the report topo edit part to process the model event through the GraphicsViewModelEventProcessor.
 */

public abstract class AbstractReportEditPart extends ReportElementEditPart implements
		IAdvanceModelEventFactory
{

	public final static String MODEL_EVENT_DISPATCH = "model event dipatch";//$NON-NLS-1$
	public final static String START = "start";//$NON-NLS-1$
	public final static String END = "end";//$NON-NLS-1$
	private boolean isDispatch = false;
	/**
	 * @param model
	 */
	public AbstractReportEditPart( Object model )
	{
		super( model );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
	 */
	public Object getAdapter( Class key )
	{
		if ( key == IModelEventProcessor.class )
		{
			return new GraphicsViewModelEventProcessor( this );
		}
		return super.getAdapter( key );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.GraphicsViewModelEventProcessor.IModelEventFactory#createModelEventRunnable(java.lang.Object, int, java.util.Map)
	 */
	public Runnable createModelEventRunnable( Object focus, int type,
			Map args )
	{
		switch ( type )
		{
			case NotificationEvent.CONTENT_REPLACE_EVENT :
			case NotificationEvent.TEMPLATE_TRANSFORM_EVENT :
			case NotificationEvent.CONTENT_EVENT :
			{
				return new EditpartReportEventRunnable( focus, type, args ) {

					public void runModelChange( )
					{
						contentChange( getFocus( ), getArgs( ) );
					}
				};
			}
			case NotificationEvent.NAME_EVENT :
			case NotificationEvent.STYLE_EVENT :
			case NotificationEvent.EXTENSION_PROPERTY_DEFINITION_EVENT :
			case NotificationEvent.THEME_EVENT :
			case NotificationEvent.LIBRARY_EVENT :
			case NotificationEvent.ELEMENT_LOCALIZE_EVENT :
			
			case NotificationEvent.PROPERTY_EVENT :
			{
				return new EditpartReportEventRunnable( focus, type, args ) {

					public void runModelChange( )
					{
						propertyChange( getFocus( ), getArgs() );
					}
				};
			}
			case NotificationEvent.LIBRARY_RELOADED_EVENT :
			{
				return new EditpartReportEventRunnable( focus, type, args ) {

					public void runModelChange( )
					{
						reloadTheChildren( );
					}
				};

			}

			default :
				break;
		}
		return null;
	}

	/**
	 * @param focus
	 * @param info
	 */
	protected void propertyChange( Object focus, Map info )
	{
		if (getViewer( )==null)
		{
			return;
		}
		Object obj = getViewer( ).getEditPartRegistry( ).get( focus );
		if ( obj instanceof ReportElementEditPart && !((ReportElementEditPart)obj).isDelete( ))
		{
			( (ReportElementEditPart) obj ).propertyChange( info );
			//return;
{'fraction_non_alphanumeric': 0.13776402529261403, 'fraction_numerical': 0.006995829409390556, 'mean_word_length': 4.095270733379027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '837289', 'n_tokens_mistral': 2567, 'n_tokens_neox': 2151, 'n_words': 478}