diff org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerSorter.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerSorter.d	Sat Mar 14 18:23:29 2009 +0100
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * 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:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module org.eclipse.jface.viewers.ViewerSorter;
+
+import org.eclipse.jface.viewers.ViewerComparator;
+
+import java.lang.all;
+import java.text.Collator;
+
+/**
+ * A viewer sorter is used by a {@link StructuredViewer} to reorder the elements
+ * provided by its content provider.
+ * <p>
+ * The default <code>compare</code> method compares elements using two steps.
+ * The first step uses the values returned from <code>category</code>.
+ * By default, all elements are in the same category.
+ * The second level is based on a case insensitive compare of the strings obtained
+ * from the content viewer's label provider via <code>ILabelProvider.getText</code>.
+ * </p>
+ * <p>
+ * Subclasses may implement the <code>isSorterProperty</code> method;
+ * they may reimplement the <code>category</code> method to provide
+ * categorization; and they may override the <code>compare</code> methods
+ * to provide a totally different way of sorting elements.
+ * </p>
+ * <p>
+ * It is recommended to use <code>ViewerComparator</code> instead.
+ * </p>
+ * @see IStructuredContentProvider
+ * @see StructuredViewer
+ */
+public class ViewerSorter : ViewerComparator {
+    /**
+     * The collator used to sort strings.
+     *
+     * @deprecated as of 3.3 Use {@link ViewerComparator#getComparator()}
+     */
+    protected Collator collator;
+
+    /**
+     * Creates a new viewer sorter, which uses the default collator
+     * to sort strings.
+     */
+    public this() {
+        this(Collator.getInstance());
+    }
+
+    /**
+     * Creates a new viewer sorter, which uses the given collator
+     * to sort strings.
+     *
+     * @param collator the collator to use to sort strings
+     */
+    public this(Collator collator) {
+        super(collator);
+        this.collator = collator;
+    }
+
+    /**
+     * Returns the collator used to sort strings.
+     *
+     * @return the collator used to sort strings
+     * @deprecated as of 3.3 Use {@link ViewerComparator#getComparator()}
+     */
+    public Collator getCollator() {
+        return collator;
+    }
+
+}