Grid viewer for Portal Workspace

git-svn-id: https://svn.libreccm.org/ccm/trunk@2925 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-10-28 15:04:06 +00:00
parent eb56a010ba
commit c559329701
15 changed files with 1054 additions and 622 deletions

View File

@ -5,7 +5,7 @@ insert into pw_workspace_page_layouts (layout_id, title, description, format)
values (nextval('acs_object_id_seq'), '2 Column', 'Two columns, equal size', '50%,50%'); values (nextval('acs_object_id_seq'), '2 Column', 'Two columns, equal size', '50%,50%');
insert into pw_workspace_page_layouts (layout_id, title, description, format) insert into pw_workspace_page_layouts (layout_id, title, description, format)
values (nextval('acs_object_id_seq'), '3 Column', 'Three columns, equal size', '30%,40%,30%'); values (nextval('acs_object_id_seq'), '3 Column', 'Three columns, equal size', '33.33%,33.33%,33.33%');
insert into pw_workspace_page_layouts (layout_id, title, description, format) insert into pw_workspace_page_layouts (layout_id, title, description, format)
values (nextval('acs_object_id_seq'), '4 Column', 'Four columns, equal size', '25%,25%,25%,25%'); values (nextval('acs_object_id_seq'), '4 Column', 'Four columns, equal size', '25%,25%,25%,25%');

View File

