@Override
    protected void setStateActionCol(CmsListMetadata metadata) {

        // create column for state change
        CmsListColumnDefinition stateCol = new CmsListColumnDefinition(LIST_COLUMN_STATE);
        stateCol.setName(Messages.get().container(Messages.GUI_ORGUNITUSERS_LIST_COLS_STATE_0));
        stateCol.setHelpText(Messages.get().container(Messages.GUI_ORGUNITUSERS_LIST_COLS_STATE_HELP_0));
        stateCol.setWidth("20");
        stateCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
        stateCol.setSorteable(false);
        // add add action
        CmsListDirectAction stateAction = new CmsListDirectAction(LIST_ACTION_ADD) {

            /**
             * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getHelpText()
             */
            @Override
            public CmsMessageContainer getHelpText() {

                if (!isEnabled()) {
                    return Messages.get().container(Messages.GUI_ORGUNITUSERS_LIST_DISABLED_DELETE_HELP_0);
                }
                return super.getHelpText();
            }

            /**
             * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isEnabled()
             */
            @Override
            public boolean isEnabled() {

                if (getItem() != null) {
                    try {
                        String userName = getItem().get(LIST_COLUMN_NAME).toString();
                        List<CmsUser> currentUsers = OpenCms.getOrgUnitManager().getUsers(
                            getWp().getCms(),
                            ((A_CmsOrgUnitUsersList)getWp()).getParamOufqn(),
                            false);
                        Iterator<CmsUser> itCurrentUsers = currentUsers.iterator();
                        while (itCurrentUsers.hasNext()) {
                            CmsUser user = itCurrentUsers.next();
                            if (user.getSimpleName().equals(userName)) {
                                return false;
                            }
                            if (((A_CmsOrgUnitUsersList)getWp()).getCms().getGroupsOfUser(
                                getItem().get(LIST_COLUMN_LOGIN).toString(),
                                false).size() > 0) {
                                return false;
                            }
                        }
                        return true;
                    } catch (CmsException e) {
                        return super.isVisible();
                    }
                }
                return super.isVisible();
            }
        };
        stateAction.setName(Messages.get().container(Messages.GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_NAME_0));
        stateAction.setHelpText(Messages.get().container(Messages.GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_HELP_0));
        stateAction.setIconPath(ICON_ADD);
        stateCol.addDirectAction(stateAction);
        // add it to the list definition
        metadata.addColumn(stateCol);
        // keep the id
        m_addActionIds.add(stateAction.getId());
    }
@ Override protected void setStateActionCol ( CmsListMetadata metadata ) { CmsListColumnDefinition stateCol = new CmsListColumnDefinition ( LIST_COLUMN_STATE ) ; stateCol . setName ( Messages . get ( ) . container ( Messages . GUI_ORGUNITUSERS_LIST_COLS_STATE_0 ) ) ; stateCol . setHelpText ( Messages . get ( ) . container ( Messages . GUI_ORGUNITUSERS_LIST_COLS_STATE_HELP_0 ) ) ; stateCol . setWidth ( "20" ) ; stateCol . setAlign ( CmsListColumnAlignEnum . ALIGN_CENTER ) ; stateCol . setSorteable ( false ) ; CmsListDirectAction stateAction = new CmsListDirectAction ( LIST_ACTION_ADD ) { @ Override public CmsMessageContainer getHelpText ( ) { if ( ! isEnabled ( ) ) { return Messages . get ( ) . container ( Messages . GUI_ORGUNITUSERS_LIST_DISABLED_DELETE_HELP_0 ) ; } return super . getHelpText ( ) ; } @ Override public boolean isEnabled ( ) { if ( getItem ( ) != null ) { try { String userName = getItem ( ) . get ( LIST_COLUMN_NAME ) . toString ( ) ; List < CmsUser > currentUsers = OpenCms . getOrgUnitManager ( ) . getUsers ( getWp ( ) . getCms ( ) , ( ( A_CmsOrgUnitUsersList ) getWp ( ) ) . getParamOufqn ( ) , false ) ; Iterator < CmsUser > itCurrentUsers = currentUsers . iterator ( ) ; while ( itCurrentUsers . hasNext ( ) ) { CmsUser user = itCurrentUsers . next ( ) ; if ( user . getSimpleName ( ) . equals ( userName ) ) { return false ; } if ( ( ( A_CmsOrgUnitUsersList ) getWp ( ) ) . getCms ( ) . getGroupsOfUser ( getItem ( ) . get ( LIST_COLUMN_LOGIN ) . toString ( ) , false ) . size ( ) > 0 ) { return false ; } } return true ; } catch ( CmsException e ) { return super . isVisible ( ) ; } } return super . isVisible ( ) ; } } ; stateAction . setName ( Messages . get ( ) . container ( Messages . GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_NAME_0 ) ) ; stateAction . setHelpText ( Messages . get ( ) . container ( Messages . GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_HELP_0 ) ) ; stateAction . setIconPath ( ICON_ADD ) ; stateCol . addDirectAction ( stateAction ) ; metadata . addColumn ( stateCol ) ; m_addActionIds . add ( stateAction . getId ( ) ) ; }
@see org.opencms.workplace.tools.accounts.A_CmsOrgUnitUsersList#setStateActionCol(org.opencms.workplace.list.CmsListMetadata)