Nicht sichtbare Kategorien (Category#setVisible(false)) werden jetzt nur noch angezeigt, wenn sie explizit aufgerufen werden.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2173 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
4edddb7faa
commit
d29291bd87
|
|
@ -15,10 +15,8 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.navigation.ui.category;
|
package com.arsdigita.navigation.ui.category;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.navigation.ui.CategoryComponent;
|
import com.arsdigita.navigation.ui.CategoryComponent;
|
||||||
import com.arsdigita.navigation.Navigation;
|
import com.arsdigita.navigation.Navigation;
|
||||||
|
|
||||||
|
|
@ -87,8 +85,7 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
children.put(parentID, childList);
|
children.put(parentID, childList);
|
||||||
}
|
}
|
||||||
|
|
||||||
childList.add(new CategorySortKeyPair
|
childList.add(new CategorySortKeyPair(category,
|
||||||
(category,
|
|
||||||
(BigDecimal) cats.get("parents.link.sortKey"),
|
(BigDecimal) cats.get("parents.link.sortKey"),
|
||||||
isDefault.booleanValue()));
|
isDefault.booleanValue()));
|
||||||
|
|
||||||
|
|
@ -107,7 +104,6 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* implementations may override this method to change the parent associated with the current category
|
* implementations may override this method to change the parent associated with the current category
|
||||||
* enabling categories to be skipped without breaking the tree
|
* enabling categories to be skipped without breaking the tree
|
||||||
|
|
@ -119,7 +115,6 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
return (BigDecimal) cats.get("parents.id");
|
return (BigDecimal) cats.get("parents.id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Element generateNodeXML(HttpServletRequest request,
|
protected Element generateNodeXML(HttpServletRequest request,
|
||||||
HttpServletResponse response,
|
HttpServletResponse response,
|
||||||
Category cat,
|
Category cat,
|
||||||
|
|
@ -129,9 +124,14 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
String path,
|
String path,
|
||||||
List idPath) {
|
List idPath) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!cat.isEnabled()) {
|
if (!cat.isEnabled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
s_log.debug("generating node XML for category " + cat.getName());
|
s_log.debug("generating node XML for category " + cat.getName());
|
||||||
|
|
||||||
// replace idPath list with one containing cat.id appended
|
// replace idPath list with one containing cat.id appended
|
||||||
|
|
@ -148,6 +148,21 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
s_log.debug(buff.toString());
|
s_log.debug(buff.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isSelected = false;
|
||||||
|
if (selected.length >= idPath.size()) {
|
||||||
|
isSelected = true;
|
||||||
|
for (int x = 0; x < idPath.size(); x++) {
|
||||||
|
if (!idPath.get(x).equals(selected[x])) {
|
||||||
|
isSelected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isSelected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isSelected && !cat.isVisible()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// We will concatenate category URLs only if all ancestors have
|
// We will concatenate category URLs only if all ancestors have
|
||||||
// their URLs set correctly. We recognize that is the case if
|
// their URLs set correctly. We recognize that is the case if
|
||||||
|
|
@ -166,18 +181,22 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
|
|
||||||
el.addAttribute("sortKey", XML.format(sortKey));
|
el.addAttribute("sortKey", XML.format(sortKey));
|
||||||
|
|
||||||
// compare idPath with the start of selected
|
|
||||||
if (selected.length >= idPath.size()) {
|
|
||||||
boolean isSelected = true;
|
|
||||||
for (int x=0; x<idPath.size(); x++) {
|
|
||||||
if (!idPath.get(x).equals(selected[x])) {
|
|
||||||
isSelected = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
el.addAttribute("isSelected", "true");
|
el.addAttribute("isSelected", "true");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// compare idPath with the start of selected
|
||||||
|
// if (selected.length >= idPath.size()) {
|
||||||
|
// boolean isSelected = true;
|
||||||
|
// for (int x = 0; x < idPath.size(); x++) {
|
||||||
|
// if (!idPath.get(x).equals(selected[x])) {
|
||||||
|
// isSelected = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (isSelected) {
|
||||||
|
// el.addAttribute("isSelected", "true");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Quasimodo: Begin
|
// Quasimodo: Begin
|
||||||
Set c = (Set) children.get(cat.getID());
|
Set c = (Set) children.get(cat.getID());
|
||||||
|
|
@ -203,8 +222,7 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
concatURLs && child.getURL() != null
|
concatURLs && child.getURL() != null
|
||||||
? path + child.getURL() + "/"
|
? path + child.getURL() + "/"
|
||||||
: null,
|
: null,
|
||||||
idPath
|
idPath);
|
||||||
);
|
|
||||||
|
|
||||||
if (childEl != null) {
|
if (childEl != null) {
|
||||||
|
|
||||||
|
|
@ -242,13 +260,17 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
protected boolean compareCategoryCollection(CategoryCollection a, CategoryCollection b) {
|
protected boolean compareCategoryCollection(CategoryCollection a, CategoryCollection b) {
|
||||||
|
|
||||||
// Not equal, if sizes don't match
|
// Not equal, if sizes don't match
|
||||||
if(a.size() != b.size()) return false;
|
if (a.size() != b.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Access every Object in the Collections
|
// Access every Object in the Collections
|
||||||
while (a.next() && b.next()) {
|
while (a.next() && b.next()) {
|
||||||
|
|
||||||
// If they don't match, they ain't equal
|
// If they don't match, they ain't equal
|
||||||
if(!a.getCategory().equals(b.getCategory())) return false;
|
if (!a.getCategory().equals(b.getCategory())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hurray, they are equal
|
// Hurray, they are equal
|
||||||
|
|
@ -268,6 +290,7 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
// Quasimodo: End
|
// Quasimodo: End
|
||||||
|
|
||||||
private class CategorySortKeyPair implements Comparable {
|
private class CategorySortKeyPair implements Comparable {
|
||||||
|
|
||||||
private Category m_category;
|
private Category m_category;
|
||||||
private BigDecimal m_sortKey;
|
private BigDecimal m_sortKey;
|
||||||
private boolean m_isDefault;
|
private boolean m_isDefault;
|
||||||
|
|
@ -277,18 +300,22 @@ public abstract class AbstractTree extends CategoryComponent {
|
||||||
m_sortKey = sortKey;
|
m_sortKey = sortKey;
|
||||||
m_isDefault = isDefault;
|
m_isDefault = isDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Category getCategory() {
|
public Category getCategory() {
|
||||||
return m_category;
|
return m_category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getSortKey() {
|
public BigDecimal getSortKey() {
|
||||||
return m_sortKey;
|
return m_sortKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDefault() {
|
public boolean isDefault() {
|
||||||
return m_isDefault;
|
return m_isDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(Object o) {
|
public int compareTo(Object o) {
|
||||||
return m_sortKey.compareTo(((CategorySortKeyPair) o).m_sortKey);
|
return m_sortKey.compareTo(((CategorySortKeyPair) o).m_sortKey);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue