Project

General

Profile

Revision 538800b4

ID538800b4f2368ffa91c458c26f59d08e2e7705d7
Parent 83ea2d24
Child fca87395

Added by Andreas Kohlbecker over 3 years ago

ref #6169 first implementation of delete operations

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
18 18
import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider;
19 19
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
20 20

  
21
import com.vaadin.ui.ListSelect;
22

  
21
import eu.etaxonomy.cdm.api.service.DeleteResult;
23 22
import eu.etaxonomy.cdm.api.service.pager.Pager;
24 23
import eu.etaxonomy.cdm.model.reference.Reference;
25 24
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
......
139 138
       if(event.getPopup().equals(inReferencePopup)){
140 139
           if(event.getReason().equals(Reason.SAVE)){
141 140
               Reference bean = inReferencePopup.getBean();
142
               // TODO update items from db instead of just adding the new item
143
               ListSelect localInReferenceSelectSelect = getView().getInReferenceSelect().getSelect();
144
               localInReferenceSelectSelect.addItem(bean);
145
               localInReferenceSelectSelect.select(bean);
141
               getView().getInReferenceCombobox().selectNewItem(bean);
142
           }
143
           if(event.getReason().equals(Reason.DELETE)){
144
               getView().getInReferenceCombobox().selectNewItem(null);
146 145
           }
147 146
           inReferencePopup = null;
148 147
       }
149 148

  
150 149
   }
151 150

  
151
    /**
152
     * {@inheritDoc}
153
     */
154
    @Override
155
    protected DeleteResult executeServiceDeleteOperation(Reference bean) {
156
        return getRepo().getReferenceService().delete(bean);
157
    }
158

  
152 159
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java
27 27
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
28 28
import eu.etaxonomy.vaadin.component.SwitchableTextField;
29 29
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
30
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityListSelect;
31 30
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
32 31

  
33 32
/**
......
47 46

  
48 47
    private ListSelect typeSelect;
49 48

  
50
    private ToOneRelatedEntityListSelect<Reference> inReferenceSelect;
51

  
52 49
    private ToOneRelatedEntityCombobox<Reference> inReferenceCombobox;
53 50

  
54 51
    /**
......
119 116
        addTextField("Pages", "pages", 2, row);
120 117
        addTextField("Editor", "editor", 3, row).setWidth(100, Unit.PERCENTAGE);
121 118
        row++;
122
        /*
123
        inReferenceSelect = new ToOneRelatedEntityListSelect<Reference>("In-reference", Reference.class, new BeanItemContainer<>(Reference.class));
124
        inReferenceSelect.setWidth(100, Unit.PERCENTAGE);
125
        inReferenceSelect.getSelect().setRows(1);
126
        inReferenceSelect.addClickListenerAddEntity(e -> getEventBus().publishEvent(
127
                new ReferenceEditorAction(AbstractEditorAction.Action.ADD, null, inReferenceSelect, this)
128
                ));
129
        inReferenceSelect.addClickListenerEditEntity(e -> {
130
            if(inReferenceSelect.getSelect().getValue() != null){
131
                getEventBus().publishEvent(
132
                    new ReferenceEditorAction(AbstractEditorAction.Action.EDIT, ((Reference)inReferenceSelect.getSelect().getValue()).getId(), inReferenceSelect, this)
133
                );
134
            }
135
            });
136
        addField(inReferenceSelect, "inReference", 0, row, 3, row);
137
        */
119

  
138 120
        inReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("In-reference", Reference.class);
139 121
        inReferenceCombobox.setWidth(100, Unit.PERCENTAGE);
140 122
        inReferenceCombobox.addClickListenerAddEntity(e -> getEventBus().publishEvent(
141
                new ReferenceEditorAction(AbstractEditorAction.Action.ADD, null, inReferenceSelect, this)
123
                new ReferenceEditorAction(AbstractEditorAction.Action.ADD, null, inReferenceCombobox, this)
142 124
                ));
143 125
        inReferenceCombobox.addClickListenerEditEntity(e -> {
144 126
            if(inReferenceCombobox.getSelect().getValue() != null){
145 127
                getEventBus().publishEvent(
146
                    new ReferenceEditorAction(AbstractEditorAction.Action.EDIT, ((Reference)inReferenceSelect.getSelect().getValue()).getId(), inReferenceSelect, this)
128
                    new ReferenceEditorAction(
129
                            AbstractEditorAction.Action.EDIT,
130
                            inReferenceCombobox.getValue().getId(),
131
                            inReferenceCombobox,
132
                            this)
147 133
                );
148 134
            }
149 135
            });
......
242 228
        return typeSelect;
243 229
    }
244 230

  
245
    @Override
246
    public ToOneRelatedEntityListSelect<Reference> getInReferenceSelect() {
247
        return inReferenceSelect;
248
    }
249

  
250 231
    /**
251 232
     * {@inheritDoc}
252 233
     */
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditorView.java
12 12

  
13 13
import eu.etaxonomy.cdm.model.reference.Reference;
14 14
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
15
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityListSelect;
16 15
import eu.etaxonomy.vaadin.mvp.ApplicationView;
17 16

  
18 17
/**
......
24 23

  
25 24
    public ListSelect getTypeSelect();
26 25

  
27
    public ToOneRelatedEntityListSelect<Reference> getInReferenceSelect();
28

  
29 26
    public ToOneRelatedEntityCombobox<Reference> getInReferenceCombobox();
30 27

  
31 28

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationEditorPresenter.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view.registration;
10 10

  
11
import eu.etaxonomy.cdm.api.service.DeleteResult;
11 12
import eu.etaxonomy.cdm.model.name.Registration;
12 13
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
13 14

  
......
20 21

  
21 22
    private static final long serialVersionUID = 6930557602995331944L;
22 23

  
24
    /**
25
     * {@inheritDoc}
26
     */
27
    @Override
28
    protected DeleteResult executeServiceDeleteOperation(Registration bean) {
29
        return getRepo().getRegistrationService().delete(bean);
30
    }
31

  
23 32

  
24 33
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/taxon/TaxonNameEditorPresenter.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view.taxon;
10 10

  
11
import eu.etaxonomy.cdm.api.service.DeleteResult;
12
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
11 13
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
12 14
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
13 15

  
......
20 22

  
21 23
    private static final long serialVersionUID = -3538980627079389221L;
22 24

  
25
    /**
26
     * {@inheritDoc}
27
     */
28
    @Override
29
    protected DeleteResult executeServiceDeleteOperation(TaxonNameBase bean) {
30
        NameDeletionConfigurator config = new NameDeletionConfigurator();
31
        return getRepo().getNameService().delete(bean.getUuid(), config);
32
    }
33

  
23 34

  
24 35
}
src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityCombobox.java
25 25
 * @since May 24, 2017
26 26
 *
27 27
 */
28
public class ToOneRelatedEntityCombobox<V extends Object> extends CompositeCustomField<V> implements ToOneRelatedEntityField {
28
public class ToOneRelatedEntityCombobox<V extends Object> extends CompositeCustomField<V> implements ToOneRelatedEntityField<V> {
29 29

  
30 30
    private static final long serialVersionUID = 6277565876657520311L;
31 31

  
......
42 42

  
43 43
    public ToOneRelatedEntityCombobox(String caption, Class<V> type){
44 44
        this.type = type;
45
        setCaption(caption);
45 46
        lazySelect = new LazyComboBox<V>(type);
46 47
        addStyledComponents(lazySelect, addButton, editButton);
47 48
        addSizedComponents(lazySelect, container);
49
        lazySelect.addValueChangeListener(e -> {
50
            // update the itemContainer immediately so that the edit button acts on the chosen item
51
            lazySelect.commit();
52
        });
48 53
    }
49 54

  
50 55

  
......
114 119
        editButton.addClickListener(listener);
115 120
    }
116 121

  
122
    @Override
123
    public void selectNewItem(V bean){
124
        lazySelect.refresh();
125
        lazySelect.setValue(bean);
126
        lazySelect.markAsDirty();
127
    }
128

  
117 129
}
src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityField.java
15 15
 * @since May 25, 2017
16 16
 *
17 17
 */
18
public interface ToOneRelatedEntityField {
18
public interface ToOneRelatedEntityField<V extends Object> {
19 19

  
20 20
    /**
21 21
     * Adds the click listener to the add-entity-button.
......
33 33
     */
34 34
    public void addClickListenerEditEntity(ClickListener listener);
35 35

  
36
    public void selectNewItem(V bean);
37

  
36 38
}
src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityListSelect.java
24 24
 * @since May 24, 2017
25 25
 *
26 26
 */
27
public class ToOneRelatedEntityListSelect<V extends Object> extends CompositeCustomField<V> implements ToOneRelatedEntityField {
27
public class ToOneRelatedEntityListSelect<V extends Object> extends CompositeCustomField<V> implements ToOneRelatedEntityField<V> {
28 28

  
29 29
    private static final long serialVersionUID = 6277565876657520311L;
30 30

  
......
42 42

  
43 43
    public ToOneRelatedEntityListSelect(String caption, Class<V> type, Container dataSource){
44 44
        this.type = type;
45
        setCaption(caption);
45 46
        select = new ListSelect(caption, dataSource);
46 47
        addStyledComponents(select, addButton, editButton);
47 48
        addSizedComponent(select);
......
91 92
        return select;
92 93
    }
93 94

  
94

  
95

  
96 95
    /**
97 96
     * {@inheritDoc}
98 97
     */
......
122 121
        editButton.addClickListener(listener);
123 122
    }
124 123

  
124
    /**
125
     * {@inheritDoc}
126
     */
127
    @Override
128
    public void selectNewItem(V bean) {
129

  
130
      select.addItem(bean);
131
      select.select(bean);
132
    }
133

  
125 134

  
126 135
}
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java
14 14
import org.springframework.context.event.EventListener;
15 15
import org.springframework.transaction.TransactionStatus;
16 16

  
17
import com.vaadin.data.fieldgroup.BeanFieldGroup;
18
import com.vaadin.data.fieldgroup.FieldGroup.CommitEvent;
19
import com.vaadin.data.util.BeanItem;
17
import com.vaadin.ui.Notification;
18
import com.vaadin.ui.UI;
20 19

  
20
import eu.etaxonomy.cdm.api.service.DeleteResult;
21 21
import eu.etaxonomy.cdm.model.common.CdmBase;
22
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
22 23
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
23 24
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent.Type;
24 25
import eu.etaxonomy.vaadin.mvp.event.EditorPreSaveEvent;
......
46 47

  
47 48
    @Override
48 49
    @EventListener
49
    public void onEditorPreSaveEvent(EditorPreSaveEvent preSaveEvent){
50
    public void onEditorPreSaveEvent(EditorPreSaveEvent<DTO> preSaveEvent){
50 51
        if(!isFromOwnView(preSaveEvent)){
51 52
            return;
52 53
        }
54
        startTransaction();
55
        // merge the bean and update the fieldGroup with the merged bean, so that updating
56
        // of field values in turn of the commit are can not cause LazyInitializationExeptions
57
        // the bean still has the original values at this point
58
        logger.trace(this._toString() + ".onEditorPreSaveEvent - merging bean into session");
59
        mergedBean(preSaveEvent.getBean());
60

  
61
    }
62

  
63
    /**
64
     *
65
     */
66
    protected void startTransaction() {
53 67
        if(tx != null){
54 68
            // @formatter:off
55 69
            // holding the TransactionStatus as state is not good design. we should change the save operation
......
64 78

  
65 79
        logger.trace(this._toString() + ".onEditorPreSaveEvent - starting transaction");
66 80
        tx = getRepo().startTransaction(true);
67
        // merge the bean and update the fieldGroup with the merged bean, so that updating
68
        // of field values in turn of the commit are can not cause LazyInitializationExeptions
69
        // the bean still has the original values at this point
70
        logger.trace(this._toString() + ".onEditorPreSaveEvent - merging bean into session");
71
        mergedBean(preSaveEvent.getCommitEvent());
72

  
73 81
    }
74 82

  
75 83
    @Override
......
81 89
        // the bean is now updated with the changes made by the user
82 90
        // merge the bean into the session, ...
83 91
        logger.trace(this._toString() + ".onEditorSaveEvent - merging bean into session");
84
        DTO bean = mergedBean(saveEvent.getCommitEvent());
92
        DTO bean = mergedBean((DTO) saveEvent.getBean());
85 93

  
86 94
        Type changeEventType;
87 95
        if(bean.getId() > 1){
......
106 114
     * @param CommitEvent
107 115
     * @return The bean merged to the session or original bean in case a merge was not necessary.
108 116
     */
109
    private DTO mergedBean(CommitEvent commitEvent) {
117
    private DTO mergedBean(DTO bean) {
110 118
        // using just some service to get hold of the session
111 119
        Session session = getSession();
112
        @SuppressWarnings("unchecked")
113
        BeanItem<DTO> itemDataSource = ((BeanFieldGroup<DTO>)commitEvent.getFieldBinder()).getItemDataSource();
114
        DTO bean = itemDataSource.getBean();
115 120
        if(session.contains(bean)){
116 121

  
117 122
            if(session.isOpen()){
......
123 128
            @SuppressWarnings("unchecked")
124 129
            DTO mergedBean = (DTO) session.merge(bean);
125 130
            logger.trace(this._toString() + ".mergedBean() - bean after merge " + bean.toString());
126
            itemDataSource.setBean(mergedBean);
131
            ((AbstractPopupEditor<DTO, AbstractCdmEditorPresenter<DTO, V>>)getView()).showInEditor(mergedBean);
127 132
            return mergedBean;
128 133
        }
129 134
        return bean;
......
144 149
        // blank implementation, since this is not needed in this or any sub class
145 150
    }
146 151

  
152
    @Override
153
    protected final void deleteBean(DTO bean){
154
        startTransaction();
155
        logger.trace(this._toString() + ".deleteBean - deleting" + bean.toString());
156
        DeleteResult result = executeServiceDeleteOperation(bean);
157
        if(result.isOk()){
158
            getSession().flush();
159
            logger.trace(this._toString() + ".deleteBean - session flushed");
160
            getRepo().commitTransaction(tx);
161
            tx = null;
162
            logger.trace(this._toString() + ".deleteBean - transaction comitted");
163
            eventBus.publishEvent(new EntityChangeEvent(bean.getClass(), bean.getId(), Type.REMOVED));
164
        } else {
165
            String notificationTitle;
166
            StringBuffer messageBody = new StringBuffer();
167
            if(result.isAbort()){
168
                notificationTitle = "The delete operation as abborded by the system.";
169
            } else {
170
                notificationTitle = "An error occured during the delete operation.";
171
            }
172
            if(!result.getExceptions().isEmpty()){
173
                messageBody.append("<h3>").append("Exceptions:").append("</h3>").append("<ul>");
174
                result.getExceptions().forEach(e -> messageBody.append("<li>").append(e.getMessage()).append("</li>"));
175
                messageBody.append("</ul>");
176
            }
177
            if(!result.getRelatedObjects().isEmpty()){
178
                messageBody.append("<h3>").append("Related objects exist:").append("</h3>").append("<ul>");
179
                result.getRelatedObjects().forEach(e -> {
180
                    messageBody.append("<li>");
181
                    if(IdentifiableEntity.class.isAssignableFrom(e.getClass())){
182
                        messageBody.append(((IdentifiableEntity)e).getTitleCache());
183
                    } else {
184
                        messageBody.append(e.toString());
185
                    }
186
                    messageBody.append("</li>");
187
                }
188
                );
189

  
190
                messageBody.append("</ul>");
191
            }
192

  
193
            Notification notification = new Notification(
194
                   notificationTitle,
195
                   messageBody.toString(),
196
                   com.vaadin.ui.Notification.Type.ERROR_MESSAGE,
197
                   true);
198
            notification.show(UI.getCurrent().getPage());
199
        }
200
    }
201

  
202
    /**
203
     * Implementations will execute the {@link
204
     *
205
     * @return
206
     */
207
    protected abstract DeleteResult executeServiceDeleteOperation(DTO bean);
208

  
147 209
    private String _toString(){
148 210
        return this.getClass().getSimpleName() + "@" + this.hashCode();
149 211
    }
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java
12 12
import org.springframework.context.ApplicationEventPublisher;
13 13
import org.springframework.context.event.EventListener;
14 14

  
15
import com.vaadin.data.fieldgroup.BeanFieldGroup;
16

  
17 15
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction;
16
import eu.etaxonomy.vaadin.mvp.event.EditorDeleteEvent;
18 17
import eu.etaxonomy.vaadin.mvp.event.EditorPreSaveEvent;
19 18
import eu.etaxonomy.vaadin.mvp.event.EditorSaveEvent;
20 19
import eu.etaxonomy.vaadin.mvp.event.EditorViewEvent;
......
33 32
    protected ApplicationEventPublisher eventBus;
34 33

  
35 34
    @EventListener
36
    public void onEditorPreSaveEvent(EditorPreSaveEvent preSaveEvent){
35
    public void onEditorPreSaveEvent(EditorPreSaveEvent<DTO> preSaveEvent){
37 36
        if(!isFromOwnView(preSaveEvent)){
38 37
            return;
39 38
        }
......
44 43
     * @param saveEvent
45 44
     */
46 45
    @EventListener
47
    public void onEditorSaveEvent(EditorSaveEvent saveEvent){
46
    public void onEditorSaveEvent(EditorSaveEvent<DTO> saveEvent){
48 47
        if(!isFromOwnView(saveEvent)){
49 48
            return;
50 49
        }
51
        DTO bean = ((BeanFieldGroup<DTO>)saveEvent.getCommitEvent().getFieldBinder()).getItemDataSource().getBean();
50
        DTO bean = saveEvent.getBean();
52 51
        saveBean(bean);
53 52
    }
54 53

  
54
    // EditorDeleteEvent
55
    /**
56
    *
57
    * @param saveEvent
58
    */
59
   @EventListener
60
   public void onEditorDeleteEvent(EditorDeleteEvent<DTO> deleteEvent){
61
       if(!isFromOwnView(deleteEvent)){
62
           return;
63
       }
64
       deleteBean(deleteEvent.getBean());
65
   }
66

  
55 67
    /**
56 68
     * @param saveEvent
57 69
     * @return
......
70 82

  
71 83
    protected abstract void saveBean(DTO bean);
72 84

  
85
    /**
86
     * @param bean
87
     */
88
    protected abstract void deleteBean(DTO bean);
89

  
73 90
}
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
46 46
import eu.etaxonomy.cdm.database.PermissionDeniedException;
47 47
import eu.etaxonomy.vaadin.component.NestedFieldGroup;
48 48
import eu.etaxonomy.vaadin.component.SwitchableTextField;
49
import eu.etaxonomy.vaadin.mvp.event.EditorDeleteEvent;
49 50
import eu.etaxonomy.vaadin.mvp.event.EditorPreSaveEvent;
50 51
import eu.etaxonomy.vaadin.mvp.event.EditorSaveEvent;
51 52
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent;
......
71 72

  
72 73
    private Button cancel;
73 74

  
75
    private Button delete;
76

  
74 77
    private CssLayout toolBar = new CssLayout();
75 78

  
76 79
    private CssLayout toolBarButtonGroup = new CssLayout();
......
114 117
        cancel = new Button("Cancel", FontAwesome.TRASH);
115 118
        cancel.addClickListener(e -> cancel());
116 119

  
117
        buttonLayout.addComponents(save, cancel);
118
        buttonLayout.setExpandRatio(save, 1);
120
        delete = new Button("Delete", FontAwesome.REMOVE);
121
        delete.setStyleName(ValoTheme.BUTTON_DANGER);
122
        delete.addClickListener(e -> delete());
123

  
124
        buttonLayout.addComponents(delete, save, cancel);
125
        buttonLayout.setExpandRatio(delete, 1);
126
        buttonLayout.setComponentAlignment(delete, Alignment.TOP_RIGHT);
119 127
        buttonLayout.setComponentAlignment(save, Alignment.TOP_RIGHT);
120 128
        buttonLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT);
121 129

  
......
216 224
        public void preCommit(CommitEvent commitEvent) throws CommitException {
217 225
            logger.debug("preCommit");
218 226
            // notify the presenter to start a transaction
219
            eventBus.publishEvent(new EditorPreSaveEvent(commitEvent, AbstractPopupEditor.this));
227
            eventBus.publishEvent(new EditorPreSaveEvent<DTO>(AbstractPopupEditor.this, fieldGroup.getItemDataSource().getBean()));
220 228
        }
221 229

  
222 230
        @Override
223 231
        public void postCommit(CommitEvent commitEvent) throws CommitException {
224 232
            try {
225 233
                // notify the presenter to persist the bean and to commit the transaction
226
                eventBus.publishEvent(new EditorSaveEvent(commitEvent, AbstractPopupEditor.this));
234
                eventBus.publishEvent(new EditorSaveEvent<DTO>(AbstractPopupEditor.this, fieldGroup.getItemDataSource().getBean()));
227 235

  
228 236
                // notify the NavigationManagerBean to close the window and to dispose the view
229 237
                eventBus.publishEvent(new DoneWithPopupEvent(AbstractPopupEditor.this, Reason.SAVE));
......
248 256
    }
249 257

  
250 258
    /**
259
     * @return
260
     */
261
    private void delete() {
262
        eventBus.publishEvent(new EditorDeleteEvent(this, fieldGroup.getItemDataSource().getBean()));
263
        eventBus.publishEvent(new DoneWithPopupEvent(this, Reason.DELETE));
264
    }
265

  
266
    /**
251 267
     * Save the changes made in the editor.
252 268
     */
253 269
    private void save() {
src/main/java/eu/etaxonomy/vaadin/mvp/event/EditorBeanEvent.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.vaadin.mvp.event;
10

  
11
/**
12
 * @author a.kohlbecker
13
 * @since Jun 1, 2017
14
 *
15
 */
16
public interface EditorBeanEvent<DTO extends Object> {
17

  
18
    public DTO getBean();
19

  
20
}
src/main/java/eu/etaxonomy/vaadin/mvp/event/EditorDeleteEvent.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.vaadin.mvp.event;
10

  
11
import eu.etaxonomy.vaadin.mvp.AbstractView;
12

  
13
/**
14
 * @author a.kohlbecker
15
 * @since Jun 1, 2017
16
 *
17
 */
18
public class EditorDeleteEvent<DTO extends Object> implements EditorViewEvent, EditorBeanEvent<DTO> {
19

  
20
    // FIXME this is only a iterim solution for the problem described in https://dev.e-taxonomy.eu/redmine/issues/6562
21
    private AbstractView<?> view;
22

  
23
    private DTO bean;
24

  
25
    public EditorDeleteEvent(AbstractView<?> view, DTO bean){
26
        this.view = view;
27
        this.bean = bean;
28
    }
29

  
30
    /**
31
     * {@inheritDoc}
32
     */
33
    @Override
34
    public AbstractView<?> getView() {
35
        return view;
36
    }
37

  
38
    /**
39
     * {@inheritDoc}
40
     */
41
    @Override
42
    public DTO getBean() {
43
        return bean;
44
    }
45

  
46
}
src/main/java/eu/etaxonomy/vaadin/mvp/event/EditorPreSaveEvent.java
8 8
*/
9 9
package eu.etaxonomy.vaadin.mvp.event;
10 10

  
11
import com.vaadin.data.fieldgroup.FieldGroup.CommitEvent;
12

  
13 11
import eu.etaxonomy.vaadin.mvp.AbstractView;
14 12

  
15 13
/**
......
20 18
 * @since Apr 5, 2017
21 19
 *
22 20
 */
23
public class EditorPreSaveEvent implements EditorViewEvent{
24

  
25
    private CommitEvent commitEvent;
21
public class EditorPreSaveEvent<DTO extends Object> implements EditorViewEvent, EditorBeanEvent<DTO>{
26 22

  
27 23
    // FIXME this is only a iterim solution for the problem described in https://dev.e-taxonomy.eu/redmine/issues/6562
28
    private AbstractView view;
24
    private AbstractView<?> view;
25

  
26
    private DTO bean;
29 27

  
30 28
    /**
31 29
     * @param commitEvent
32 30
     */
33
    public EditorPreSaveEvent(CommitEvent commitEvent, AbstractView view) {
34
        this.commitEvent = commitEvent;
31
    public EditorPreSaveEvent(AbstractView<?> view, DTO bean) {
32
        this.bean = bean;
35 33
        this.view = view;
36 34
    }
37 35

  
38
    public CommitEvent getCommitEvent(){
39
        return commitEvent;
40
    }
41 36

  
42 37
    /**
43 38
     * @return the view
44 39
     */
45 40
    @Override
46
    public AbstractView getView() {
41
    public AbstractView<?> getView() {
47 42
        return view;
48 43
    }
49 44

  
45

  
46
    /**
47
     * {@inheritDoc}
48
     */
49
    @Override
50
    public DTO getBean() {
51
        return bean;
52
    }
53

  
50 54
}
src/main/java/eu/etaxonomy/vaadin/mvp/event/EditorSaveEvent.java
8 8
*/
9 9
package eu.etaxonomy.vaadin.mvp.event;
10 10

  
11
import com.vaadin.data.fieldgroup.FieldGroup.CommitEvent;
12

  
13 11
import eu.etaxonomy.vaadin.mvp.AbstractView;
14 12

  
15 13
/**
......
20 18
 * @since Apr 5, 2017
21 19
 *
22 20
 */
23
public class EditorSaveEvent implements EditorViewEvent {
24

  
25
    private CommitEvent commitEvent;
21
public class EditorSaveEvent<DTO extends Object> implements EditorViewEvent, EditorBeanEvent<DTO> {
26 22

  
27 23
    // FIXME this is only a iterim solution for the problem described in https://dev.e-taxonomy.eu/redmine/issues/6562
28
    private AbstractView view;
24
    private AbstractView<?> view;
25

  
29 26

  
27
    private DTO bean;
30 28

  
31 29
    /**
32
     * @param commitEvent
33 30
     */
34
    public EditorSaveEvent(CommitEvent commitEvent, AbstractView view) {
35
        this.commitEvent = commitEvent;
31
    public EditorSaveEvent(AbstractView<?> view, DTO bean) {
32
        this.bean = bean;
36 33
        this.view = view;
37 34
    }
38 35

  
39
    public CommitEvent getCommitEvent(){
40
        return commitEvent;
41
    }
42

  
43 36
    /**
44 37
     * @return the view
45 38
     */
46 39
    @Override
47
    public AbstractView getView() {
40
    public AbstractView<?> getView() {
48 41
        return view;
49 42
    }
50 43

  
44
    /**
45
     * {@inheritDoc}
46
     */
47
    @Override
48
    public DTO getBean() {
49
        return bean;
50
    }
51 51
}
src/main/java/eu/etaxonomy/vaadin/mvp/event/EditorViewEvent.java
17 17
 */
18 18
public interface EditorViewEvent {
19 19

  
20
    public AbstractView getView();
20
    public AbstractView<?> getView();
21 21

  
22 22
}
src/main/java/eu/etaxonomy/vaadin/ui/view/DoneWithPopupEvent.java
3 3
public class DoneWithPopupEvent {
4 4

  
5 5
	public enum Reason {
6
		CANCEL, SAVE;
6
		CANCEL, SAVE, DELETE;
7 7
	}
8 8

  
9 9
	private final Reason reason;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)