mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
. Fixed several minor bugs where the various small icons for Space objects were not displayed:
- Clipboard, Recent Spaces, Shortcuts and Space Selector now all show correct Forum or small Space icons as appropriate for the node - this is now possible since the forums icons patch standardised the way in which all small icons named . Externalised actions missing from forums.jsp, forum.jsp and topic.jsp . Added Create Shortcut action to Forums, Forum and Topic details pages (why not!) - The user can now create shortcuts to a Forums space, a Forum or a Topic . Prototype work for Paste-as-link (not visible yet) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2571 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,9 +26,10 @@ import javax.faces.event.ActionEvent;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -50,14 +51,6 @@ public class ClipboardBean
|
||||
{
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean property getters and setters
|
||||
|
||||
/**
|
||||
* @return Returns the NodeService.
|
||||
*/
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
return this.nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService The NodeService to set.
|
||||
@@ -66,29 +59,12 @@ public class ClipboardBean
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the NodeOperationsService.
|
||||
* @param fileFolderService The FileFolderService to set.
|
||||
*/
|
||||
public CopyService getNodeOperationsService()
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
return this.nodeOperationsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeOperationsService The NodeOperationsService to set.
|
||||
*/
|
||||
public void setNodeOperationsService(CopyService nodeOperationsService)
|
||||
{
|
||||
this.nodeOperationsService = nodeOperationsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the navigation bean instance.
|
||||
*/
|
||||
public NavigationBean getNavigator()
|
||||
{
|
||||
return this.navigator;
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +128,7 @@ public class ClipboardBean
|
||||
*/
|
||||
public void pasteAll(ActionEvent event)
|
||||
{
|
||||
performPasteItems(-1);
|
||||
performPasteItems(-1, UIClipboardShelfItem.ACTION_PASTE_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,15 +144,16 @@ public class ClipboardBean
|
||||
throw new IllegalStateException("Clipboard attempting paste a non existent item index: " + index);
|
||||
}
|
||||
|
||||
performPasteItems(index);
|
||||
performPasteItems(index, clipEvent.Action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a paste for the specified clipboard item(s)
|
||||
*
|
||||
* @param index of clipboard item to paste or -1 for all
|
||||
* @param action the clipboard action to perform (see UIClipboardShelfItem)
|
||||
*/
|
||||
private void performPasteItems(int index)
|
||||
private void performPasteItems(int index, int action)
|
||||
{
|
||||
UserTransaction tx = null;
|
||||
try
|
||||
@@ -189,7 +166,7 @@ public class ClipboardBean
|
||||
// paste all
|
||||
for (int i=0; i<this.items.size(); i++)
|
||||
{
|
||||
performClipboardOperation(this.items.get(i));
|
||||
performClipboardOperation(this.items.get(i), action);
|
||||
}
|
||||
// remove the cut operation item from the clipboard
|
||||
List<ClipboardItem> newItems = new ArrayList<ClipboardItem>(this.items.size());
|
||||
@@ -208,7 +185,7 @@ public class ClipboardBean
|
||||
{
|
||||
// single paste operation
|
||||
ClipboardItem item = this.items.get(index);
|
||||
performClipboardOperation(item);
|
||||
performClipboardOperation(item, action);
|
||||
if (item.Mode == ClipboardStatus.CUT)
|
||||
{
|
||||
this.items.remove(index);
|
||||
@@ -233,45 +210,56 @@ public class ClipboardBean
|
||||
/**
|
||||
* Perform the operation for the specified clipboard item
|
||||
*
|
||||
* @param item
|
||||
* @param item the ClipboardItem
|
||||
* @param action the clipboard action to perform (see UIClipboardShelfItem)
|
||||
*/
|
||||
private void performClipboardOperation(ClipboardItem item)
|
||||
private void performClipboardOperation(ClipboardItem item, int action)
|
||||
throws FileExistsException, FileNotFoundException
|
||||
{
|
||||
NodeRef parentRef = new NodeRef(Repository.getStoreRef(),
|
||||
this.navigator.getCurrentNodeId());
|
||||
NodeRef destRef = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
|
||||
|
||||
// TODO: should we use primary parent here?
|
||||
// The problem is we can't pass round ChildAssocRefs as form params etc. in the UI!
|
||||
// It's tricky if we need to pass childassocref around everywhere...!
|
||||
// TODO: Should we use primary parent here?
|
||||
// We are assuming that the item exists in only a single parent and that the source for
|
||||
// the clipboard operation (e.g. the source folder) is specifically that parent node.
|
||||
// This does not allow for more than one possible parent node - or for linked objects!
|
||||
ChildAssociationRef assocRef = this.nodeService.getPrimaryParent(item.Node.getNodeRef());
|
||||
|
||||
if (item.Mode == ClipboardStatus.COPY)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to copy node ID: " + item.Node.getId() + " into node ID: " + parentRef.getId());
|
||||
|
||||
// call the node ops service to initiate the copy
|
||||
// TODO: should the assoc qname be derived from the type...?
|
||||
DictionaryService dd = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getDictionaryService();
|
||||
boolean copyChildren = dd.isSubClass(item.Node.getType(), ContentModel.TYPE_FOLDER);
|
||||
NodeRef copyRef = this.nodeOperationsService.copy(
|
||||
item.Node.getNodeRef(),
|
||||
parentRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
assocRef.getQName(),
|
||||
copyChildren);
|
||||
if (action == UIClipboardShelfItem.ACTION_PASTE_LINK)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Attempting to link node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
|
||||
|
||||
// copy as link was specifically requested by the user
|
||||
this.nodeService.addChild(
|
||||
destRef,
|
||||
item.Node.getNodeRef(),
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
assocRef.getQName());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Attempting to copy node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
|
||||
|
||||
// call the node ops service to initiate the copy
|
||||
this.fileFolderService.copy(
|
||||
item.Node.getNodeRef(),
|
||||
destRef,
|
||||
null); // TODO: could add "Copy of ..." here if copy fails
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to move node ID: " + item.Node.getId() + " into node ID: " + parentRef.getId());
|
||||
logger.debug("Attempting to move node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
|
||||
|
||||
// move the node
|
||||
this.nodeService.moveNode(
|
||||
this.fileFolderService.move(
|
||||
item.Node.getNodeRef(),
|
||||
parentRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
assocRef.getQName());
|
||||
destRef,
|
||||
null); // TODO: could add "Copy of ..." here if move fails
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,8 +313,8 @@ public class ClipboardBean
|
||||
/** The NodeService to be used by the bean */
|
||||
protected NodeService nodeService;
|
||||
|
||||
/** The NodeOperationsService to be used by the bean */
|
||||
protected CopyService nodeOperationsService;
|
||||
/** The FileFolderService to be used by the bean */
|
||||
protected FileFolderService fileFolderService;
|
||||
|
||||
/** The NavigationBean reference */
|
||||
protected NavigationBean navigator;
|
||||
|
@@ -128,9 +128,11 @@ public abstract class AbstractItemSelector extends UIInput
|
||||
public abstract Collection<NodeRef> getRootChildren(FacesContext context);
|
||||
|
||||
/**
|
||||
* @return The icon image to display next to the item links, or null for no icon
|
||||
* @param ref NodeRef to the item to get the icon for
|
||||
*
|
||||
* @return The icon image to display next to the item links, or null for no icon
|
||||
*/
|
||||
public abstract String getItemIcon();
|
||||
public abstract String getItemIcon(FacesContext context, NodeRef ref);
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
|
||||
@@ -278,12 +280,6 @@ public abstract class AbstractItemSelector extends UIInput
|
||||
boolean showValueInHiddenField = false;
|
||||
NodeRef value = null;
|
||||
|
||||
String image = null;
|
||||
if (getItemIcon() != null)
|
||||
{
|
||||
image = "<span style='padding-right:4px'>" + Utils.buildImageTag(context, getItemIcon(), null, "absmiddle") + "</span>";
|
||||
}
|
||||
|
||||
switch (this.mode)
|
||||
{
|
||||
case MODE_BEFORE_SELECTION:
|
||||
@@ -486,7 +482,15 @@ public abstract class AbstractItemSelector extends UIInput
|
||||
// get the name for the child and output as link
|
||||
NodeRef childNodeRef = new NodeRef(Repository.getStoreRef(), childId);
|
||||
String name = Repository.getNameForNode(service, childNodeRef);
|
||||
renderNodeLink(context, childId, name, image, buf);
|
||||
String prefixHtml = null;
|
||||
String icon = getItemIcon(context, childNodeRef);
|
||||
if (icon != null)
|
||||
{
|
||||
prefixHtml = "<span style='padding-right:4px'>" +
|
||||
Utils.buildImageTag(context, icon, null, "absmiddle") +
|
||||
"</span>";
|
||||
}
|
||||
renderNodeLink(context, childId, name, prefixHtml, buf);
|
||||
buf.append("</td></tr>");
|
||||
}
|
||||
|
||||
|
@@ -144,7 +144,7 @@ public class UICategorySelector extends AbstractItemSelector
|
||||
/**
|
||||
* @see org.alfresco.web.ui.repo.component.AbstractItemSelector#getItemIcon()
|
||||
*/
|
||||
public String getItemIcon()
|
||||
public String getItemIcon(FacesContext context, NodeRef ref)
|
||||
{
|
||||
return WebResources.IMAGE_CATEGORY;
|
||||
}
|
||||
|
@@ -141,8 +141,17 @@ public class UISpaceSelector extends AbstractItemSelector
|
||||
/**
|
||||
* @see org.alfresco.web.ui.repo.component.AbstractItemSelector#getItemIcon()
|
||||
*/
|
||||
public String getItemIcon()
|
||||
public String getItemIcon(FacesContext context, NodeRef ref)
|
||||
{
|
||||
return WebResources.IMAGE_SPACE;
|
||||
String icon = (String)getNodeService(context).getProperty(ref, ContentModel.PROP_ICON);
|
||||
if (icon != null)
|
||||
{
|
||||
icon = "/images/icons/" + icon + "-16.gif";
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = WebResources.IMAGE_SPACE;
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
@@ -122,6 +122,7 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
|
||||
case ACTION_PASTE_ALL:
|
||||
case ACTION_PASTE_ITEM:
|
||||
case ACTION_PASTE_LINK:
|
||||
Utils.processActionMethod(getFacesContext(), getPasteActionListener(), clipEvent);
|
||||
break;
|
||||
}
|
||||
@@ -158,7 +159,7 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
ClipboardItem item = items.get(i);
|
||||
|
||||
// start row with cut/copy state icon
|
||||
out.write("<tr><td>");
|
||||
out.write("<tr><td width=16>");
|
||||
if (item.Mode == ClipboardStatus.COPY)
|
||||
{
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_COPY, 14, 16, bundle.getString(MSG_COPY), null, "absmiddle"));
|
||||
@@ -167,17 +168,26 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
{
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_CUT, 13, 16, bundle.getString(MSG_CUT), null, "absmiddle"));
|
||||
}
|
||||
out.write("</td><td>");
|
||||
out.write("</td><td width=16>");
|
||||
|
||||
if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
// start row with Space icon
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_SPACE, 16, 16, null, null, "absmiddle"));
|
||||
// start row with correct node icon
|
||||
String icon = (String)item.Node.getProperties().get("app:icon");
|
||||
if (icon != null)
|
||||
{
|
||||
icon = "/images/icons/" + icon + "-16.gif";
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = WebResources.IMAGE_SPACE;
|
||||
}
|
||||
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
|
||||
}
|
||||
else if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
String image = Utils.getFileTypeImage(item.Node.getName(), true);
|
||||
out.write(Utils.buildImageTag(context, image, 16, 16, null, null, "absmiddle"));
|
||||
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
|
||||
}
|
||||
|
||||
// output cropped item label - we also output with no breaks, this is ok
|
||||
@@ -190,6 +200,11 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
out.write(buildActionLink(ACTION_REMOVE_ITEM, i, bundle.getString(MSG_REMOVE_ITEM), WebResources.IMAGE_REMOVE));
|
||||
out.write(" ");
|
||||
out.write(buildActionLink(ACTION_PASTE_ITEM, i, bundle.getString(MSG_PASTE_ITEM), WebResources.IMAGE_PASTE));
|
||||
//if (item.Mode == ClipboardStatus.COPY)
|
||||
//{
|
||||
// out.write(" ");
|
||||
// out.write(buildActionLink(ACTION_PASTE_LINK, i, bundle.getString(MSG_PASTE_LINK), WebResources.IMAGE_PASTE_LINK));
|
||||
//}
|
||||
|
||||
// end actions cell and end row
|
||||
out.write("</nobr></td></tr>");
|
||||
@@ -337,17 +352,19 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
// Private data
|
||||
|
||||
/** I18N messages */
|
||||
private static final String MSG_REMOVE_ALL = "remove_all";
|
||||
private static final String MSG_PASTE_ALL = "paste_all";
|
||||
private static final String MSG_PASTE_ITEM = "paste_item";
|
||||
private static final String MSG_REMOVE_ALL = "remove_all";
|
||||
private static final String MSG_PASTE_ALL = "paste_all";
|
||||
private static final String MSG_PASTE_ITEM = "paste_item";
|
||||
private static final String MSG_PASTE_LINK = "paste_link";
|
||||
private static final String MSG_REMOVE_ITEM = "remove_item";
|
||||
private static final String MSG_CUT = "cut";
|
||||
private static final String MSG_COPY = "copy";
|
||||
|
||||
private final static int ACTION_REMOVE_ITEM = 0;
|
||||
private final static int ACTION_REMOVE_ALL = 1;
|
||||
private final static int ACTION_PASTE_ITEM = 2;
|
||||
private final static int ACTION_PASTE_ALL = 3;
|
||||
public final static int ACTION_REMOVE_ITEM = 0;
|
||||
public final static int ACTION_REMOVE_ALL = 1;
|
||||
public final static int ACTION_PASTE_ITEM = 2;
|
||||
public final static int ACTION_PASTE_ALL = 3;
|
||||
public final static int ACTION_PASTE_LINK = 4;
|
||||
|
||||
/** the current list of clipboard items */
|
||||
private List<ClipboardItem> collections;
|
||||
|
@@ -153,9 +153,18 @@ public class UIRecentSpacesShelfItem extends UIShelfItem
|
||||
{
|
||||
Node item = items.get(i);
|
||||
|
||||
// start row with Space icon
|
||||
out.write("<tr><td>");
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_SPACE, 16, 16, null, null, "absmiddle"));
|
||||
// start row with correct node icon
|
||||
out.write("<tr><td width=16>");
|
||||
String icon = (String)item.getProperties().get("app:icon");
|
||||
if (icon != null)
|
||||
{
|
||||
icon = "/images/icons/" + icon + "-16.gif";
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = WebResources.IMAGE_SPACE;
|
||||
}
|
||||
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
|
||||
|
||||
// output cropped item label - we also output with no breaks, this is ok
|
||||
// as the copped label will ensure a sensible maximum width
|
||||
|
@@ -179,16 +179,25 @@ public class UIShortcutsShelfItem extends UIShelfItem
|
||||
{
|
||||
Node item = items.get(i);
|
||||
|
||||
out.write("<tr><td>");
|
||||
out.write("<tr><td width=16>");
|
||||
if (dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
// start row with Space icon
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_SPACE, 16, 16, null, null, "absmiddle"));
|
||||
// start row with correct node icon
|
||||
String icon = (String)item.getProperties().get("app:icon");
|
||||
if (icon != null)
|
||||
{
|
||||
icon = "/images/icons/" + icon + "-16.gif";
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = WebResources.IMAGE_SPACE;
|
||||
}
|
||||
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
|
||||
}
|
||||
else if (dd.isSubClass(item.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
String image = Utils.getFileTypeImage(item.getName(), true);
|
||||
out.write(Utils.buildImageTag(context, image, 16, 16, null, null, "absmiddle"));
|
||||
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
|
||||
}
|
||||
|
||||
// output cropped item label - we also output with no breaks, this is ok
|
||||
|
Reference in New Issue
Block a user