/***********************************************************************
 * 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.chart.ui.swt;

import java.util.List;
import java.util.Vector;

import org.eclipse.birt.chart.exception.ChartException;
import org.eclipse.birt.chart.log.ILogger;
import org.eclipse.birt.chart.log.Logger;
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.ui.i18n.Messages;
import org.eclipse.birt.chart.ui.swt.interfaces.IUIServiceProvider;

/**
 * DefaultUIServiceProviderImpl
 */
public class DefaultUIServiceProviderImpl implements IUIServiceProvider
{

	private static ILogger logger = Logger.getLogger( "org.eclipse.birt.chart.ui/swt" ); //$NON-NLS-1$

	/**
	 * 
	 */
	public DefaultUIServiceProviderImpl( )
	{
		super( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.chart.ui.swt.interfaces.IUIServiceProvider#invoke(java.lang.String)
	 */
	public String invoke( String sExpression, Object oContext, String sTitle )
	{
		logger.log( ILogger.WARNING,
				Messages.getString( "DefaultUIServiceProviderImpl.Warn.Placeholder" ) ); //$NON-NLS-1$
		return sExpression;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.chart.ui.swt.interfaces.IUIServiceProvider#invoke(java.lang.String)
	 */
	public String invoke( String sExpression, Object oContext, String sTitle,
			boolean isChartProvider )
	{
		logger.log( ILogger.WARNING,
				Messages.getString( "DefaultUIServiceProviderImpl.Warn.Placeholder" ) ); //$NON-NLS-1$
		return sExpression;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.chart.ui.swt.interfaces.IUIServiceProvider#validate(org.eclipse.birt.chart.model.Chart,
	 *      java.lang.Object)
	 */
	public String[] validate( Chart chartModel, Object oContext )
	{
		return null;
	}

	/**
	 * Fetches the list of registered keys for externalizing chart content
	 * 
	 * @return List containing available keys for externalized content
	 */
	public List getRegisteredKeys( )
	{
		List list = new Vector( );
		list.add( "SampleKey" ); //$NON-NLS-1$
		return list;
	}

	/**
	 * Fetches the value for the externalized resource identified by the
	 * specified key
	 * 
	 * @return String that represents the value for the specified resource in
	 *         the current locale
	 */
	public String getValue( String sKey )
	{
		if ( sKey.equals( "SampleKey" ) ) //$NON-NLS-1$
		{
			return "Sample Value"; //$NON-NLS-1$
		}
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.chart.ui.swt.interfaces.IUIServiceProvider#getConvertedValue(double,
	 *      java.lang.String, java.lang.String)
	 */
	public double getConvertedValue( double dOriginalValue, String sFromUnits,
			String sToUnits )
	{
		return dOriginalValue;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.chart.ui.swt.interfaces.IUIServiceProvider#invoke(int,
	 *      java.lang.String, java.lang.Object, java.lang.String)
	 */
	public String invoke( int command, String value, Object context,
			String sTitle ) throws ChartException
	{
		return value;
	}

	public boolean isInvokingSupported( )
	{
		return false;
	}
}