mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Checkpoint of WCM UI
- More implementation of the User sandboxes UI - added actions placeholders for Preview, Create and Browse for sandbox - Modified files list component framework and placeholder - Import Website Content dialog component framework pieces git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3791 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,8 +19,10 @@ package org.alfresco.web.ui.wcm.component;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.component.NamingContainer;
|
||||
@@ -42,15 +44,23 @@ import org.alfresco.web.bean.wcm.AVMConstants;
|
||||
import org.alfresco.web.ui.common.PanelGenerator;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
import org.alfresco.web.ui.repo.component.UIActions;
|
||||
import org.alfresco.web.ui.wcm.WebResources;
|
||||
import org.springframework.web.jsf.FacesContextUtils;
|
||||
|
||||
import sun.swing.UIAction;
|
||||
|
||||
/**
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class UIUserSandboxes extends SelfRenderingComponent
|
||||
{
|
||||
private static final String MSG_USERNAME = "username";
|
||||
private static final String MSG_NAME = "name";
|
||||
private static final String MSG_DESCRIPTION = "description";
|
||||
private static final String MSG_MODIFIED = "modified_date";
|
||||
private static final String MSG_ACTIONS = "actions";
|
||||
|
||||
/** website to show sandboxes for */
|
||||
private NodeRef value;
|
||||
@@ -87,6 +97,22 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
values[2] = this.expandedPanels;
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#getRendersChildren()
|
||||
*/
|
||||
public boolean getRendersChildren()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
|
||||
*/
|
||||
public void encodeChildren(FacesContext context) throws IOException
|
||||
{
|
||||
// the child components are rendered explicitly during the encodeBegin()
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
|
||||
@@ -127,11 +153,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
|
||||
ResponseWriter out = context.getResponseWriter();
|
||||
|
||||
if (getChildCount() == 0)
|
||||
{
|
||||
// create any sub-component for the first time
|
||||
}
|
||||
|
||||
ResourceBundle bundle = Application.getBundle(context);
|
||||
AVMService avmService = getAVMService(context);
|
||||
NodeService nodeService = getNodeService(context);
|
||||
UserTransaction tx = null;
|
||||
@@ -153,45 +175,92 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
{
|
||||
String username = users.get(i);
|
||||
|
||||
// build the name of the main store for the user
|
||||
String mainStore = storeRoot + '-' + username + AVMConstants.STORE_MAIN;
|
||||
AVMStoreDescriptor store = avmService.getAVMStore(mainStore);
|
||||
|
||||
// for each user sandbox, generate an outer panel table
|
||||
PanelGenerator.generatePanelStart(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white",
|
||||
"white");
|
||||
|
||||
// components for the current username, preview, browse and modified items inner list
|
||||
out.write("<table cellspacing=2 cellpadding=2 border=0 width=100%><tr><td>");
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_SANDBOX_32, 32, 32, ""));
|
||||
out.write("</td><td width=100%>");
|
||||
out.write("<b>");
|
||||
out.write(Application.getMessage(context, MSG_USERNAME));
|
||||
out.write(":</b> ");
|
||||
out.write(username); // TODO: convert to full name
|
||||
out.write("</td><td><nobr>");
|
||||
// direct actions for a sandbox
|
||||
// TODO: add actions for a sandbox
|
||||
out.write("(Preview) (Create) (Browse)");
|
||||
out.write("</nobr></td></tr>");
|
||||
// modified items panel
|
||||
out.write("<tr><td></td><td colspan=2>");
|
||||
String panelImage = this.expandedPanels.contains(username) ? WebResources.IMAGE_EXPANDED : WebResources.IMAGE_COLLAPSED;
|
||||
out.write(Utils.buildImageTag(context, panelImage, 11, 11, "",
|
||||
Utils.generateFormSubmit(context, this, getClientId(context), username)));
|
||||
out.write(" <b>Modified Items (3)</b>");
|
||||
out.write("</td></tr></table>");
|
||||
|
||||
// end the outer panel for this sandbox
|
||||
PanelGenerator.generatePanelEnd(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white");
|
||||
|
||||
// spacer row
|
||||
if (i < users.size() - 1)
|
||||
// check it exists before we render the view
|
||||
if (avmService.getAVMStore(mainStore) != null)
|
||||
{
|
||||
out.write("<div style='padding:4px'></div>");
|
||||
// for each user sandbox, generate an outer panel table
|
||||
PanelGenerator.generatePanelStart(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white",
|
||||
"white");
|
||||
|
||||
// components for the current username, preview, browse and modified items inner list
|
||||
out.write("<table cellspacing=2 cellpadding=2 border=0 width=100%><tr><td>");
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_SANDBOX_32, 32, 32, ""));
|
||||
out.write("</td><td width=100%>");
|
||||
out.write("<b>");
|
||||
out.write(bundle.getString(MSG_USERNAME));
|
||||
out.write(":</b> ");
|
||||
out.write(username); // TODO: convert to full name?
|
||||
out.write("</td><td><nobr>");
|
||||
|
||||
// direct actions for a sandbox
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, "sandbox_preview", "/images/icons/preview_website.gif"));
|
||||
out.write(" ");
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, "sandbox_create", "/images/icons/new_content.gif"));
|
||||
out.write(" ");
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, "sandbox_browse", "/images/icons/space_small.gif"));
|
||||
out.write("</nobr></td></tr>");
|
||||
|
||||
// modified items panel
|
||||
out.write("<tr><td></td><td colspan=2>");
|
||||
String panelImage = WebResources.IMAGE_COLLAPSED;
|
||||
if (this.expandedPanels.contains(username))
|
||||
{
|
||||
panelImage = WebResources.IMAGE_EXPANDED;
|
||||
}
|
||||
out.write(Utils.buildImageTag(context, panelImage, 11, 11, "",
|
||||
Utils.generateFormSubmit(context, this, getClientId(context), username)));
|
||||
out.write(" <b>Modified Items (3)</b>");
|
||||
if (this.expandedPanels.contains(username))
|
||||
{
|
||||
out.write("<div style='padding:2px'></div>");
|
||||
out.write("<table cellspacing=2 cellpadding=2 border=0 width=100%>");
|
||||
|
||||
// header row
|
||||
out.write("<tr align=left><th width=16></th><th>");
|
||||
out.write(bundle.getString(MSG_NAME));
|
||||
out.write("</th><th>");
|
||||
out.write(bundle.getString(MSG_DESCRIPTION));
|
||||
out.write("</th><th>");
|
||||
out.write(bundle.getString(MSG_MODIFIED));
|
||||
out.write("</th><th>");
|
||||
out.write(bundle.getString(MSG_ACTIONS));
|
||||
out.write("</th></tr>");
|
||||
|
||||
// row per modified doc item
|
||||
// TODO: add modified items list for this sandbox user
|
||||
out.write("<tr><td width=16>(O)</td><td>");
|
||||
out.write("Some document.html");
|
||||
out.write("</td><td>");
|
||||
out.write("A description would go here");
|
||||
out.write("</td><td>");
|
||||
out.write("01-01-2006 11:58am");
|
||||
out.write("</td><td>");
|
||||
// TODO: add UI actions for this item
|
||||
out.write("(P) (E) (T) (D)");
|
||||
out.write("</td></tr>");
|
||||
|
||||
out.write("</table>");
|
||||
}
|
||||
out.write("</td></tr></table>");
|
||||
|
||||
// end the outer panel for this sandbox
|
||||
PanelGenerator.generatePanelEnd(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white");
|
||||
|
||||
// spacer row
|
||||
if (i < users.size() - 1)
|
||||
{
|
||||
out.write("<div style='padding:4px'></div>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +273,47 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
}
|
||||
}
|
||||
|
||||
private UIActionLink aquireAction(FacesContext fc, String name, String icon)
|
||||
{
|
||||
UIActionLink action = findAction(name);
|
||||
if (action == null)
|
||||
{
|
||||
action = createAction(fc, name, icon);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
private UIActionLink findAction(String name)
|
||||
{
|
||||
UIActionLink action = null;
|
||||
String actionId = getId() + name;
|
||||
for (UIComponent component : (List<UIComponent>)getChildren())
|
||||
{
|
||||
if (actionId.equals(component.getId()))
|
||||
{
|
||||
action = (UIActionLink)component;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
private UIActionLink createAction(FacesContext fc, String name, String icon)
|
||||
{
|
||||
javax.faces.application.Application facesApp = fc.getApplication();
|
||||
UIActionLink control = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK);
|
||||
|
||||
control.setRendererType(UIActions.RENDERER_ACTIONLINK);
|
||||
control.setId(getId() + name);
|
||||
control.setValue(Application.getMessage(fc, name));
|
||||
control.setShowLink(false);
|
||||
control.setImage(icon);
|
||||
|
||||
this.getChildren().add(control);
|
||||
|
||||
return control;
|
||||
}
|
||||
|
||||
private AVMService getAVMService(FacesContext fc)
|
||||
{
|
||||
return (AVMService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMService");
|
||||
|
Reference in New Issue
Block a user