Search in sources :

Example 31 with UIActionLink

use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.

the class DocumentDetailsDialog method nextItem.

/**
 * Navigates to next item in the list of content for the current Space
 */
public void nextItem(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id != null && id.length() != 0) {
        List<Node> nodes = this.browseBean.getContent();
        if (nodes.size() > 1) {
            String currentSortColumn = this.browseBean.getContentRichList().getCurrentSortColumn();
            if (currentSortColumn != null) {
                boolean currentSortDescending = this.browseBean.getContentRichList().isCurrentSortDescending();
                Collections.sort(nodes, new NodePropertyComparator(currentSortColumn, !currentSortDescending));
            }
            Node next = NodeListUtils.nextItem(nodes, id);
            getRecentNodeRefsStack().clear();
            this.browseBean.setupContentAction(next.getId(), false);
        }
    }
}
Also used : UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) NodePropertyComparator(org.alfresco.web.ui.common.NodePropertyComparator)

Example 32 with UIActionLink

use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.

the class DocumentDetailsDialog method previousItem.

/**
 * Navigates to the previous item in the list of content for the current Space
 */
public void previousItem(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id != null && id.length() != 0) {
        List<Node> nodes = this.browseBean.getContent();
        if (nodes.size() > 1) {
            String currentSortColumn = this.browseBean.getContentRichList().getCurrentSortColumn();
            if (currentSortColumn != null) {
                boolean currentSortDescending = this.browseBean.getContentRichList().isCurrentSortDescending();
                Collections.sort(nodes, new NodePropertyComparator(currentSortColumn, !currentSortDescending));
            }
            Node previous = NodeListUtils.previousItem(nodes, id);
            getRecentNodeRefsStack().clear();
            this.browseBean.setupContentAction(previous.getId(), false);
        }
    }
}
Also used : UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) NodePropertyComparator(org.alfresco.web.ui.common.NodePropertyComparator)

Example 33 with UIActionLink

use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.

the class BaseDetailsBean method approve.

/**
 * Event handler called to handle the approve step of the simple workflow
 *
 * @param event The event that was triggered
 */
public void approve(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id == null || id.length() == 0) {
        throw new AlfrescoRuntimeException("approve called without an id");
    }
    final NodeRef docNodeRef = new NodeRef(Repository.getStoreRef(), id);
    try {
        RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
        RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {

            public Object execute() throws Throwable {
                // call the service to perform the approve
                WorkflowUtil.approve(docNodeRef, getNodeService(), getCopyService());
                return null;
            }
        };
        txnHelper.doInTransaction(callback);
        // if this was called via the node details dialog we need to reset the node
        if (getNode() != null) {
            getNode().reset();
        }
        // also make sure the UI will get refreshed
        UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
    } catch (Throwable e) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_WORKFLOW_APPROVE), e.getMessage()), e);
        ReportedException.throwIfNecessary(e);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 34 with UIActionLink

use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.

the class BrowseBean method deleteFile.

/**
 * Event handler used when a file is being deleted, checks that the node
 * does not have an associated working copy.
 *
 * @param event The event
 */
public void deleteFile(ActionEvent event) {
    setupContentAction(event);
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String ref = params.get("ref");
    if (ref != null && ref.length() > 0) {
        NodeRef nodeRef = new NodeRef(ref);
        NodeRef workingCopyNodeRef = getCheckOutCheckInService().getWorkingCopy(nodeRef);
        if (workingCopyNodeRef != null) {
            // if node has a working copy setup error message and return
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_CANNOT_DELETE_NODE_HAS_WORKING_COPY), new Object[] { getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME) }));
            return;
        }
        // if there isn't a working copy go to normal delete dialog
        boolean hasMultipleParents = false;
        boolean showDeleteAssocDialog = false;
        // get type of node being deleted
        Node node = this.getDocument();
        QName type = node.getType();
        TypeDefinition typeDef = this.dictionaryService.getType(type);
        // determine if the node being delete has multiple parents
        if (!type.equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER) && !node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) && !node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT) && !type.equals(ContentModel.TYPE_LINK) && !this.dictionaryService.isSubClass(typeDef.getName(), ContentModel.TYPE_LINK)) {
            List<ChildAssociationRef> parents = this.nodeService.getParentAssocs(node.getNodeRef(), ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
            if (parents != null && parents.size() > 1) {
                hasMultipleParents = true;
            }
        }
        // determine which delete dialog to display
        if (this.navigator.getSearchContext() == null && hasMultipleParents) {
            // if we are not in a search and the node has multiple parents
            // see if the current node has the primary parent association
            NodeRef parentSpace = this.navigator.getCurrentNode().getNodeRef();
            ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
            // show delete assoc dialog if the current space is not the primary parent for the node
            showDeleteAssocDialog = !parentSpace.equals(assoc.getParentRef());
        }
        // show the appropriate dialog
        FacesContext fc = FacesContext.getCurrentInstance();
        if (showDeleteAssocDialog) {
            fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteFileAssoc");
        } else {
            final Map<String, String> dialogParams = new HashMap<String, String>(1);
            dialogParams.put("hasMultipleParents", Boolean.toString(hasMultipleParents));
            Application.getDialogManager().setupParameters(dialogParams);
            fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteFile");
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) HashMap(java.util.HashMap) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) QName(org.alfresco.service.namespace.QName) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef)

Example 35 with UIActionLink

use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.

the class BrowseBean method setupSpaceAction.

/**
 * Action event called by all Browse actions that need to setup a Space context
 * before an action page/wizard is called. The context will be a Node in setActionSpace() which
 * can be retrieved on the action page from BrowseBean.getActionSpace().
 *
 * @param event   ActionEvent
 */
public void setupSpaceAction(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    setupSpaceAction(id, true);
}
Also used : UIActionLink(org.alfresco.web.ui.common.component.UIActionLink)

Aggregations

UIActionLink (org.alfresco.web.ui.common.component.UIActionLink)56 NodeRef (org.alfresco.service.cmr.repository.NodeRef)31 Node (org.alfresco.web.bean.repository.Node)28 NodePropertyComparator (org.alfresco.web.ui.common.NodePropertyComparator)18 FacesContext (javax.faces.context.FacesContext)11 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)9 MapNode (org.alfresco.web.bean.repository.MapNode)7 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)4 ArrayList (java.util.ArrayList)3 UserTransaction (javax.transaction.UserTransaction)3 UIComponent (javax.faces.component.UIComponent)2 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)2 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)2 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)2 Version (org.alfresco.service.cmr.version.Version)2 Writer (java.io.Writer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 FacesMessage (javax.faces.application.FacesMessage)1