- Admin-Oberfläche für Instanzen von ccm-navigation in den ApplicationsAdministrationTab unter /ccm/admin integriert.
- Einige Verbesserungen an Tabs für /ccm/admin. Unter anderem sind diese jetzt direkt von LayoutPanel abgeleitet. git-svn-id: https://svn.libreccm.org/ccm/trunk@2295 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
397a8a4622
commit
6a06a18e8c
|
|
@ -54,7 +54,8 @@ public class LayoutPanel extends ComponentMap {
|
|||
put("bottom", bottom);
|
||||
}
|
||||
|
||||
public final void generateXML(final PageState state, final Element parent) {
|
||||
@Override
|
||||
public void generateXML(final PageState state, final Element parent) {
|
||||
if (isVisible(state)) {
|
||||
final Element layout = parent.newChildElement
|
||||
("bebop:layoutPanel", BEBOP_XML_NS);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import com.arsdigita.bebop.SimpleContainer;
|
|||
import com.arsdigita.bebop.Tree;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstancePane;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationManager;
|
||||
import com.arsdigita.ui.admin.applications.BaseApplicationPane;
|
||||
|
|
@ -46,7 +46,7 @@ import java.util.Map;
|
|||
* @author pb
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class ApplicationsAdministrationTab extends SimpleContainer implements AdminConstants {
|
||||
public class ApplicationsAdministrationTab extends LayoutPanel implements AdminConstants {
|
||||
|
||||
private final Tree applicationTree;
|
||||
private final Map<String, BaseApplicationPane> appPanes = new HashMap<String, BaseApplicationPane>();
|
||||
|
|
@ -65,17 +65,10 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
|
||||
applicationTree = new Tree(new ApplicationTreeModelBuilder());
|
||||
applicationTree.addChangeListener(new TreeStateChangeListener());
|
||||
|
||||
//final Section treeSection = new Section();
|
||||
//treeSection.setHeading(GlobalizationUtil.globalize("ui.admin.applications.tree.heading"));
|
||||
//treeSection.setBody(applicationTree);
|
||||
|
||||
//final LayoutPanel panel = new LayoutPanel();
|
||||
//panel.setLeft(treeSection);
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
panel.setClassAttr("navbar");
|
||||
//panel.add(treeSection);
|
||||
panel.add(applicationTree);
|
||||
|
||||
setClassAttr("navbar");
|
||||
|
||||
setLeft(applicationTree);
|
||||
|
||||
|
||||
final ApplicationTypeCollection applicationTypes = ApplicationType.retrieveAllApplicationTypes();
|
||||
|
|
@ -90,8 +83,7 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
createAppPane(applicationTypes.getApplicationType(), appManagers);
|
||||
}
|
||||
}
|
||||
|
||||
//final BoxPanel
|
||||
|
||||
appPanel = new BoxPanel();
|
||||
appPanel.setClassAttr("main");
|
||||
for (Map.Entry<String, BaseApplicationPane> entry : appPanes.entrySet()) {
|
||||
|
|
@ -101,32 +93,10 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
for (Map.Entry<String, ApplicationInstancePane> entry : instancePanes.entrySet()) {
|
||||
appPanel.add(entry.getValue());
|
||||
}
|
||||
//panel.setRight(appPanel);
|
||||
panel.add(appPanel);
|
||||
|
||||
add(panel);
|
||||
|
||||
setRight(appPanel);
|
||||
}
|
||||
|
||||
// @SuppressWarnings("rawtypes")
|
||||
// private Map<String, ApplicationCreateForm<?>> retrieveAppCreateForms() {
|
||||
// final Map<String, ApplicationCreateForm<?>> appCreateForms = new HashMap<String, ApplicationCreateForm<?>>();
|
||||
// final ServiceLoader<ApplicationCreateForm> loader = ServiceLoader.load(ApplicationCreateForm.class);
|
||||
// for (ApplicationCreateForm<?> appCreateForm : loader) {
|
||||
// appCreateForms.put(appCreateForm.getAppClassName(), appCreateForm);
|
||||
// }
|
||||
// return appCreateForms;
|
||||
// }
|
||||
// @SuppressWarnings("rawtypes")
|
||||
// private Map<String, ApplicationManager<?>> retrieveAppManagers() {
|
||||
// final Map<String, ApplicationManager<?>> appManagers = new HashMap<String, ApplicationManager<?>>();
|
||||
//
|
||||
// final ServiceLoader<ApplicationManager> loader = ServiceLoader.load(ApplicationManager.class);
|
||||
// for (ApplicationManager<?> appManager : loader) {
|
||||
// appManagers.put(appManager.getApplication().getName(), appManager);
|
||||
// }
|
||||
//
|
||||
// return appManagers;
|
||||
// }
|
||||
private void createSingletonAppPane(final ApplicationType applicationType,
|
||||
final Map<String, ApplicationManager<?>> appManagers) {
|
||||
final String appObjectType = applicationType.getApplicationObjectType();
|
||||
|
|
@ -156,13 +126,6 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
final MultiInstanceApplicationPane<?> appPane = new MultiInstanceApplicationPane(applicationType, createForm);
|
||||
appPanes.put(applicationType.getApplicationObjectType(), appPane);
|
||||
createInstancePane(applicationType, appManagers);
|
||||
|
||||
// final ApplicationCollection instances = Application.retrieveAllApplications(
|
||||
// applicationType.getApplicationObjectType());
|
||||
//
|
||||
// while (instances.next()) {
|
||||
// createInstancePane(instances.getApplication(), appManagers);
|
||||
// }
|
||||
}
|
||||
|
||||
private void createInstancePane(final ApplicationType applicationType,
|
||||
|
|
@ -179,22 +142,6 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
instancePanes.put(applicationType.getApplicationObjectType(), instPane);
|
||||
}
|
||||
|
||||
// private void createInstancePane(final Application application,
|
||||
// final Map<String, ApplicationManager<?>> managementForms) {
|
||||
// final ApplicationManager<?> manager = managementForms.get(application.getClass().getName());
|
||||
//
|
||||
// final ApplicationInstancePane instPane;
|
||||
// if (manager == null) {
|
||||
// instPane = new ApplicationInstancePane(application, null);
|
||||
// } else {
|
||||
// instPane = new ApplicationInstancePane(
|
||||
// application,
|
||||
// managementForms.get(application.getClass().getName()).getApplicationAdminForm());
|
||||
// }
|
||||
// //instancePanes.put(application.getClass().getName(), instPane);
|
||||
// instancePanes.put(application.getPath(), instPane);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void register(final Page page) {
|
||||
super.register(page);
|
||||
|
|
@ -208,10 +155,6 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
}
|
||||
|
||||
private void setPaneVisible(final SimpleContainer pane, final PageState state) {
|
||||
// if (visiblePane != null) {
|
||||
// visiblePane.setVisible(state, false);
|
||||
// }
|
||||
|
||||
for (Map.Entry<String, BaseApplicationPane> entry : appPanes.entrySet()) {
|
||||
entry.getValue().setVisible(state, false);
|
||||
}
|
||||
|
|
@ -219,8 +162,7 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
entry.getValue().setVisible(state, false);
|
||||
}
|
||||
|
||||
pane.setVisible(state, true);
|
||||
//visiblePane = pane;
|
||||
pane.setVisible(state, true);
|
||||
}
|
||||
|
||||
private class TreeStateChangeListener implements ChangeListener {
|
||||
|
|
@ -242,9 +184,7 @@ public class ApplicationsAdministrationTab extends SimpleContainer implements Ad
|
|||
setPaneVisible(pane, state);
|
||||
}
|
||||
} else {
|
||||
// Selected key is the name of a instance pane
|
||||
// final ApplicationInstancePane pane = instancePanes.get(selectedKey);
|
||||
|
||||
// Selected key is the name of a instance pane
|
||||
final ApplicationCollection applications = Application.retrieveAllApplications();
|
||||
applications.addEqualsFilter(Application.PRIMARY_URL, selectedKey + "/");
|
||||
final ApplicationInstancePane pane;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ import org.apache.log4j.Logger;
|
|||
* @author David Dao
|
||||
*
|
||||
*/
|
||||
class GroupAdministrationTab extends SimpleContainer implements AdminConstants, ChangeListener {
|
||||
class GroupAdministrationTab extends LayoutPanel implements AdminConstants, ChangeListener {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GroupAdministrationTab.class);
|
||||
private final Tree groupTree;
|
||||
|
|
@ -81,7 +81,7 @@ class GroupAdministrationTab extends SimpleContainer implements AdminConstants,
|
|||
@Override
|
||||
public void register(final Page page) {
|
||||
for (int i = 0; i < panelList.size(); i++) {
|
||||
page.setVisibleDefault((Component) panelList.get(i), false);
|
||||
page.setVisibleDefault(panelList.get(i), false);
|
||||
}
|
||||
|
||||
page.setVisibleDefault(groupAddPanel, true);
|
||||
|
|
@ -148,19 +148,13 @@ class GroupAdministrationTab extends SimpleContainer implements AdminConstants,
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
//final LayoutPanel panel = new LayoutPanel();
|
||||
panel.setClassAttr("navbar");
|
||||
|
||||
//m_tree = new Tree(new GroupTreeMode());
|
||||
|
||||
setClassAttr("navbar");
|
||||
|
||||
groupTree = new Tree(new GroupTreeModelBuilder());
|
||||
groupTree.addChangeListener(this);
|
||||
panel.add(groupTree);
|
||||
//panel.setLeft(groupTree);
|
||||
|
||||
add(panel);
|
||||
|
||||
setLeft(groupTree);
|
||||
|
||||
final SegmentedPanel rightSide = new SegmentedPanel();
|
||||
rightSide.setClassAttr("main");
|
||||
|
||||
|
|
@ -187,9 +181,8 @@ class GroupAdministrationTab extends SimpleContainer implements AdminConstants,
|
|||
|
||||
groupDeleteFailedPanel = buildGroupDeleteFailedPanel(rightSide);
|
||||
panelList.add(groupDeleteFailedPanel);
|
||||
|
||||
panel.add(rightSide);
|
||||
//panel.setRight(rightSide);
|
||||
|
||||
setRight(rightSide);
|
||||
}
|
||||
|
||||
public void displayAddGroupPanel(final PageState state) {
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ import com.arsdigita.bebop.List;
|
|||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.TabbedPane;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.list.ListModel;
|
||||
import com.arsdigita.bebop.list.ListModelBuilder;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_NAVBAR_TITLE;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_TAB_SUMMARY;
|
||||
import com.arsdigita.util.Assert;
|
||||
|
|
@ -44,7 +44,7 @@ import java.util.ArrayList;
|
|||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
class UserAdministrationTab extends SimpleContainer implements AdminConstants {
|
||||
class UserAdministrationTab extends LayoutPanel implements AdminConstants {
|
||||
|
||||
private final List sections;
|
||||
private final java.util.List<Component> components = new ArrayList<Component>();
|
||||
|
|
@ -54,16 +54,13 @@ class UserAdministrationTab extends SimpleContainer implements AdminConstants {
|
|||
public UserAdministrationTab(final TabbedPane parent, final GroupAdministrationTab groupAdminTab) {
|
||||
super();
|
||||
|
||||
//final LayoutPanel panel = new LayoutPanel();
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
setClassAttr("sidebarNavPanel");
|
||||
|
||||
sections = new List(new GlobalizedTabModelBuilder());
|
||||
sections.addChangeListener(new SectionChangeListener());
|
||||
sections.setClassAttr("navbar");
|
||||
//panel.setLeft(sections);
|
||||
panel.add(sections);
|
||||
|
||||
setLeft(sections);
|
||||
|
||||
final UserBrowsePane browsePane = new UserBrowsePane();
|
||||
final UserSummarySection summarySection = new UserSummarySection(this, browsePane);
|
||||
final UserSearchSection searchSection = new UserSearchSection(this, browsePane);
|
||||
|
|
@ -77,9 +74,7 @@ class UserAdministrationTab extends SimpleContainer implements AdminConstants {
|
|||
addSection(USER_TAB_SEARCH, searchSection, right);
|
||||
addSection(USER_TAB_CREATE_USER, createSection, right);
|
||||
|
||||
//panel.setRight(right);
|
||||
panel.add(right);
|
||||
add(panel);
|
||||
setRight(right);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,6 +135,7 @@ class UserAdministrationTab extends SimpleContainer implements AdminConstants {
|
|||
//Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
final int selectedIndex = Integer.parseInt((String) sections.getSelectedKey(state));
|
||||
|
|
@ -154,6 +150,7 @@ class UserAdministrationTab extends SimpleContainer implements AdminConstants {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListModel makeModel(final List list, final PageState state) {
|
||||
return new TabNameListModel(state);
|
||||
}
|
||||
|
|
@ -169,10 +166,12 @@ class UserAdministrationTab extends SimpleContainer implements AdminConstants {
|
|||
pageState = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElement() {
|
||||
return keys.get(index).getLabel(pageState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return String.valueOf(index);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.arsdigita.bebop.Label;
|
|||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.navigation.ui.admin.CategoryPanel;
|
||||
import com.arsdigita.navigation.ui.admin.NavigationCreateForm;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationManager;
|
||||
|
|
@ -37,10 +38,12 @@ import com.arsdigita.ui.admin.applications.ApplicationManager;
|
|||
*/
|
||||
public class NavigationAppManager implements ApplicationManager<Navigation> {
|
||||
|
||||
@Override
|
||||
public Class<Navigation> getApplication() {
|
||||
return Navigation.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationInstanceAwareContainer getApplicationAdminForm() {
|
||||
// final ApplicationInstanceAwareContainer container = new ApplicationInstanceAwareContainer();
|
||||
// final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
|
|
@ -52,6 +55,7 @@ public class NavigationAppManager implements ApplicationManager<Navigation> {
|
|||
return new ApplicationAdminForm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Form getApplicationCreateForm() {
|
||||
return new NavigationCreateForm();
|
||||
}
|
||||
|
|
@ -60,19 +64,23 @@ public class NavigationAppManager implements ApplicationManager<Navigation> {
|
|||
|
||||
public ApplicationAdminForm() {
|
||||
super();
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
add(panel);
|
||||
|
||||
panel.add(new Label(NavigationGlobalizationUtil.globalize("ui.admin.instance_not_compatible_yet")));
|
||||
panel.add(new Link(new PrintListener() {
|
||||
public void prepare(final PrintEvent event) {
|
||||
final Link link = (Link) event.getTarget();
|
||||
|
||||
link.setTarget(String.format("%s/admin", getAppInstance().getPath()));
|
||||
link.setChild(new Label(getAppInstance().getTitle()));
|
||||
}
|
||||
|
||||
}));
|
||||
// final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
// add(panel);
|
||||
//
|
||||
// panel.add(new Label(NavigationGlobalizationUtil.globalize("ui.admin.instance_not_compatible_yet")));
|
||||
// panel.add(new Link(new PrintListener() {
|
||||
// @Override
|
||||
// public void prepare(final PrintEvent event) {
|
||||
// final Link link = (Link) event.getTarget();
|
||||
//
|
||||
// link.setTarget(String.format("%s/admin", getAppInstance().getPath()));
|
||||
// link.setChild(new Label(getAppInstance().getTitle()));
|
||||
// }
|
||||
//
|
||||
// }));
|
||||
|
||||
final CategoryPanel categoryPanel = new CategoryPanel(this);
|
||||
add(categoryPanel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,47 +24,64 @@ import com.arsdigita.bebop.PageState;
|
|||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.navigation.Navigation;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
|
||||
/**
|
||||
* Panel for managing the JSP templates assigned to categories. The templates are
|
||||
* describing which components and which data is rendered when accessing a category
|
||||
* using the navigation application.
|
||||
*
|
||||
* @author Unknown
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
*/
|
||||
public class CategoryPanel extends SimpleContainer {
|
||||
|
||||
private CategorySelectionModel m_category;
|
||||
private CategoryTree m_tree;
|
||||
private CategoryFormAddContext m_addForm;
|
||||
private CategoryForm m_form;
|
||||
private QuickLinkPanel m_links;
|
||||
private final CategorySelectionModel category;
|
||||
private final CategoryTree tree;
|
||||
private final CategoryFormAddContext addForm;
|
||||
private final CategoryForm form;
|
||||
private final QuickLinkPanel links;
|
||||
|
||||
public CategoryPanel() {
|
||||
super(Navigation.NAV_PREFIX + ":categoryPanel",
|
||||
Navigation.NAV_NS);
|
||||
|
||||
m_category = new CategorySelectionModel();
|
||||
m_category.addChangeListener(
|
||||
category = new CategorySelectionModel();
|
||||
category.addChangeListener(
|
||||
new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
boolean selected = m_category.isSelected(state);
|
||||
m_addForm.setVisible(state, selected);
|
||||
m_form.setVisible(state, selected);
|
||||
m_links.setVisible(state, selected);
|
||||
@Override
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
final boolean selected = category.isSelected(state);
|
||||
addForm.setVisible(state, selected);
|
||||
form.setVisible(state, selected);
|
||||
links.setVisible(state, selected);
|
||||
}
|
||||
});
|
||||
|
||||
m_tree = new CategoryTree(m_category);
|
||||
m_addForm = new CategoryFormAddContext(m_category);
|
||||
m_form = new CategoryForm(m_category);
|
||||
m_links = new QuickLinkPanel(m_category);
|
||||
tree = new CategoryTree(category);
|
||||
addForm = new CategoryFormAddContext(category);
|
||||
form = new CategoryForm(category);
|
||||
links = new QuickLinkPanel(category);
|
||||
|
||||
add(m_tree);
|
||||
add(m_addForm);
|
||||
add(m_form);
|
||||
add(m_links);
|
||||
add(tree);
|
||||
add(addForm);
|
||||
add(form);
|
||||
add(links);
|
||||
}
|
||||
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
public CategoryPanel(final ApplicationInstanceAwareContainer parent) {
|
||||
this();
|
||||
|
||||
p.setVisibleDefault(m_addForm, false);
|
||||
p.setVisibleDefault(m_form, false);
|
||||
p.setVisibleDefault(m_links, false);
|
||||
tree.setParent(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(final Page page) {
|
||||
super.register(page);
|
||||
|
||||
page.setVisibleDefault(addForm, false);
|
||||
page.setVisibleDefault(form, false);
|
||||
page.setVisibleDefault(links, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,49 +17,71 @@
|
|||
*/
|
||||
package com.arsdigita.navigation.ui.admin;
|
||||
|
||||
import com.arsdigita.bebop.Tree;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.tree.TreeModelBuilder;
|
||||
import com.arsdigita.bebop.Tree;
|
||||
import com.arsdigita.bebop.tree.TreeModel;
|
||||
import com.arsdigita.bebop.tree.TreeModelBuilder;
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.CategoryTreeModelLite;
|
||||
import com.arsdigita.cms.TemplateContext;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import com.arsdigita.navigation.Navigation;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.web.Web;
|
||||
|
||||
/**
|
||||
* Lists category tree.
|
||||
*
|
||||
* @author Tri Tran (tri@arsdigita.com)
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id: CategoryTree.java 2070 2010-01-28 08:47:41Z pboy $
|
||||
*/
|
||||
public class CategoryTree extends Tree {
|
||||
|
||||
private final SectionTreeModelBuilder modelBuilder;
|
||||
|
||||
/**
|
||||
* Construct a new CategoryTree
|
||||
*
|
||||
* @param model The {@link CategorySelectionModel} used for storing the selected category.
|
||||
*/
|
||||
public CategoryTree(CategorySelectionModel model) {
|
||||
public CategoryTree(final CategorySelectionModel model) {
|
||||
super(new SectionTreeModelBuilder());
|
||||
modelBuilder = (SectionTreeModelBuilder) getModelBuilder();
|
||||
setSelectionModel(model);
|
||||
}
|
||||
|
||||
protected void setParent(final ApplicationInstanceAwareContainer parent) {
|
||||
modelBuilder.setParent(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* A TreeModelBuilder that loads the tree from the current category
|
||||
*/
|
||||
private static class SectionTreeModelBuilder extends LockableImpl
|
||||
implements TreeModelBuilder {
|
||||
private static class SectionTreeModelBuilder extends LockableImpl implements TreeModelBuilder {
|
||||
|
||||
private ApplicationInstanceAwareContainer parent;
|
||||
|
||||
public SectionTreeModelBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TreeModel makeModel(Tree t, PageState s) {
|
||||
Navigation app = (Navigation) Web.getContext().getApplication();
|
||||
TemplateContext ctx = Navigation.getContext().getTemplateContext();
|
||||
String dispatcherContext = ctx == null ? null : ctx.getContext();
|
||||
Category root = Category.getRootForObject(app, dispatcherContext);
|
||||
public void setParent(final ApplicationInstanceAwareContainer parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeModel makeModel(final Tree tree, final PageState state) {
|
||||
final Navigation app;
|
||||
if (parent == null) {
|
||||
app = (Navigation) Web.getContext().getApplication();
|
||||
} else {
|
||||
app = (Navigation) parent.getAppInstance();
|
||||
}
|
||||
|
||||
final TemplateContext ctx = Navigation.getContext().getTemplateContext();
|
||||
final String dispatcherContext = ctx == null ? null : ctx.getContext();
|
||||
final Category root = Category.getRootForObject(app, dispatcherContext);
|
||||
return new CategoryTreeModelLite(root);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue