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

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

Introduction

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

Prototype

public CompoundComparator() 

Source Link

Document

Construct a CompoundComparator with initially no Comparators.

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//w ww .  j  a va 2 s  .com
 * @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 + "]");
    }//from w w  w  .  j  ava2 s. c om
    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()));
}