/*******************************************************************************
 * Caleydo - Visualization for Molecular Biology - http://caleydo.org
 * Copyright (c) The Caleydo Team. All rights reserved.
 * Licensed under the new BSD license, available at http://caleydo.org/license
 *******************************************************************************/
package org.caleydo.core.util.base;

import java.util.Comparator;

import org.eclipse.jface.viewers.LabelProvider;

import com.google.common.base.Function;

/**
 * function utilities for labels
 *
 * @author Samuel Gratzl
 *
 */
public class Labels {
	/**
	 * comparator by case insensitivve label
	 */
	public static final Comparator<ILabelProvider> BY_LABEL = new Comparator<ILabelProvider>() {
		@Override
		public int compare(ILabelProvider dd1, ILabelProvider dd2) {
			return String.CASE_INSENSITIVE_ORDER.compare(dd1.getLabel(), dd2.getLabel());
		}
	};

	/**
	 * function to map to label
	 */
	public static final Function<ILabelProvider, String> TO_LABEL = new Function<ILabelProvider, String>() {
		@Override
		public String apply(ILabelProvider arg0) {
			return arg0 == null ? null : arg0.getLabel();
		}
	};

	/**
	 * swt label provider
	 */
	public static final LabelProvider PROVIDER = new LabelProvider() {
		@Override
		public String getText(Object element) {
			if (element instanceof ILabeled) {
				return ((ILabeled) element).getLabel();
			}
			return super.getText(element);
		}
	};
}

@@ -702,24 +702,18 @@
 r%3CILabel
-Provider
+ed
 %3E BY_LAB
@@ -738,24 +738,18 @@
 r%3CILabel
-Provider
+ed
 %3E() %7B%0A%09%09
@@ -785,24 +785,18 @@
 e(ILabel
-Provider
+ed
  dd1, IL
@@ -799,24 +799,18 @@
 , ILabel
-Provider
+ed
  dd2) %7B%0A
@@ -970,32 +970,26 @@
 ction%3CILabel
-Provider
+ed
 , String%3E TO
@@ -1016,24 +1016,18 @@
 n%3CILabel
-Provider
+ed
 , String
@@ -1072,24 +1072,18 @@
 y(ILabel
-Provider
+ed
  arg0) %7B

generalize Labels.