Project

General

Profile

« Previous | Next » 

Revision 150c2624

Added by Andreas Kohlbecker about 5 years ago

fix #8069 removing all message hub related code from the Registration UI:

  • Buttons
  • Views & Components
  • Spring configuration

View differences:

src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java
73 73
        "eu.etaxonomy.vaadin.ui",
74 74
        "eu.etaxonomy.cdm.vaadin",
75 75
        "eu.etaxonomy.cdm.service",
76
        "org.springframework.context.event",
77
        "eu.etaxonomy.cdm.ext.registration.messages.redmine" // FIXME needed???
76
        "org.springframework.context.event"
78 77
        },
79 78
        // exclude UI classes, these are provided via the @Bean annotated methods below
80 79
        excludeFilters={@Filter(
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java
61 61
 */
62 62
public class RegistrationItem extends GridLayout {
63 63

  
64

  
65

  
66 64
    public static final String VALIDATION_PROBLEMS = "validationProblems";
67 65

  
68
    public static final String MESSAGES = "messages";
69

  
70 66
    public static final String BLOCKED_BY = "blockedBy";
71 67

  
72 68
    private static final String LABEL_CAPTION_CREATED = "Created";
......
93 89
    private Link identifierLink = new Link();
94 90
    private Label citationSummaryLabel = new Label();
95 91
    private Button blockedByButton = new Button(FontAwesome.WARNING);
96
    private Button messageButton;
92
    private Button validationProblemsButton;
97 93
    private Button openButton = new Button(FontAwesome.COGS);
98 94
    private Label submitterLabel = new Label();
99 95
    private Label createdLabel = new Label();
......
148 144
        setComponentAlignment(identifierLink, Alignment.TOP_CENTER);
149 145
        setColumnExpandRatio(1, 1.0f);
150 146

  
151
        messageButton = new Button(FontAwesome.COMMENT);
152
        CssLayout buttonGroup = new CssLayout(blockedByButton, messageButton, openButton);
147
        validationProblemsButton = new Button(FontAwesome.COMMENT);
148
        CssLayout buttonGroup = new CssLayout(blockedByButton, validationProblemsButton, openButton);
153 149
        blockedByButton.setStyleName(ValoTheme.BUTTON_TINY);
154 150
        blockedByButton.setEnabled(false);
155
        messageButton.setStyleName(ValoTheme.BUTTON_TINY);
156
        messageButton.setEnabled(false);
151
        validationProblemsButton.setStyleName(ValoTheme.BUTTON_TINY);
152
        validationProblemsButton.setEnabled(false);
157 153

  
158 154
        openButton.setStyleName(ValoTheme.BUTTON_TINY);
159 155
        openButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
......
228 224
            datePublished = workingSet.getRegistrationDTOs().get(0).getDatePublished();
229 225
            // submitterName = workingSet.getRegistrationDTOs().get(0).getSubmitterUserName();
230 226
        }
231
        updateUI(workingSet.getCitation(), workingSet.getCreated(), datePublished, workingSet.messagesCount(),
227
        updateUI(workingSet.getCitation(), workingSet.getCreated(), datePublished, workingSet.validationProblemsCount(),
232 228
                referenceEditorAction, FontAwesome.EDIT, null, submitterName);
233 229
    }
234 230

  
......
248 244
     * @param submitterUserName TODO
249 245
     *
250 246
     */
251
    private void updateUI(String citationString,  DateTime created, TimePeriod datePublished,  int messagesCount,
247
    private void updateUI(String citationString,  DateTime created, TimePeriod datePublished,  int validationProblemsCount,
252 248
            Object openButtonEvent, Resource openButtonIcon, RegistrationDTO regDto, String submitterUserName) {
253 249

  
254 250
        StringBuffer labelMarkup = new StringBuffer();
255 251
        DateTime registrationDate = null;
256 252

  
257
        if(messagesCount > 0){
258
            getMessageButton().setEnabled(true);
253
        if(validationProblemsCount > 0){
254
            getValidationProblemsButton().setEnabled(true);
259 255
            // getMessageButton().addStyleName(RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
260
            getMessageButton().addClickListener(e -> {
256
            getValidationProblemsButton().addClickListener(e -> {
261 257
                ShowDetailsEvent detailsEvent;
262 258
                if(regDto != null){
263 259
                    detailsEvent = new ShowDetailsEvent<RegistrationDTO, UUID>(
......
275 271
                publishEvent(detailsEvent);
276 272
                }
277 273
            );
278
            getMessageButton().setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + messagesCount + "</span>");
279
            getMessageButton().setCaptionAsHtml(true);
274
            getValidationProblemsButton().setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + validationProblemsCount + "</span>");
275
            getValidationProblemsButton().setCaptionAsHtml(true);
280 276
        }
281 277

  
282 278
        if(regDto != null && regDto.isBlocked()){
......
400 396
    /**
401 397
     * @return the validationProblemsButton
402 398
     */
403
    public Button getMessageButton() {
404
        return messageButton;
399
    public Button getValidationProblemsButton() {
400
        return validationProblemsButton;
405 401
    }
406 402

  
407 403
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemButtons.java
27 27

  
28 28
    Button validationProblemsButton;
29 29

  
30
    Button messagesButton;
31

  
32 30
    public RegistrationItemButtons() {
33 31

  
34 32
          setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
......
39 37
          validationProblemsButton = new Button(FontAwesome.WARNING);
40 38
          validationProblemsButton.setEnabled(false);
41 39

  
42
          messagesButton = new Button(FontAwesome.COMMENT);
43
          messagesButton.setEnabled(false);
44

  
45
          addComponents(blockingRegistrationButton, validationProblemsButton, messagesButton);
40
          addComponents(blockingRegistrationButton, validationProblemsButton);
46 41
    }
47 42

  
48 43
    /**
......
59 54
        return validationProblemsButton;
60 55
    }
61 56

  
62
    /**
63
     * @return the messagesButton
64
     */
65
    public Button getMessagesButton() {
66
        return messagesButton;
67
    }
68

  
69

  
70

  
71

  
72

  
73

  
74 57
}
src/main/java/eu/etaxonomy/cdm/vaadin/toolbar/RegistrationToolbar.java
61 61
    UserHelper userHelper;
62 62

  
63 63
    CssLayout buttonGroup = new CssLayout();
64
    Button messageButton;
65 64
    Button loginButton;
66 65
    Button logoutButton;
67 66
    Button userButton;
......
74 73

  
75 74
        setWidth("100%");
76 75
        buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
77
        messageButton = new Button(FontAwesome.COMMENT);
78 76
        loginButton = new Button("login");
79 77
        userButton = new Button(FontAwesome.USER);
80 78
        logoutButton = new Button("logout");
81 79

  
82
        messageButton.setEnabled(false);
83 80
        logoutButton.addClickListener(e -> performLogut());
84 81
        loginButton.addClickListener(e -> performLogin());
85
        buttonGroup.addComponent(messageButton);
86 82
        buttonGroup.addComponent(loginButton);
87 83
        buttonGroup.addComponent(logoutButton);
88 84
        buttonGroup.addComponent(userButton);
......
105 101
        if(userHelper.userIsAutheticated() && !userHelper.userIsAnnonymous()){
106 102
            userButton.setCaption(userHelper.userName());
107 103
            userButton.setVisible(true);
108
            messageButton.setVisible(true);
109 104
            logoutButton.setVisible(true);
110 105
            loginButton.setVisible(false);
111 106

  
112 107
        } else {
113 108
            userButton.setCaption(null);
114 109
            userButton.setVisible(false);
115
            messageButton.setVisible(false);
116 110
            logoutButton.setVisible(false);
117 111
            loginButton.setVisible(true);
118 112
        }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
201 201
        UUID registrationUuid = event.getIdentifier();
202 202

  
203 203
        RegistrationDTO regDto = getWorkingSetService().loadDtoByUuid(registrationUuid);
204
        if(event.getProperty().equals("messages")){
204
        if(event.getProperty().equals(RegistrationItem.VALIDATION_PROBLEMS)){
205 205

  
206
            getView().openDetailsPopup("Messages", regDto.getValidationProblems());
206
            getView().openDetailsPopup("Validation Problems", regDto.getValidationProblems());
207 207

  
208 208
        } else if(event.getProperty().equals("blockedBy")){
209 209

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPopup.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.view.registration;
10

  
11
import java.text.SimpleDateFormat;
12
import java.util.Collection;
13
import java.util.List;
14
import java.util.UUID;
15

  
16
import org.apache.commons.lang3.StringUtils;
17
import org.springframework.context.annotation.Scope;
18
import org.springframework.security.core.GrantedAuthority;
19

  
20
import com.vaadin.server.FontAwesome;
21
import com.vaadin.shared.ui.label.ContentMode;
22
import com.vaadin.spring.annotation.SpringComponent;
23
import com.vaadin.ui.Alignment;
24
import com.vaadin.ui.Button;
25
import com.vaadin.ui.HorizontalLayout;
26
import com.vaadin.ui.Label;
27
import com.vaadin.ui.Panel;
28
import com.vaadin.ui.TextArea;
29
import com.vaadin.ui.VerticalLayout;
30
import com.vaadin.ui.themes.ValoTheme;
31

  
32
import eu.etaxonomy.cdm.ext.registration.messages.Message;
33
import eu.etaxonomy.cdm.vaadin.event.error.DelegatingErrorHandler;
34
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
35
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
36
import eu.etaxonomy.vaadin.mvp.AbstractPopupView;
37

  
38
@SpringComponent
39
@Scope("prototype")
40
public class RegistrationMessagesPopup extends AbstractPopupView<RegistrationMessagesPresenter>
41
    implements RegistrationMessagesView, AccessRestrictedView {
42

  
43
    private static final long serialVersionUID = 713522519903334889L;
44

  
45
    Panel messagesPanel;
46

  
47
    TextArea newMessageField;
48

  
49
    Button sendMessageButton;
50

  
51
    private VerticalLayout mainLayout;
52

  
53
    private DelegatingErrorHandler errrorHandler = new DelegatingErrorHandler();
54

  
55
    private String accessDeniedMessage;
56

  
57
    public RegistrationMessagesPopup() {
58

  
59
        mainLayout = new VerticalLayout();
60
        // IMPORTANT: mainLayout must be set to full size otherwise the
61
        // popup window may have problems with automatic resizing of its
62
        // content.
63
        mainLayout.setSizeFull();
64

  
65
        setCompositionRoot(mainLayout);
66
    }
67

  
68

  
69
    @Override
70
    protected void initContent() {
71

  
72
        messagesPanel = new Panel();
73
        messagesPanel.setStyleName(EditValoTheme.PANEL_CONTENT_PADDING_LEFT);
74

  
75
        newMessageField = new TextArea();
76
        newMessageField.setNullRepresentation("");
77
        newMessageField.addTextChangeListener(e -> {
78
            sendMessageButton.setEnabled(StringUtils.isNoneBlank(e.getText()));
79
        });
80
        newMessageField.setHeight("64px"); // height of the Submit button when ValoTheme.BUTTON_HUGE
81
        newMessageField.setWidth("100%");
82

  
83
        sendMessageButton = new Button(FontAwesome.SEND);
84
        sendMessageButton.addClickListener(e -> postNewMessage());
85
        sendMessageButton.setStyleName(ValoTheme.BUTTON_HUGE + " " +ValoTheme.BUTTON_PRIMARY);
86

  
87
        HorizontalLayout sendMessagebar = new HorizontalLayout(newMessageField, sendMessageButton);
88
        sendMessagebar.setComponentAlignment(sendMessageButton, Alignment.MIDDLE_RIGHT);
89
        sendMessagebar.setExpandRatio(newMessageField, 1f);
90
        sendMessagebar.setWidth("100%");
91

  
92
        mainLayout.addComponents(messagesPanel, sendMessagebar);
93

  
94
        mainLayout.setErrorHandler(errrorHandler);
95
        mainLayout.setComponentAlignment(sendMessagebar, Alignment.BOTTOM_CENTER);
96
    }
97

  
98

  
99
    @Override
100
    public int getWindowHeight() {
101
        // undefined
102
        return -1;
103
    }
104

  
105
    @Override
106
    public boolean isClosable() {
107
        return true;
108
    }
109

  
110
    @Override
111
    public boolean isResizable() {
112
        return true;
113
    }
114

  
115
    /**
116
     * @return
117
     */
118
    private void postNewMessage() {
119
        // quick and dirty implementation, better send an event
120
        String text = newMessageField.getValue();
121
        if(StringUtils.isNotBlank(text)){
122
            getPresenter().postMessage(text);
123
            newMessageField.setValue(null);
124
        }
125
    }
126

  
127
    /**
128
     * {@inheritDoc}
129
     */
130
    @Override
131
    public String getWindowCaption() {
132
        return "Messages";
133
    }
134

  
135
    /**
136
     * {@inheritDoc}
137
     */
138
    @Override
139
    public void focusFirst() {
140
        // none
141
    }
142

  
143

  
144
    /**
145
     * {@inheritDoc}
146
     */
147
    @Override
148
    public boolean allowAnonymousAccess() {
149
        return false;
150
    }
151

  
152
    /**
153
     * {@inheritDoc}
154
     */
155
    @Override
156
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
157
        return null;
158
    }
159

  
160
    @Override
161
    public String getAccessDeniedMessage() {
162
        return accessDeniedMessage;
163
    }
164

  
165
    @Override
166
    public void setAccessDeniedMessage(String accessDeniedMessage) {
167
        this.accessDeniedMessage = accessDeniedMessage;
168

  
169
    }
170

  
171
    /**
172
     * {@inheritDoc}
173
     */
174
    @Override
175
    public void cancel() {
176
        // not needed
177

  
178
    }
179

  
180
    /**
181
     * @param identifier
182
     */
183
    public void loadMessagesFor(UUID registrationEntityUuid) {
184
        getPresenter().loadMessagesFor(registrationEntityUuid);
185

  
186
    }
187

  
188
    /**
189
     * {@inheritDoc}
190
     */
191
    @Override
192
    public void showMessages(String registrationLabel, List<Message> messages) {
193

  
194
        VerticalLayout messagesList = new VerticalLayout();
195

  
196
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
197

  
198
        for(Message message : messages){
199
            Label item = new Label("<span class=\"date-time\">(" +  dateFormat.format(message.getCreatedOn()) + ")</span> <span class=\"user-name\">" + message.getFrom().getUsername() + "</span>: <span class=\"message-text\">"  + message.getText() + "</span>");
200
            item.setStyleName("message-item");
201
            item.setContentMode(ContentMode.HTML);
202
            messagesList.addComponent(item);
203

  
204
        }
205
        messagesPanel.setCaption(registrationLabel);
206
        messagesPanel.setContent(messagesList);
207

  
208
    }
209

  
210
    // TODO move into AbstractPopupView?
211
    @Override
212
    public DelegatingErrorHandler getErrrorHandler(){
213
        return errrorHandler;
214
    }
215

  
216

  
217
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.view.registration;
10

  
11
import java.util.Arrays;
12
import java.util.List;
13
import java.util.Stack;
14
import java.util.UUID;
15

  
16
import org.springframework.beans.factory.annotation.Autowired;
17
import org.springframework.context.annotation.Scope;
18

  
19
import com.vaadin.spring.annotation.SpringComponent;
20

  
21
import eu.etaxonomy.cdm.api.service.IRegistrationService;
22
import eu.etaxonomy.cdm.api.utility.RoleProber;
23
import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
24
import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService;
25
import eu.etaxonomy.cdm.ext.registration.messages.Message;
26
import eu.etaxonomy.cdm.model.common.User;
27
import eu.etaxonomy.cdm.model.name.Registration;
28
import eu.etaxonomy.cdm.service.UserHelperAccess;
29
import eu.etaxonomy.cdm.vaadin.event.error.ExternalServiceExceptionHandler;
30
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
31
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
32

  
33
/**
34
 * @author a.kohlbecker
35
 * @since Feb 27, 2018
36
 *
37
 */
38
@SpringComponent
39
@Scope("prototype")
40
public class RegistrationMessagesPresenter extends AbstractPresenter<RegistrationMessagesView> {
41

  
42
    private static final long serialVersionUID = -1069755744585623770L;
43

  
44
    @Autowired
45
    IRegistrationMessageService messageService;
46

  
47
    @Autowired
48
    IRegistrationService registrationService;
49

  
50
    Registration registration;
51

  
52
    @Override
53
    public void onPresenterReady() {
54
        getView().getErrrorHandler().registerHandler(
55
                new ExternalServiceExceptionHandler("The external messages service reported an error")
56
                );
57
    }
58

  
59
    /**
60
     * @param identifier
61
     */
62
    public void loadMessagesFor(UUID uuid) {
63
        if(registration == null){
64
            registration = registrationService.load(uuid, Arrays.asList("submitter"));
65
        }
66
        try {
67
            List<Message> messages = messageService.listMessages(registration);
68
            getView().showMessages("On Registration " + registration.getIdentifier(), messages);
69
        } catch (ExternalServiceException e) {
70
            throw new RuntimeException(e);
71
        }
72

  
73
    }
74

  
75
    /**
76
     * @param value
77
     */
78
    public void postMessage(String message) {
79

  
80
        User user = UserHelperAccess.userHelper().user();
81
        List<Message> activeMessages;
82
        try {
83
            activeMessages = messageService.listActiveMessagesFor(registration, user);
84
        } catch (ExternalServiceException e) {
85
            throw new RuntimeException(e);
86
        }
87
        User toUser = null;
88
        if(UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION))){
89
            toUser = registration.getSubmitter();
90
        } else {
91
            Stack<Message> stack = new Stack<>();
92
            stack.addAll(activeMessages);
93
            while(!stack.empty()){
94
                toUser = stack.pop().getFrom();
95
                if(!toUser.equals(user)){
96
                    break;
97
                }
98
            }
99
            if(toUser == null){
100
                throw new RuntimeException("Only a curator can initiate a communication");
101
            }
102
        }
103
        try {
104
            messageService.postMessage(registration, message, user, toUser);
105
            loadMessagesFor(registration.getUuid());
106
        } catch (ExternalServiceException e) {
107
            logger.error(e);
108
            throw new RuntimeException(e);
109
        }
110

  
111

  
112
    }
113

  
114
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesView.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.view.registration;
10

  
11
import java.util.List;
12

  
13
import eu.etaxonomy.cdm.ext.registration.messages.Message;
14
import eu.etaxonomy.cdm.vaadin.event.error.DelegatingErrorHandler;
15
import eu.etaxonomy.vaadin.mvp.ApplicationView;
16

  
17
/**
18
 * @author a.kohlbecker
19
 * @since Feb 27, 2018
20
 *
21
 */
22
public interface RegistrationMessagesView extends ApplicationView<RegistrationMessagesPresenter> {
23

  
24
    /**
25
     * @param messages
26
     */
27
    void showMessages(String registrationLabel, List<Message> messages);
28

  
29
    DelegatingErrorHandler getErrrorHandler();
30

  
31
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
27 27
import org.vaadin.spring.events.EventScope;
28 28
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
29 29

  
30
import com.vaadin.server.SystemError;
31 30
import com.vaadin.spring.annotation.SpringComponent;
32 31
import com.vaadin.spring.annotation.ViewScope;
33 32
import com.vaadin.ui.AbstractField;
34
import com.vaadin.ui.Button;
35 33
import com.vaadin.ui.Label;
36 34
import com.vaadin.ui.UI;
37 35
import com.vaadin.ui.VerticalLayout;
......
45 43
import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
46 44
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
47 45
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
48
import eu.etaxonomy.cdm.api.utility.RoleProber;
49 46
import eu.etaxonomy.cdm.api.utility.UserHelper;
50 47
import eu.etaxonomy.cdm.cache.CdmTransientEntityAndUuidCacher;
51 48
import eu.etaxonomy.cdm.database.PermissionDeniedException;
52
import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
53
import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService;
54 49
import eu.etaxonomy.cdm.model.ICdmEntityUuidCacher;
55 50
import eu.etaxonomy.cdm.model.common.CdmBase;
56
import eu.etaxonomy.cdm.model.common.User;
57 51
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
58 52
import eu.etaxonomy.cdm.model.name.Rank;
59 53
import eu.etaxonomy.cdm.model.name.Registration;
......
85 79
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
86 80
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
87 81
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
88
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
89
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
90 82
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
91 83
import eu.etaxonomy.cdm.vaadin.ui.config.TaxonNamePopupEditorConfig;
92 84
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
......
121 113
    @Autowired
122 114
    private IRegistrationWorkingSetService regWorkingSetService;
123 115

  
124
    @Autowired
125
    private IRegistrationMessageService messageService;
126

  
127 116
    @Autowired
128 117
    private CdmFilterablePagingProviderFactory pagingProviderFactory;
129 118

  
......
295 284
         getView().setWorkingset(workingset);
296 285
        // PagingProviders and CacheGenerator for the existingNameCombobox
297 286
        activateComboboxes();
298
        // update the messages
299
        // updateMessages(); // disabled see  #7908
300 287
    }
301 288

  
302 289
    protected void activateComboboxes() {
......
306 293
        getView().getAddExistingNameCombobox().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize());
307 294
    }
308 295

  
309
    protected void updateMessages() {
310
        User user = UserHelperAccess.userHelper().user();
311
        for (UUID registrationUuid : getView().getRegistrationItemMap().keySet()) {
312
            Button messageButton = getView().getRegistrationItemMap().get(registrationUuid).regItemButtons.getMessagesButton();
313

  
314
            RegistrationDTO regDto = workingset.getRegistrationDTO(registrationUuid).get();
315
            try {
316
                int messageCount = messageService.countActiveMessagesFor(regDto.registration(), user);
317

  
318
                boolean activeMessages = messageCount > 0;
319
                boolean currentUserIsSubmitter = regDto.getSubmitterUserName() != null && regDto.getSubmitterUserName().equals(UserHelperAccess.userHelper().userName());
320
                boolean currentUserIsCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION));
321
                messageButton.setEnabled(false);
322
                if(currentUserIsCurator){
323
                    if(currentUserIsSubmitter){
324
                        messageButton.setDescription("No point sending messages to your self.");
325
                    } else {
326
                        messageButton.setEnabled(true);
327
                        messageButton.setDescription("Open the messages dialog.");
328
                    }
329
                } else {
330
                    messageButton.setDescription("Sorry, only a curator can start a conversation.");
331
                }
332
                if(activeMessages){
333
                    messageButton.setEnabled(true);
334
                    messageButton.addStyleName(EditValoTheme.BUTTON_HIGHLITE);
335
                    String who = currentUserIsSubmitter ? "curator" : "submitter";
336
                    messageButton.setDescription("The " + who + " is looking forward to your reply.");
337

  
338
                }
339
            } catch (ExternalServiceException e) {
340
                messageButton.setComponentError(new SystemError(e.getMessage(), e));
341
            }
342
        }
343
    }
344

  
345

  
346 296
    /**
347 297
     * @param referenceID
348 298
     */
......
897 847
                blockingRegs = new HashSet<RegistrationDTO>(getWorkingSetService().makeDTOs(regDto.registration().getBlockedBy()));
898 848
            }
899 849
            getView().setBlockingRegistrations(registrationUuid, blockingRegs);
900
        } else if(event.getProperty().equals(RegistrationItem.MESSAGES)){
901

  
902
            RegistrationMessagesPopup popup = openPopupEditor(RegistrationMessagesPopup.class, null);
903
            popup.loadMessagesFor(regDto.getUuid());
904

  
905 850
        } else if(event.getProperty().equals(RegistrationItem.VALIDATION_PROBLEMS)){
906 851
            getView().openDetailsPopup("Validation Problems", regDto.getValidationProblems());
907 852
        }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
424 424
        validationProblemsButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getValidationProblems().size() + "</span>");
425 425
        validationProblemsButton.setCaptionAsHtml(true);
426 426

  
427
        Button messageButton = regItemButtons.getMessagesButton();
428
        messageButton.addClickListener(e -> getViewEventBus().publish(this,
429
                    new ShowDetailsEvent<RegistrationDTO, UUID>(
430
                        e,
431
                        RegistrationDTO.class,
432
                        dto.getUuid(),
433
                        RegistrationItem.MESSAGES
434
                        )
435
                    )
436
                );
437
        messageButton.setStyleName(ValoTheme.BUTTON_TINY);
438

  
439 427
        Component statusComponent;
440 428
        if(statusFieldInstantiator != null){
441 429
            statusComponent = statusFieldInstantiator.create(dto);

Also available in: Unified diff