From: <pb...@fe...> - 2013-02-02 23:34:56
|
Author: pboy Date: 2013-02-02 23:34:47 +0000 (Sat, 02 Feb 2013) New Revision: 2477 Added: trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java.nolongerInUse Removed: trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java trunk/ccm-cms/src/com/arsdigita/cms/ui/contentcenter/MainPage.java Log: Code clean-up after migration of ContentCenter to new style legacy free bebop pages served by a servlet. Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java 2013-02-02 23:31:41 UTC (rev 2476) +++ trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java 2013-02-02 23:34:47 UTC (rev 2477) @@ -20,7 +20,7 @@ package com.arsdigita.cms; import com.arsdigita.bebop.Page; -import com.arsdigita.cms.dispatcher.ResourceHandler; +import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.dispatcher.SimpleCache; import com.arsdigita.cms.ui.contentcenter.MainPage; import com.arsdigita.developersupport.DeveloperSupport; @@ -37,7 +37,6 @@ import com.arsdigita.xml.Document; import java.io.IOException; - import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -69,7 +68,7 @@ "/WEB-INF/resources/content-center-old-map.xml"; /** Mapping between a relative URL and the class name of a ResourceHandler.*/ - private static HashMap s_pageClasses = ContentCenterSetup.getURLToClassMap(); + // private static HashMap s_pageClasses = ContentCenterSetup.getURLToClassMap(); private static HashMap s_pageURLs = ContentCenterSetup.getClassToURLMap(); /** Instantiated ResourceHandlers cache. This allows for lazy loading. */ @@ -205,7 +204,6 @@ } - // ResourceHandler page = getResource(url); final Page page = (Page) m_pages.get(pathInfo); if ( page != null ) { @@ -271,6 +269,7 @@ * Service Method returns the URL stub for the class name, * can return null if not mapped */ + // Currently still in use by c.ad.cms.ui.ItemSearchWidget public static String getURLStubForClass(String classname) { s_log.debug("Getting URL Stub for : " + classname); Iterator itr = s_pageURLs.keySet().iterator(); @@ -284,66 +283,12 @@ } /** - * Fetch a page based on the URL stub. - * - * @param url The URL stub following the site-node URL - * @return A ResourceHandler or null if none exists. - * @pre (url != null) - */ - protected ResourceHandler getResource(String url) throws ServletException { - - // First check the pages cache for existing pages. - ResourceHandler page = (ResourceHandler) s_pages.get(url); - if ( page == null ) { - - // Next check if the URL maps to a page class. - String pageClassName = (String) s_pageClasses.get(url); - if ( pageClassName != null ) { - - Class pageClass; - try { - pageClass = Class.forName(pageClassName); - } catch (ClassNotFoundException e) { - s_log.error("error fetching class for ResourceHandler", e); - throw new ServletException(e); - } - - // Try and instantiate the page. - try { - page = (ResourceHandler) pageClass.newInstance(); - } catch (InstantiationException e) { - s_log.error("error instantiating a ResourceHandler", e); - throw new ServletException(e); - } catch (IllegalAccessException e) { - s_log.error("error instantiating a ResourceHandler", e); - throw new ServletException(e); - } - - page.init(); - s_pages.put(url, page); - } - } - return page; - } - - /** - * Map a page to a URL. - * - * @param url The URL - * @param className The name of the ResourceHandler class - * @pre (url != null && className != null) - */ - protected void addResource(String url, String className) { - s_pageClasses.put(url, className); - s_pageURLs.put(className, url); - } - - /** * Release the page at the specified URL. * * @param url The URL * @pre (url != null) */ + // Currently still in use by c.ad.cms.dispatcher.Utilities public static void releaseResource(String url) { s_pages.remove(url); } Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java 2013-02-02 23:31:41 UTC (rev 2476) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java 2013-02-02 23:34:47 UTC (rev 2477) @@ -18,38 +18,18 @@ */ package com.arsdigita.cms.ui; -import com.arsdigita.cms.dispatcher.*; -import com.arsdigita.bebop.Bebop; -import com.arsdigita.bebop.Container; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.Page; -import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.*; import com.arsdigita.bebop.page.PageTransformer; -import com.arsdigita.cms.CMSExcursion; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; -import com.arsdigita.cms.ContentSectionServlet; -import com.arsdigita.cms.SecurityManager; -import com.arsdigita.developersupport.DeveloperSupport; -import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.User; -import com.arsdigita.kernel.permissions.PermissionDescriptor; -import com.arsdigita.kernel.permissions.PermissionService; -import com.arsdigita.persistence.OID; import com.arsdigita.templating.PresentationManager; -import com.arsdigita.util.Assert; -import com.arsdigita.web.Application; import com.arsdigita.xml.Document; import com.arsdigita.xml.Element; -import java.io.IOException; -import java.math.BigDecimal; import java.util.HashMap; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; @@ -57,19 +37,18 @@ // //////////////////////////////////////////////////////////////////////////// // // Currently under development as a replacement for CMSPage without the -// dispatcher mechanism but a new application style "pure" bebop page +// dispatcher mechanism but a new application style "pure" bebop pageElement // served by an application servlet. // // //////////////////////////////////////////////////////////////////////////// /** - * <p>A <tt>CMSPage</tt> is a Bebop {@link com.arsdigita.bebop.Page} - * implementation of the {@link com.arsdigita.cms.dispatcher.ResourceHandler} - * interface.</p> + * <p>A <tt>CMSApplicationPage</tt> is a Bebop {@link com.arsdigita.bebop.Page} + * implementation serving as a base for any CMS pageElement served by a servlet. </p> * * <p>It stores the current {@link com.arsdigita.cms.ContentSection} and, if - * applicable, the {@link com.arsdigita.cms.ContentItem} in the page state as + * applicable, the {@link com.arsdigita.cms.ContentItem} in the pageElement state as * request local objects. Components that are part of the <tt>CMSPage</tt> * may access these objects by calling:</p> * <blockquote><code><pre> @@ -87,7 +66,7 @@ /** The global assets URL stub XML parameter name. */ public final static String ASSETS = "ASSETS"; - /** The XML page class. */ + /** The XML pageElement class. */ public final static String PAGE_CLASS = "CMS"; /** Map of XML parameters */ @@ -122,10 +101,11 @@ } /** - * Builds the page. + * Builds the pageElement. */ - protected void buildPage() { - // Set the class attribute. + private void buildPage() { + + // Set the class attribute value (down in SimpleComponent). setClassAttr(PAGE_CLASS); // Global XML params. @@ -151,10 +131,10 @@ } /** - * Finishes and locks the page. If the page is already locked, does nothing. + * Finishes and locks the pageElement. If the pageElement is already locked, does nothing. * * This method is called by the {@link com.arsdigita.dispatcher.Dispatcher} - * that initializes this page. + * that initializes this pageElement. */ public synchronized void init() { s_log.debug("Initializing the page"); @@ -194,7 +174,7 @@ * @param request The HTTP request * @return The current content section * - * @deprecated use com.arsdigita.cms.CMS.getContext().getContentSection() + * @ deprecated use com.arsdigita.cms.CMS.getContext().getContentSection() * instead * Despite of being deprecated it can not be removed because it * is required by the interface Resourcehandler which is @@ -202,27 +182,27 @@ * On the other hand, if deprecated, implementing ResourceHandler * may not be required */ - public ContentSection getContentSection(HttpServletRequest request) { - // Resets all content sections associations. - // return ContentSectionDispatcher.getContentSection(request); - return ContentSectionServlet.getContentSection(request); - } +// public ContentSection getContentSection(HttpServletRequest request) { +// // Resets all content sections associations. +// // return ContentSectionDispatcher.getContentSection(request); +// return ContentSectionServlet.getContentSection(request); +// } /** * Fetch the request-local content section. * - * @param state The page state + * @param state The pageElement state * @return The current content section * - * @deprecated use com.arsdigita.cms.CMS.getContext().getContentSection() + * @ deprecated use com.arsdigita.cms.CMS.getContext().getContentSection() * instead * Despite of being deprecated it can not be removed because it * is required by ContentItemPage which extends CMSPage and * uses this method. */ - public ContentSection getContentSection(PageState state) { - return getContentSection(state.getRequest()); - } +// public ContentSection getContentSection(PageState state) { +// return getContentSection(state.getRequest()); +// } /** * Fetch the request-local content item. @@ -230,7 +210,7 @@ * @param request The HTTP request * @return The current content item * - * @deprecated use com.arsdigita.cms.CMS.getContext().getContentItem() + * @ deprecated use com.arsdigita.cms.CMS.getContext().getContentItem() * instead * Despite of being deprecated it can not be removed because it * is required by the interface Resourcehandler which is @@ -238,41 +218,41 @@ * On the other hand, if deprecated, implementing ResourceHandler * may not be required */ - public ContentItem getContentItem(HttpServletRequest request) { - // resets all content item associations - return ContentSectionDispatcher.getContentItem(request); - } +// public ContentItem getContentItem(HttpServletRequest request) { +// // resets all content item associations +// return ContentSectionDispatcher.getContentItem(request); +// } /** * Fetch the request-local content item. * - * @param state The page state + * @param state The pageElement state * @return The current content item - * @deprecated use com.arsdigita.cms.CMS.getContext().getContentItem() + * @ deprecated use com.arsdigita.cms.CMS.getContext().getContentItem() * instead. * Despite of being deprecated it can not be removed because it * is required by ContentItemPage which extends CMSPage and * uses this method. */ - public ContentItem getContentItem(PageState state) { - return getContentItem(state.getRequest()); - } + // public ContentItem getContentItem(PageState state) { + // return getContentItem(state.getRequest()); + // } /** - * Services the Bebop page. + * Services the Bebop pageElement. * * @param request The servlet request object * @param response the servlet response object * * @pre m_transformer != null */ - public void dispatch(final HttpServletRequest request, +/* public void dispatch(final HttpServletRequest request, final HttpServletResponse response // , // RequestContext actx ) throws IOException, ServletException { - DeveloperSupport.startStage("CMSPage.dispatch: serve page"); + DeveloperSupport.startStage("CMSPage.dispatch: serve pageElement"); CMSExcursion excursion = new CMSExcursion() { public void excurse() throws IOException, ServletException { @@ -331,21 +311,35 @@ try { excursion.run(); } finally { - DeveloperSupport.endStage("CMSPage.dispatch: serve page"); + DeveloperSupport.endStage("CMSPage.dispatch: serve pageElement"); } - } + } */ + /** + * Overwrites bebop.Page#generateXMLHelper to add the name of the user + * logged in to the pageElement (displayed as part of the header). + * @param ps + * @param parent + * @return pageElement for use in generateXML + */ @Override protected Element generateXMLHelper(PageState ps, Document parent) { - Element page = super.generateXMLHelper(ps,parent); + /* Retain elements already included. */ + Element pageElement = super.generateXMLHelper(ps,parent); + /* Add name of user logged in. */ + // Note: There are at least 2 ways in the API to determin the user + // TODO: Check for differences, determin the best / recommended way and + // document it in the classes. Probably remove one ore the other + // way from the API if possible. User user = (User) Kernel.getContext().getParty(); + // User user = Web.getContext().getUser(); if ( user != null ) { - page.addAttribute("name",user.getDisplayName()); + pageElement.addAttribute("name",user.getDisplayName()); } - return page; + return pageElement; } } Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java 2013-02-02 23:31:41 UTC (rev 2476) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java 2013-02-02 23:34:47 UTC (rev 2477) @@ -18,12 +18,16 @@ */ package com.arsdigita.cms.ui; -import com.arsdigita.cms.ContentSection; import com.arsdigita.bebop.form.DHTMLEditor; +import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.cms.ContentSection; +/** + * + * + */ public class CMSDHTMLEditor extends DHTMLEditor { public CMSDHTMLEditor(String name) { Deleted: trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java 2013-02-02 23:31:41 UTC (rev 2476) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java 2013-02-02 23:34:47 UTC (rev 2477) @@ -1,205 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.ui; - -import com.arsdigita.bebop.Component; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.SimpleContainer; -import com.arsdigita.bebop.TabbedPane; -import com.arsdigita.bebop.event.ActionEvent; -import com.arsdigita.bebop.event.ActionListener; -import com.arsdigita.bebop.parameters.BigDecimalParameter; -import com.arsdigita.cms.ContentItem; -import com.arsdigita.cms.ContentSection; -import com.arsdigita.cms.ContentType; -import com.arsdigita.cms.dispatcher.CMSPage; -import com.arsdigita.cms.ui.contentcenter.TasksPanel; -import com.arsdigita.cms.util.GlobalizationUtil; -import com.arsdigita.kernel.ui.ACSObjectSelectionModel; -import com.arsdigita.ui.DebugPanel; - - -/** - * <p>The Content Center main page (index page). </p> - * - * This class uses the dispatcher based page creation mechanism. - * - * @author Jack Chung (fl...@ar...) - * @author Michael Pih (pi...@ar...) - * @version $Id: CMSPageWorkspacePage.java 2090 2010-04-17 08:04:14Z pboy $ - */ -public class CMSPageWorkspacePage extends CMSPage implements ActionListener { - - private final static String XSL_CLASS = "CMS Admin"; - - private TabbedPane m_tabbedPane; - - private TasksPanel m_tasks; - private ItemSearch m_search; - private ACSObjectSelectionModel m_typeSel; - private ACSObjectSelectionModel m_sectionSel; - - public static final String CONTENT_TYPE = "type_id"; - public static final String CONTENT_SECTION = "section_id"; - - /** - * Construct a new CMSPageWorkspacePage - */ - public CMSPageWorkspacePage() { // Constructor Page - - /* specifically invokes PresentationManager / PageTransformer to create - * a page instantiation. */ - super(new Label( GlobalizationUtil.globalize - ("cms.ui.content_center")), - new SimpleContainer()); - - setClassAttr("cms-admin"); - - BigDecimalParameter typeId = new BigDecimalParameter(CONTENT_TYPE); - addGlobalStateParam(typeId); - m_typeSel = new ACSObjectSelectionModel(ContentType.class.getName(), - ContentType.BASE_DATA_OBJECT_TYPE, - typeId); - - BigDecimalParameter sectionId = new BigDecimalParameter(CONTENT_SECTION); - addGlobalStateParam(sectionId); - m_sectionSel = new ACSObjectSelectionModel - (ContentSection.class.getName(), - ContentSection.BASE_DATA_OBJECT_TYPE, - sectionId); - - add( new WorkspaceContextBar() ); - add( new GlobalNavigation() ); - - m_tasks = getTasksPane(m_typeSel, m_sectionSel); - m_search = getSearchPane(); - - m_tabbedPane = createTabbedPane(); - m_tabbedPane.setIdAttr("page-body"); - add(m_tabbedPane); - - add(new DebugPanel()); - } - - /** - * Creates, and then caches, the Tasks pane. Overriding this - * method to return null will prevent this tab from appearing. - */ - protected TasksPanel getTasksPane(ACSObjectSelectionModel typeModel, - ACSObjectSelectionModel sectionModel) { - if (m_tasks == null) { - m_tasks = new TasksPanel(typeModel,sectionModel); - } - return m_tasks; - } - - /** - * Creates, and then caches, the Search pane. Overriding this - * method to return null will prevent this tab from appearing. - **/ - protected ItemSearch getSearchPane() { - if (m_search == null) { - m_search = new ItemSearch(ContentItem.DRAFT); - } - - return m_search; - } - -/* - private SimpleContainer makeHeader() { - PrintListener l = new PrintListener() { - public void prepare(PrintEvent event) { - PageState state = event.getPageState(); - Link link = (Link) event.getTarget(); - - User user = KernelHelper.getCurrentUser(state.getRequest()); - - link.setChild(new Label(user.getName())); - link.setTarget("/pvt/"); - } - }; - - SimpleContainer sc = new SimpleContainer(); - Label welcomeLabel = new Label(GlobalizationUtil.globalize("cms.ui.welcome")); - Link nameLink = new Link(l); - - sc.add(welcomeLabel); - sc.add(nameLink); - return sc; - - } -*/ - - /** - * Created the TabbedPane to use for this page. - * - * This is the "index" page, displayed at the base address (content-center - * by default). - * - * Sets the class attribute for this tabbed pane. The default implementation - * uses a {@link com.arsdigita.bebop.TabbedPane} and sets the class - * attribute to "CMS Admin." This implementation also adds tasks, - * content sections, and search panes. - * - * Developers can override this method to add only the tabs they want, - * or to add additional tabs after the default CMS tabs are added. - */ - protected TabbedPane createTabbedPane() { - TabbedPane pane = new TabbedPane(); - pane.setClassAttr(XSL_CLASS); - addToPane(pane, "Tasks/Sections", getTasksPane(m_typeSel, m_sectionSel)); - addToPane(pane, "Search", getSearchPane()); - pane.addActionListener(this); - return pane; - } - - - /** - * Adds the specified component, with the specified tab name, to the - * tabbed pane only if it is not null. - * - * @param pane The pane to which to add the tab - * @param tabName The name of the tab if it's added - * @param comp The component to add to the pane - **/ - protected void addToPane(TabbedPane pane, String tabName, Component comp) { - if (comp != null) { - pane.addTab(tabName, comp); - } - } - - - /** - * When a new tab is selected, reset the state of the - * formerly-selected pane. - * - * @param event The event fired by selecting a tab - */ - public void actionPerformed(ActionEvent event) { - PageState state = event.getPageState(); - Component pane = m_tabbedPane.getCurrentPane(state); - - if ( pane == m_tasks ) { - m_tasks.reset(state); - } else if ( pane == m_search ) { - m_search.reset(state); - } - } -} Added: trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java.nolongerInUse =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java.nolongerInUse (rev 0) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSPageWorkspacePage.java.nolongerInUse 2013-02-02 23:34:47 UTC (rev 2477) @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SimpleContainer; +import com.arsdigita.bebop.TabbedPane; +import com.arsdigita.bebop.event.ActionEvent; +import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.parameters.BigDecimalParameter; +import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.dispatcher.CMSPage; +import com.arsdigita.cms.ui.contentcenter.TasksPanel; +import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.kernel.ui.ACSObjectSelectionModel; +import com.arsdigita.ui.DebugPanel; + + +/** + * <p>The Content Center main page (index page). </p> + * + * This class uses the dispatcher based page creation mechanism. + * + * @author Jack Chung (fl...@ar...) + * @author Michael Pih (pi...@ar...) + * @version $Id: CMSPageWorkspacePage.java 2090 2010-04-17 08:04:14Z pboy $ + */ +public class CMSPageWorkspacePage extends CMSPage implements ActionListener { + + private final static String XSL_CLASS = "CMS Admin"; + + private TabbedPane m_tabbedPane; + + private TasksPanel m_tasks; + private ItemSearch m_search; + private ACSObjectSelectionModel m_typeSel; + private ACSObjectSelectionModel m_sectionSel; + + public static final String CONTENT_TYPE = "type_id"; + public static final String CONTENT_SECTION = "section_id"; + + /** + * Construct a new CMSPageWorkspacePage + */ + public CMSPageWorkspacePage() { // Constructor Page + + /* specifically invokes PresentationManager / PageTransformer to create + * a page instantiation. */ + super(new Label( GlobalizationUtil.globalize + ("cms.ui.content_center")), + new SimpleContainer()); + + setClassAttr("cms-admin"); + + BigDecimalParameter typeId = new BigDecimalParameter(CONTENT_TYPE); + addGlobalStateParam(typeId); + m_typeSel = new ACSObjectSelectionModel(ContentType.class.getName(), + ContentType.BASE_DATA_OBJECT_TYPE, + typeId); + + BigDecimalParameter sectionId = new BigDecimalParameter(CONTENT_SECTION); + addGlobalStateParam(sectionId); + m_sectionSel = new ACSObjectSelectionModel + (ContentSection.class.getName(), + ContentSection.BASE_DATA_OBJECT_TYPE, + sectionId); + + add( new WorkspaceContextBar() ); + add( new GlobalNavigation() ); + + m_tasks = getTasksPane(m_typeSel, m_sectionSel); + m_search = getSearchPane(); + + m_tabbedPane = createTabbedPane(); + m_tabbedPane.setIdAttr("page-body"); + add(m_tabbedPane); + + add(new DebugPanel()); + } + + /** + * Creates, and then caches, the Tasks pane. Overriding this + * method to return null will prevent this tab from appearing. + */ + protected TasksPanel getTasksPane(ACSObjectSelectionModel typeModel, + ACSObjectSelectionModel sectionModel) { + if (m_tasks == null) { + m_tasks = new TasksPanel(typeModel,sectionModel); + } + return m_tasks; + } + + /** + * Creates, and then caches, the Search pane. Overriding this + * method to return null will prevent this tab from appearing. + **/ + protected ItemSearch getSearchPane() { + if (m_search == null) { + m_search = new ItemSearch(ContentItem.DRAFT); + } + + return m_search; + } + +/* + private SimpleContainer makeHeader() { + PrintListener l = new PrintListener() { + public void prepare(PrintEvent event) { + PageState state = event.getPageState(); + Link link = (Link) event.getTarget(); + + User user = KernelHelper.getCurrentUser(state.getRequest()); + + link.setChild(new Label(user.getName())); + link.setTarget("/pvt/"); + } + }; + + SimpleContainer sc = new SimpleContainer(); + Label welcomeLabel = new Label(GlobalizationUtil.globalize("cms.ui.welcome")); + Link nameLink = new Link(l); + + sc.add(welcomeLabel); + sc.add(nameLink); + return sc; + + } +*/ + + /** + * Created the TabbedPane to use for this page. + * + * This is the "index" page, displayed at the base address (content-center + * by default). + * + * Sets the class attribute for this tabbed pane. The default implementation + * uses a {@link com.arsdigita.bebop.TabbedPane} and sets the class + * attribute to "CMS Admin." This implementation also adds tasks, + * content sections, and search panes. + * + * Developers can override this method to add only the tabs they want, + * or to add additional tabs after the default CMS tabs are added. + */ + protected TabbedPane createTabbedPane() { + TabbedPane pane = new TabbedPane(); + pane.setClassAttr(XSL_CLASS); + addToPane(pane, "Tasks/Sections", getTasksPane(m_typeSel, m_sectionSel)); + addToPane(pane, "Search", getSearchPane()); + pane.addActionListener(this); + return pane; + } + + + /** + * Adds the specified component, with the specified tab name, to the + * tabbed pane only if it is not null. + * + * @param pane The pane to which to add the tab + * @param tabName The name of the tab if it's added + * @param comp The component to add to the pane + **/ + protected void addToPane(TabbedPane pane, String tabName, Component comp) { + if (comp != null) { + pane.addTab(tabName, comp); + } + } + + + /** + * When a new tab is selected, reset the state of the + * formerly-selected pane. + * + * @param event The event fired by selecting a tab + */ + public void actionPerformed(ActionEvent event) { + PageState state = event.getPageState(); + Component pane = m_tabbedPane.getCurrentPane(state); + + if ( pane == m_tasks ) { + m_tasks.reset(state); + } else if ( pane == m_search ) { + m_search.reset(state); + } + } +} Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/contentcenter/MainPage.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/contentcenter/MainPage.java 2013-02-02 23:31:41 UTC (rev 2476) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/contentcenter/MainPage.java 2013-02-02 23:34:47 UTC (rev 2477) @@ -24,16 +24,14 @@ import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ui.CMSApplicationPage; import com.arsdigita.cms.ui.GlobalNavigation; import com.arsdigita.cms.ui.ItemSearch; import com.arsdigita.cms.ui.WorkspaceContextBar; import com.arsdigita.cms.util.GlobalizationUtil; -import com.arsdigita.kernel.User; import com.arsdigita.kernel.ui.ACSObjectSelectionModel; import com.arsdigita.ui.DebugPanel; -import com.arsdigita.web.Web; -import com.arsdigita.xml.Document; -import com.arsdigita.xml.Element; + import org.apache.log4j.Logger; @@ -49,7 +47,7 @@ * @author Peter Boy (pb...@ba...) * @version $Id: MainPage.java pboy $ */ -public class MainPage extends Page implements ActionListener { +public class MainPage extends CMSApplicationPage implements ActionListener { private static final Logger s_log = Logger.getLogger(MainPage.class); @@ -109,7 +107,8 @@ add(new DebugPanel()); /* Page complete, locked now. */ - lock(); + // lock(); + init(); } /** @@ -168,11 +167,8 @@ * attribute to "CMS Admin." This implementation also adds tasks, * content sections, and search panes. * - *<p> - * - * Developers can override this method to add only the tabs they - * want, or to add additional tabs after the default CMS tabs are - * added. + * Developers can override this method to add only the tabs they want, + * or to add additional tabs after the default CMS tabs are added. **/ protected TabbedPane createTabbedPane() { TabbedPane pane = new TabbedPane(); @@ -216,31 +212,4 @@ } } - /** - * Overwrites bebop.Page#generateXMLHelper to add the name of the user - * logged in to the page (displayed as part of the header). - * @param ps - * @param parent - * @return - */ - // ToDo: This code fragment is used by several pages of CMS package. It - // should be factored out into a kind of CMSBasePage, as it had been in - // the deprecated CMSPage. - // Should be checked when refactoring the content section pages to work - // as bebop pages without dispatcher mechanism and in new style application. - @Override - protected Element generateXMLHelper(PageState ps, Document parent) { - - /* Retain elements already included. */ - Element page = super.generateXMLHelper(ps,parent); - - /* Add name of user logged in. */ - User user = Web.getContext().getUser(); - if ( user != null ) { - page.addAttribute("name",user.getDisplayName()); - } - - return page; - } - } |