Project

General

Profile

« Previous | Next » 

Revision de625740

Added by Andreas Kohlbecker almost 7 years ago

ref #6169 RegistrationItem separate name button + action for type buttons

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
26 26
import com.vaadin.ui.Component;
27 27
import com.vaadin.ui.CssLayout;
28 28
import com.vaadin.ui.GridLayout;
29
import com.vaadin.ui.Label;
29 30
import com.vaadin.ui.Notification;
30 31
import com.vaadin.ui.Panel;
31 32
import com.vaadin.ui.TabSheet;
......
43 44
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction;
44 45
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
45 46
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
47
import eu.etaxonomy.cdm.vaadin.event.TypedesignationsEditorAction;
46 48
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
47 49
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
48 50
import eu.etaxonomy.cdm.vaadin.model.registration.WorkflowStep;
......
74 76

  
75 77
    public static final String ACTION_EDIT = "edit";
76 78

  
79
    private static final boolean REG_ITEM_AS_BUTTON_GROUP = true;
80

  
77 81
    public RegistrationType regType = null;
78 82

  
79 83
    private CssLayout workflow;
......
234 238
        messageButton.setCaptionAsHtml(true);
235 239
        buttonGroup.addComponent(messageButton);
236 240

  
241
        TypeStateLabel typeStateLabel = new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus());
242

  
243

  
237 244
        if(UserHelper.fromSession().userIsRegistrationCurator() || UserHelper.fromSession().userIsAdmin()) {
238
        Button editButton = new Button(FontAwesome.EDIT);
239
        editButton.setStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_PRIMARY);
240
        editButton.addClickListener(e -> getEventBus().publishEvent(new RegistrationEditorAction(
241
            AbstractEditorAction.Action.EDIT,
242
            dto.getId(),
243
            null,
244
            this
245
            )));
246
        buttonGroup.addComponent(editButton);
245
            Button editRegistrationButton = new Button(FontAwesome.COG);
246
            editRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
247
            editRegistrationButton.setDescription("Edit registration");
248
            editRegistrationButton.addClickListener(e -> getEventBus().publishEvent(new RegistrationEditorAction(
249
                AbstractEditorAction.Action.EDIT,
250
                dto.getId(),
251
                null,
252
                this
253
                )));
254
            buttonGroup.addComponent(editRegistrationButton);
247 255
        }
248 256

  
249
        TypeStateLabel typeStateLabel = new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus());
250
        namesTypesList.addComponent(typeStateLabel, 0, row);
251
        namesTypesList.setComponentAlignment(typeStateLabel, Alignment.MIDDLE_LEFT);
252

  
253
        RegistrationItemEditButtonGroup editButtonGroup = new RegistrationItemEditButtonGroup(dto);
254
        if(editButtonGroup.getNameButton() != null){
257
        Button editNameButton = new Button(FontAwesome.TAG);
258
        editNameButton.setStyleName(ValoTheme.BUTTON_TINY);
259
        editNameButton.setDescription("Edit name");
260
        if(dto.getName() != null){
261
            editNameButton.addClickListener(e -> {
262
                    Integer nameId = dto.getName().getId();
263
                    getEventBus().publishEvent(new TaxonNameEditorAction(
264
                        AbstractEditorAction.Action.EDIT,
265
                        nameId
266
                        )
267
                    );
268
                });
269
        } else {
270
            editNameButton.setEnabled(false);
271
        }
255 272

  
256
            editButtonGroup.getNameButton().getButton().addClickListener(e -> {
257
                Integer nameId = editButtonGroup.getNameButton().getId();
258
                getEventBus().publishEvent(new TaxonNameEditorAction(
259
                    AbstractEditorAction.Action.EDIT,
260
                    nameId
261
                    )
262
                );
263
            });
273
        Button editTypesButton = new Button(FontAwesome.LEAF);
274
        editTypesButton.setStyleName(ValoTheme.BUTTON_TINY);
275
        editTypesButton.setDescription("Edit type designations");
276
        if(!dto.getTypeDesignations().isEmpty()){
277
            editTypesButton.addClickListener(e -> {
278
                int regId = dto.getId();
279
                    getEventBus().publishEvent(new TypedesignationsEditorAction(
280
                        AbstractEditorAction.Action.EDIT,
281
                        regId
282
                        )
283
                    );
284
                });
285
        } else {
286
            editTypesButton.setEnabled(false);
264 287
        }
265
        namesTypesList.addComponent(editButtonGroup, 1, row);
288
        buttonGroup.addComponents(editNameButton, editTypesButton);
289

  
290
        Component regItem;
291
        if(REG_ITEM_AS_BUTTON_GROUP){
292
            RegistrationItemEditButtonGroup editButtonGroup = new RegistrationItemEditButtonGroup(dto);
293
            if(editButtonGroup.getNameButton() != null){
294

  
295
                editButtonGroup.getNameButton().getButton().addClickListener(e -> {
296
                    Integer nameId = editButtonGroup.getNameButton().getId();
297
                    getEventBus().publishEvent(new TaxonNameEditorAction(
298
                        AbstractEditorAction.Action.EDIT,
299
                        nameId
300
                        )
301
                    );
302
                });
303
            }
304
            regItem = editButtonGroup;
305
        } else {
306
            regItem = new Label(dto.getSummary());
307
        }
308

  
309
        namesTypesList.addComponent(typeStateLabel, 0, row);
310
        namesTypesList.setComponentAlignment(typeStateLabel, Alignment.TOP_LEFT);
311
        namesTypesList.addComponent(regItem, 1, row);
266 312
        namesTypesList.addComponent(buttonGroup, 2, row);
267
        namesTypesList.setComponentAlignment(buttonGroup, Alignment.MIDDLE_LEFT);
313
        namesTypesList.setComponentAlignment(buttonGroup, Alignment.TOP_LEFT);
268 314
    }
269 315

  
270 316

  

Also available in: Unified diff