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%');
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)
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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.portalworkspace;
import com.arsdigita.kernel.Kernel;
@ -40,16 +39,15 @@ import com.arsdigita.web.ApplicationType;
import org.apache.log4j.Logger;
/**
* Executes nonrecurring at install time and loads (and configures ) a default
* workspace instance (i.e. instance of ccm-portalworkspace) in a default
* configuration.
* Executes nonrecurring at install time and loads (and configures ) a default workspace instance
* (i.e. instance of ccm-portalworkspace) in a default configuration.
*
* Configuration can be modified by configuration parameters before processing,
* otherwise hardcoded default values take effect. A set of portlets, part of
* the ccm-ldn-portal package, are loaded as well, so they are statically available.
* Configuration can be modified by configuration parameters before processing, otherwise hardcoded
* default values take effect. A set of portlets, part of the ccm-ldn-portal package, are loaded as
* well, so they are statically available.
*
* After processing the installation values can not be modified anymore without
* a fresh installation of the whole system.
* After processing the installation values can not be modified anymore without a fresh installation
* of the whole system.
*
* @author Justin Ross <jross@redhat.com>
* @author Peter Boy <pboy@barkhof.uni-bremen.de>
@ -57,7 +55,9 @@ import org.apache.log4j.Logger;
*/
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 StringParameter m_url = new StringParameter(
@ -71,9 +71,8 @@ public class Loader extends PackageLoader {
"Portal Homepage");
/**
* If true the group created for the instance of portal workspace will
* contain the public user as a member.
* NOTE: Current implementation actually doesn't check for access permission!
* If true the group created for the instance of portal workspace will contain the public user
* as a member. NOTE: Current implementation actually doesn't check for access permission!
*/
private BooleanParameter m_isPublic = new BooleanParameter(
"com.arsdigita.portalworkspace.default_is_public",
@ -96,6 +95,7 @@ public class Loader extends PackageLoader {
public void run(final ScriptContext ctx) {
new KernelExcursion() {
public void excurse() {
setEffectiveParty(Kernel.getSystemParty());
@ -111,17 +111,17 @@ public class Loader extends PackageLoader {
loadRSSFeedPortlet();
// loadTimeOfDayPortlet();
}
}.run();
}
/**
* Prepares creation of application type by checking proper formatting of
* applications url and determining whether a parent is specified as part
* of the url.
* Prepares creation of application type by checking proper formatting of applications url and
* determining whether a parent is specified as part of the url.
*
* @param url Sting containing the full url (including parents url in any
* @param isPublic if true the group created for this instance will include
* the public user as a member
* @param isPublic if true the group created for this instance will include the public user as a
* member
* @param 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)
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() {
s_log.debug("Creating an application type for portal workspace. " +
"Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE);
s_log.debug("Creating an application type for portal workspace. "
+ "Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE);
/* Create legacy-free application type
*
@ -198,11 +199,12 @@ public class Loader extends PackageLoader {
/**
* Setup WorkspacePage type.
*
* Creates an entry for class (=type) c.ad.portalworkspace.WorkspacePage in
* table application_types, but not in apm_package_types.
* Creates an entry for class (=type) c.ad.portalworkspace.WorkspacePage in table
* 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
*/
private ResourceType setupWorkspacePageType() {
@ -213,7 +215,6 @@ public class Loader extends PackageLoader {
return type;
}
/**
*
*/
@ -240,13 +241,15 @@ public class Loader extends PackageLoader {
private void loadLoginPortlet() {
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");
}
private void loadRSSFeedPortlet() {
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");
}
@ -259,5 +262,4 @@ public class Loader extends PackageLoader {
// TimeOfDayPortlet.BASE_DATA_OBJECT_TYPE);
// 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.portalworkspace;
import java.math.BigDecimal;
@ -37,8 +36,7 @@ import com.arsdigita.util.UncheckedWrapperException;
*/
public class PageLayout extends DomainObject {
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.portalworkspace.PageLayout";
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.portalworkspace.PageLayout";
public static final String ID = "id";
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_ONE_COLUMN = "100%";
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 PageLayout() {
@ -68,6 +67,7 @@ public class PageLayout extends DomainObject {
/**
*
*/
@Override
public void initialize() {
super.initialize();
@ -102,6 +102,7 @@ public class PageLayout extends DomainObject {
* @param title
* @param description
* @param format
*
* @return
*/
public static PageLayout create(String title, String description,
@ -155,4 +156,5 @@ public class PageLayout extends DomainObject {
String[] bits = StringUtils.split(getFormat(), ',');
return bits.length;
}
}

View File

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

View File

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

View File

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

View File

@ -15,7 +15,6 @@
* 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.portalworkspace.ui;
import com.arsdigita.bebop.PageState;
@ -37,25 +36,42 @@ import com.arsdigita.xml.XML;
*/
public class WorkspaceDetails extends SimpleComponent {
private WorkspaceSelectionAbstractModel m_workspace;
private WorkspaceSelectionAbstractModel workspaceModel;
public WorkspaceDetails(WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace;
public WorkspaceDetails(final WorkspaceSelectionAbstractModel workspace) {
super();
this.workspaceModel = workspace;
}
public void setWorkspaceModel(WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace;
public void setWorkspaceModel(final WorkspaceSelectionAbstractModel workspace) {
this.workspaceModel = workspace;
}
public Workspace getSelectedWorkspace(PageState state) {
return m_workspace.getSelectedWorkspace(state);
public Workspace getSelectedWorkspace(final PageState 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
public void generateXML(PageState state, Element parent) {
Workspace workspace = getSelectedWorkspace(state);
public void generateXML(final PageState state, final Element parent) {
final Workspace workspace = getSelectedWorkspace(state);
Element content = new Element("portal:workspaceDetails",
final Element content = new Element("portal:workspaceDetails",
WorkspacePage.PORTAL_XML_NS);
exportAttributes(content);
@ -65,29 +81,30 @@ public class WorkspaceDetails extends SimpleComponent {
parent.addContent(content);
}
protected void generateWorkspaceXML(PageState state, Element content,
Workspace workspace) {
protected void generateWorkspaceXML(final PageState state,
final Element content,
final Workspace workspace) {
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(content);
xr.setWrapRoot(false);
xr.setWrapAttributes(true);
xr.setWrapObjects(false);
final DomainObjectXMLRenderer renderer = new DomainObjectXMLRenderer(content);
renderer.setWrapRoot(false);
renderer.setWrapAttributes(true);
renderer.setWrapObjects(false);
xr.walk(workspace, WorkspaceDetails.class.getName());
renderer.walk(workspace, WorkspaceDetails.class.getName());
}
protected void generatePermissionXML(PageState state, Element content,
Workspace workspace) {
Party party = Kernel.getContext().getParty();
protected void generatePermissionXML(final PageState state,
final Element content,
final Workspace workspace) {
final Party party = Kernel.getContext().getParty();
PermissionDescriptor edit = new PermissionDescriptor(
final PermissionDescriptor edit = new PermissionDescriptor(
PrivilegeDescriptor.EDIT, workspace, party);
PermissionDescriptor admin = new PermissionDescriptor(
final PermissionDescriptor admin = new PermissionDescriptor(
PrivilegeDescriptor.ADMIN, workspace, party);
content.addAttribute("canEdit", XML.format(new Boolean(
PermissionService.checkPermission(edit))));
content.addAttribute("canAdmin", XML.format(new Boolean(
PermissionService.checkPermission(admin))));
content.addAttribute("canEdit", XML.format(PermissionService.checkPermission(edit)));
content.addAttribute("canAdmin", XML.format(PermissionService.checkPermission(admin)));
}
}

View File

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