Index: presentation/tool/src/java/org/theospi/portfolio/presentation/control/AddPresentationController.java =================================================================== --- presentation/tool/src/java/org/theospi/portfolio/presentation/control/AddPresentationController.java (revision 992) +++ presentation/tool/src/java/org/theospi/portfolio/presentation/control/AddPresentationController.java (revision 993) @@ -45,8 +45,10 @@ import org.sakaiproject.metaobj.shared.mgt.AgentManager; import org.sakaiproject.metaobj.shared.mgt.HomeFactory; import org.sakaiproject.metaobj.shared.mgt.IdManager; +import org.sakaiproject.metaobj.shared.model.ContentResourceArtifact; import org.sakaiproject.metaobj.shared.model.Agent; import org.sakaiproject.metaobj.shared.model.Id; +import org.sakaiproject.metaobj.shared.model.Artifact; import org.sakaiproject.metaobj.utils.Config; import org.sakaiproject.metaobj.utils.mvc.impl.servlet.ServletRequestBeanDataBinder; import org.sakaiproject.metaobj.utils.mvc.intf.ListScroll; @@ -78,6 +80,7 @@ import org.theospi.portfolio.presentation.model.PresentationItem; import org.theospi.portfolio.presentation.model.PresentationItemDefinition; import org.theospi.portfolio.presentation.model.PresentationTemplate; +import org.theospi.portfolio.wizard.model.CompletedWizard; import org.theospi.portfolio.security.AudienceSelectionHelper; import org.theospi.portfolio.security.AuthorizationFacade; import org.theospi.portfolio.shared.model.Node; @@ -283,7 +286,23 @@ if (artifactCache.containsKey(itemDef.getType()) && !itemDef.getHasMimeTypes()){ artifacts.put(itemDef.getId().getValue(), artifactCache.get(itemDef.getType())); } else { - Collection itemArtifacts = getPresentationManager().loadArtifactsForItemDef(itemDef, agent); + List itemArtifacts = (List) getPresentationManager().loadArtifactsForItemDef(itemDef, agent); + // For content, we have an artifact created just for this list, + // so it's safe to change the display name. + // Add the folder, but because the column is very narrow, + // abbreviate the name. + if (itemArtifacts.size() > 0 && itemArtifacts.get(0) instanceof ContentResourceArtifact) { + // don't do this for forms, as their display name is OK as is + if (! ((ContentResourceArtifact)itemArtifacts.get(0)).getBase().getResourceType().startsWith("org.sakaiproject.metaobj.")) + for (ContentResourceArtifact art: (List)itemArtifacts) + art.setDisplayName(abbrev(art.getBase().getContainingCollection().getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME)) + "/" + art.getDisplayName()); + } + // now sort; we can sort anything, because all artifacts have a displayname + // but we have a special sort for artifacts that includes date + if (itemArtifacts.size() > 0 && itemArtifacts.get(0) instanceof CompletedWizard) + Collections.sort((List)itemArtifacts, new SortWizards()); + else + Collections.sort((List)itemArtifacts, new SortArtifacts()); if (!itemDef.getHasMimeTypes()) { // cache only full list @@ -310,6 +329,33 @@ return model; } + protected String abbrev(String s) { + int len = s.length(); + if (len > 12) + return s.substring(0,5) + ".." + s.substring(len-5,len); + else + return s; + } + + + protected class SortArtifacts implements Comparator { + public int compare(Artifact o1,Artifact o2) { + return o1.getDisplayName().compareTo(o2.getDisplayName()); + } + } + + // this may happen only in testing, but I have sites with + // a number of wizards of the same name. Sort them by date + // so I have a chance to guessing which to use. + protected class SortWizards implements Comparator { + public int compare(CompletedWizard o1,CompletedWizard o2) { + if (o1.getDisplayName().equals(o2.getDisplayName())) { + return o1.getCreated().compareTo(o2.getCreated()); + } else + return o1.getDisplayName().compareTo(o2.getDisplayName()); + } + } + protected void setupSessionInfoForPropertyForm(HttpSession session, String presentationTitle, String formTypeId, String currentFormId) { Index: presentation/tool/src/webapp/WEB-INF/jsp/presentation/addPresentation2.jsp =================================================================== --- presentation/tool/src/webapp/WEB-INF/jsp/presentation/addPresentation2.jsp (revision 992) +++ presentation/tool/src/webapp/WEB-INF/jsp/presentation/addPresentation2.jsp (revision 993) @@ -103,15 +103,16 @@

- "> +
"> - -
+ +