use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class UIMimeTypeSelector method createList.
/**
* Creates the list of SelectItem components to represent the list
* of MIME types the user can select from
*
* @return List of SelectItem components
*/
protected List<SelectItem> createList() {
List<SelectItem> items = new ArrayList<SelectItem>(80);
ServiceRegistry registry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
MimetypeService mimetypeService = registry.getMimetypeService();
// get the mime type display names
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
for (String mimeType : mimeTypes.keySet()) {
items.add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
}
// 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 UINavigator method encodeBegin.
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
if (!isRendered())
return;
// TODO: pull width and height from user preferences and/or the main config,
// if present override below using the style attribute
ResponseWriter out = context.getResponseWriter();
NavigationBean navBean = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
NavigatorPluginBean navPluginBean = (NavigatorPluginBean) FacesHelper.getManagedBean(context, NavigatorPluginBean.BEAN_NAME);
List<TreeNode> rootNodesForArea = null;
String area = this.getActiveArea();
String areaTitle = null;
boolean treePanel = true;
if (NavigationBean.LOCATION_COMPANY.equals(area)) {
rootNodesForArea = navPluginBean.getCompanyHomeRootNodes();
areaTitle = Application.getMessage(context, NavigationBean.MSG_COMPANYHOME);
} else if (NavigationBean.LOCATION_HOME.equals(area)) {
rootNodesForArea = navPluginBean.getMyHomeRootNodes();
areaTitle = Application.getMessage(context, NavigationBean.MSG_MYHOME);
} else if (NavigationBean.LOCATION_GUEST.equals(area)) {
rootNodesForArea = navPluginBean.getGuestHomeRootNodes();
areaTitle = Application.getMessage(context, NavigationBean.MSG_GUESTHOME);
} else {
treePanel = false;
areaTitle = Application.getMessage(context, NavigationBean.MSG_MYALFRESCO);
}
// order the root nodes by the tree label
if (rootNodesForArea != null && rootNodesForArea.size() > 1) {
QuickSort sorter = new QuickSort(rootNodesForArea, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
// main container div
out.write("<div id=\"navigator\" class=\"navigator\">");
// generate the active panel title
String cxPath = context.getExternalContext().getRequestContextPath();
out.write("<div class=\"sidebarButtonSelected\" style=\"background-image: url(" + cxPath + "/images/parts/navigator_blue_gradient_bg.gif)\">");
out.write("<a class='sidebarButtonSelectedLink' onclick=\"");
out.write(Utils.generateFormSubmit(context, this, getClientId(context), PANEL_ACTION + area));
out.write("\" href=\"#\">");
out.write(Utils.encode(areaTitle));
out.write("</a></div>");
// generate the javascript method to capture the tree node click events
if (treePanel) {
out.write("<script type=\"text/javascript\">");
out.write("function treeNodeSelected(nodeRef) {");
out.write(Utils.generateFormSubmit(context, this, getClientId(context), "nodeRef", true, null));
out.write("}</script>");
// generate the active panel containing the tree
out.write("<div class=\"navigatorPanelBody\">");
UITree tree = (UITree) context.getApplication().createComponent(UITree.COMPONENT_TYPE);
tree.setId("tree");
tree.setRootNodes(rootNodesForArea);
tree.setRetrieveChildrenUrl(AJAX_URL_START + ".retrieveChildren?area=" + area);
tree.setNodeCollapsedUrl(AJAX_URL_START + ".nodeCollapsed?area=" + area);
tree.setNodeSelectedCallback("treeNodeSelected");
tree.setNodeCollapsedCallback("informOfCollapse");
Utils.encodeRecursive(context, tree);
out.write("</div>");
}
// generate the closed panel title areas
String sideBarStyle = "style=\"background-image: url(" + cxPath + "/images/parts/navigator_grey_gradient_bg.gif)\"";
if (NavigationBean.LOCATION_COMPANY.equals(area) == false && navBean.getCompanyHomeVisible()) {
encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_COMPANY, NavigationBean.MSG_COMPANYHOME);
}
if (NavigationBean.LOCATION_HOME.equals(area) == false) {
encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_HOME, NavigationBean.MSG_MYHOME);
}
if (NavigationBean.LOCATION_GUEST.equals(area) == false && navBean.getIsGuest() == false && navBean.getGuestHomeVisible()) {
encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_GUEST, NavigationBean.MSG_GUESTHOME);
}
if (NavigationBean.LOCATION_MYALFRESCO.equals(area) == false) {
encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_MYALFRESCO, NavigationBean.MSG_MYALFRESCO);
}
out.write("</div>");
}
use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class UICategoryBrowser method encodeBegin.
/*
* (non-Javadoc)
*
* @see org.alfresco.web.ui.repo.component.UINavigator#encodeBegin(javax.faces.context.FacesContext)
*/
@Override
public void encodeBegin(FacesContext context) throws IOException {
if (!isRendered())
return;
// TODO: pull width and height from user preferences and/or the main config,
// if present override below using the style attribute
ResponseWriter out = context.getResponseWriter();
CategoryBrowserPluginBean categoryBrowserPluginBean = (CategoryBrowserPluginBean) FacesHelper.getManagedBean(context, CategoryBrowserPluginBean.BEAN_NAME);
CategoryBrowserBean categoryBrowserBean = (CategoryBrowserBean) FacesHelper.getManagedBean(context, CategoryBrowserBean.BEAN_NAME);
List<TreeNode> rootNodes = null;
rootNodes = categoryBrowserPluginBean.getCategoryRootNodes();
// order the root nodes by the tree label
if (rootNodes != null && rootNodes.size() > 1) {
QuickSort sorter = new QuickSort(rootNodes, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
// main container div
out.write("<div id=\"category-navigator\" class=\"navigator\">");
// Subcategories parameter
String includeSub = Application.getMessage(context, "category_browser_plugin_include_subcategories");
out.write("<input type='checkbox' id='" + SUBCATEGORIES_PARAM + "' name='" + SUBCATEGORIES_PARAM + "' value=1 " + (categoryBrowserBean.isIncludeSubcategories() ? "checked" : "") + "/>");
out.write("<label for='" + SUBCATEGORIES_PARAM + "'>" + includeSub + "</label>");
// generate the javascript method to capture the tree node click events
out.write("<script type=\"text/javascript\">");
out.write("function treeNodeSelected(nodeRef) {");
out.write(Utils.generateFormSubmit(context, this, getClientId(context), "nodeRef", true, null));
out.write("}</script>");
// generate the active panel containing the tree
out.write("<div class=\"navigatorPanelBody\">");
UITree tree = (UITree) context.getApplication().createComponent(UITree.COMPONENT_TYPE);
tree.setId("tree");
tree.setRootNodes(rootNodes);
tree.setRetrieveChildrenUrl(AJAX_URL_START + ".retrieveChildren?");
tree.setNodeCollapsedUrl(AJAX_URL_START + ".nodeCollapsed?");
tree.setNodeSelectedCallback("treeNodeSelected");
tree.setNodeCollapsedCallback("informOfCollapse");
Utils.encodeRecursive(context, tree);
out.write("</div>");
out.write("</div>");
}
use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class AdvancedSearchDialog method getContentFormats.
/**
* @return Returns a list of content formats to allow the user to select from
*/
public List<SelectItem> getContentFormats() {
if ((properties.getContentFormats() == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
properties.setContentFormats(new ArrayList<SelectItem>(80));
ServiceRegistry registry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
MimetypeService mimetypeService = registry.getMimetypeService();
// get the mime type display names
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
for (String mimeType : mimeTypes.keySet()) {
properties.getContentFormats().add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
}
// make sure the list is sorted by the values
QuickSort sorter = new QuickSort(properties.getContentFormats(), "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
// add the "All Formats" constant marker at the top of the list (default selection)
properties.getContentFormats().add(0, new SelectItem("", Application.getMessage(FacesContext.getCurrentInstance(), MSG_ALL_FORMATS)));
}
return properties.getContentFormats();
}
use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.
the class AdvancedSearchDialog method getSavedSearches.
/**
* @return list of saved searches as SelectItem objects
*/
public List<SelectItem> getSavedSearches() {
List<SelectItem> savedSearches = properties.getCachedSavedSearches().get();
if (savedSearches == null) {
FacesContext fc = FacesContext.getCurrentInstance();
ServiceRegistry services = Repository.getServiceRegistry(fc);
// get the searches list from the current user or global searches location
NodeRef searchesRef = null;
if (SAVED_SEARCHES_USER.equals(properties.getSavedSearchMode()) == true) {
searchesRef = getUserSearchesRef();
} else if (SAVED_SEARCHES_GLOBAL.equals(properties.getSavedSearchMode()) == true) {
searchesRef = getGlobalSearchesRef();
}
// read the content nodes under the folder
if (searchesRef != null) {
DictionaryService dd = services.getDictionaryService();
List<ChildAssociationRef> childRefs = getNodeService().getChildAssocs(searchesRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
savedSearches = new ArrayList<SelectItem>(childRefs.size() + 1);
if (childRefs.size() != 0) {
for (ChildAssociationRef ref : childRefs) {
Node childNode = new Node(ref.getChildRef());
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT)) {
savedSearches.add(new SelectItem(childNode.getId(), childNode.getName()));
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(savedSearches, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
} else {
// handle missing/access denied folder case
savedSearches = new ArrayList<SelectItem>(1);
}
// add an entry (at the start) to instruct the user to select a saved search
savedSearches.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), MSG_SELECT_SAVED_SEARCH)));
// store in the cache (will auto-expire)
properties.getCachedSavedSearches().put(savedSearches);
}
return savedSearches;
}
Aggregations