Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "ICU4J"

(Replacement Plug-in)
(Effect on JFace - ViewerSorter and StructuredViewer)
Line 1: Line 1:
 
ICU4J is a set of Java libraries that provides more comprehensive support for Unicode, software globalization, and internationalization.  In order to provide this functionality to the Eclipse community, ICU4J was added to the Eclipse platform build in 3.2.  You will see it in the build as a plugin named com.ibm.icu.
 
ICU4J is a set of Java libraries that provides more comprehensive support for Unicode, software globalization, and internationalization.  In order to provide this functionality to the Eclipse community, ICU4J was added to the Eclipse platform build in 3.2.  You will see it in the build as a plugin named com.ibm.icu.
 
==Effect on JFace - ViewerSorter and StructuredViewer==
 
In order to support ICU4J in JFace, some creative API additions were made without actually referencing classes in the ICU4J plug-in in the API.  This resulted in the addition of:
 
 
1. a new class called org.eclipse.jface.viewers.ViewerComparator, of which org.eclipse.jface.viewers.Viewer Sorter is now a subclass
 
 
2. two new methods to StructuredViewer, to support the addition of the ViewerComparator class
 
 
 
<strong>Rationale</strong>
 
 
The ViewerSorter class has a public method getCollator() that returns a java.text.Collator.  Since this method is API it could not simply be changed to use an ICU Collator.  Also, ICU classes cannot be part of the API (signatures) as a direct plug-in dependency on ICU would prevent JFace from being used standalone (with SWT).  To accomodate these constraints, the ViewerComparator class that uses a java.util.Comparator, rather than an ICU Collator, was added.  This was done because ICU's Collator class implements java.util.Comparator, so StructuredViewers now have the option to use ICU's Collator rather than the java.text.Collator, but JFace doesn't have to add a dependency on the ICU4J plug-in. 
 
 
The two new methods added to StructuredViewer support using ICU's Collator to sort the contents of the Viewer via a ViewerComparator, rather than a ViewerSorter.  It is recommended that StructuredViewers now use these methods to get/set the viewer's sorter, instead of the getSorter() and setSorter(ViewerSorter) methods.
 
<pre>
 
/**
 
* Return this viewer's comparator used to sort elements.
 
* This method should be used instead of <code>getSorter()</code>.
 
*
 
* @return a viewer comparator, or <code>null</code> if none
 
*
 
* @since 3.2
 
*/
 
public ViewerComparator getComparator()
 
 
/**
 
* Sets this viewer's comparator to be used for sorting elements, and triggers refiltering and
 
* resorting of this viewer's element.  <code>null</code> turns sorting off.
 
* To get the viewer's comparator, call <code>getComparator()</code>.
 
* <p>
 
* IMPORTANT: This method was introduced in 3.2. If a reference to this viewer object
 
* is passed to clients who call <code>getSorter()<code>, null may be returned from
 
* from that method even though the viewer is sorting its elements using the
 
* viewer's comparator.
 
* </p>
 
*
 
* @param comparator a viewer comparator, or <code>null</code> if none
 
*
 
* @since 3.2
 
*/
 
public void setComparator(ViewerComparator comparator)
 
</pre>
 
  
 
==ICU4J Usage in Eclipse==
 
==ICU4J Usage in Eclipse==

Revision as of 04:03, 27 November 2020

ICU4J is a set of Java libraries that provides more comprehensive support for Unicode, software globalization, and internationalization. In order to provide this functionality to the Eclipse community, ICU4J was added to the Eclipse platform build in 3.2. You will see it in the build as a plugin named com.ibm.icu.

ICU4J Usage in Eclipse

Link to a table that lists all the plugins in the Eclipse SDK that have a dependency on ICU4J.

More Info

For more information about ICU4J visit the official home page:

http://www.icu-project.org/

Back to the top