<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.item.crosstab.ui.views.attributes.widget;

import java.util.Arrays;

import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.PropertyDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.SimpleComboPropertyDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.widget.SimpleComboPropertyDescriptor;
import org.eclipse.birt.report.item.crosstab.ui.views.attributes.provider.CrosstabSimpleComboPropertyDescriptorProvider;

/**
 * @author Administrator
 * 
 */
public class CrosstabSimpleComboPropertyDescriptor extends
		SimpleComboPropertyDescriptor {

	public CrosstabSimpleComboPropertyDescriptor(boolean formStyle) {
		super(formStyle);
	}

	protected void refresh(String value) {
		if (getDescriptorProvider() instanceof CrosstabSimpleComboPropertyDescriptorProvider) {

				String[] items = ( (CrosstabSimpleComboPropertyDescriptorProvider) getDescriptorProvider( ) ).getItems( );
				combo.setItems( items );
				boolean stateFlag = ( ( value == null ) == combo.getEnabled( ) );
				if ( stateFlag )
					combo.setEnabled( value != null );

				if ( ( (PropertyDescriptorProvider) getDescriptorProvider( ) ).isReadOnly( ) )
				{
					combo.setEnabled( false );
				}

				int sindex = Arrays.asList( items ).indexOf( oldValue );<commit_msg>Overwrite the createControl method in the CrosstabSimpeComboPropertyDescriptor.<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.item.crosstab.ui.views.attributes.widget;

import java.util.Arrays;

import org.eclipse.birt.report.designer.internal.ui.swt.custom.FormWidgetFactory;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.PropertyDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.SimpleComboPropertyDescriptorProvider;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.widget.SimpleComboPropertyDescriptor;
import org.eclipse.birt.report.item.crosstab.ui.views.attributes.provider.CrosstabSimpleComboPropertyDescriptorProvider;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

/**
 * @author Administrator
 * 
 */
public class CrosstabSimpleComboPropertyDescriptor extends
		SimpleComboPropertyDescriptor {

	public CrosstabSimpleComboPropertyDescriptor(boolean formStyle) {
		super(formStyle);
	}

	public Control createControl( Composite parent )
	{
		if ( isFormStyle( ) )
		{
			combo = FormWidgetFactory.getInstance( ).createCCombo( parent, false );
		}
		else
		{
			combo = new CCombo( parent, getStyle() );
			combo.setVisibleItemCount( 30 );
		}
		combo.addControlListener( new ControlListener( ) {

			public void controlMoved( ControlEvent e )
			{
				combo.clearSelection( );
			}

			public void controlResized( ControlEvent e )
			{
				combo.clearSelection( );
			}
		} );
		combo.addSelectionListener( new SelectionListener( ) {

			public void widgetSelected( SelectionEvent e )
			{
				handleComboSelectEvent( );
			}

			public void widgetDefaultSelected( SelectionEvent e )
			{
				handleComboSelectEvent( );
			}
		} );
		return combo;
	}
	
	protected void refresh(String value) {
		if (getDescriptorProvider() instanceof CrosstabSimpleComboPropertyDescriptorProvider) {

				String[] items = ( (CrosstabSimpleComboPropertyDescriptorProvider) getDescriptorProvider( ) ).getItems( );
				combo.setItems( items );
				boolean stateFlag = ( ( value == null ) == combo.getEnabled( ) );
				if ( stateFlag )
					combo.setEnabled( value != null );

				if ( ( (PropertyDescriptorProvider) getDescriptorProvider( ) ).isReadOnly( ) )
				{
					combo.setEnabled( false );
				}
				
				combo.setEditable( ( (SimpleComboPropertyDescriptorProvider) getDescriptorProvider( ) ).isEditable( ) );

				int sindex = Arrays.asList( items ).indexOf( oldValue );
{'fraction_non_alphanumeric': 0.15476649942107296, 'fraction_numerical': 0.0034735623311462757, 'mean_word_length': 4.984988452655889, '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': '147125', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1382, 'n_words': 284}