mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. First part of the Clipboard UI refactoring ready for AVM node support
- Clipboard actions now based on NodeRef not "id" - Added notion of "workspace" and "AVM" specific clipboard items - Clipboard bean supports creating different ClipboardItem types (workspace or avm) . ActionLink parameters are now "toString()"ed rather than assumed String . Optimization to Portal Tree Navigator support git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4924 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -311,7 +311,8 @@
|
||||
<image>/images/icons/cut.gif</image>
|
||||
<action-listener>#{ClipboardBean.cutNode}</action-listener>
|
||||
<params>
|
||||
<param name="id">#{actionContext.id}</param>
|
||||
<param name="ref">#{actionContext.nodeRef}</param>
|
||||
<!--<param name="protocol">#{actionContext.nodeRef.storeRef.protocol}</param>-->
|
||||
<!--<param name="parent">#{NavigationBean.currentNodeId}</param>-->
|
||||
</params>
|
||||
</action>
|
||||
@@ -322,36 +323,11 @@
|
||||
<image>/images/icons/copy.gif</image>
|
||||
<action-listener>#{ClipboardBean.copyNode}</action-listener>
|
||||
<params>
|
||||
<param name="id">#{actionContext.id}</param>
|
||||
<param name="ref">#{actionContext.nodeRef}</param>
|
||||
<!--<param name="parent">#{NavigationBean.currentNodeId}</param>-->
|
||||
</params>
|
||||
</action>
|
||||
|
||||
<!-- Cut a document or space to the clipboard, from space details screen -->
|
||||
<!--<action id="cut_space_details">
|
||||
<permissions>
|
||||
<permission allow="true">Delete</permission>
|
||||
</permissions>
|
||||
<label-id>cut</label-id>
|
||||
<image>/images/icons/cut.gif</image>
|
||||
<action-listener>#{ClipboardBean.cutNode}</action-listener>
|
||||
<params>
|
||||
<param name="id">#{actionContext.id}</param>
|
||||
<param name="parent">#{SpaceDetailsBean.space}</param>
|
||||
</params>
|
||||
</action>-->
|
||||
|
||||
<!-- Copy a document or space to the clipboard, from space details screen -->
|
||||
<!--<action id="copy_space_details">
|
||||
<label-id>copy</label-id>
|
||||
<image>/images/icons/copy.gif</image>
|
||||
<action-listener>#{ClipboardBean.copyNode}</action-listener>
|
||||
<params>
|
||||
<param name="id">#{actionContext.id}</param>
|
||||
<param name="parent">#{SpaceDetailsBean.space}</param>
|
||||
</params>
|
||||
</action>-->
|
||||
|
||||
<!-- Paste All clipboard items into a space -->
|
||||
<action id="paste_all">
|
||||
<permissions>
|
||||
|
@@ -28,7 +28,7 @@
|
||||
<image>/images/icons/cut.gif</image>
|
||||
<action-listener>#{ClipboardBean.cutNode}</action-listener>
|
||||
<params>
|
||||
<param name="id">#{actionContext.id}</param>
|
||||
<param name="ref">#{actionContext.nodeRef}</param>
|
||||
<!--<param name="parent">#{NavigationBean.currentNodeId}</param>-->
|
||||
</params>
|
||||
</action>
|
||||
@@ -41,7 +41,7 @@
|
||||
<image>/images/icons/copy.gif</image>
|
||||
<action-listener>#{ClipboardBean.copyNode}</action-listener>
|
||||
<params>
|
||||
<param name="id">#{actionContext.id}</param>
|
||||
<param name="ref">#{actionContext.nodeRef}</param>
|
||||
<!--<param name="parent">#{NavigationBean.currentNodeId}</param>-->
|
||||
</params>
|
||||
</action>
|
||||
|
@@ -42,6 +42,7 @@ import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
@@ -98,18 +99,22 @@ public class InvokeCommand extends BaseAjaxCommand
|
||||
// to cover this scenario we have to go through the names of
|
||||
// all the objects in the session to find the bean we want.
|
||||
Object bean = null;
|
||||
Enumeration enumNames = request.getSession().getAttributeNames();
|
||||
while (enumNames.hasMoreElements())
|
||||
|
||||
if (Application.inPortalServer())
|
||||
{
|
||||
String name = (String)enumNames.nextElement();
|
||||
if (name.endsWith(variableName))
|
||||
Enumeration enumNames = request.getSession().getAttributeNames();
|
||||
while (enumNames.hasMoreElements())
|
||||
{
|
||||
bean = request.getSession().getAttribute(name);
|
||||
String name = (String)enumNames.nextElement();
|
||||
if (name.endsWith(variableName))
|
||||
{
|
||||
bean = request.getSession().getAttribute(name);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Found bean " + bean + " in the session");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Found bean " + bean + " in the session");
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.clipboard;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Class representing an 'avm' store protocol clipboard item
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class AVMClipboardItem extends AbstractClipboardItem
|
||||
{
|
||||
/**
|
||||
* @param ref
|
||||
* @param mode
|
||||
*/
|
||||
public AVMClipboardItem(NodeRef ref, ClipboardStatus mode)
|
||||
{
|
||||
super(ref, mode);
|
||||
}
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.clipboard;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Base class representing a single item added to the clipboard.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
abstract class AbstractClipboardItem implements ClipboardItem
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ref The ref of the item on the clipboard
|
||||
* @param mode The ClipboardStatus enum value
|
||||
*/
|
||||
public AbstractClipboardItem(NodeRef ref, ClipboardStatus mode)
|
||||
{
|
||||
this.ref = ref;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public ClipboardStatus getMode()
|
||||
{
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (this.name == null)
|
||||
{
|
||||
this.name = (String)getNodeService().getProperty(this.ref, ContentModel.PROP_NAME);
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public QName getType()
|
||||
{
|
||||
if (this.type == null)
|
||||
{
|
||||
this.type = getNodeService().getType(this.ref);
|
||||
}
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getIcon()
|
||||
{
|
||||
if (this.icon == null)
|
||||
{
|
||||
this.icon = (String)getNodeService().getProperty(this.ref, ApplicationModel.PROP_ICON);
|
||||
}
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.ref.getId();
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override equals() to compare NodeRefs
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ClipboardItem)
|
||||
{
|
||||
return ((ClipboardItem)obj).getNodeRef().equals(this.ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override hashCode() to use the internal NodeRef hashcode instead
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
protected static NodeService getNodeService()
|
||||
{
|
||||
return Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
|
||||
}
|
||||
|
||||
protected NodeRef ref;
|
||||
protected ClipboardStatus mode;
|
||||
|
||||
// cached values
|
||||
private String name;
|
||||
private QName type;
|
||||
private String icon;
|
||||
}
|
@@ -17,7 +17,6 @@
|
||||
package org.alfresco.web.bean.clipboard;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -37,16 +36,15 @@ import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
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;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
import org.alfresco.web.bean.NavigationBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
@@ -128,10 +126,10 @@ public class ClipboardBean
|
||||
{
|
||||
UIActionLink link = (UIActionLink)event.getComponent();
|
||||
Map<String, String> params = link.getParameterMap();
|
||||
String id = params.get("id");
|
||||
if (id != null && id.length() != 0)
|
||||
String ref = params.get("ref");
|
||||
if (ref != null && ref.length() != 0)
|
||||
{
|
||||
addClipboardNode(id, ClipboardStatus.COPY);
|
||||
addClipboardNode(new NodeRef(ref), ClipboardStatus.COPY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,10 +140,10 @@ public class ClipboardBean
|
||||
{
|
||||
UIActionLink link = (UIActionLink)event.getComponent();
|
||||
Map<String, String> params = link.getParameterMap();
|
||||
String id = params.get("id");
|
||||
if (id != null && id.length() != 0)
|
||||
String ref = params.get("ref");
|
||||
if (ref != null && ref.length() != 0)
|
||||
{
|
||||
addClipboardNode(id, ClipboardStatus.CUT);
|
||||
addClipboardNode(new NodeRef(ref), ClipboardStatus.CUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ public class ClipboardBean
|
||||
for (int i=0; i<this.items.size(); i++)
|
||||
{
|
||||
ClipboardItem item = this.items.get(i);
|
||||
if (item.Mode != ClipboardStatus.CUT)
|
||||
if (item.getMode() != ClipboardStatus.CUT)
|
||||
{
|
||||
newItems.add(item);
|
||||
}
|
||||
@@ -208,7 +206,7 @@ public class ClipboardBean
|
||||
// single paste operation
|
||||
ClipboardItem item = this.items.get(index);
|
||||
performClipboardOperation(item, action);
|
||||
if (item.Mode == ClipboardStatus.CUT)
|
||||
if (item.getMode() == ClipboardStatus.CUT)
|
||||
{
|
||||
this.items.remove(index);
|
||||
}
|
||||
@@ -243,10 +241,10 @@ public class ClipboardBean
|
||||
// the clipboard operation (e.g. the source folder) is specifically that parent node.
|
||||
// So does not allow for more than one possible parent node - or for linked objects!
|
||||
// This code should be refactored to use a parent ID when appropriate.
|
||||
ChildAssociationRef assocRef = this.nodeService.getPrimaryParent(item.Node.getNodeRef());
|
||||
ChildAssociationRef assocRef = this.nodeService.getPrimaryParent(item.getNodeRef());
|
||||
|
||||
// initial name to attempt the copy of the item with
|
||||
String name = item.Node.getName();
|
||||
String name = item.getName();
|
||||
if (action == UIClipboardShelfItem.ACTION_PASTE_LINK)
|
||||
{
|
||||
// copy as link was specifically requested by the user
|
||||
@@ -263,13 +261,13 @@ public class ClipboardBean
|
||||
// attempt each copy/paste in its own transaction
|
||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
||||
tx.begin();
|
||||
if (item.Mode == ClipboardStatus.COPY)
|
||||
if (item.getMode() == ClipboardStatus.COPY)
|
||||
{
|
||||
if (action == UIClipboardShelfItem.ACTION_PASTE_LINK)
|
||||
{
|
||||
// LINK operation
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Attempting to link node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
|
||||
logger.debug("Attempting to link node ID: " + item.getId() + " into node ID: " + destRef.getId());
|
||||
|
||||
// we create a special Link Object node that has a property to reference the original
|
||||
// create the node using the nodeService (can only use FileFolderService for content)
|
||||
@@ -277,8 +275,8 @@ public class ClipboardBean
|
||||
{
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(ContentModel.PROP_NAME, name + ".lnk");
|
||||
props.put(ContentModel.PROP_LINK_DESTINATION, item.Node.getNodeRef());
|
||||
if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT))
|
||||
props.put(ContentModel.PROP_LINK_DESTINATION, item.getNodeRef());
|
||||
if (dd.isSubClass(item.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
// create File Link node
|
||||
ChildAssociationRef childRef = this.nodeService.createNode(
|
||||
@@ -320,21 +318,21 @@ public class ClipboardBean
|
||||
{
|
||||
// COPY operation
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Attempting to copy node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
|
||||
logger.debug("Attempting to copy node ID: " + item.getId() + " into node ID: " + destRef.getId());
|
||||
|
||||
if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT) ||
|
||||
dd.isSubClass(item.Node.getType(), ContentModel.TYPE_FOLDER))
|
||||
if (dd.isSubClass(item.getType(), ContentModel.TYPE_CONTENT) ||
|
||||
dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
// copy the file/folder
|
||||
// first check that we are not attempting to copy a duplicate into the same parent
|
||||
if (destRef.equals(assocRef.getParentRef()) && name.equals(item.Node.getName()))
|
||||
if (destRef.equals(assocRef.getParentRef()) && name.equals(item.getName()))
|
||||
{
|
||||
// manually change the name if this occurs
|
||||
String copyOf = Application.getMessage(FacesContext.getCurrentInstance(), MSG_COPY_OF);
|
||||
name = copyOf + ' ' + name;
|
||||
}
|
||||
this.fileFolderService.copy(
|
||||
item.Node.getNodeRef(),
|
||||
item.getNodeRef(),
|
||||
destRef,
|
||||
name);
|
||||
}
|
||||
@@ -344,7 +342,7 @@ public class ClipboardBean
|
||||
if (checkExists(name, destRef) == false)
|
||||
{
|
||||
this.copyService.copy(
|
||||
item.Node.getNodeRef(),
|
||||
item.getNodeRef(),
|
||||
destRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
assocRef.getQName(),
|
||||
@@ -360,14 +358,14 @@ public class ClipboardBean
|
||||
{
|
||||
// MOVE operation
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Attempting to move node ID: " + item.Node.getId() + " into node ID: " + destRef.getId());
|
||||
logger.debug("Attempting to move node ID: " + item.getId() + " into node ID: " + destRef.getId());
|
||||
|
||||
if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_CONTENT) ||
|
||||
dd.isSubClass(item.Node.getType(), ContentModel.TYPE_FOLDER))
|
||||
if (dd.isSubClass(item.getType(), ContentModel.TYPE_CONTENT) ||
|
||||
dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
// move the file/folder
|
||||
this.fileFolderService.move(
|
||||
item.Node.getNodeRef(),
|
||||
item.getNodeRef(),
|
||||
destRef,
|
||||
name);
|
||||
}
|
||||
@@ -375,7 +373,7 @@ public class ClipboardBean
|
||||
{
|
||||
// move the node
|
||||
this.nodeService.moveNode(
|
||||
item.Node.getNodeRef(),
|
||||
item.getNodeRef(),
|
||||
destRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
assocRef.getQName());
|
||||
@@ -387,7 +385,7 @@ public class ClipboardBean
|
||||
}
|
||||
catch (FileExistsException fileExistsErr)
|
||||
{
|
||||
if (item.Mode != ClipboardStatus.COPY)
|
||||
if (item.getMode() != ClipboardStatus.COPY)
|
||||
{
|
||||
// we should not rename an item when it is being moved - so exit
|
||||
throw fileExistsErr;
|
||||
@@ -439,27 +437,32 @@ public class ClipboardBean
|
||||
return (nodeRefs.size() != 0);
|
||||
}
|
||||
|
||||
/** Shallow search for nodes with a name pattern */
|
||||
private static final String XPATH_QUERY_NODE_MATCH =
|
||||
"./*" +
|
||||
"[like(@cm:name, $cm:name, false)]";// +
|
||||
//" and not (subtypeOf('" + ContentModel.TYPE_SYSTEM_FOLDER + "'))" +
|
||||
//" and (subtypeOf('" + ContentModel.TYPE_FOLDER + "') or subtypeOf('" + ContentModel.TYPE_CONTENT + "'))]";
|
||||
|
||||
/**
|
||||
* Add a clipboard node for an operation to the clipboard
|
||||
*
|
||||
* @param id ID of the node for the operation
|
||||
* @param ref NodeRef of the item for the operation
|
||||
* @param mode ClipboardStatus for the operation
|
||||
*/
|
||||
private void addClipboardNode(String id, ClipboardStatus mode)
|
||||
private void addClipboardNode(NodeRef ref, ClipboardStatus mode)
|
||||
{
|
||||
try
|
||||
// construct item based on store protocol
|
||||
ClipboardItem item = null;
|
||||
if (StoreRef.PROTOCOL_WORKSPACE.equals(ref.getStoreRef().getProtocol()))
|
||||
{
|
||||
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
|
||||
item = new WorkspaceClipboardItem(ref, mode);
|
||||
}
|
||||
else if (StoreRef.PROTOCOL_AVM.equals(ref.getStoreRef().getProtocol()))
|
||||
{
|
||||
item = new AVMClipboardItem(ref, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Unable to add item to clipboard - unknown store protocol: " + ref.getStoreRef().getProtocol());
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
// check for duplicates first
|
||||
ClipboardItem item = new ClipboardItem(new Node(ref), mode);
|
||||
boolean foundDuplicate = false;
|
||||
for (int i=0; i<items.size(); i++)
|
||||
{
|
||||
@@ -477,11 +480,6 @@ public class ClipboardBean
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
catch (InvalidNodeRefException refErr)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] {id}) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -495,6 +493,9 @@ public class ClipboardBean
|
||||
private static final String MSG_COPY_OF = "copy_of";
|
||||
private static final String MSG_LINK_TO = "link_to";
|
||||
|
||||
/** Shallow search for nodes with a name pattern */
|
||||
private static final String XPATH_QUERY_NODE_MATCH = "./*[like(@cm:name, $cm:name, false)]";
|
||||
|
||||
/** The NodeService to be used by the bean */
|
||||
protected NodeService nodeService;
|
||||
|
||||
|
@@ -16,53 +16,32 @@
|
||||
*/
|
||||
package org.alfresco.web.bean.clipboard;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Simple class representing a single item added to the clipboard.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class ClipboardItem
|
||||
public interface ClipboardItem
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param node The node on the clipboard
|
||||
* @param mode The ClipboardStatus enum value
|
||||
*/
|
||||
public ClipboardItem(Node node, ClipboardStatus mode)
|
||||
{
|
||||
this.Node = node;
|
||||
this.Mode = mode;
|
||||
}
|
||||
public ClipboardStatus getMode();
|
||||
|
||||
/**
|
||||
* Override equals() to compare NodeRefs
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ClipboardItem)
|
||||
{
|
||||
return ((ClipboardItem)obj).Node.getNodeRef().equals(Node.getNodeRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Override hashCode() to use the internal NodeRef hashcode instead
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return Node.getNodeRef().hashCode();
|
||||
}
|
||||
public QName getType();
|
||||
|
||||
public String getIcon();
|
||||
|
||||
public Node Node;
|
||||
public ClipboardStatus Mode;
|
||||
public String getId();
|
||||
|
||||
public NodeRef getNodeRef();
|
||||
}
|
||||
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.clipboard;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Class representing a 'workspace' store protocol clipboard item
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class WorkspaceClipboardItem extends AbstractClipboardItem
|
||||
{
|
||||
/**
|
||||
* @param ref
|
||||
* @param mode
|
||||
*/
|
||||
public WorkspaceClipboardItem(NodeRef ref, ClipboardStatus mode)
|
||||
{
|
||||
super(ref, mode);
|
||||
}
|
||||
}
|
@@ -96,16 +96,7 @@ public abstract class BaseRenderer extends Renderer
|
||||
if (child instanceof UIParameter)
|
||||
{
|
||||
final UIParameter param = (UIParameter)child;
|
||||
if (param.getValue() == null || param.getValue() instanceof String)
|
||||
{
|
||||
params.put(param.getName(), (String)param.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ClassCastException("value of parameter " + param.getName() +
|
||||
" is a " + param.getValue().getClass().getName() +
|
||||
". Expected a " + String.class.getName());
|
||||
}
|
||||
params.put(param.getName(), param.getValue() != null ? param.getValue().toString() : null);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
|
@@ -160,7 +160,7 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
|
||||
// start row with cut/copy state icon
|
||||
out.write("<tr><td width=16>");
|
||||
if (item.Mode == ClipboardStatus.COPY)
|
||||
if (item.getMode() == ClipboardStatus.COPY)
|
||||
{
|
||||
out.write(Utils.buildImageTag(context, WebResources.IMAGE_COPY, 14, 16, bundle.getString(MSG_COPY), null, "absmiddle"));
|
||||
}
|
||||
@@ -170,10 +170,10 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
}
|
||||
out.write("</td><td width=16>");
|
||||
|
||||
if (dd.isSubClass(item.Node.getType(), ContentModel.TYPE_FOLDER))
|
||||
if (dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
// start row with correct node icon
|
||||
String icon = (String)item.Node.getProperties().get("app:icon");
|
||||
String icon = (String)item.getIcon();
|
||||
if (icon != null)
|
||||
{
|
||||
icon = "/images/icons/" + icon + "-16.gif";
|
||||
@@ -186,21 +186,21 @@ public class UIClipboardShelfItem extends UIShelfItem
|
||||
}
|
||||
else
|
||||
{
|
||||
String image = Utils.getFileTypeImage(item.Node.getName(), true);
|
||||
String image = Utils.getFileTypeImage(item.getName(), true);
|
||||
out.write(Utils.buildImageTag(context, image, 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
|
||||
out.write("</td><td width=100%><nobr> ");
|
||||
out.write(Utils.cropEncode(item.Node.getName()));
|
||||
out.write(Utils.cropEncode(item.getName()));
|
||||
|
||||
// output actions
|
||||
out.write("</nobr></td><td align=right><nobr>");
|
||||
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 && dd.isSubClass(item.Node.getType(), ContentModel.TYPE_LINK) == false)
|
||||
if (item.getMode() == ClipboardStatus.COPY && dd.isSubClass(item.getType(), ContentModel.TYPE_LINK) == false)
|
||||
{
|
||||
out.write(" ");
|
||||
out.write(buildActionLink(ACTION_PASTE_LINK, i, bundle.getString(MSG_PASTE_LINK), WebResources.IMAGE_PASTE_LINK));
|
||||
|
Reference in New Issue
Block a user