@ -15,7 +15,6 @@
* 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.portalworkspace; package com.arsdigita.portalworkspace;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
@ -40,16 +39,15 @@ import com.arsdigita.web.ApplicationType;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Executes nonrecurring at install time and loads (and configures ) a default * Executes nonrecurring at install time and loads (and configures ) a default workspace instance
* workspace instance (i.e. instance of ccm-portalworkspace) in a default * (i.e. instance of ccm-portalworkspace) in a default configuration.
* configuration.
* *
* Configuration can be modified by configuration parameters before processing, * Configuration can be modified by configuration parameters before processing, otherwise hardcoded
* otherwise hardcoded default values take effect. A set of portlets, part of * default values take effect. A set of portlets, part of the ccm-ldn-portal package, are loaded as
* the ccm-ldn-portal package, are loaded as well, so they are statically available. * well, so they are statically available.
* *
* After processing the installation values can not be modified anymore without * After processing the installation values can not be modified anymore without a fresh installation
* a fresh installation of the whole system. * of the whole system.
* *
* @author Justin Ross <jross@redhat.com> * @author Justin Ross <jross@redhat.com>
* @author Peter Boy <pboy@barkhof.uni-bremen.de> * @author Peter Boy <pboy@barkhof.uni-bremen.de>
@ -57,7 +55,9 @@ import org.apache.log4j.Logger;
*/ */
public class Loader extends PackageLoader { public class Loader extends PackageLoader {
/** Private Logger instance for debugging purpose. */ /**
* Private Logger instance for debugging purpose.
*/
private static final Logger s_log = Logger.getLogger(Loader.class); private static final Logger s_log = Logger.getLogger(Loader.class);
private StringParameter m_url = new StringParameter( private StringParameter m_url = new StringParameter(
@ -71,9 +71,8 @@ public class Loader extends PackageLoader {
"Portal Homepage"); "Portal Homepage");
/** /**
* If true the group created for the instance of portal workspace will * If true the group created for the instance of portal workspace will contain the public user
* contain the public user as a member. * as a member. NOTE: Current implementation actually doesn't check for access permission!
* NOTE: Current implementation actually doesn't check for access permission!
*/ */
private BooleanParameter m_isPublic = new BooleanParameter( private BooleanParameter m_isPublic = new BooleanParameter(
"com.arsdigita.portalworkspace.default_is_public", "com.arsdigita.portalworkspace.default_is_public",
@ -96,6 +95,7 @@ public class Loader extends PackageLoader {
public void run(final ScriptContext ctx) { public void run(final ScriptContext ctx) {
new KernelExcursion() { new KernelExcursion() {
public void excurse() { public void excurse() {
setEffectiveParty(Kernel.getSystemParty()); setEffectiveParty(Kernel.getSystemParty());
@ -111,17 +111,17 @@ public class Loader extends PackageLoader {
loadRSSFeedPortlet(); loadRSSFeedPortlet();
// loadTimeOfDayPortlet(); // loadTimeOfDayPortlet();
} }
}.run(); }.run();
} }
/** /**
* Prepares creation of application type by checking proper formatting of * Prepares creation of application type by checking proper formatting of applications url and
* applications url and determining whether a parent is specified as part * determining whether a parent is specified as part of the url.
* of the url.
* *
* @param url Sting containing the full url (including parents url in any * @param url Sting containing the full url (including parents url in any
* @param isPublic if true the group created for this instance will include * @param isPublic if true the group created for this instance will include the public user as a
* the public user as a member * member
* @param title * @param title
*/ */
private void createApplication(String url, Boolean isPublic, String title) { private void createApplication(String url, Boolean isPublic, String title) {
@ -156,7 +156,8 @@ public class Loader extends PackageLoader {
// set up the portal workspace default node (instance) // set up the portal workspace default node (instance)
Workspace workspace = Workspace.createWorkspace(type, name, title, Workspace workspace = Workspace.createWorkspace(type, name, title,
null, parent, Boolean.TRUE.equals(isPublic)); null, parent, Boolean.TRUE.equals(
isPublic));
} }
} }
@ -170,8 +171,8 @@ public class Loader extends PackageLoader {
*/ */
private ApplicationType setupWorkspaceType() { private ApplicationType setupWorkspaceType() {
s_log.debug("Creating an application type for portal workspace. " + s_log.debug("Creating an application type for portal workspace. "
"Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE); + "Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE);
/* Create legacy-free application type /* Create legacy-free application type
* *
@ -198,11 +199,12 @@ public class Loader extends PackageLoader {
/** /**
* Setup WorkspacePage type. * Setup WorkspacePage type.
* *
* Creates an entry for class (=type) c.ad.portalworkspace.WorkspacePage in * Creates an entry for class (=type) c.ad.portalworkspace.WorkspacePage in table
* table application_types, but not in apm_package_types. * application_types, but not in apm_package_types.
*
* Uses the legacy free type of application Information (i.e. a title string and the object type
* = fully qualified domain class name) for creation
* *
* Uses the legacy free type of application Information (i.e. a title string
* and the object type = fully qualified domain class name) for creation
* @return * @return
*/ */
private ResourceType setupWorkspacePageType() { private ResourceType setupWorkspacePageType() {
@ -213,7 +215,6 @@ public class Loader extends PackageLoader {
return type; return type;
} }
/** /**
* *
*/ */
@ -240,13 +241,15 @@ public class Loader extends PackageLoader {
private void loadLoginPortlet() { private void loadLoginPortlet() {
PortletType type = PortletType.createPortletType("Site Login", PortletType type = PortletType.createPortletType("Site Login",
PortletType.WIDE_PROFILE, LoginPortlet.BASE_DATA_OBJECT_TYPE); PortletType.WIDE_PROFILE,
LoginPortlet.BASE_DATA_OBJECT_TYPE);
type.setDescription("Display a login form or user details"); type.setDescription("Display a login form or user details");
} }
private void loadRSSFeedPortlet() { private void loadRSSFeedPortlet() {
PortletType type = PortletType.createPortletType("RSS Feed", PortletType type = PortletType.createPortletType("RSS Feed",
PortletType.WIDE_PROFILE, RSSFeedPortlet.BASE_DATA_OBJECT_TYPE); PortletType.WIDE_PROFILE,
RSSFeedPortlet.BASE_DATA_OBJECT_TYPE);
type.setDescription("Displays an RSS Feed"); type.setDescription("Displays an RSS Feed");
} }
@ -259,5 +262,4 @@ public class Loader extends PackageLoader {
// TimeOfDayPortlet.BASE_DATA_OBJECT_TYPE); // TimeOfDayPortlet.BASE_DATA_OBJECT_TYPE);
// type.setDescription("Displays the current date and time"); // type.setDescription("Displays the current date and time");
// } // }
} }

View File

@ -15,7 +15,6 @@
* 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.portalworkspace; package com.arsdigita.portalworkspace;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -37,8 +36,7 @@ import com.arsdigita.util.UncheckedWrapperException;
*/ */
public class PageLayout extends DomainObject { public class PageLayout extends DomainObject {
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.portalworkspace.PageLayout";
"com.arsdigita.portalworkspace.PageLayout";
public static final String ID = "id"; public static final String ID = "id";
public static final String TITLE = "title"; public static final String TITLE = "title";
@ -46,7 +44,8 @@ public class PageLayout extends DomainObject {
public static final String FORMAT = "format"; public static final String FORMAT = "format";
public static final String FORMAT_ONE_COLUMN = "100%"; public static final String FORMAT_ONE_COLUMN = "100%";
public static final String FORMAT_TWO_COLUMNS = "50%,50%"; public static final String FORMAT_TWO_COLUMNS = "50%,50%";
public static final String FORMAT_THREE_COLUMNS = "30%,40%,30%"; //public static final String FORMAT_THREE_COLUMNS = "30%,40%,30%";
public static final String FORMAT_THREE_COLUMNS = "33.33%,33.33%,33.33%";
public static final String FORMAT_FOUR_COLUMNS = "25%,25%,25%,25%"; public static final String FORMAT_FOUR_COLUMNS = "25%,25%,25%,25%";
public PageLayout() { public PageLayout() {
@ -68,6 +67,7 @@ public class PageLayout extends DomainObject {
/** /**
* *
*/ */
@Override
public void initialize() { public void initialize() {
super.initialize(); super.initialize();
@ -102,6 +102,7 @@ public class PageLayout extends DomainObject {
* @param title * @param title
* @param description * @param description
* @param format * @param format
*
* @return * @return
*/ */
public static PageLayout create(String title, String description, public static PageLayout create(String title, String description,
@ -155,4 +156,5 @@ public class PageLayout extends DomainObject {
String[] bits = StringUtils.split(getFormat(), ','); String[] bits = StringUtils.split(getFormat(), ',');
return bits.length; return bits.length;
} }
} }

View File

@ -15,7 +15,6 @@
* 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.portalworkspace; package com.arsdigita.portalworkspace;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor; import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
@ -34,20 +33,23 @@ import org.apache.log4j.Logger;
public class WorkspaceConfig extends AbstractConfig { public class WorkspaceConfig extends AbstractConfig {
/** Internal logger instance to faciliate debugging. Enable logging output /**
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment * Internal logger instance to faciliate debugging. Enable logging output by editing
* and set com.arsdigita.portalworkspace.WorkspaceConfig=DEBUG by * /WEB-INF/conf/log4j.properties int hte runtime environment and set
* uncommenting or adding it. */ * com.arsdigita.portalworkspace.WorkspaceConfig=DEBUG by uncommenting or adding it.
*/
private static final Logger s_log = Logger.getLogger(WorkspaceConfig.class); private static final Logger s_log = Logger.getLogger(WorkspaceConfig.class);
/** Singelton config object. */ /**
* Singelton config object.
*/
private static WorkspaceConfig s_conf; private static WorkspaceConfig s_conf;
/** /**
* Gain a WorkspaceConfig object. * Gain a WorkspaceConfig object.
* *
* Singelton pattern, don't instantiate a config object using the * Singelton pattern, don't instantiate a config object using the constructor directly!
* constructor directly! *
* @return * @return
*/ */
public static synchronized WorkspaceConfig getInstanceOf() { public static synchronized WorkspaceConfig getInstanceOf() {
@ -59,56 +61,62 @@ public class WorkspaceConfig extends AbstractConfig {
return s_conf; return s_conf;
} }
// set of configuration parameters // set of configuration parameters
/** File with rules for configuring information in generated XML */ /**
private final Parameter m_adapters = * File with rules for configuring information in generated XML
new ResourceParameter( */
private final Parameter m_adapters = new ResourceParameter(
"com.arsdigita.portalworkspace.traversal_adapters", "com.arsdigita.portalworkspace.traversal_adapters",
Parameter.REQUIRED, Parameter.REQUIRED,
"/WEB-INF/resources/portalworkspace-adapters.xml"); "/WEB-INF/resources/portalworkspace-adapters.xml");
/** Default column layout for workspace portals */ /**
private final Parameter m_defaultLayout = * Default column layout for workspace portals
new StringParameter( */
private final Parameter m_defaultLayout = new StringParameter(
"com.arsdigita.portalworkspace.default_layout", "com.arsdigita.portalworkspace.default_layout",
Parameter.REQUIRED, PageLayout.FORMAT_THREE_COLUMNS); Parameter.REQUIRED, PageLayout.FORMAT_THREE_COLUMNS);
/** Whether non-admin users should have their own custom workspaces */ /**
private final Parameter m_createUserWorkspaces = * Whether non-admin users should have their own custom workspaces
new BooleanParameter( */
private final Parameter m_createUserWorkspaces = new BooleanParameter(
"com.arsdigita.portalworkspace.create_user_workspaces", "com.arsdigita.portalworkspace.create_user_workspaces",
Parameter.REQUIRED, Boolean.TRUE); Parameter.REQUIRED, Boolean.TRUE);
/** Types not to be included in the drop down list of portlets to add to a page*/ /**
private final Parameter m_excludedPortletTypes = * Types not to be included in the drop down list of portlets to add to a page
new StringArrayParameter( */
private final Parameter m_excludedPortletTypes = new StringArrayParameter(
"com.arsdigita.portalworkspace.excluded_portlet_types", "com.arsdigita.portalworkspace.excluded_portlet_types",
Parameter.OPTIONAL, new String[0]); Parameter.OPTIONAL, new String[0]);
/** Types only available to administrator of homepage, or subsite frontpage*/ /**
private final Parameter m_adminPortletTypes = * Types only available to administrator of homepage, or subsite frontpage
new StringArrayParameter( */
private final Parameter m_adminPortletTypes = new StringArrayParameter(
"com.arsdigita.portalworkspace.admin_only_portlet_types", "com.arsdigita.portalworkspace.admin_only_portlet_types",
Parameter.OPTIONAL, new String[0]); Parameter.OPTIONAL, new String[0]);
/** Whether to use editor specified by waf.bebop.dhtml_editor for editing /**
freeform html portlet*/ * Whether to use editor specified by waf.bebop.dhtml_editor for editing freeform html portlet
private final Parameter m_htmlPortletWysiwygEditor = */
new BooleanParameter( private final Parameter m_htmlPortletWysiwygEditor = new BooleanParameter(
"com.arsdigita.portalworkspace.portlet.freeform_html_editor", "com.arsdigita.portalworkspace.portlet.freeform_html_editor",
Parameter.REQUIRED, Boolean.FALSE); Parameter.REQUIRED, Boolean.FALSE);
/** Which privilege ("read" or "edit") is granted to the workspace party. */ /**
private final Parameter m_workspacePartyPrivilege = * Which privilege ("read" or "edit") is granted to the workspace party.
new StringParameter( */
private final Parameter m_workspacePartyPrivilege = new StringParameter(
"com.arsdigita.portalworkspace.workspacePartyPrivilege", "com.arsdigita.portalworkspace.workspacePartyPrivilege",
Parameter.OPTIONAL, "read"); Parameter.OPTIONAL, "read");
/** Whether READ permissions will be checked when viewing workspaces. /**
By default we don't, which is odd. */ * Whether READ permissions will be checked when viewing workspaces. By default we don't, which
private final Parameter m_checkWorkspaceReadPermissions = * is odd.
new BooleanParameter( */
private final Parameter m_checkWorkspaceReadPermissions = new BooleanParameter(
"com.arsdigita.portalworkspace.checkWorkspaceReadPermissions", "com.arsdigita.portalworkspace.checkWorkspaceReadPermissions",
Parameter.OPTIONAL, Boolean.FALSE); Parameter.OPTIONAL, Boolean.FALSE);
@ -178,4 +186,5 @@ public class WorkspaceConfig extends AbstractConfig {
public boolean getCheckWorkspaceReadPermissions() { public boolean getCheckWorkspaceReadPermissions() {
return ((Boolean) get(m_checkWorkspaceReadPermissions)).booleanValue(); return ((Boolean) get(m_checkWorkspaceReadPermissions)).booleanValue();
} }
} }

View File

@ -15,7 +15,6 @@
* 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.portalworkspace; package com.arsdigita.portalworkspace;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
@ -36,8 +35,8 @@ public class WorkspacePage extends Portal {
public static final String WORKSPACE = "workspace"; public static final String WORKSPACE = "workspace";
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE
"com.arsdigita.portalworkspace.WorkspacePage"; = "com.arsdigita.portalworkspace.WorkspacePage";
public static final String MODE_EDITOR = "editor"; public static final String MODE_EDITOR = "editor";
public static final String PORTAL_XML_NS = "http://www.uk.arsdigita.com/portal/1.0"; public static final String PORTAL_XML_NS = "http://www.uk.arsdigita.com/portal/1.0";
public static final String PORTLET_XML_NS = "http://www.uk.arsdigita.com/portlet/1.0"; public static final String PORTLET_XML_NS = "http://www.uk.arsdigita.com/portlet/1.0";

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings=No settings yet cw.workspace.ui.admin.no_settings=No settings yet
cw.workspace.default_layout=Layout cw.workspace.default_layout=Layout
cw.workspace.ui.categorized.create_workspace.info=Currently there is no Portal Workspace for this category. If you want to create one now, please click the link below.
cw.workspace.ui.categorized.create_workspace.link=Create PortalWorkspace for this category
cw.workspace.ui.categorized.workspace.add_row.link=Add new row

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings=Noch keine Einstellungen cw.workspace.ui.admin.no_settings=Noch keine Einstellungen
cw.workspace.default_layout=Layout cw.workspace.default_layout=Layout
cw.workspace.ui.categorized.create_workspace.info=Es gibt noch keinen Portal Workspace f\u00fcr diese Kategorie. Wenn Sie jetzt einen neuen Workspace f\u00fcr diese Kategorie anlegen m\u00f6chten klicken Sie bitte auf untenstehenden Link.
cw.workspace.ui.categorized.create_workspace.link=PortalWorkspace f\u00fcr diese Kategorie anlegen
cw.workspace.ui.categorized.workspace.add_row.link=Weitere Zeile hinzuf\u00fcgen

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings= cw.workspace.ui.admin.no_settings=
cw.workspace.default_layout= cw.workspace.default_layout=
cw.workspace.ui.categorized.create_workspace.info=
cw.workspace.ui.categorized.create_workspace.link=
cw.workspace.ui.categorized.workspace.add_row.link=

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings= cw.workspace.ui.admin.no_settings=
cw.workspace.default_layout= cw.workspace.default_layout=
cw.workspace.ui.categorized.create_workspace.info=
cw.workspace.ui.categorized.create_workspace.link=
cw.workspace.ui.categorized.workspace.add_row.link=

View File

@ -15,7 +15,6 @@
* 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.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import com.arsdigita.portalworkspace.StatefulPersistentPortal; import com.arsdigita.portalworkspace.StatefulPersistentPortal;
@ -74,11 +73,11 @@ import org.apache.log4j.Logger;
// XXX this class is disgusting // XXX this class is disgusting
/** /**
* PersistentPortals are able to have more than one column, and the constructor * PersistentPortals are able to have more than one column, and the constructor for PersistentPortal
* for PersistentPortal takes in an integer argument for number of columns. * takes in an integer argument for number of columns.
* *
* HomepagePortals defined on the jsp page each construct instances of this * HomepagePortals defined on the jsp page each construct instances of this class, one for the
* class, one for the portal in view mode, one in edit mode. * portal in view mode, one in edit mode.
* *
*/ */
public class PersistentPortal extends SimpleContainer { public class PersistentPortal extends SimpleContainer {
@ -91,7 +90,6 @@ public class PersistentPortal extends SimpleContainer {
public static final String ACTION_MOVE_LEFT = "moveLeft"; public static final String ACTION_MOVE_LEFT = "moveLeft";
public static final String ACTION_MOVE_RIGHT = "moveRight"; public static final String ACTION_MOVE_RIGHT = "moveRight";
public static final String ACTION_DELETE = "delete"; public static final String ACTION_DELETE = "delete";
private WorkspaceSelectionAbstractModel m_workspace; private WorkspaceSelectionAbstractModel m_workspace;
@ -119,9 +117,9 @@ public class PersistentPortal extends SimpleContainer {
// pixels wide... // pixels wide...
public static final int MAX_COLUMNS = 10; public static final int MAX_COLUMNS = 10;
/** /**
* Constructor * Constructor
*
* @param portal * @param portal
* @param mode * @param mode
*/ */
@ -150,7 +148,6 @@ public class PersistentPortal extends SimpleContainer {
m_column = new ParameterSingleSelectionModel(new IntegerParameter("column")); m_column = new ParameterSingleSelectionModel(new IntegerParameter("column"));
if (m_mode.equals(WorkspacePage.MODE_EDITOR)) { if (m_mode.equals(WorkspacePage.MODE_EDITOR)) {
for (int i = 0; i < m_adders.length; i++) { for (int i = 0; i < m_adders.length; i++) {
m_adders[i] = new PortletTypeForm("add" + name + i); m_adders[i] = new PortletTypeForm("add" + name + i);
@ -166,6 +163,7 @@ public class PersistentPortal extends SimpleContainer {
new BigDecimalParameter("create")); new BigDecimalParameter("create"));
m_portal.addChangeListener(new ChangeListener() { m_portal.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
if (m_portal.isSelected(state)) { if (m_portal.isSelected(state)) {
@ -177,14 +175,16 @@ public class PersistentPortal extends SimpleContainer {
m_parentResource.set(state, null); m_parentResource.set(state, null);
} }
} }
}); });
m_portlet.addChangeListener(new ChangeListener() { m_portlet.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
if (m_portal.isSelected(state)) { if (m_portal.isSelected(state)) {
com.arsdigita.portal.Portlet portlet = com.arsdigita.portal.Portlet portlet
m_portlet.getSelectedPortlet(state); = m_portlet.getSelectedPortlet(state);
s_log.debug("Setting portlet" + portlet); s_log.debug("Setting portlet" + portlet);
m_currentResource.set(state, portlet); m_currentResource.set(state, portlet);
} else { } else {
@ -192,26 +192,33 @@ public class PersistentPortal extends SimpleContainer {
m_currentResource.set(state, null); m_currentResource.set(state, null);
} }
} }
}); });
m_parentApp = new DomainObjectParameter("parentApp"); m_parentApp = new DomainObjectParameter("parentApp");
m_parentResource = new RequestLocal() { m_parentResource = new RequestLocal() {
public Object initialValue(PageState state) { public Object initialValue(PageState state) {
return state.getValue(m_parentApp); return state.getValue(m_parentApp);
} }
}; };
m_currentResource = new RequestLocal() { m_currentResource = new RequestLocal() {
public Object initialValue(PageState state) { public Object initialValue(PageState state) {
return m_portlet.getSelectedPortlet(state); return m_portlet.getSelectedPortlet(state);
} }
}; };
m_currentApp = new RequestLocal() { m_currentApp = new RequestLocal() {
public Object initialValue(PageState state) { public Object initialValue(PageState state) {
return Kernel.getContext().getResource(); return Kernel.getContext().getResource();
} }
}; };
PortletTypeCollection types = PortletType.retrieveAllPortletTypes(); PortletTypeCollection types = PortletType.retrieveAllPortletTypes();
@ -223,22 +230,23 @@ public class PersistentPortal extends SimpleContainer {
PortletType type = types.getPortletType(); PortletType type = types.getPortletType();
s_log.debug("Add type " + type.getResourceObjectType()); s_log.debug("Add type " + type.getResourceObjectType());
final ResourceConfigComponent create = final ResourceConfigComponent create
type.getCreateComponent(m_parentResource); = type.getCreateComponent(m_parentResource);
final ResourceConfigComponent modify = final ResourceConfigComponent modify
type.getModifyComponent(m_currentResource); = type.getModifyComponent(m_currentResource);
ApplicationType appType = type.getProviderApplicationType(); ApplicationType appType = type.getProviderApplicationType();
SimpleContainer createApp = null; SimpleContainer createApp = null;
if (appType != null) { if (appType != null) {
final ResourceConfigComponent appCreate = final ResourceConfigComponent appCreate
appType.getCreateComponent(m_currentApp); = appType.getCreateComponent(m_currentApp);
ApplicationSelector sel = new ApplicationSelector( ApplicationSelector sel = new ApplicationSelector(
appType, appType,
m_parentApp, m_parentApp,
appType.getConfig() == null ? null : appType.getConfig().getViewPrivilege()); appType.getConfig() == null ? null : appType.getConfig().
getViewPrivilege());
appCreate.addCompletionListener(new ActionListener() { appCreate.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
s_log.debug("Do create of portlet"); s_log.debug("Do create of portlet");
@ -251,19 +259,21 @@ public class PersistentPortal extends SimpleContainer {
state.setValue(m_parentApp, resource); state.setValue(m_parentApp, resource);
} }
} }
}); });
sel.addCompletionListener(new ActionListener() { sel.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
if (state.getValue(m_parentApp) == null) { if (state.getValue(m_parentApp) == null) {
s_log.debug("Sel no resource, reset"); s_log.debug("Sel no resource, reset");
m_portletType.clearSelection(e.getPageState()); m_portletType.clearSelection(e.getPageState());
} else { } else {
s_log.debug("Got res " + s_log.debug("Got res " + state.getValue(m_parentApp));
state.getValue(m_parentApp));
} }
} }
}); });
createApp = new SimpleContainer(); createApp = new SimpleContainer();
@ -275,14 +285,14 @@ public class PersistentPortal extends SimpleContainer {
s_log.debug("Modify component is " + modify); s_log.debug("Modify component is " + modify);
create.addCompletionListener(new ActionListener() { create.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
s_log.debug("Do create of portlet"); s_log.debug("Do create of portlet");
Resource resource = create.createResource(state); Resource resource = create.createResource(state);
if (resource != null) { if (resource != null) {
Integer column = (Integer) Integer column = (Integer) m_column.getSelectedKey(state);
m_column.getSelectedKey(state);
Assert.exists(column, Integer.class); Assert.exists(column, Integer.class);
WorkspacePage portal = m_portal WorkspacePage portal = m_portal
@ -299,17 +309,17 @@ public class PersistentPortal extends SimpleContainer {
s_log.debug("Stateful portlet added"); s_log.debug("Stateful portlet added");
// check if the maximum number of stateful // check if the maximum number of stateful
// portlets has increased // portlets has increased
PortletType portletType = PortletType portletType
((Portlet) resource).getPortletType(); = ((Portlet) resource).getPortletType();
DataQuery findMaxInstances = DataQuery findMaxInstances
SessionManager.getSession().retrieveQuery( = SessionManager.getSession().retrieveQuery(
"com.arsdigita.london.portal.MaxPortletInstances"); "com.arsdigita.london.portal.MaxPortletInstances");
findMaxInstances.setParameter("portletType", findMaxInstances.setParameter("portletType",
portletType.getID()); portletType.getID());
int maxCount = 0; int maxCount = 0;
while (findMaxInstances.next()) { while (findMaxInstances.next()) {
maxCount = maxCount
((Integer) findMaxInstances = ((Integer) findMaxInstances
.get("maxCount")) .get("maxCount"))
.intValue(); .intValue();
} }
@ -325,15 +335,18 @@ public class PersistentPortal extends SimpleContainer {
if (maxCount > previousMax) { if (maxCount > previousMax) {
DefinePage.invalidatePage( DefinePage.invalidatePage(
DispatcherHelper DispatcherHelper
.getCurrentResourcePath(state.getRequest())); } .getCurrentResourcePath(state.getRequest()));
}
} }
m_portletType.clearSelection(e.getPageState()); m_portletType.clearSelection(e.getPageState());
state.setValue(m_parentApp, null); state.setValue(m_parentApp, null);
m_parentResource.set(state, null); m_parentResource.set(state, null);
} }
}); });
modify.addCompletionListener(new ActionListener() { modify.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
s_log.debug("Do modify of portlet"); s_log.debug("Do modify of portlet");
PageState state = e.getPageState(); PageState state = e.getPageState();
@ -342,6 +355,7 @@ public class PersistentPortal extends SimpleContainer {
portlet.save(); portlet.save();
m_portlet.clearSelection(state); m_portlet.clearSelection(state);
} }
}); });
m_create.put(type.getResourceObjectType(), create); m_create.put(type.getResourceObjectType(), create);
m_modify.put(type.getResourceObjectType(), modify); m_modify.put(type.getResourceObjectType(), modify);
@ -358,10 +372,15 @@ public class PersistentPortal extends SimpleContainer {
+ " " + m_modify.size()); + " " + m_modify.size());
Assert.exists(m_parentResource, RequestLocal.class); Assert.exists(m_parentResource, RequestLocal.class);
m_portalModelBuilder = new PortalEditModelBuilder( m_portalModelBuilder = new PortalEditModelBuilder(portal,
portal, m_adders, m_adders,
m_portletType, m_column, m_portlet, m_portletType,
m_create, m_modify, m_createApp, m_parentResource); m_column,
m_portlet,
m_create,
m_modify,
m_createApp,
m_parentResource);
} else { } else {
m_portalModelBuilder = new PortalViewModelBuilder(portal); m_portalModelBuilder = new PortalViewModelBuilder(portal);
} }
@ -483,13 +502,17 @@ public class PersistentPortal extends SimpleContainer {
} else if (ACTION_MOVE_LEFT.equals(key)) { } else if (ACTION_MOVE_LEFT.equals(key)) {
int cell = portlet.getCellNumber(); int cell = portlet.getCellNumber();
cell = cell - 1; cell = cell - 1;
if (cell < 1) { cell = 1; } if (cell < 1) {
cell = 1;
}
portlet.setCellNumber(cell); portlet.setCellNumber(cell);
portlet.save(); portlet.save();
} else if (ACTION_MOVE_RIGHT.equals(key)) { } else if (ACTION_MOVE_RIGHT.equals(key)) {
int cello = portlet.getCellNumber(); int cello = portlet.getCellNumber();
cello = cello + 1; cello = cello + 1;
if (cello > 3) { cello = 3; } if (cello > 3) {
cello = 3;
}
portlet.setCellNumber(cello); portlet.setCellNumber(cello);
portlet.save(); portlet.save();
} else if (ACTION_DELETE.equals(key)) { } else if (ACTION_DELETE.equals(key)) {
@ -542,11 +565,12 @@ public class PersistentPortal extends SimpleContainer {
PortletType type = PortletType.retrievePortletType( PortletType type = PortletType.retrievePortletType(
form.getPortletType(state)); form.getPortletType(state));
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Got create event for type " + s_log.debug("Got create event for type " + type.getID() + " column " + m_col);
type.getID() + " column " + m_col);
} }
m_portletType.setSelectedKey(state, type.getID()); m_portletType.setSelectedKey(state, type.getID());
m_column.setSelectedKey(state, new Integer(m_col)); m_column.setSelectedKey(state, new Integer(m_col));
} }
} }
} }

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -32,14 +31,17 @@ public class PortletTypeSelectionModel extends AbstractSingleSelectionModel {
m_model = new ParameterSingleSelectionModel(p); m_model = new ParameterSingleSelectionModel(p);
} }
@Override
public Object getSelectedKey(PageState state) { public Object getSelectedKey(PageState state) {
return m_model.getSelectedKey(state); return m_model.getSelectedKey(state);
} }
@Override
public void setSelectedKey(PageState state, Object key) { public void setSelectedKey(PageState state, Object key) {
m_model.setSelectedKey(state, key); m_model.setSelectedKey(state, key);
} }
@Override
public ParameterModel getStateParameter() { public ParameterModel getStateParameter() {
return m_model.getStateParameter(); return m_model.getStateParameter();
} }

