Search in sources :

Example 11 with UIActionLink

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

the class NewUserWizard method startWizardForEdit.

/**
 * Action listener called when the wizard is being launched for editing an
 * existing node.
 */
public void startWizardForEdit(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id != null && id.length() != 0) {
        try {
            // create the node ref, then our node representation
            NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
            Node node = new Node(ref);
            // remember the Person node
            setPerson(node);
            // set the wizard in edit mode
            this.editMode = true;
            // populate the wizard's default values with the current value
            // from the node being edited
            init();
            populate();
            // clear the UI state in preparation for finishing the action
            // and returning to the main page
            invalidateUserList();
            if (logger.isDebugEnabled())
                logger.debug("Started wizard : " + getWizardTitle() + " for editing");
        } catch (InvalidNodeRefException refErr) {
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
        }
    } else {
        setPerson(null);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 12 with UIActionLink

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

the class SpaceDetailsDialog method nextItem.

// ------------------------------------------------------------------------------
// Action event handlers
/**
 * Navigates to next item in the list of Spaces
 */
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();
            if (currentSortColumn != null) {
                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)

Example 13 with UIActionLink

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

the class TrashcanDialog method setupItemAction.

/**
 * Action handler called to prepare the selected item for an action
 */
public void setupItemAction(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id != null && id.length() != 0) {
        try {
            // create the node ref, then our node representation
            NodeRef ref = new NodeRef(getArchiveRootRef().getStoreRef(), id);
            Node node = new Node(ref);
            node.addPropertyResolver("locationPath", resolverLocationPath);
            node.addPropertyResolver("deletedDate", resolverDeletedDate);
            node.addPropertyResolver("deletedBy", resolverDeletedBy);
            node.addPropertyResolver("isFolder", resolverIsFolder);
            node.addPropertyResolver("mimetype", resolverMimetype);
            node.addPropertyResolver("size", resolverSize);
            node.addPropertyResolver("encoding", resolverEncoding);
            if (getDictionaryService().isSubClass(node.getType(), ContentModel.TYPE_FOLDER) == true && getDictionaryService().isSubClass(node.getType(), ContentModel.TYPE_SYSTEM_FOLDER) == false) {
                node.addPropertyResolver("icon", this.resolverLargeIcon);
            } else {
                node.addPropertyResolver("icon", this.resolverFileType32);
            }
            // prepare a node for the action context
            property.setItem(node);
            property.setDestination(null);
        } catch (InvalidNodeRefException refErr) {
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
        }
    } else {
        property.setItem(null);
    }
    // clear the UI state in preparation for finishing the next action
    contextUpdated();
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 14 with UIActionLink

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

the class RulesDialog method reapplyRules.

/**
 * Reapply the currently defines rules to the
 * @param event ActionEvent
 */
public void reapplyRules(ActionEvent event) {
    boolean toChildren = false;
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String toChildrenStr = params.get("toChildren");
    if (toChildrenStr != null) {
        toChildren = new Boolean(toChildrenStr).booleanValue();
    }
    FacesContext fc = FacesContext.getCurrentInstance();
    UserTransaction tx = null;
    try {
        tx = Repository.getUserTransaction(fc);
        tx.begin();
        // Set the include inherited parameter to match the current filter value
        boolean executeInherited = true;
        if (this.filterModeMode.equals(LOCAL)) {
            executeInherited = false;
        }
        // Reapply the rules
        reapplyRules(this.getSpace().getNodeRef(), executeInherited, toChildren);
        // TODO how do I get the message here ...
        String msg = Application.getMessage(fc, MSG_REAPPLY_RULES_SUCCESS);
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
        String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
        fc.addMessage(formId + ":rulesList", facesMsg);
        // commit the transaction
        tx.commit();
    } catch (Throwable e) {
        // rollback the transaction
        try {
            if (tx != null) {
                tx.rollback();
            }
        } catch (Exception ex) {
        }
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(fc, Repository.ERROR_GENERIC), e.getMessage()), e);
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) FacesContext(javax.faces.context.FacesContext) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) FacesMessage(javax.faces.application.FacesMessage)

Example 15 with UIActionLink

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

the class UserShortcutsBean method createShortcut.

// ------------------------------------------------------------------------------
// Action method handlers
/**
 * Action handler called when a new shortcut is to be added to the list
 */
public void createShortcut(ActionEvent event) {
    // TODO: add this action to the Details screen for Space and Document
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id != null && id.length() != 0) {
        try {
            NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
            Node node = new Node(ref);
            boolean foundShortcut = false;
            for (int i = 0; i < getShortcuts().size(); i++) {
                if (node.getId().equals(getShortcuts().get(i).getId())) {
                    // found same node already in the list - so we don't need to add it again
                    foundShortcut = true;
                    break;
                }
            }
            if (foundShortcut == false) {
                // add to persistent store
                UserTransaction tx = null;
                try {
                    FacesContext context = FacesContext.getCurrentInstance();
                    tx = Repository.getUserTransaction(context);
                    tx.begin();
                    List<String> shortcuts = getShortcutList(context);
                    shortcuts.add(node.getNodeRef().getId());
                    PreferencesService.getPreferences(context).setValue(PREF_SHORTCUTS, (Serializable) shortcuts);
                    // commit the transaction
                    tx.commit();
                    // add our new shortcut Node to the in-memory list
                    getShortcuts().add(node);
                    if (logger.isDebugEnabled())
                        logger.debug("Added node: " + node.getName() + " to the user shortcuts list.");
                } catch (Throwable err) {
                    Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
                    try {
                        if (tx != null) {
                            tx.rollback();
                        }
                    } catch (Exception tex) {
                    }
                }
            }
        } catch (InvalidNodeRefException refErr) {
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
        }
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) FacesContext(javax.faces.context.FacesContext) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) NodeRef(org.alfresco.service.cmr.repository.NodeRef) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

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