use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getObjectTypes.
/**
* @return Returns a list of object types to allow the user to select from
*/
public List<SelectItem> getObjectTypes() {
if ((this.objectTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext context = FacesContext.getCurrentInstance();
// add the well known object type to start with
this.objectTypes = new ArrayList<SelectItem>(5);
// add any configured content or folder sub-types to the list
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement typesCfg = wizardCfg.getConfigElement("specialise-types");
if (typesCfg != null) {
for (ConfigElement child : typesCfg.getChildren()) {
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
// the content or folder type itself
if (typeDef != null && typeDef.getName().equals(ContentModel.TYPE_CONTENT) == false && typeDef.getName().equals(ContentModel.TYPE_FOLDER) == false && (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_CONTENT) || this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER))) {
// try and 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) {
label = typeDef.getTitle(this.getDictionaryService());
}
// finally, just use the localname
if (label == null) {
label = idQName.getLocalName();
}
this.objectTypes.add(new SelectItem(idQName.toString(), label));
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
// add the select an action item at the start of the list
this.objectTypes.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_type")));
} else {
logger.warn("Could not find 'specialise-types' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.objectTypes;
}
use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getRemovableAspects.
/**
* Returns a list of aspects that can be removed
*
* @return List of SelectItem objects representing the aspects that can be removed
*/
public List<SelectItem> getRemovableAspects() {
if ((this.removableAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
// get the list of common aspects
this.removableAspects = new ArrayList<SelectItem>();
this.removableAspects.addAll(getCommonAspects());
// get those aspects configured to appear only in the remove aspect action
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-remove");
if (aspectsCfg != null) {
List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
this.removableAspects.addAll(aspects);
} else {
logger.warn("Could not find 'aspects-remove' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.removableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
return this.removableAspects;
}
use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getTransformers.
/**
* Returns the transformers that are available
*
* @return List of SelectItem objects representing the available transformers
*/
public List<SelectItem> getTransformers() {
if ((this.transformers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement transformersCfg = wizardCfg.getConfigElement("transformers");
if (transformersCfg != null) {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> mimeTypes = this.getMimetypeService().getDisplaysByMimetype();
this.transformers = new ArrayList<SelectItem>();
for (ConfigElement child : transformersCfg.getChildren()) {
String id = child.getAttribute("name");
// try and get the display label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label get it from the mime type service
if (label == null) {
label = mimeTypes.get(id);
}
// if there is still no label use the raw mimetype
if (label == null) {
label = id;
}
this.transformers.add(new SelectItem(id, label));
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.transformers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
} else {
logger.warn("Could not find 'transformers' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.transformers;
}
use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class UIStoreSelector method createList.
/**
* @return List of SelectItem components
*/
protected List<SelectItem> createList() {
List<SelectItem> items = new ArrayList<SelectItem>(5);
Constraint storesConstraint = ConstraintRegistry.getInstance().getConstraint("defaultStoreSelector");
for (String store : ((ListOfValuesConstraint) storesConstraint).getAllowedValues()) {
items.add(new SelectItem(store, store));
}
// make sure the list is sorted by the values
QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return items;
}
use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class BaseInviteUsersWizard method getEmailTemplates.
/**
* @return Returns the list of email templates for user notification
*/
public List<SelectItem> getEmailTemplates() {
List<SelectItem> wrappers = null;
try {
FacesContext fc = FacesContext.getCurrentInstance();
NodeRef rootNodeRef = this.getNodeService().getRootNode(Repository.getStoreRef());
NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
List<NodeRef> results = this.getSearchService().selectNodes(rootNodeRef, getEmailTemplateXPath(), null, resolver, false);
wrappers = new ArrayList<SelectItem>(results.size() + 1);
if (results.size() != 0) {
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
for (NodeRef ref : results) {
if (this.getNodeService().exists(ref) == true) {
Node childNode = new Node(ref);
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT)) {
wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
}
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(wrappers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
} catch (AccessDeniedException accessErr) {
// ignore the result if we cannot access the root
}
// add an entry (at the start) to instruct the user to select an item
if (wrappers == null) {
wrappers = new ArrayList<SelectItem>(1);
}
wrappers.add(0, new SelectItem("none", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
return wrappers;
}
Aggregations