mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added actions to broken file and form items so they can be modified and previewed.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5931 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,7 @@ package org.alfresco.web.ui.wcm.component;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.el.ValueBinding;
|
||||
@@ -35,6 +36,7 @@ import org.alfresco.config.JNDIConstants;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.wcm.LinkValidationState;
|
||||
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
|
||||
import org.alfresco.web.ui.repo.component.UIActions;
|
||||
|
||||
/**
|
||||
* Base class for all the link validation report JSF components.
|
||||
@@ -67,6 +69,22 @@ public abstract class AbstractLinkValidationReportComponent extends SelfRenderin
|
||||
values[1] = this.state;
|
||||
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()
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper methods
|
||||
@@ -229,6 +247,45 @@ public abstract class AbstractLinkValidationReportComponent extends SelfRenderin
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aquire the UIActions component for the specified action group ID.
|
||||
* Search for the component in the child list or create as needed.
|
||||
*
|
||||
* @param id ActionGroup id of the UIActions component
|
||||
*
|
||||
* @return UIActions component
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected UIActions aquireUIActions(String id, String store)
|
||||
{
|
||||
UIActions uiActions = null;
|
||||
String componentId = id + '_' + store;
|
||||
|
||||
for (UIComponent component : (List<UIComponent>)getChildren())
|
||||
{
|
||||
if (componentId.equals(component.getId()))
|
||||
{
|
||||
uiActions = (UIActions)component;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (uiActions == null)
|
||||
{
|
||||
javax.faces.application.Application facesApp = FacesContext.getCurrentInstance().getApplication();
|
||||
uiActions = (UIActions)facesApp.createComponent("org.alfresco.faces.Actions");
|
||||
uiActions.setShowLink(false);
|
||||
uiActions.getAttributes().put("styleClass", "inlineAction");
|
||||
uiActions.setId(componentId);
|
||||
uiActions.setParent(this);
|
||||
uiActions.setValue(id);
|
||||
|
||||
this.getChildren().add(uiActions);
|
||||
}
|
||||
|
||||
return uiActions;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Strongly typed component property accessors
|
||||
|
||||
|
@@ -30,8 +30,16 @@ import java.util.List;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMNode;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.bean.wcm.LinkValidationState;
|
||||
import org.alfresco.web.config.ClientConfigElement;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.repo.component.UIActions;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -84,9 +92,19 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom
|
||||
}
|
||||
else
|
||||
{
|
||||
UIActions actions = aquireUIActions("broken_file_actions", getValue().getStore());
|
||||
AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
|
||||
int rootPathIndex = AVMUtil.buildSandboxRootPath(linkState.getStore()).length();
|
||||
String dns = AVMUtil.lookupStoreDNS(linkState.getStore());
|
||||
ClientConfigElement config = Application.getClientConfig(context);
|
||||
String wcmDomain = config.getWCMDomain();
|
||||
String wcmPort = config.getWCMPort();
|
||||
|
||||
// render each broken file
|
||||
for (String file : brokenFiles)
|
||||
{
|
||||
renderBrokenFile(context, out, file, linkState);
|
||||
renderBrokenFile(context, out, file, linkState, actions, avmService,
|
||||
rootPathIndex, wcmDomain, wcmPort, dns);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +115,10 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom
|
||||
// Helpers
|
||||
|
||||
private void renderBrokenFile(FacesContext context, ResponseWriter out,
|
||||
String file, LinkValidationState linkState) throws IOException
|
||||
String file, LinkValidationState linkState, UIActions actions,
|
||||
AVMService avmService, int rootPathIndex, String wcmDomain,
|
||||
String wcmPort, String dns)
|
||||
throws IOException
|
||||
{
|
||||
// gather the data to show for the file
|
||||
String[] nameAndPath = this.getFileNameAndPath(file);
|
||||
@@ -126,11 +147,19 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom
|
||||
out.write("'><td>");
|
||||
renderFile(out, context, fileName, filePath, brokenLinks);
|
||||
out.write("</td><td align='right' valign='top'><div style='white-space: nowrap; padding-top: 10px; padding-right: 20px;'>");
|
||||
out.write(" ");
|
||||
// out.write("<img src='/alfresco/images/icons/edit_icon.gif' /> ");
|
||||
// out.write("<img src='/alfresco/images/icons/update.gif' /> ");
|
||||
// out.write("<img src='/alfresco/images/icons/revert.gif' /> ");
|
||||
// out.write("<img src='/alfresco/images/icons/preview_website.gif' /> ");
|
||||
|
||||
// setup the context for the actions
|
||||
AVMNodeDescriptor desc = avmService.lookup(-1, file);
|
||||
AVMNode node = new AVMNode(desc);
|
||||
|
||||
String assetPath = file.substring(rootPathIndex);
|
||||
String previewUrl = AVMUtil.buildAssetUrl(assetPath, wcmDomain, wcmPort, dns);
|
||||
node.getProperties().put("previewUrl", previewUrl);
|
||||
actions.setContext(node);
|
||||
|
||||
// render the actions
|
||||
Utils.encodeRecursive(context, actions);
|
||||
|
||||
out.write("</div></td></tr>");
|
||||
}
|
||||
}
|
||||
|
@@ -30,8 +30,15 @@ import java.util.List;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMNode;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.bean.wcm.LinkValidationState;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.repo.component.UIActions;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -84,9 +91,12 @@ public class UILinkValidationBrokenForms extends AbstractLinkValidationReportCom
|
||||
}
|
||||
else
|
||||
{
|
||||
UIActions actions = aquireUIActions("broken_form_actions", getValue().getStore());
|
||||
AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
|
||||
|
||||
for (String form : brokenForms)
|
||||
{
|
||||
renderBrokenForm(context, out, form, linkState);
|
||||
renderBrokenForm(context, out, form, linkState, actions, avmService);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +107,8 @@ public class UILinkValidationBrokenForms extends AbstractLinkValidationReportCom
|
||||
// Helpers
|
||||
|
||||
private void renderBrokenForm(FacesContext context, ResponseWriter out,
|
||||
String file, LinkValidationState linkState) throws IOException
|
||||
String file, LinkValidationState linkState, UIActions actions,
|
||||
AVMService avmService) throws IOException
|
||||
{
|
||||
// get the web form name and path
|
||||
String[] formNamePath = this.getFileNameAndPath(file);
|
||||
@@ -146,7 +157,15 @@ public class UILinkValidationBrokenForms extends AbstractLinkValidationReportCom
|
||||
|
||||
out.write("</td><td align='right' valign='top'><div style='white-space: nowrap; padding-top: 10px; padding-right: 20px;'>");
|
||||
out.write(" ");
|
||||
// out.write("<img src='/alfresco/images/icons/edit_icon.gif' /> ");
|
||||
|
||||
// setup the context for the actions
|
||||
AVMNodeDescriptor desc = avmService.lookup(-1, file);
|
||||
AVMNode node = new AVMNode(desc);
|
||||
actions.setContext(node);
|
||||
|
||||
// render the actions
|
||||
Utils.encodeRecursive(context, actions);
|
||||
|
||||
out.write("</div></td></tr>");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user