Search in sources :

Example 46 with UIActionLink

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

the class SpaceDetailsDialog method previousItem.

/**
 * Navigates to the previous item in the list Spaces
 */
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) {
        NodeRef currNodeRef = new NodeRef(Repository.getStoreRef(), id);
        List<Node> nodes = this.browseBean.getParentNodes(currNodeRef);
        Node previous = null;
        if (nodes.size() > 1) {
            String currentSortColumn = this.browseBean.getSpacesRichList().getCurrentSortColumn();
            if (currentSortColumn != null) {
                boolean currentSortDescending = this.browseBean.getSpacesRichList().isCurrentSortDescending();
                Collections.sort(nodes, new NodePropertyComparator(currentSortColumn, !currentSortDescending));
            }
            previous = NodeListUtils.previousItem(nodes, id);
            this.browseBean.setupSpaceAction(previous.getId(), false);
        }
        if (previous == null) {
            Node currNode = new Node(currNodeRef);
            this.navigator.setupDispatchContext(currNode);
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) NodePropertyComparator(org.alfresco.web.ui.common.NodePropertyComparator)

Example 47 with UIActionLink

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

the class VersionedDocumentDetailsDialog method nextItem.

/**
 * Navigates to next item in the list of versioned content for the current VersionHistory
 */
public void nextItem(ActionEvent event) {
    // Get the properties of the action event
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String versionLabel = params.get("versionLabel");
    // if the version is not specified, get the next version
    if (versionLabel == null) {
        List<Version> nextVersions = new ArrayList<Version>(this.versionHistory.getSuccessors(this.documentVersion));
        // if the version history doesn't contains successor, get the root version (the first one)
        if (nextVersions == null || nextVersions.size() < 1) {
            this.documentVersion = versionHistory.getRootVersion();
        } else {
            this.documentVersion = nextVersions.get(0);
        }
    } else {
        this.documentVersion = this.versionHistory.getVersion(versionLabel);
    }
}
Also used : Version(org.alfresco.service.cmr.version.Version) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) ArrayList(java.util.ArrayList)

Example 48 with UIActionLink

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

the class VersionedDocumentDetailsDialog method previousItem.

/**
 * Navigates to previous item in the list of versioned content for the current VersionHistory
 */
public void previousItem(ActionEvent event) {
    // Get the properties of the action event
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String versionLabel = params.get("versionLabel");
    // if the version is not specified, get the next version
    if (versionLabel == null) {
        Version prevVersion = this.versionHistory.getPredecessor(this.documentVersion);
        // if the version history doesn't contains predecessor, get the last version (ie. most recent)
        if (prevVersion == null) {
            List<Version> allVersions = new ArrayList<Version>(this.versionHistory.getAllVersions());
            this.documentVersion = allVersions.get(0);
        } else {
            this.documentVersion = prevVersion;
        }
    } else {
        this.documentVersion = this.versionHistory.getVersion(versionLabel);
    }
}
Also used : Version(org.alfresco.service.cmr.version.Version) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) ArrayList(java.util.ArrayList)

Example 49 with UIActionLink

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

the class ForumsBean method discuss.

/**
 * Event handler called when a user wants to view or participate
 * in a discussion on an object
 *
 * @param event ActionEvent
 */
public void discuss(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("discuss called without an id");
    }
    FacesContext context = FacesContext.getCurrentInstance();
    NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), id);
    if (this.getNodeService().hasAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE) == false) {
        throw new AlfrescoRuntimeException("discuss called for an object that does not have a discussion!");
    }
    // as the node has the discussable aspect there must be a discussions child assoc
    List<ChildAssociationRef> children = this.getNodeService().getChildAssocs(nodeRef, ForumModel.ASSOC_DISCUSSION, RegexQNamePattern.MATCH_ALL);
    // there should only be one child, retrieve it if there is
    if (children.size() == 1) {
        // show the forum for the discussion
        NodeRef forumNodeRef = children.get(0).getChildRef();
        this.browseBean.clickSpace(forumNodeRef);
        context.getApplication().getNavigationHandler().handleNavigation(context, null, "showForum");
    } else {
        // this should never happen as the action evaluator should stop the action
        // from displaying, just in case print a warning to the console
        logger.warn("Node has the discussable aspect but does not have 1 child, it has " + children.size() + " children!");
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 50 with UIActionLink

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

the class ForumsDetailsDialog method nextItem.

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) {
        NodeRef currNodeRef = new NodeRef(Repository.getStoreRef(), id);
        List<Node> nodes = this.browseBean.getParentNodes(currNodeRef);
        Node next = null;
        if (nodes.size() > 1) {
            String currentSortColumn = this.browseBean.getSpacesRichList().getCurrentSortColumn();
            boolean currentSortDescending = this.browseBean.getSpacesRichList().isCurrentSortDescending();
            Collections.sort(nodes, new NodePropertyComparator(currentSortColumn, !currentSortDescending));
            next = NodeListUtils.nextItem(nodes, id);
            this.browseBean.setupSpaceAction(next.getId(), false);
        }
        if (next == null) {
            Node currNode = new Node(currNodeRef);
            this.navigator.setupDispatchContext(currNode);
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) NodePropertyComparator(org.alfresco.web.ui.common.NodePropertyComparator)

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