Search in sources :

Example 26 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class StartWorkflowWizard method getStartableWorkflows.

/**
 * Returns a list of workflows that can be started.
 *
 * @return List of SelectItem objects representing the workflows
 */
public List<SelectItem> getStartableWorkflows() {
    if (availableWorkflows == null) {
        initializeWorkflows();
    }
    // Alphabetical list sorting
    // Fix bug reported in https://issues.alfresco.com/browse/ETWOTWO-302
    QuickSort sorter = new QuickSort(availableWorkflows, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
    sorter.sort();
    // select the first workflow in the list
    if (this.availableWorkflows.size() > 0 && previouslySelectedWorkflow == null) {
        this.selectedWorkflow = (String) this.availableWorkflows.get(0).getValue();
    }
    return availableWorkflows;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort)

Example 27 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class CreateRuleWizard method getMimeTypes.

/**
 * Returns a list of mime types in the system
 *
 * @return List of mime types
 */
public List<SelectItem> getMimeTypes() {
    if (this.mimeTypes == null) {
        this.mimeTypes = new ArrayList<SelectItem>(50);
        Map<String, String> mimeTypes = getMimetypeService().getDisplaysByMimetype();
        for (String mimeType : mimeTypes.keySet()) {
            this.mimeTypes.add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
        }
        // make sure the list is sorted by the values
        QuickSort sorter = new QuickSort(this.mimeTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    return this.mimeTypes;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) SelectItem(javax.faces.model.SelectItem)

Example 28 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class CreateRuleWizard method getConditions.

/**
 * @return Returns the list of selectable conditions
 */
public List<SelectItem> getConditions() {
    if (this.conditions == null) {
        List<ActionConditionDefinition> ruleConditions = this.getActionService().getActionConditionDefinitions();
        this.conditions = new ArrayList<SelectItem>(ruleConditions.size());
        for (ActionConditionDefinition ruleConditionDef : ruleConditions) {
            // add to SelectItem list
            this.conditions.add(new SelectItem(ruleConditionDef.getName(), ruleConditionDef.getTitle()));
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.conditions, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
        // add the "Select a condition" entry at the beginning of the list
        this.conditions.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_condition")));
    }
    return this.conditions;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) SelectItem(javax.faces.model.SelectItem) ActionConditionDefinition(org.alfresco.service.cmr.action.ActionConditionDefinition)

Example 29 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class CreateRuleWizard method getModelTypes.

/**
 * Returns a list of the types available in the repository
 *
 * @return List of SelectItem objects
 */
public List<SelectItem> getModelTypes() {
    if ((this.modelTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        FacesContext context = FacesContext.getCurrentInstance();
        ConfigService svc = Application.getConfigService(context);
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement typesCfg = wizardCfg.getConfigElement("subtypes");
            if (typesCfg != null) {
                this.modelTypes = new ArrayList<SelectItem>();
                for (ConfigElement child : typesCfg.getChildren()) {
                    QName idQName = Repository.resolveToQName(child.getAttribute("name"));
                    // get the display label from config
                    String label = Utils.getDisplayLabel(context, child);
                    // if there wasn't a client based label try and get it from the dictionary
                    if (label == null) {
                        TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
                        if (typeDef != null) {
                            label = typeDef.getTitle(this.getDictionaryService());
                        } else {
                            label = idQName.getLocalName();
                        }
                    }
                    this.modelTypes.add(new SelectItem(idQName.toString(), label));
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.modelTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
            } else {
                logger.warn("Could not find 'subtypes' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.modelTypes;
}
Also used : FacesContext(javax.faces.context.FacesContext) QuickSort(org.alfresco.web.data.QuickSort) ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config) SelectItem(javax.faces.model.SelectItem) QName(org.alfresco.service.namespace.QName) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 30 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class YahooTreeRenderer method generateNode.

/**
 * Generates the JavaScript required to create the branch of a tree from
 * the given node.
 *
 * @param node The node to generate
 * @param out Response writer
 * @param parentVarName Name of the parent variable, null if the node has no parent
 */
protected void generateNode(TreeNode node, ResponseWriter out, String parentVarName) throws IOException {
    String currentVarName = getNextVarName();
    // generate the Javascript to create the given node using the
    // appropriate parent variable
    out.write("      var ");
    out.write(currentVarName);
    out.write(" = createYahooTreeNode(");
    if (node.getParent() == null) {
        out.write("root");
    } else {
        out.write(parentVarName);
    }
    out.write(", \"");
    out.write(node.getNodeRef());
    out.write("\", \"");
    out.write(node.getName());
    out.write("\", \"");
    out.write(node.getIcon());
    out.write("\", ");
    out.write(Boolean.toString(node.isExpanded()));
    out.write(", ");
    out.write(Boolean.toString(node.isSelected()));
    out.write(");\n");
    // iterate through the child nodes and generate them
    if (node.isExpanded() && node.getChildren().size() > 0) {
        // order the children
        List<TreeNode> children = node.getChildren();
        if (children.size() > 1) {
            QuickSort sorter = new QuickSort(children, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
            sorter.sort();
        }
        for (TreeNode child : children) {
            generateNode(child, out, currentVarName);
        }
    }
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) TreeNode(org.alfresco.web.ui.repo.component.UITree.TreeNode)

Aggregations

QuickSort (org.alfresco.web.data.QuickSort)30 SelectItem (javax.faces.model.SelectItem)22 FacesContext (javax.faces.context.FacesContext)11 Config (org.springframework.extensions.config.Config)9 ConfigElement (org.springframework.extensions.config.ConfigElement)9 ConfigService (org.springframework.extensions.config.ConfigService)9 NodeRef (org.alfresco.service.cmr.repository.NodeRef)8 Node (org.alfresco.web.bean.repository.Node)6 ArrayList (java.util.ArrayList)5 QName (org.alfresco.service.namespace.QName)5 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)5 ResponseWriter (javax.faces.context.ResponseWriter)4 ServiceRegistry (org.alfresco.service.ServiceRegistry)4 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)4 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)4 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)4 IOException (java.io.IOException)3 UserTransaction (javax.transaction.UserTransaction)3 MimetypeService (org.alfresco.service.cmr.repository.MimetypeService)3 HashMap (java.util.HashMap)2