Example usage for org.springframework.util.comparator CompoundComparator addComparator

List of usage examples for org.springframework.util.comparator CompoundComparator addComparator

Introduction

In this page you can find the example usage for org.springframework.util.comparator CompoundComparator addComparator.

Prototype

@SuppressWarnings("unchecked")
public void addComparator(Comparator<? extends T> comparator) 

Source Link

Document

Add a Comparator to the end of the chain.

Usage

From source file:org.alfresco.web.ui.wcm.component.UIDeployWebsite.java

/**
 * Utility method to read the details of the deployment nodes
 * @param nodeService the node service/*  ww w. jav a 2s  .  c o  m*/
 * @param refs a list of NodeRefs
 * 
 * @return a sorted list of DeploymentServerConfig objects.
 */
@SuppressWarnings("unchecked")
private List<DeploymentServerConfig> toSortedDeploymentServerConfig(NodeService nodeService,
        List<NodeRef> refs) {
    // Resolve the list of NodeRef to a list of DeploymentServerConfig.
    List<DeploymentServerConfig> servers = new ArrayList<DeploymentServerConfig>();
    for (NodeRef ref : refs) {
        DeploymentServerConfig server = new DeploymentServerConfig(ref, nodeService.getProperties(ref));
        servers.add(server);
    }

    // Sort the deployment servers by display group then display name      
    CompoundComparator comp = new CompoundComparator();
    comp.addComparator(new DeploymentServerConfigComparator(DeploymentServerConfig.PROP_GROUP));
    comp.addComparator(new DeploymentServerConfigComparator(DeploymentServerConfig.PROP_NAME));
    Collections.sort(servers, comp);

    return servers;
}

From source file:org.springframework.richclient.factory.DefaultComponentFactory.java

public void configureForEnum(JComboBox comboBox, Class enumType) {
    Collection enumValues = getEnumResolver().getLabeledEnumSet(enumType);
    if (logger.isDebugEnabled()) {
        logger.debug("Populating combo box model with enums of type '" + enumType.getName() + "'; enums are ["
                + enumValues + "]");
    }//w  w  w  .  ja v  a 2  s  . c  o m
    CompoundComparator comparator = new CompoundComparator();
    comparator.addComparator(LabeledEnum.LABEL_ORDER);
    comparator.addComparator(new ComparableComparator());
    comboBox.setModel(new ComboBoxListModel(new ArrayList(enumValues), comparator));
    comboBox.setRenderer(new LabeledEnumListRenderer(messageSource));
    comboBox.setEditor(new LabeledEnumComboBoxEditor(messageSource, comboBox.getEditor()));
}