diff --git a/config/alfresco/web-client-config-actions.xml b/config/alfresco/web-client-config-actions.xml index cec89c8457..36c07eb227 100644 --- a/config/alfresco/web-client-config-actions.xml +++ b/config/alfresco/web-client-config-actions.xml @@ -18,9 +18,9 @@ org.alfresco.web.action.evaluator.EditDocHttpEvaluator - edit + edit My Tooltip - tooltip + tooltip false @@ -28,7 +28,7 @@ inlineAction /images/icons/edit_icon.gif - #{CheckinCheckoutBean.editFile} + #{CheckinCheckoutBean.editFile} editDocument http://... new @@ -36,7 +36,7 @@ - id + #{actionContext.id} @@ -46,11 +46,11 @@ Write org.alfresco.web.action.evaluator.EditDocHttpEvaluator - edit + edit /images/icons/edit_icon.gif #{CheckinCheckoutBean.editFile} - id + #{actionContext.id} @@ -61,10 +61,10 @@ Write org.alfresco.web.action.evaluator.EditDocWebDavEvaluator - edit + edit /images/icons/edit_icon.gif - - javascript:openDoc('#{actioncontext.webdavUrl}'); + + javascript:openDoc('#{actionContext.webdavUrl}'); @@ -73,33 +73,394 @@ Write org.alfresco.web.action.evaluator.EditDocCIFSEvaluator - edit + edit /images/icons/edit_icon.gif - - #{actioncontext.cifsPath} + + #{actionContext.cifsPath} cifs + + + + org.alfresco.web.action.evaluator.CheckinDocEvaluator + checkin + /images/icons/CheckIn_icon.gif + #{CheckinCheckoutBean.setupContentAction} + checkinFile + + #{actionContext.id} + + + - + + + + + org.alfresco.web.action.evaluator.CancelCheckoutDocEvaluator + undocheckout + /images/icons/undo_checkout.gif + #{CheckinCheckoutBean.setupContentAction} + undoCheckoutFile + + #{actionContext.id} + + + + + + + org.alfresco.web.action.evaluator.DiscussNodeEvaluator + discuss + /images/icons/forum-16.gif + #{ForumsBean.discuss} + + #{actionContext.id} + + + + + + + + CreateChildren + + org.alfresco.web.action.evaluator.CreateForumNodeEvaluator + start_discussion + /images/icons/create_forum.gif + #{CreateDiscussionDialog.startWizard} + + #{actionContext.id} + + + + + + view_details + /images/icons/View_details.gif + #{BrowseBean.setupContentAction} + dialog:showDocDetails + + #{actionContext.id} + + + + + + view_details + /images/icons/View_details.gif + #{BrowseBean.setupSpaceAction} + dialog:showSpaceDetails + + #{actionContext.id} + + + + + + preview + /images/icons/preview.gif + #{BrowseBean.setupContentAction} + previewContent + + #{actionContext.id} + + + + + + preview + /images/icons/preview.gif + #{BrowseBean.setupSpaceAction} + previewSpace + + #{actionContext.id} + + + + + + + Delete + + org.alfresco.web.action.evaluator.DeleteDocEvaluator + delete + /images/icons/delete.gif + #{BrowseBean.setupContentAction} + dialog:deleteFile + + #{actionContext.id} + + + + + + + Delete + + delete + /images/icons/delete.gif + #{BrowseBean.setupDeleteAction} + dialog:deleteSpace + + #{actionContext.id} + + + + + + + Write + + org.alfresco.web.action.evaluator.UpdateDocEvaluator + update + /images/icons/update.gif + #{CheckinCheckoutBean.setupContentAction} + updateFile + + #{actionContext.id} + + + + + + org.alfresco.web.action.evaluator.ApproveDocEvaluator + + /images/icons/approve.gif + #{DocumentDetailsBean.approve} + browse + + #{actionContext.id} + + + + + + org.alfresco.web.action.evaluator.RejectDocEvaluator + + /images/icons/reject.gif + #{DocumentDetailsBean.reject} + browse + + #{actionContext.id} + + + + + + org.alfresco.web.action.evaluator.ApproveDocEvaluator + + /images/icons/approve.gif + #{DocumentDetailsBean.approve} + browse + + #{actionContext.id} + + + + + + org.alfresco.web.action.evaluator.RejectDocEvaluator + + /images/icons/reject.gif + #{DocumentDetailsBean.reject} + browse + + #{actionContext.id} + + + + + + + Delete + + cut + /images/icons/cut.gif + #{ClipboardBean.cutNode} + + #{actionContext.id} + + + + + + copy + /images/icons/copy.gif + #{ClipboardBean.copyNode} + + #{actionContext.id} + + + + + + + Write + + paste_all + /images/icons/paste.gif + #{ClipboardBean.pasteAll} + + + + + + CreateChildren + + create_content + /images/icons/new_content.gif + createContent + #{CreateContentWizard.startWizard} + + + + + + CreateChildren + + new_space + /images/icons/create_space.gif + createSpace + #{NewSpaceDialog.startWizard} + + + + + + CreateChildren + + advanced_space_wizard + /images/icons/create_space.gif + createAdvancedSpace + #{NewSpaceWizard.startWizard} + + + + + + ChangePermissions + + manage_invited_users + /images/icons/invite.gif + dialog:manageInvitedUsers + #{BrowseBean.setupSpaceAction} + + #{actionContext.id} + + + + + + + Write + + manage_rules + /images/icons/rule.gif + dialog:manageRules + #{BrowseBean.setupSpaceAction} + + #{actionContext.id} + + + + + + + TakeOwnership + + take_ownership + /images/icons/take_ownership.gif + #{DocumentDetailsBean.takeOwnership} + + + + + + TakeOwnership + + take_ownership + /images/icons/take_ownership.gif + #{SpaceDetailsBean.takeOwnership} + + + + + + ChangePermissions + + manage_content_users + /images/icons/invite.gif + dialog:manageContentUsers + #{BrowseBean.setupContentAction} + + #{actionContext.id} + + + + + + org.alfresco.web.action.evaluator.ShortcutNodeEvaluator + create_shortcut + /images/icons/shortcut.gif + #{UserShortcutsBean.createShortcut} + + #{actionContext.id} + + + + + + other_action + /images/icons/action.gif + createAction + #{NewActionWizard.startWizard} + + + + + + Write + + import + /images/icons/import.gif + dialog:import + #{BrowseBean.setupSpaceAction} + + #{actionContext.id} + + + + + + export + /images/icons/export.gif + dialog:export + #{BrowseBean.setupSpaceAction} + + #{actionContext.id} + + - + + + + false inlineAction @@ -107,19 +468,115 @@ + + + + + - + + + + + + + + + + + + + + + + false + inlineAction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/java/org/alfresco/web/action/ActionEvaluator.java b/source/java/org/alfresco/web/action/ActionEvaluator.java index 7e2a710d9f..6a53a8feef 100644 --- a/source/java/org/alfresco/web/action/ActionEvaluator.java +++ b/source/java/org/alfresco/web/action/ActionEvaluator.java @@ -30,5 +30,13 @@ import org.alfresco.web.bean.repository.Node; */ public interface ActionEvaluator { + /** + * The evaluator should decide if the action precondition is valid based on the appropriate + * logic and the properties etc. of the Node context and return the result. + * + * @param node Node context for the action + * + * @return result of whether the action can proceed. + */ public boolean evaluate(Node node); } diff --git a/source/java/org/alfresco/web/action/evaluator/ApproveDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/ApproveDocEvaluator.java new file mode 100644 index 0000000000..5f4ea1ebb9 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/ApproveDocEvaluator.java @@ -0,0 +1,43 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - 'Approve' workflow step for document. + * + * @author Kevin Roast + */ +public final class ApproveDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.getProperties().get("app:approveStep") != null && + node.isLocked() == false && + node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/CancelCheckoutDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CancelCheckoutDocEvaluator.java new file mode 100644 index 0000000000..b8a37db14d --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/CancelCheckoutDocEvaluator.java @@ -0,0 +1,42 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Cancel checkout document. + * + * @author Kevin Roast + */ +public final class CancelCheckoutDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.hasPermission(PermissionService.CANCEL_CHECK_OUT) && + node.hasAspect(ContentModel.ASPECT_WORKING_COPY)); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/CheckinDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CheckinDocEvaluator.java new file mode 100644 index 0000000000..2c7c05434a --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/CheckinDocEvaluator.java @@ -0,0 +1,42 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Checkin document. + * + * @author Kevin Roast + */ +public final class CheckinDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.hasPermission(PermissionService.CHECK_IN) && + node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == true); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/CheckoutDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CheckoutDocEvaluator.java new file mode 100644 index 0000000000..d03ce52cf6 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/CheckoutDocEvaluator.java @@ -0,0 +1,43 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Checkout document. + * + * @author Kevin Roast + */ +public final class CheckoutDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.hasPermission(PermissionService.CHECK_OUT) && + (node.isLocked() == false && + node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/CreateForumNodeEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CreateForumNodeEvaluator.java new file mode 100644 index 0000000000..cda684ec76 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/CreateForumNodeEvaluator.java @@ -0,0 +1,42 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.model.ForumModel; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Create a forum around a node. + * + * @author Kevin Roast + */ +public final class CreateForumNodeEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE) == false && + node.isLocked() == false); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/DeleteDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/DeleteDocEvaluator.java new file mode 100644 index 0000000000..6d39cf10ae --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/DeleteDocEvaluator.java @@ -0,0 +1,41 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Delete document. + * + * @author Kevin Roast + */ +public final class DeleteDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.isLocked() == false && + node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/DiscussNodeEvaluator.java b/source/java/org/alfresco/web/action/evaluator/DiscussNodeEvaluator.java new file mode 100644 index 0000000000..47183fa100 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/DiscussNodeEvaluator.java @@ -0,0 +1,41 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.model.ForumModel; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Discuss a node. + * + * @author Kevin Roast + */ +public final class DiscussNodeEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE) == true); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/EditDocCIFSEvaluator.java b/source/java/org/alfresco/web/action/evaluator/EditDocCIFSEvaluator.java index 9b64833296..631d89ab93 100644 --- a/source/java/org/alfresco/web/action/evaluator/EditDocCIFSEvaluator.java +++ b/source/java/org/alfresco/web/action/evaluator/EditDocCIFSEvaluator.java @@ -19,16 +19,16 @@ package org.alfresco.web.action.evaluator; import javax.faces.context.FacesContext; import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.lock.LockService; import org.alfresco.web.action.ActionEvaluator; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.bean.repository.Repository; /** + * UI Action Evaluator - Edit document via CIFS. + * * @author Kevin Roast */ -public class EditDocCIFSEvaluator implements ActionEvaluator +public final class EditDocCIFSEvaluator implements ActionEvaluator { /** * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) @@ -41,11 +41,8 @@ public class EditDocCIFSEvaluator implements ActionEvaluator if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == false && "webdav".equals(Application.getClientConfig(fc).getEditLinkType())) { - LockService lockService = - Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getLockService(); - - if (Repository.isNodeOwner(node, lockService) == true || - (node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY))) + if (node.isWorkingCopyOwner() == true || + (node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)) { return true; } diff --git a/source/java/org/alfresco/web/action/evaluator/EditDocHttpEvaluator.java b/source/java/org/alfresco/web/action/evaluator/EditDocHttpEvaluator.java index 63526adaba..b751209d4e 100644 --- a/source/java/org/alfresco/web/action/evaluator/EditDocHttpEvaluator.java +++ b/source/java/org/alfresco/web/action/evaluator/EditDocHttpEvaluator.java @@ -19,16 +19,16 @@ package org.alfresco.web.action.evaluator; import javax.faces.context.FacesContext; import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.lock.LockService; import org.alfresco.web.action.ActionEvaluator; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.bean.repository.Repository; /** + * UI Action Evaluator - Edit document via HTTP or inline edit. + * * @author Kevin Roast */ -public class EditDocHttpEvaluator implements ActionEvaluator +public final class EditDocHttpEvaluator implements ActionEvaluator { /** * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) @@ -42,11 +42,8 @@ public class EditDocHttpEvaluator implements ActionEvaluator if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == true || "http".equals(Application.getClientConfig(fc).getEditLinkType())) { - LockService lockService = - Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getLockService(); - - if (Repository.isNodeOwner(node, lockService) == true || - (node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY))) + if (node.isWorkingCopyOwner() == true || + (node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)) { return true; } diff --git a/source/java/org/alfresco/web/action/evaluator/EditDocWebDavEvaluator.java b/source/java/org/alfresco/web/action/evaluator/EditDocWebDavEvaluator.java index 33a2ea78a2..bd3dc04113 100644 --- a/source/java/org/alfresco/web/action/evaluator/EditDocWebDavEvaluator.java +++ b/source/java/org/alfresco/web/action/evaluator/EditDocWebDavEvaluator.java @@ -19,16 +19,16 @@ package org.alfresco.web.action.evaluator; import javax.faces.context.FacesContext; import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.lock.LockService; import org.alfresco.web.action.ActionEvaluator; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.bean.repository.Repository; /** + * UI Action Evaluator - Edit document via Webdav. + * * @author Kevin Roast */ -public class EditDocWebDavEvaluator implements ActionEvaluator +public final class EditDocWebDavEvaluator implements ActionEvaluator { /** * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) @@ -41,11 +41,8 @@ public class EditDocWebDavEvaluator implements ActionEvaluator if (node.hasAspect(ContentModel.ASPECT_INLINEEDITABLE) == false && "cifs".equals(Application.getClientConfig(fc).getEditLinkType())) { - LockService lockService = - Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getLockService(); - - if (Repository.isNodeOwner(node, lockService) == true || - (node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY))) + if (node.isWorkingCopyOwner() == true || + (node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)) { return true; } diff --git a/source/java/org/alfresco/web/action/evaluator/RejectDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/RejectDocEvaluator.java new file mode 100644 index 0000000000..9ad88edcf7 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/RejectDocEvaluator.java @@ -0,0 +1,43 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - 'Reject' workflow step for document. + * + * @author Kevin Roast + */ +public final class RejectDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.getProperties().get("app:rejectStep") != null && + node.isLocked() == false && + node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/ShortcutNodeEvaluator.java b/source/java/org/alfresco/web/action/evaluator/ShortcutNodeEvaluator.java new file mode 100644 index 0000000000..61f076953e --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/ShortcutNodeEvaluator.java @@ -0,0 +1,45 @@ +/* + * 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.action.evaluator; + +import javax.faces.context.FacesContext; + +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.app.servlet.FacesHelper; +import org.alfresco.web.bean.NavigationBean; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Create a shortcut to a node. + * + * @author Kevin Roast + */ +public final class ShortcutNodeEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + NavigationBean nav = + (NavigationBean)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "NavigationBean"); + return (nav.getIsGuest() == false); + } +} +/* +rendered="#{NavigationBean.isGuest == false}" +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/action/evaluator/UpdateDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/UpdateDocEvaluator.java new file mode 100644 index 0000000000..74de8e5265 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/UpdateDocEvaluator.java @@ -0,0 +1,42 @@ +/* + * 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.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Update document content. + * + * @author Kevin Roast + */ +public final class UpdateDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.isWorkingCopyOwner() == true || + (node.isLocked() == false && + node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)); + } +} +/* + +*/ \ No newline at end of file diff --git a/source/java/org/alfresco/web/app/DebugPhaseListener.java b/source/java/org/alfresco/web/app/DebugPhaseListener.java index bf76fc5600..767acaa0a8 100644 --- a/source/java/org/alfresco/web/app/DebugPhaseListener.java +++ b/source/java/org/alfresco/web/app/DebugPhaseListener.java @@ -17,6 +17,11 @@ */ package org.alfresco.web.app; +import java.util.ArrayList; +import java.util.List; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; @@ -33,30 +38,67 @@ public class DebugPhaseListener implements PhaseListener { private static final Log logger = LogFactory.getLog(DebugPhaseListener.class); + public int indent = 0; + public static final String INDENT = " "; + /** * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent) */ public void afterPhase(PhaseEvent event) { if (logger.isDebugEnabled()) - logger.debug("********** Exiting phase: " + event.getPhaseId().toString()); + { + printComponentTree(FacesContext.getCurrentInstance().getViewRoot()); + } } - + /** * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent) */ public void beforePhase(PhaseEvent event) { - if (logger.isDebugEnabled()) - logger.debug("********** Entering phase: " + event.getPhaseId().toString()); } - + /** * @see javax.faces.event.PhaseListener#getPhaseId() */ public PhaseId getPhaseId() { - return PhaseId.ANY_PHASE; + return PhaseId.RENDER_RESPONSE; } - + + public void printComponentTree(UIComponent comp){ + printComponentInfo(comp); + + List complist = comp.getChildren(); + if (complist.size()>0) + indent++; + for (int i = 0; i < complist.size(); i++) { + UIComponent uicom = (UIComponent) complist.get(i); + printComponentTree(uicom); + if (i+1 == complist.size()) + indent--; + } + + } + + public void printComponentInfo(UIComponent comp){ + + if (comp.getId() == null){ + logger.debug("UIViewRoot" + " " + "(" + comp.getClass().getName() + ")"); + } else { + logger.debug(getIndent() + "|"); + logger.debug(getIndent() + comp.getId() + " " + "(" + comp.getClass().getName() + ")"); + } + } + + public String getIndent() + { + String indent = ""; + for (int i=0; i aspects = null; private Map permissions; private Boolean locked = null; + private Boolean workingCopyOwner = null; protected QNameNodeMap properties; protected boolean propsRetrieved = false; protected ServiceRegistry services = null; @@ -404,6 +406,32 @@ public class Node implements Serializable return this.locked.booleanValue(); } + /** + * @return whether a the Node is a WorkingCopy owned by the current User + */ + public final boolean isWorkingCopyOwner() + { + if (this.workingCopyOwner == null) + { + this.workingCopyOwner = Boolean.FALSE; + + if (hasAspect(ContentModel.ASPECT_WORKING_COPY)) + { + Object obj = getProperties().get(ContentModel.PROP_WORKING_COPY_OWNER); + if (obj instanceof String) + { + User user = Application.getCurrentUser(FacesContext.getCurrentInstance()); + if ( ((String)obj).equals(user.getUserName())) + { + this.workingCopyOwner = Boolean.TRUE; + } + } + } + } + + return workingCopyOwner.booleanValue(); + } + /** * Resets the state of the node to force re-retrieval of the data */ @@ -413,6 +441,7 @@ public class Node implements Serializable this.type = null; this.path = null; this.locked = null; + this.workingCopyOwner = null; this.properties.clear(); this.propsRetrieved = false; this.aspects = null; diff --git a/source/java/org/alfresco/web/bean/repository/Repository.java b/source/java/org/alfresco/web/bean/repository/Repository.java index fa0cc76954..357a221fb4 100644 --- a/source/java/org/alfresco/web/bean/repository/Repository.java +++ b/source/java/org/alfresco/web/bean/repository/Repository.java @@ -219,34 +219,6 @@ public final class Repository return locked; } - /** - * Return whether a WorkingCopy Node is owned by the current User - * - * @param node The Node wrapper to test against - * @param lockService The LockService to use - * - * @return whether a WorkingCopy Node is owned by the current User - */ - public static Boolean isNodeOwner(Node node, LockService lockService) - { - Boolean locked = Boolean.FALSE; - - if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY)) - { - Object obj = node.getProperties().get("workingCopyOwner"); - if (obj instanceof String) - { - User user = Application.getCurrentUser(FacesContext.getCurrentInstance()); - if ( ((String)obj).equals(user.getUserName())) - { - locked = Boolean.TRUE; - } - } - } - - return locked; - } - /** * Return the human readable form of the specified node Path. Fast version of the method that * simply converts QName localname components to Strings. diff --git a/source/java/org/alfresco/web/config/ActionsConfigElement.java b/source/java/org/alfresco/web/config/ActionsConfigElement.java index 999f564871..6ef546ffeb 100644 --- a/source/java/org/alfresco/web/config/ActionsConfigElement.java +++ b/source/java/org/alfresco/web/config/ActionsConfigElement.java @@ -72,11 +72,18 @@ public class ActionsConfigElement extends ConfigElementAdapter ActionsConfigElement existingElement = (ActionsConfigElement)configElement; ActionsConfigElement combinedElement = new ActionsConfigElement(); + combinedElement.actionDefs.putAll(this.actionDefs); + combinedElement.actionDefs.putAll(existingElement.actionDefs); + + combinedElement.actionGroups.putAll(this.actionGroups); + combinedElement.actionGroups.putAll(existingElement.actionGroups); + // - // TODO: implement to allow override of config elements + // TODO: do we need to check all groups here and update ActionDefinition references incase they + // have changed? e.g. if an actiondef ID is overriden, a group using it will not know! // - return null; + return combinedElement; } /*package*/ void addActionDefinition(ActionDefinition actionDef) @@ -173,7 +180,7 @@ public class ActionsConfigElement extends ConfigElementAdapter public String LabelMsg; public String Tooltip; public String TooltipMsg; - public boolean ShowLink; + public boolean ShowLink = true; public String Style; public String StyleClass; public String Image; @@ -181,6 +188,7 @@ public class ActionsConfigElement extends ConfigElementAdapter public String Action; public String Href; public String Target; + public String Onclick; } diff --git a/source/java/org/alfresco/web/config/ActionsElementReader.java b/source/java/org/alfresco/web/config/ActionsElementReader.java index 95698b19cb..8824eb4514 100644 --- a/source/java/org/alfresco/web/config/ActionsElementReader.java +++ b/source/java/org/alfresco/web/config/ActionsElementReader.java @@ -39,14 +39,15 @@ public class ActionsElementReader implements ConfigElementReader public static final String ELEMENT_PERMISSION = "permission"; public static final String ELEMENT_EVALUATOR = "evaluator"; public static final String ELEMENT_LABEL = "label"; - public static final String ELEMENT_LABELMSG = "label-msg"; + public static final String ELEMENT_LABELMSG = "label-id"; public static final String ELEMENT_TOOLTIP = "tooltip"; - public static final String ELEMENT_TOOLTIPMSG = "tooltip-msg"; + public static final String ELEMENT_TOOLTIPMSG = "tooltip-id"; public static final String ELEMENT_SHOWLINK = "show-link"; public static final String ELEMENT_STYLE = "style"; public static final String ELEMENT_STYLECLASS = "style-class"; public static final String ELEMENT_IMAGE = "image"; public static final String ELEMENT_ACTIONLISTENER = "action-listener"; + public static final String ELEMENT_ONCLICK = "onclick"; public static final String ELEMENT_HREF = "href"; public static final String ELEMENT_TARGET = "target"; public static final String ELEMENT_PARAMS = "params"; @@ -250,6 +251,7 @@ public class ActionsElementReader implements ConfigElementReader actionDef.Target = actionElement.elementTextTrim(ELEMENT_TARGET); actionDef.Action = actionElement.elementTextTrim(ELEMENT_ACTION); actionDef.ActionListener = actionElement.elementTextTrim(ELEMENT_ACTIONLISTENER); + actionDef.Onclick = actionElement.elementTextTrim(ELEMENT_ONCLICK); actionDef.Image = actionElement.elementTextTrim(ELEMENT_IMAGE); actionDef.Style = actionElement.elementTextTrim(ELEMENT_STYLE); actionDef.StyleClass = actionElement.elementTextTrim(ELEMENT_STYLECLASS); diff --git a/source/java/org/alfresco/web/ui/common/ComponentConstants.java b/source/java/org/alfresco/web/ui/common/ComponentConstants.java index de4acd43d4..81b0e51816 100644 --- a/source/java/org/alfresco/web/ui/common/ComponentConstants.java +++ b/source/java/org/alfresco/web/ui/common/ComponentConstants.java @@ -28,6 +28,7 @@ public final class ComponentConstants public static final String JAVAX_FACES_PANEL = "javax.faces.Panel"; public static final String JAVAX_FACES_CHECKBOX = "javax.faces.Checkbox"; public static final String JAVAX_FACES_SELECT_BOOLEAN = "javax.faces.SelectBoolean"; + public static final String JAVAX_FACES_PARAMETER = "javax.faces.Parameter"; /** * Private constructor diff --git a/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java index d0dc9faf3f..85cdb404b5 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java @@ -27,6 +27,7 @@ import javax.faces.event.ActionEvent; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.common.component.UIMenu; +import org.alfresco.web.ui.repo.component.UIActions; /** * @author kevinr @@ -78,10 +79,17 @@ public class ActionLinkRenderer extends BaseRenderer UIActionLink link = (UIActionLink)component; - if (isInMenu(link) == true) + UIComponent verticalContiner = getVerticalContainer(link); + if (verticalContiner != null) { - // render as menu item - out.write( renderMenuAction(context, link) ); + int padding = link.getPadding(); + + if (verticalContiner instanceof UIActions) + { + padding = ((UIActions)verticalContiner).getVerticalSpacing(); + } + // render as menu item style action link + out.write( renderMenuAction(context, link, padding) ); } else { @@ -239,7 +247,7 @@ public class ActionLinkRenderer extends BaseRenderer * * @return action link HTML */ - private String renderMenuAction(FacesContext context, UIActionLink link) + private String renderMenuAction(FacesContext context, UIActionLink link, int padding) { StringBuilder buf = new StringBuilder(256); @@ -252,7 +260,6 @@ public class ActionLinkRenderer extends BaseRenderer } buf.append("'); - for (int i=0; i'); - - // output the header facet if any - UIComponent header = column.getHeader(); - if (header != null) - { - header.encodeBegin(context); - header.encodeChildren(context); - header.encodeEnd(context); - } - } - - // we don't render child controls for the header row - out.write(""); - } - out.write(""); - */ - this.rowIndex = 0; } diff --git a/source/java/org/alfresco/web/ui/repo/component/UIActions.java b/source/java/org/alfresco/web/ui/repo/component/UIActions.java new file mode 100644 index 0000000000..eda8b1c040 --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/component/UIActions.java @@ -0,0 +1,587 @@ +/* + * 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.ui.repo.component; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.faces.component.NamingContainer; +import javax.faces.component.UIComponent; +import javax.faces.component.UIParameter; +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; +import javax.faces.el.ValueBinding; + +import org.alfresco.config.Config; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.repository.Node; +import org.alfresco.web.config.ActionsConfigElement; +import org.alfresco.web.config.ActionsConfigElement.ActionDefinition; +import org.alfresco.web.config.ActionsConfigElement.ActionGroup; +import org.alfresco.web.ui.common.ComponentConstants; +import org.alfresco.web.ui.common.ConstantMethodBinding; +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.evaluator.ActionInstanceEvaluator; +import org.alfresco.web.ui.repo.component.evaluator.PermissionEvaluator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.myfaces.taglib.UIComponentTagUtils; + +/** + * @author kevinr + */ +public class UIActions extends SelfRenderingComponent +{ + // ------------------------------------------------------------------------------ + // Component implementation + + private static final String ATTR_VALUE = "value"; + + private static Log logger = LogFactory.getLog(UIActions.class); + + private static final String ATTR_SHOWLINK = "showLink"; + private static final String ATTR_STYLECLASS = "styleClass"; + private static final String ATTR_STYLE = "style"; + private static final String ACTION_CONTEXT = "actionContext"; + private static final String RENDERER_ACTIONLINK = "org.alfresco.faces.ActionLinkRenderer"; + private static final String COMPONENT_ACTIONLINK = "org.alfresco.faces.ActionLink"; + private static final String COMPONENT_PERMISSIONEVAL = "org.alfresco.faces.PermissionEvaluator"; + private static final String COMPONENT_ACTIONEVAL = "org.alfresco.faces.ActionInstanceEvaluator"; + + private final static Class ACTION_CLASS_ARGS[] = {javax.faces.event.ActionEvent.class}; + + /** + * @see javax.faces.component.UIComponent#getFamily() + */ + public String getFamily() + { + return "org.alfresco.faces.Controls"; + } + + /** + * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object) + */ + public void restoreState(FacesContext context, Object state) + { + Object values[] = (Object[])state; + // standard component attributes are restored by the super class + super.restoreState(context, values[0]); + this.value = (String)values[1]; + this.showLink = (Boolean)values[2]; + this.verticalSpacing = (Integer)values[3]; + } + + /** + * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext) + */ + public Object saveState(FacesContext context) + { + Object values[] = new Object[4]; + // standard component attributes are saved by the super class + values[0] = super.saveState(context); + values[1] = this.value; + values[2] = this.showLink; + values[3] = this.verticalSpacing; + return (values); + } + + /** + * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext) + */ + public void encodeBegin(FacesContext context) throws IOException + { + if (isRendered() == false) + { + return; + } + + if (logger.isDebugEnabled()) + logger.debug("encodeBegin() for Id: " + getId() + " groupId: " + getValue()); + + // put the context object into the requestMap so it is accessable + // by any child component value binding expressions + Map requestMap = getFacesContext().getExternalContext().getRequestMap(); + requestMap.put(ACTION_CONTEXT, getContext()); + + if (getChildCount() != 0) + { + if (logger.isDebugEnabled()) + logger.debug("---already built component tree for actions."); + return; + } + + ResponseWriter out = context.getResponseWriter(); + + String groupId = getValue(); + if (groupId != null && groupId.length() != 0) + { + Config config = Application.getConfigService(context).getConfig("Actions"); + if (config != null) + { + // find the Actions specific config element + ActionsConfigElement actionConfig = + (ActionsConfigElement)config.getConfigElement(ActionsConfigElement.CONFIG_ELEMENT_ID); + if (actionConfig != null) + { + // and lookup our ActionGroup by Id + ActionGroup actionGroup = actionConfig.getActionGroup(groupId); + if (actionGroup != null) + { + // render the action group component tree + if (logger.isDebugEnabled()) + logger.debug("-constructing ActionGroup: " + groupId); + buildActionGroup(context, actionGroup); + } + else + { + logger.warn("Unable to find specified Action Group config ID: " + groupId); + } + } + } + } + } + + /** + * @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 + { + ResponseWriter out = context.getResponseWriter(); + int verticalSpacing = getVerticalSpacing(); + if (verticalSpacing != 0) + { + out.write(""); + } + + for (Iterator i=getChildren().iterator(); i.hasNext(); /**/) + { + UIComponent child = (UIComponent)i.next(); + Utils.encodeRecursive(context, child); + } + + if (verticalSpacing != 0) + { + out.write("
"); + } + } + + /** + * @see javax.faces.component.UIComponentBase#encodeEnd(javax.faces.context.FacesContext) + */ + public void encodeEnd(FacesContext context) throws IOException + { + if (logger.isDebugEnabled()) + logger.debug("encodeEnd() for Id: " + getId()); + + Map requestMap = getFacesContext().getExternalContext().getRequestMap(); + requestMap.remove(ACTION_CONTEXT); + } + + /** + * Build an action group as reusable UIActionLink components. + * + * @param context + * @param actionGroup + */ + private void buildActionGroup(FacesContext context, ActionGroup actionGroup) + throws IOException + { + javax.faces.application.Application facesApp = context.getApplication(); + Node node = getContext(); + ResourceBundle messages = Application.getBundle(context); + + // get overriding display attributes + String style = (String)getAttributes().get(ATTR_STYLE); + String styleClass = (String)getAttributes().get(ATTR_STYLECLASS); + Boolean showLink = null; + if (getAttributes().get(ATTR_SHOWLINK) != null) + { + showLink = (Boolean)getAttributes().get(ATTR_SHOWLINK); + } + + // process each ActionDefinition in the order they were defined + for (ActionDefinition actionDef : actionGroup) + { + if (logger.isDebugEnabled()) + logger.debug("---processing ActionDefinition: " + actionDef.getId()); + + UIComponent currentParent = this; + + // build a permissions evaluator component to wrap the actionlink + PermissionEvaluator permEval = null; + List allow = actionDef.getAllowPermissions(); + if (allow != null && allow.size() != 0) + { + // found some permissions to test + permEval = (PermissionEvaluator)facesApp.createComponent(COMPONENT_PERMISSIONEVAL); + String condition = allow.get(0); + if (allow.size() != 1) + { + for (int i=1; i deny = actionDef.getDenyPermissions(); + if (deny != null && deny.size() != 0) + { + if (permEval == null) + { + permEval = (PermissionEvaluator)facesApp.createComponent(COMPONENT_PERMISSIONEVAL); + } + String condition = deny.get(0); + if (deny.size() != 1) + { + for (int i=1; i components that are needed. + Map params = actionDef.getParams(); + if (params != null) + { + for (String name : params.keySet()) + { + UIParameter param = + (UIParameter)facesApp.createComponent(ComponentConstants.JAVAX_FACES_PARAMETER); + param.setId(createUniqueId()); + param.setName(name); + String value = params.get(name); + if (UIComponentTagUtils.isValueReference(value)) + { + param.setValueBinding(ATTR_VALUE, facesApp.createValueBinding(value)); + } + else + { + param.setValue(value); + } + control.getChildren().add(param); + } + } + + if (logger.isDebugEnabled()) + logger.debug("-----adding UIActionLink component for: " + actionDef.getId()); + currentParent.getChildren().add(control); + } + } + + + // ------------------------------------------------------------------------------ + // Strongly typed component property accessors + + /** + * Get the value (for this component the value is the ID of an Action Group config block) + * + * @return the value + */ + public String getValue() + { + if (this.value == null) + { + ValueBinding vb = getValueBinding(ATTR_VALUE); + if (vb != null) + { + this.value = (String)vb.getValue(getFacesContext()); + } + } + return this.value; + } + + /** + * Set the value (for this component the value is the ID of an Action Group config block) + * + * @param value the value + */ + public void setValue(String value) + { + this.value = value; + } + + /** + * Get the Node that forms the context object for this group of actions + * + * @return the context + */ + public Node getContext() + { + ValueBinding vb = getValueBinding("context"); + if (vb != null) + { + this.context = (Node)vb.getValue(getFacesContext()); + } + + return this.context; + } + + /** + * Set the the Node that forms the context object for this group of actions + * + * @param context the context + */ + public void setContext(Node context) + { + this.context = context; + } + + /** + * Get whether to show the link as well as the image if specified + * + * @return true to show the link as well as the image if specified + */ + public boolean getShowLink() + { + ValueBinding vb = getValueBinding(ATTR_SHOWLINK); + if (vb != null) + { + this.showLink = (Boolean)vb.getValue(getFacesContext()); + } + + if (this.showLink != null) + { + return this.showLink.booleanValue(); + } + else + { + // return default + return true; + } + } + + /** + * Set whether to show the link as well as the image if specified + * + * @param showLink Whether to show the link as well as the image if specified + */ + public void setShowLink(boolean showLink) + { + this.showLink = Boolean.valueOf(showLink); + } + + /** + * @return Returns the vertical spacing value in pixels or zero if not set. + */ + public int getVerticalSpacing() + { + ValueBinding vb = getValueBinding("verticalSpacing"); + if (vb != null) + { + this.verticalSpacing = (Integer)vb.getValue(getFacesContext()); + } + + if (this.verticalSpacing != null) + { + return this.verticalSpacing; + } + else + { + return 0; + } + } + + /** + * @param verticalSpacing The verticalSpacing to set. + */ + public void setVerticalSpacing(int verticalSpacing) + { + this.verticalSpacing = verticalSpacing; + } + + /** + * @return a unique ID for a JSF component + */ + private static String createUniqueId() + { + return "_id_" + Short.toString(++id); + } + + + // ------------------------------------------------------------------------------ + // Private data + + /** True to show the link as well as the image if specified */ + private Boolean showLink = null; + + /** For this component the value is the ID of an Action Group config block */ + private String value = null; + + /** The context Node for the action group */ + private Node context = null; + + /** Vertical layout spacing */ + private Integer verticalSpacing = null; + + private static short id = 0; +} diff --git a/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java b/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java index 852cc7ad26..b45916ab67 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java +++ b/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java @@ -56,6 +56,8 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements public static final String PREFIX_DATE_TO = "to_"; public static final String PREFIX_DATE_FROM = "from_"; + private static final String VALUE = "value"; + private static final String MSG_TO = "to"; private static final String MSG_FROM = "from"; @@ -252,12 +254,12 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements { control = (UISelectBoolean)facesApp.createComponent(ComponentConstants.JAVAX_FACES_SELECT_BOOLEAN); control.setRendererType(ComponentConstants.JAVAX_FACES_CHECKBOX); - control.setValueBinding("value", vb); + control.setValueBinding(VALUE, vb); } else if (typeName.equals(DataTypeDefinition.CATEGORY)) { control = (UICategorySelector)facesApp.createComponent(RepoConstants.ALFRESCO_FACES_CATEGORY_SELECTOR); - control.setValueBinding("value", vb); + control.setValueBinding(VALUE, vb); } else if (typeName.equals(DataTypeDefinition.DATETIME) || typeName.equals(DataTypeDefinition.DATE)) { @@ -275,7 +277,7 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements checkbox.setId(context.getViewRoot().createUniqueId()); ValueBinding vbCheckbox = facesApp.createValueBinding( "#{" + beanBinding + "[\"" + propDef.getName().toString() + "\"]}"); - checkbox.setValueBinding("value", vbCheckbox); + checkbox.setValueBinding(VALUE, vbCheckbox); control.getChildren().add(checkbox); // main display label @@ -300,7 +302,7 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements inputFromDate.getAttributes().put("showTime", showTime); ValueBinding vbFromDate = facesApp.createValueBinding( "#{" + beanBinding + "[\"" + PREFIX_DATE_FROM + propDef.getName().toString() + "\"]}"); - inputFromDate.setValueBinding("value", vbFromDate); + inputFromDate.setValueBinding(VALUE, vbFromDate); control.getChildren().add(inputFromDate); // to date label @@ -318,13 +320,13 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements inputToDate.getAttributes().put("showTime", showTime); ValueBinding vbToDate = facesApp.createValueBinding( "#{" + beanBinding + "[\"" + PREFIX_DATE_TO + propDef.getName().toString() + "\"]}"); - inputToDate.setValueBinding("value", vbToDate); + inputToDate.setValueBinding(VALUE, vbToDate); control.getChildren().add(inputToDate); } else if (typeName.equals(DataTypeDefinition.NODE_REF)) { control = (UISpaceSelector)facesApp.createComponent(RepoConstants.ALFRESCO_FACES_SPACE_SELECTOR); - control.setValueBinding("value", vb); + control.setValueBinding(VALUE, vb); } else { @@ -333,7 +335,7 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements control.setRendererType(ComponentConstants.JAVAX_FACES_TEXT); control.getAttributes().put("size", "28"); control.getAttributes().put("maxlength", "1024"); - control.setValueBinding("value", vb); + control.setValueBinding(VALUE, vb); } // set up the common aspects of the control diff --git a/source/java/org/alfresco/web/ui/repo/component/evaluator/ActionInstanceEvaluator.java b/source/java/org/alfresco/web/ui/repo/component/evaluator/ActionInstanceEvaluator.java new file mode 100644 index 0000000000..a1a7e9d677 --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/component/evaluator/ActionInstanceEvaluator.java @@ -0,0 +1,99 @@ +/* + * 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.ui.repo.component.evaluator; + +import javax.faces.context.FacesContext; + +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; +import org.alfresco.web.ui.common.component.evaluator.BaseEvaluator; + +/** + * Evaluator for executing an ActionEvaluator instance. + * + * @author Kevin Roast + */ +public class ActionInstanceEvaluator extends BaseEvaluator +{ + /** + * Evaluate by executing the specified action instance evaluator. + * + * @return true to allow rendering of child components, false otherwise + */ + public boolean evaluate() + { + boolean result = false; + + try + { + Object obj = getValue(); + if (obj instanceof Node) + { + result = getEvaluator().evaluate((Node)obj); + } + } + catch (Exception err) + { + // return default value on error + s_logger.debug("Error during ActionInstanceEvaluator evaluation: " + err.getMessage()); + } + + return result; + } + + /** + * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object) + */ + public void restoreState(FacesContext context, Object state) + { + Object values[] = (Object[])state; + // standard component attributes are restored by the super class + super.restoreState(context, values[0]); + this.evaluator = (ActionEvaluator)values[1]; + } + + /** + * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext) + */ + public Object saveState(FacesContext context) + { + Object values[] = new Object[2]; + // standard component attributes are saved by the super class + values[0] = super.saveState(context); + values[1] = this.evaluator; + return (values); + } + + /** + * @return the ActionEvaluator to execute + */ + public ActionEvaluator getEvaluator() + { + return this.evaluator; + } + + /** + * @param evaluator The ActionEvaluator to execute + */ + public void setEvaluator(ActionEvaluator evaluator) + { + this.evaluator = evaluator; + } + + + private ActionEvaluator evaluator; +} diff --git a/source/java/org/alfresco/web/ui/repo/tag/ActionsTag.java b/source/java/org/alfresco/web/ui/repo/tag/ActionsTag.java new file mode 100644 index 0000000000..04166bcc25 --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/tag/ActionsTag.java @@ -0,0 +1,121 @@ +/* + * 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.ui.repo.tag; + +import javax.faces.component.UIComponent; + +import org.alfresco.web.ui.common.tag.HtmlComponentTag; + +/** + * @author kevinr + */ +public class ActionsTag extends HtmlComponentTag +{ + /** + * @see javax.faces.webapp.UIComponentTag#getComponentType() + */ + public String getComponentType() + { + return "org.alfresco.faces.Actions"; + } + + /** + * @see javax.faces.webapp.UIComponentTag#getRendererType() + */ + public String getRendererType() + { + return null; + } + + /** + * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent) + */ + protected void setProperties(UIComponent component) + { + super.setProperties(component); + + setBooleanProperty(component, "showLink", this.showLink); + setStringProperty(component, "value", this.value); + setStringBindingProperty(component, "context", this.context); + setIntProperty(component, "verticalSpacing", this.verticalSpacing); + } + + /** + * @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release() + */ + public void release() + { + super.release(); + this.value = null; + this.showLink = null; + this.context = null; + this.verticalSpacing = null; + } + + /** + * Set the value (id of the action group config to use) + * + * @param value the value (id of the action group config to use) + */ + public void setValue(String value) + { + this.value = value; + } + + /** + * Set the showLink + * + * @param showLink the showLink + */ + public void setShowLink(String showLink) + { + this.showLink = showLink; + } + + /** + * Set the context object + * + * @param context the context object + */ + public void setContext(String context) + { + this.context = context; + } + + /** + * Set the verticalSpacing + * + * @param verticalSpacing the verticalSpacing + */ + public void setVerticalSpacing(String verticalSpacing) + { + this.verticalSpacing = verticalSpacing; + } + + + /** the verticalSpacing */ + private String verticalSpacing; + + /** the context object */ + private String context; + + /** the value (id of the action group config to use) */ + private String value; + + /** the showLink boolean */ + private String showLink; +} diff --git a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java index 3f92d59294..87aead6eb7 100644 --- a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java +++ b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java @@ -44,7 +44,7 @@ public class PageTag extends TagSupport private final static String ALF_URL = "http://www.alfresco.com"; private final static String ALF_LOGO = "/images/logo/alfresco_logo.gif"; private final static String ALF_TEXT = "Content managed by Alfresco"; - private final static String ALF_COPY = "Alfresco Software Inc. © 2005 All rights reserved."; + private final static String ALF_COPY = "Alfresco Software Inc. (C) 2005-2006 All rights reserved."; private static Log logger = LogFactory.getLog(PageTag.class); private static String alfresco = null; diff --git a/source/java/org/alfresco/web/ui/repo/tag/evaluator/ActionInstanceEvaluatorTag.java b/source/java/org/alfresco/web/ui/repo/tag/evaluator/ActionInstanceEvaluatorTag.java new file mode 100644 index 0000000000..1b16c3ff8f --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/tag/evaluator/ActionInstanceEvaluatorTag.java @@ -0,0 +1,35 @@ +/* + * 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.ui.repo.tag.evaluator; + +import javax.faces.component.UIComponent; + +import org.alfresco.web.ui.common.tag.evaluator.GenericEvaluatorTag; + +/** + * @author Kevin Roast + */ +public class ActionInstanceEvaluatorTag extends GenericEvaluatorTag +{ + /** + * @see javax.faces.webapp.UIComponentTag#getComponentType() + */ + public String getComponentType() + { + return "org.alfresco.faces.ActionInstanceEvaluator"; + } +} diff --git a/source/web/WEB-INF/faces-config-repo.xml b/source/web/WEB-INF/faces-config-repo.xml index f65c21fbed..86b4e96aea 100644 --- a/source/web/WEB-INF/faces-config-repo.xml +++ b/source/web/WEB-INF/faces-config-repo.xml @@ -109,6 +109,17 @@ org.alfresco.web.ui.repo.component.UIMultiValueEditor + + org.alfresco.faces.Actions + org.alfresco.web.ui.repo.component.UIActions + + + + org.alfresco.faces.ActionInstanceEvaluator + org.alfresco.web.ui.repo.component.evaluator.ActionInstanceEvaluator + + + org.alfresco.faces.PermissionEvaluator @@ -119,7 +130,8 @@ org.alfresco.faces.MimeTypeConverter org.alfresco.web.ui.repo.converter.MimeTypeConverter - + + diff --git a/source/web/WEB-INF/repo.tld b/source/web/WEB-INF/repo.tld index b1a7b40864..df1fc9afbc 100644 --- a/source/web/WEB-INF/repo.tld +++ b/source/web/WEB-INF/repo.tld @@ -1321,4 +1321,71 @@ + + actions + org.alfresco.web.ui.repo.tag.ActionsTag + JSP + + + The actions component renders a group of actionLink components as defined by an Action Group + in the web-client-config-actions.xml config file. Each action groups can contain many actions + which are individually rendered as ActionLink components. The action group uses a Node object + as the context for the various actions defined in config. + + + + id + false + true + + + + value + true + true + + + + context + true + true + + + + binding + false + true + + + + rendered + false + true + + + + style + false + true + + + + styleClass + false + true + + + + verticalSpacing + false + true + + + + showLink + false + true + + + diff --git a/source/web/jsp/browse/browse.jsp b/source/web/jsp/browse/browse.jsp index 4373e11e13..2f9e7d1c1d 100644 --- a/source/web/jsp/browse/browse.jsp +++ b/source/web/jsp/browse/browse.jsp @@ -104,47 +104,14 @@ <%-- Create actions menu --%> - - - - - - - - - + <%-- More actions menu --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - + + <%-- admin user only actions --%> @@ -315,39 +282,13 @@ - - - - - - - - - - - - - - - - - - - + + <%-- actions are configured in web-client-config-actions.xml --%> + + <%-- More actions menu --%> - - - - - - - - - - - - + @@ -462,90 +403,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + <%-- actions are configured in web-client-config-actions.xml --%> + + <%-- More actions menu --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/source/web/jsp/dialog/document-details.jsp b/source/web/jsp/dialog/document-details.jsp index fec178c4bc..3f94080497 100644 --- a/source/web/jsp/dialog/document-details.jsp +++ b/source/web/jsp/dialog/document-details.jsp @@ -86,133 +86,8 @@
- - <%-- Checkin/Checkout action --%> - - - - - - - - - - - - - - - - - - <%-- Actions menu --%> - - - - - - - - - <%-- approve and reject --%> - - - - - - - - - - - - <%-- edit and update --%> - - - - - - - - - - - - <%-- cut --%> - - - - - - - <%-- copy --%> - - - - - <%-- delete --%> - - - - - - - - - <%-- Take Ownership --%> - - - - - - - - - - - <%-- create shortcut --%> - - - - - <%-- discussion --%> - - - - - - - - - - - - - - <%-- preview in template --%> - - - - - <%-- custom action --%> - - - - <%-- Navigation --%> - - + @@ -315,7 +190,7 @@ rendered="#{DocumentDetailsBean.inlineEditable == false}" /> - + @@ -475,8 +350,9 @@ + <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %> - +
@@ -484,6 +360,14 @@
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %> + +
+ + <%-- Document Actions --%> + + + diff --git a/source/web/jsp/dialog/space-details.jsp b/source/web/jsp/dialog/space-details.jsp index 127d332dce..c70e563bc2 100644 --- a/source/web/jsp/dialog/space-details.jsp +++ b/source/web/jsp/dialog/space-details.jsp @@ -31,7 +31,7 @@ <%-- load a bundle of properties with I18N strings --%> - + <%-- Main outer table --%> @@ -74,79 +74,8 @@
- - <%-- Navigation --%> - -
- <%-- Actions menu --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -240,7 +169,7 @@ columns="1" mode="view" labelStyleClass="propertiesLabel" externalConfig="true" /> - +
@@ -271,7 +200,7 @@ - + @@ -357,7 +286,7 @@ <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %> - +
@@ -365,6 +294,13 @@
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %> + +
+ + <%-- Space Actions --%> + + +