View File

@ -15,7 +15,6 @@
* 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.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -37,25 +36,42 @@ import com.arsdigita.xml.XML;
*/ */
public class WorkspaceDetails extends SimpleComponent { public class WorkspaceDetails extends SimpleComponent {
private WorkspaceSelectionAbstractModel m_workspace; private WorkspaceSelectionAbstractModel workspaceModel;
public WorkspaceDetails(WorkspaceSelectionAbstractModel workspace) { public WorkspaceDetails(final WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace; super();
this.workspaceModel = workspace;
} }
public void setWorkspaceModel(WorkspaceSelectionAbstractModel workspace) { public void setWorkspaceModel(final WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace; this.workspaceModel = workspace;
} }
public Workspace getSelectedWorkspace(PageState state) { public Workspace getSelectedWorkspace(final PageState state) {
return m_workspace.getSelectedWorkspace(state); return workspaceModel.getSelectedWorkspace(state);
}
/**
* Overridden {@link SimpleComponent#isVisible(com.arsdigita.bebop.PageState)} to ensure that
* {@code WorkspaceDetails} is not rendered when there is not Workspace to show.
*
* Previously an none existing Workspace (which can occur when using a PortalWorkspace on a
* category page) caused a NPE.
*
* @param state
* @return
*/
@Override
public boolean isVisible(final PageState state) {
return super.isVisible(state) && workspaceModel.getSelectedWorkspace(state) != null;
} }
@Override @Override
public void generateXML(PageState state, Element parent) { public void generateXML(final PageState state, final Element parent) {
Workspace workspace = getSelectedWorkspace(state); final Workspace workspace = getSelectedWorkspace(state);
Element content = new Element("portal:workspaceDetails", final Element content = new Element("portal:workspaceDetails",
WorkspacePage.PORTAL_XML_NS); WorkspacePage.PORTAL_XML_NS);
exportAttributes(content); exportAttributes(content);
@ -65,29 +81,30 @@ public class WorkspaceDetails extends SimpleComponent {
parent.addContent(content); parent.addContent(content);
} }
protected void generateWorkspaceXML(PageState state, Element content, protected void generateWorkspaceXML(final PageState state,
Workspace workspace) { final Element content,
final Workspace workspace) {
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(content); final DomainObjectXMLRenderer renderer = new DomainObjectXMLRenderer(content);
xr.setWrapRoot(false); renderer.setWrapRoot(false);
xr.setWrapAttributes(true); renderer.setWrapAttributes(true);
xr.setWrapObjects(false); renderer.setWrapObjects(false);
xr.walk(workspace, WorkspaceDetails.class.getName()); renderer.walk(workspace, WorkspaceDetails.class.getName());
} }
protected void generatePermissionXML(PageState state, Element content, protected void generatePermissionXML(final PageState state,
Workspace workspace) { final Element content,
Party party = Kernel.getContext().getParty(); final Workspace workspace) {
final Party party = Kernel.getContext().getParty();
PermissionDescriptor edit = new PermissionDescriptor( final PermissionDescriptor edit = new PermissionDescriptor(
PrivilegeDescriptor.EDIT, workspace, party); PrivilegeDescriptor.EDIT, workspace, party);
PermissionDescriptor admin = new PermissionDescriptor( final PermissionDescriptor admin = new PermissionDescriptor(
PrivilegeDescriptor.ADMIN, workspace, party); PrivilegeDescriptor.ADMIN, workspace, party);
content.addAttribute("canEdit", XML.format(new Boolean( content.addAttribute("canEdit", XML.format(PermissionService.checkPermission(edit)));
PermissionService.checkPermission(edit)))); content.addAttribute("canAdmin", XML.format(PermissionService.checkPermission(admin)));
content.addAttribute("canAdmin", XML.format(new Boolean(
PermissionService.checkPermission(admin))));
} }
} }

View File

@ -15,7 +15,6 @@
* 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.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.ActionLink; import com.arsdigita.bebop.ActionLink;
@ -42,11 +41,9 @@ import com.arsdigita.portalworkspace.util.GlobalizationUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Entry point into a standard (public or access restricted) portal workspace * Entry point into a standard (public or access restricted) portal workspace page where the page is
* page where the page is constructed in "edit" mode to allow configuration * constructed in "edit" mode to allow configuration and modification by an authorized participant.
* and modification by an authorized participant.
* *
* It is used via a jsp page which is invoked at the applications url. * It is used via a jsp page which is invoked at the applications url.
* *
@ -60,9 +57,8 @@ import org.apache.log4j.Logger;
* </jsp:scriptlet> * </jsp:scriptlet>
* </pre> * </pre>
* *
* Currently there is a jsp for the default url at * Currently there is a jsp for the default url at (web)/templates/ccm-portalworkspace/edit.jsp
* (web)/templates/ccm-portalworkspace/edit.jsp which is mapped via web.xml * which is mapped via web.xml to /ccm/portal/edit.jsp in the default, pre-configured configuration.
* to /ccm/portal/edit.jsp in the default, pre-configured configuration.
*/ */
public class WorkspaceEditor extends AbstractWorkspaceComponent { public class WorkspaceEditor extends AbstractWorkspaceComponent {
@ -74,7 +70,6 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
private ActionLink m_editBasicPropertiesLink; private ActionLink m_editBasicPropertiesLink;
/** /**
* Default Constructor constructs a new, empty WorkspaceEditor object. * Default Constructor constructs a new, empty WorkspaceEditor object.
*/ */
@ -83,8 +78,8 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
} }
/** /**
* Constructs a WorkspaceViewer for a specific workspace object * Constructs a WorkspaceViewer for a specific workspace object and sets the xml tags
* and sets the xml tags accordingly. * accordingly.
* *
* @param workspace * @param workspace
*/ */
@ -133,7 +128,6 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
return new PortalListEditor(portal); return new PortalListEditor(portal);
} }
@Override @Override
public void register(Page page) { public void register(Page page) {
super.register(page); super.register(page);
@ -143,7 +137,6 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
page.setVisibleDefault(m_basisPropertiesForm, false); page.setVisibleDefault(m_basisPropertiesForm, false);
} }
/** /**
* *
* @param portal * @param portal
@ -157,6 +150,7 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
* *
*/ */
private class BasicPropertiesLinkListener implements ActionListener { private class BasicPropertiesLinkListener implements ActionListener {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
m_editBasicPropertiesLink.setVisible(ps, false); m_editBasicPropertiesLink.setVisible(ps, false);
@ -166,6 +160,7 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
public class BasicPropertiesForm extends Form implements public class BasicPropertiesForm extends Form implements
FormProcessListener, FormInitListener { FormProcessListener, FormInitListener {
private Label title; private Label title;
private TextField m_title; private TextField m_title;

View File

@ -0,0 +1,368 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.portal.PortletRenderer;
import com.arsdigita.categorization.Category;
import com.arsdigita.dispatcher.AccessDeniedException;
import com.arsdigita.kernel.Group;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.PartyCollection;
import com.arsdigita.navigation.Navigation;
import com.arsdigita.navigation.NavigationModel;
import com.arsdigita.portal.Portlet;
import com.arsdigita.portal.PortletCollection;
import com.arsdigita.portalworkspace.Workspace;
import com.arsdigita.portalworkspace.WorkspacePage;
import com.arsdigita.portalworkspace.WorkspacePageCollection;
import com.arsdigita.portalworkspace.util.GlobalizationUtil;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
import com.arsdigita.xml.Element;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author jensp
*/
public class WorkspaceGridViewer extends SimpleContainer {
private WorkspaceSelectionAbstractModel workspaceModel;
private ParameterSingleSelectionModel rowAction;
private ParameterSingleSelectionModel rowModel;
private WorkspaceDetails workspaceDetails;
private WorkspaceCreator workspaceCreator;
private WorkspaceEditor workspaceEditor;
private WorkspaceGridRowEditor workspaceGridRowEditor;
public WorkspaceGridViewer() {
this(null);
}
public WorkspaceGridViewer(final WorkspaceSelectionAbstractModel workspaceModel) {
super("portal:gridWorkspace", WorkspacePage.PORTAL_XML_NS);
this.workspaceModel = workspaceModel;
rowAction = new ParameterSingleSelectionModel(new StringParameter("rowAction"));
rowModel = new ParameterSingleSelectionModel(new StringParameter("selectedRow"));
workspaceDetails = new WorkspaceDetails(workspaceModel);
workspaceEditor = new WorkspaceEditor();
workspaceGridRowEditor = new WorkspaceGridRowEditor();
workspaceCreator = new WorkspaceCreator();
add(workspaceCreator);
add(workspaceDetails);
add(workspaceEditor);
final SimpleContainer gridRowEditorContainer = new SimpleContainer(
"portal:workspaceGridRowEditor", WorkspacePage.PORTAL_XML_NS) {
@Override
public boolean isVisible(final PageState state) {
return super.isVisible(state) && "edit".equals(rowAction.getSelectedKey(state));
}
};
add(gridRowEditorContainer);
gridRowEditorContainer.add(workspaceGridRowEditor);
}
public WorkspaceSelectionAbstractModel getWorkspaceModel() {
return workspaceModel;
}
public void setWorkspaceModel(final WorkspaceSelectionAbstractModel workspaceModel) {
this.workspaceModel = workspaceModel;
workspaceDetails.setWorkspaceModel(workspaceModel);
}
@Override
public void register(final Page page) {
super.register(page);
page.addComponentStateParam(this, rowAction.getStateParameter());
page.addComponentStateParam(this, rowModel.getStateParameter());
}
@Override
public void generateXML(final PageState state, final Element parent) {
if (isVisible(state)) {
final Element content = generateParent(parent);
if (workspaceModel.getSelectedWorkspace(state) == null) {
workspaceDetails.setVisible(state, false);
workspaceCreator.setVisible(state, true);
} else {
workspaceDetails.setVisible(state, true);
workspaceCreator.setVisible(state, false);
}
if (rowModel.isSelected(state)) {
content.addAttribute("selectedRow", (String) rowModel.getSelectedKey(state));
}
generateChildrenXML(state, content);
if (workspaceModel.getSelectedWorkspace(state) != null) {
final WorkspacePageCollection pages = workspaceModel.getSelectedWorkspace(state).
getPages();
final Element pagesElem = content.newChildElement("portal:rows",
WorkspacePage.PORTAL_XML_NS);
while (pages.next()) {
generateRowXML(pagesElem, state, pages.getPage());
}
}
}
}
private void generateRowXML(final Element pagesElem,
final PageState state,
final WorkspacePage row) {
final Element rowElem = pagesElem.newChildElement("portal:row",
WorkspacePage.PORTAL_XML_NS);
rowElem.addAttribute("id", row.getID().toString());
rowElem.addAttribute("layout", row.getLayout().getFormat());
rowElem.addAttribute("style", row.getLayout().getTitle());
rowElem.addAttribute("title", row.getTitle());
rowElem.addAttribute("description", row.getDescription());
final HttpServletRequest request = state.getRequest();
final String pathInfo = request.getPathInfo();
final ParameterMap parameterMap = new ParameterMap(request);
parameterMap.setParameter(rowAction.getStateParameter().getName(), "edit");
parameterMap.setParameter(rowModel.getStateParameter().getName(), row.getID().toString());
rowElem.addAttribute("editLink", URL.here(request, pathInfo, parameterMap).toString());
final PortletCollection portlets = row.getPortlets();
final Element portletsElem = rowElem.newChildElement("portal:portlets",
WorkspacePage.PORTAL_XML_NS);
while (portlets.next()) {
generatePortletXML(portletsElem, state, portlets.getPortlet());
}
}
private void generatePortletXML(final Element portletsElem,
final PageState state,
final Portlet portlet) {
final PortletRenderer renderer = portlet.getPortletRenderer();
renderer.generateXML(state, portletsElem);
}
private class WorkspaceCreator extends SimpleContainer {
public WorkspaceCreator() {
super("portal:workspaceCreator", WorkspacePage.PORTAL_XML_NS);
final Label info = new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.categorized.create_workspace.info"));
add(info);
final ActionLink link = new ActionLink(new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.categorized.create_workspace.link")));
link.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
if (!canCreate()) {
throw new AccessDeniedException(
"Current party is not authorized to create a new portal workspace");
}
final NavigationModel navModel = Navigation.getConfig().getDefaultModel();
final Category category = navModel.getCategory();
final String workspaceUrl = String.format("workspace-%s-%s",
category.getID().toString(),
category.getURL());
final String workspaceTitle = String.format("Workspace-%s-%s",
category.getID().toString(),
category.getName());
final String workspaceDesc = String.format(
"Portal Workspace for category %s (ID: %s).",
category.getID().toString(),
category.getName());
final Workspace workspace = Workspace.createWorkspace(workspaceUrl,
workspaceTitle,
null,
true);
workspace.setDescription(workspaceDesc);
workspace.save();
category.addChild(workspace);
}
});
add(link);
}
@Override
public boolean isVisible(final PageState state) {
// final boolean visible = super.isVisible(state);
//
// return visible && canCreate();
return workspaceModel.getSelectedWorkspace(state) == null && canCreate();
}
public boolean canCreate() {
final PartyCollection parties = Party.retrieveAllParties();
parties.filter("Site-wide Administrators");
parties.next();
final Group admins = (Group) parties.getParty();
parties.close();
final Party currentParty = Kernel.getContext().getParty();
return currentParty != null && admins.hasMember(currentParty);
}
}
private class WorkspaceEditor extends SimpleContainer {
public WorkspaceEditor() {
super("portal:workspaceGridEditor", WorkspacePage.PORTAL_XML_NS);
final ActionLink addRowLink = new ActionLink(GlobalizationUtil.globalize(
"cw.workspace.ui.categorized.workspace.add_row.link"));
addRowLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
final Workspace workspace = workspaceModel.getSelectedWorkspace(state);
final Party currentParty = Kernel.getContext().getParty();
if (!PortalHelper.canCustomize(currentParty, workspace)) {
throw new AccessDeniedException(
"Current party has now permission to edit this workspace");
}
final WorkspacePageCollection pages = workspace.getPages();
final long size = pages.size();
pages.close();
workspace.addPage(String.format("workspace-grid-row-%d", size + 1), "");
}
});
add(addRowLink);
}
@Override
public boolean isVisible(final PageState state) {
return workspaceModel.getSelectedWorkspace(state) != null && canEdit(state);
}
public boolean canEdit(final PageState state) {
return PortalHelper.canCustomize(Kernel.getContext().getParty(),
workspaceModel.getSelectedWorkspace(state));
}
}
// private class GridRowSelectionModel extends AbstractSingleSelectionModel {
//
// private final RequestLocal selected;
//
// public GridRowSelectionModel() {
// selected = new RequestLocal();
// }
//
// @Override
// public Object getSelectedKey(final PageState state) {
// return selected.get(state);
// }
//
// @Override
// public void setSelectedKey(final PageState state, final Object key) {
// selected.set(state, key);
// }
//
// @Override
// public ParameterModel getStateParameter() {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }
//
// }
private class WorkspaceGridRowEditor extends Form {
private final TextField key;
public WorkspaceGridRowEditor() {
super("WordspaceGridRowEditor", new SimpleContainer());
final Label label = new Label();
label.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final Label target = (Label) event.getTarget();
target.setLabel(rowModel.getStateParameter().getName());
}
});
add(label);
key = new TextField("key");
add(key);
addInitListener(new FormInitListener() {
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
key.setValue(event.getPageState(),
rowModel.getSelectedKey(event.getPageState()));
}
});
}
@Override
public void generateXML(final PageState state, final Element parent) {
super.generateXML(state, parent);
if (rowModel.isSelected(state)) {
parent.addAttribute("selectedRow",
(String) rowModel.getSelectedKey(state));
}
}
}
}

View File

@ -66,6 +66,7 @@ public class WorkspaceViewer extends AbstractWorkspaceComponent {
* @param portal * @param portal
* @return * @return
*/ */
@Override
protected PortalList createPortalList(PortalSelectionModel portal) { protected PortalList createPortalList(PortalSelectionModel portal) {
return new PortalListViewer(portal); return new PortalListViewer(portal);
} }
@ -75,6 +76,7 @@ public class WorkspaceViewer extends AbstractWorkspaceComponent {
* @param portal * @param portal
* @return * @return
*/ */
@Override
protected PersistentPortal createPortalDisplay(PortalSelectionModel portal) { protected PersistentPortal createPortalDisplay(PortalSelectionModel portal) {
return new PersistentPortal(portal, WorkspacePage.MODE_DISPLAY); return new PersistentPortal(portal, WorkspacePage.MODE_DISPLAY);
} }