Search in sources :

Example 1 with UIGenericPicker

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

the class BaseActionWizard method addRecipient.

/**
 * Action handler called when the Add button is pressed to add an email recipient
 */
public void addRecipient(ActionEvent event) {
    UIGenericPicker picker = (UIGenericPicker) event.getComponent();
    String[] results = picker.getSelectedResults();
    if (results != null && results.length != 0) {
        List<RecipientWrapper> currentEmailRecipients = getEmailRecipients(this.currentActionProperties);
        for (String authority : results) {
            // first check the authority has not already been added to the list
            boolean alreadyAdded = false;
            for (int i = 0; i < currentEmailRecipients.size(); i++) {
                RecipientWrapper wrapper = currentEmailRecipients.get(i);
                if (wrapper.getAuthority().equals(authority)) {
                    alreadyAdded = true;
                    break;
                }
            }
            if (alreadyAdded == false) {
                // find a display label for the authority if it is a known Person
                String name = displayLabelForAuthority(authority);
                // add the recipient to the list
                RecipientWrapper wrapper = new RecipientWrapper(name, authority);
                currentEmailRecipients.add(wrapper);
            }
        }
    }
}
Also used : UIGenericPicker(org.alfresco.web.ui.common.component.UIGenericPicker)

Example 2 with UIGenericPicker

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

the class GenericPickerTag method setProperties.

/**
 * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
 */
protected void setProperties(UIComponent component) {
    super.setProperties(component);
    setBooleanProperty(component, "showFilter", this.showFilter);
    setBooleanProperty(component, "showContains", this.showContains);
    setBooleanProperty(component, "showAddButton", this.showAddButton);
    setBooleanProperty(component, "filterRefresh", this.filterRefresh);
    setBooleanProperty(component, "multiSelect", this.multiSelect);
    setStringProperty(component, "addButtonLabel", this.addButtonLabel);
    setStringProperty(component, "searchButtonLabel", this.searchButtonLabel);
    setActionProperty((UICommand) component, this.action);
    setActionListenerProperty((UICommand) component, this.actionListener);
    setIntProperty(component, "width", this.width);
    setIntProperty(component, "height", this.height);
    setStringBindingProperty(component, "filters", this.filters);
    if (queryCallback != null) {
        if (isValueReference(queryCallback)) {
            MethodBinding b = getFacesContext().getApplication().createMethodBinding(queryCallback, QUERYCALLBACK_CLASS_ARGS);
            ((UIGenericPicker) component).setQueryCallback(b);
        } else {
            throw new FacesException("Query Callback method binding incorrectly specified: " + queryCallback);
        }
    }
}
Also used : MethodBinding(javax.faces.el.MethodBinding) UIGenericPicker(org.alfresco.web.ui.common.component.UIGenericPicker) FacesException(javax.faces.FacesException)

Example 3 with UIGenericPicker

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

the class AddUsersDialog method addSelectedUsers.

// ------------------------------------------------------------------------------
// Event handlers
/**
 * Add the selected User to the list for adding to a Group
 */
public void addSelectedUsers(ActionEvent event) {
    UIGenericPicker picker = (UIGenericPicker) event.getComponent().findComponent("picker");
    String[] results = picker.getSelectedResults();
    if (results != null) {
        for (int i = 0; i < results.length; i++) {
            String authority = results[i];
            // check for same authority so not added twice
            boolean foundExisting = false;
            for (int n = 0; n < this.usersForGroup.size(); n++) {
                UserAuthorityDetails wrapper = this.usersForGroup.get(n);
                if (authority.equals(wrapper.getAuthority())) {
                    foundExisting = true;
                    break;
                }
            }
            if (foundExisting == false) {
                StringBuilder label = new StringBuilder(48);
                // build a display label showing the user person name
                if (this.getPersonService().personExists(authority) == true) {
                    // found a Person with a User authority
                    NodeRef ref = this.getPersonService().getPerson(authority);
                    String firstName = (String) getNodeService().getProperty(ref, ContentModel.PROP_FIRSTNAME);
                    String lastName = (String) getNodeService().getProperty(ref, ContentModel.PROP_LASTNAME);
                    // build a sensible label for display
                    label.append(firstName != null ? firstName : "").append(' ').append(lastName != null ? lastName : "");
                    // add a wrapper object with the details to the results list for display
                    UserAuthorityDetails userDetails = new UserAuthorityDetails(label.toString(), authority);
                    this.usersForGroup.add(userDetails);
                }
            }
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UserAuthorityDetails(org.alfresco.web.bean.groups.GroupsDialog.UserAuthorityDetails) UIGenericPicker(org.alfresco.web.ui.common.component.UIGenericPicker)

Example 4 with UIGenericPicker

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

the class BaseInviteUsersWizard method addSelection.

/**
 * Action handler called when the Add button is pressed to process the current selection
 */
public void addSelection(ActionEvent event) {
    UIGenericPicker picker = (UIGenericPicker) event.getComponent().findComponent("picker");
    UISelectOne rolePicker = (UISelectOne) event.getComponent().findComponent("roles");
    String[] results = picker.getSelectedResults();
    if (results != null) {
        String role = (String) rolePicker.getValue();
        if (role != null) {
            for (int i = 0; i < results.length; i++) {
                addAuthorityWithRole(results[i], role);
            }
        }
    }
}
Also used : UIGenericPicker(org.alfresco.web.ui.common.component.UIGenericPicker) UISelectOne(javax.faces.component.UISelectOne)

Example 5 with UIGenericPicker

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

the class ReassignTaskDialog method finishImpl.

@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception {
    if (logger.isDebugEnabled())
        logger.debug("Reassigning task with id: " + this.taskId);
    UIComponent picker = context.getViewRoot().findComponent("dialog:dialog-body:user-picker");
    if (picker != null && picker instanceof UIGenericPicker) {
        UIGenericPicker userPicker = (UIGenericPicker) picker;
        String[] user = userPicker.getSelectedResults();
        if (user != null && user.length > 0) {
            // create a map to hold the new owner property then update the task
            String userName = user[0];
            Map<QName, Serializable> params = new HashMap<QName, Serializable>(1);
            params.put(ContentModel.PROP_OWNER, userName);
            this.getWorkflowService().updateTask(this.taskId, params, null, null);
        } else {
            if (logger.isWarnEnabled())
                logger.warn("Failed to find selected user, reassign was unsuccessful");
        }
    } else {
        if (logger.isWarnEnabled())
            logger.warn("Failed to find user-picker component, reassign was unsuccessful");
    }
    if (logger.isDebugEnabled())
        logger.debug("Reassigning task with id: " + this.taskId);
    return outcome;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) UIComponent(javax.faces.component.UIComponent) UIGenericPicker(org.alfresco.web.ui.common.component.UIGenericPicker)

Aggregations

UIGenericPicker (org.alfresco.web.ui.common.component.UIGenericPicker)6 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 UIComponent (javax.faces.component.UIComponent)2 QName (org.alfresco.service.namespace.QName)2 FacesException (javax.faces.FacesException)1 UISelectOne (javax.faces.component.UISelectOne)1 MethodBinding (javax.faces.el.MethodBinding)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 UserAuthorityDetails (org.alfresco.web.bean.groups.GroupsDialog.UserAuthorityDetails)1