/*******************************************************************************
 * Copyright (c) 2009, 2015 Matthew Hall and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Matthew Hall - initial API and implementation (bug 264286)
 *******************************************************************************/

package org.eclipse.jface.internal.databinding.swt;

import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.TrayItem;
import org.eclipse.swt.widgets.TreeColumn;

/**
 * @since 3.3
 *
 */
public class WidgetTooltipTextProperty extends WidgetDelegatingValueProperty {
	private IValueProperty cTabItem;
	private IValueProperty control;
	private IValueProperty tabItem;
	private IValueProperty tableColumn;
	private IValueProperty toolItem;
	private IValueProperty trayItem;
	private IValueProperty treeColumn;

	/**
	 *
	 */
	public WidgetTooltipTextProperty() {
		super(String.class);
	}

	@Override
	protected IValueProperty doGetDelegate(Object source) {
		if (source instanceof CTabItem) {
			if (cTabItem == null)
				cTabItem = new CTabItemTooltipTextProperty();
			return cTabItem;
		}
		if (source instanceof Control) {
			if (control == null)
				control = new ControlTooltipTextProperty();
			return control;
		}
		if (source instanceof TabItem) {
			if (tabItem == null)
				tabItem = new TabItemTooltipTextProperty();
			return tabItem;
		}
		if (source instanceof TableColumn) {
			if (tableColumn == null)
				tableColumn = new TableColumnTooltipTextProperty();
			return tableColumn;
		}
		if (source instanceof ToolItem) {
			if (toolItem == null)
				toolItem = new ToolItemTooltipTextProperty();
			return toolItem;
		}
		if (source instanceof TrayItem) {
			if (trayItem == null)
				trayItem = new TrayItemTooltipTextProperty();
			return trayItem;
		}
		if (source instanceof TreeColumn) {
			if (treeColumn == null)
				treeColumn = new TreeColumnTooltipTextProperty();
			return treeColumn;
		}
		throw notSupported(source);
	}
}