Project

General

Profile

« Previous | Next » 

Revision f3783332

Added by Andreas Kohlbecker over 6 years ago

fix #7132 readonly mode for SpecimenTypeDesignationWorkingsetPopupEditor and TaxonNamePopupEditor

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemEditButtonGroup.java
76 76
            Label nameLabel = new Label(regDto.getNameRef().getLabel());
77 77
            nameLabel.setWidthUndefined();
78 78
            boolean userHasPermission = UserHelper.fromSession().userHasPermission(regDto.registration().getName(), CRUD.UPDATE);
79
            nameButton.setEnabled(!isRegistrationLocked && userHasPermission);
79
            nameButton.setReadOnly(isRegistrationLocked || ! userHasPermission);
80 80

  
81 81
            addComponent(nameIdButton.getButton());
82 82
            PermissionDebugUtils.addGainPerEntityPermissionButton(this, TaxonName.class, regDto.getNameRef().getId(),
......
95 95
                String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType";
96 96
                Button tdButton = new Button(buttonLabel + ":");
97 97
                tdButton.setDescription("Edit the type designation working set");
98
                tdButton.setEnabled(!isRegistrationLocked && UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getId(), CRUD.UPDATE));
98
                boolean userHasPermission = UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getId(), CRUD.UPDATE);
99
                tdButton.setReadOnly(isRegistrationLocked || !userHasPermission);
99 100
                addComponent(tdButton);
100 101

  
101 102
                PermissionDebugUtils.addGainPerEntityPermissionButton(this, SpecimenOrObservationBase.class,
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetPopupEditor.java
278 278
        }
279 279
    }
280 280

  
281
    /**
282
     * {@inheritDoc}
283
     */
284
    @Override
285
    public void setReadOnly(boolean readOnly) {
286
        super.setReadOnly(readOnly);
287
        getFieldLayout().iterator().forEachRemaining(c -> c.setReadOnly(readOnly));
288
        typeDesignationsCollectionField.getLayout().iterator().forEachRemaining(c -> c.setReadOnly(readOnly));
289

  
290
    }
281 291

  
282 292

  
283 293

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
209 209
        popup.loadInEditor(event.getEntityId());
210 210
    }
211 211

  
212
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT && #event.sourceComponent == null")
212
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT")
213 213
    public void onTaxonNameEditorActionEdit(TaxonNameEditorAction event) {
214 214

  
215
        if(!checkFromOwnView(event)){
216
            return;
217
        }
218

  
215 219
        TaxonNamePopupEditor popup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class);
216 220
        popup.withDeleteButton(true);
217 221
        // disable NomReferenceCombobox:
218 222
        // the in the registration application inReferences should only edited centrally
219 223
        popup.getNomReferenceCombobox().setEnabled(false);
220 224
        popup.loadInEditor(event.getEntityId());
225
        if(event.getSourceComponent() != null){
226
            popup.setReadOnly(event.getSourceComponent().isReadOnly());
227
        }
221 228
    }
222 229

  
230

  
223 231
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
224 232
    public void onTaxonNameEditorActionAdd(TaxonNameEditorAction event) {
225 233

  
......
299 307

  
300 308
    }
301 309

  
302
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT && #event.sourceComponent == null")
310
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT")
303 311
    public void onTypeDesignationsEditorActionEdit(TypeDesignationWorkingsetEditorAction event) {
304 312

  
305
            if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET ){
306
                SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class);
307
                popup.withDeleteButton(true);
308
                popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getEntityId()));
309
            } else {
310
                // TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET
311
                // FIXME implement NameTypeDesignationWorkingsetPopupEditor
313
        if(!checkFromOwnView(event)){
314
            return;
315
        }
316

  
317
        if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET ){
318
            SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class);
319
            popup.withDeleteButton(true);
320
            popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getEntityId()));
321
            if(event.getSourceComponent() != null){
322
                popup.setReadOnly(event.getSourceComponent().isReadOnly());
312 323
            }
324
        } else {
325
            // TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET
326
            // FIXME implement NameTypeDesignationWorkingsetPopupEditor
327
        }
313 328
    }
314 329

  
315 330
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD && #event.sourceComponent == null")
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
272 272
                getEventBus().publishEvent(new TaxonNameEditorAction(
273 273
                    AbstractEditorAction.Action.EDIT,
274 274
                    nameId,
275
                    null, //e.getButton(), the listener method expects this to be null
275
                    e.getButton(),
276 276
                    this
277 277
                    )
278 278
                );
......
289 289
                        typeDesignationWorkingsetId,
290 290
                        workingsetType,
291 291
                        registrationEntityID,
292
                        null, //e.getButton(), the listener method expects this to be null
292
                        e.getButton(),
293 293
                        this
294 294
                        )
295 295
                    );
src/main/java/eu/etaxonomy/vaadin/component/CompositeCustomField.java
17 17
import com.vaadin.data.fieldgroup.FieldGroup.CommitEvent;
18 18
import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
19 19
import com.vaadin.data.fieldgroup.FieldGroup.CommitHandler;
20
import com.vaadin.ui.Button;
20 21
import com.vaadin.ui.Component;
21 22
import com.vaadin.ui.CustomField;
22 23
import com.vaadin.ui.Field;
24
import com.vaadin.ui.Layout;
23 25

  
24 26
/**
25 27
 * TODO implement height methods for full component size support
......
203 205
       );
204 206
    }
205 207

  
208
    /**
209
     * {@inheritDoc}
210
     */
211
    @Override
212
    public void setReadOnly(boolean readOnly) {
213
        super.setReadOnly(readOnly);
214
        setDeepReadOnly(readOnly, getContent());
215
    }
216

  
217
    /**
218
     * @param readOnly
219
     */
220
    protected void setDeepReadOnly(boolean readOnly, Component component) {
221

  
222
        component.setReadOnly(readOnly);
223
        if(Button.class.isAssignableFrom(component.getClass())){
224
            component.setEnabled(false);
225
        }
226
        if(Layout.class.isAssignableFrom(component.getClass())){
227
            for(Component nestedComponent : ((Layout)component)){
228
                setDeepReadOnly(readOnly, nestedComponent);
229
            }
230
        }
231
    }
232

  
233

  
206 234
}
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmPopupEditor.java
98 98
        getPresenter().setGrantsForCurrentUser(crud);
99 99
    }
100 100

  
101
    /**
102
     * {@inheritDoc}
103
     */
104
    @Override
105
    public void setReadOnly(boolean readOnly) {
106
        super.setReadOnly(readOnly);
107
        getFieldLayout().iterator().forEachRemaining(c -> c.setReadOnly(readOnly));
108
    }
109

  
110

  
111

  
112

  
113

  
101 114
}
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
166 166
    public void setReadOnly(boolean readOnly) {
167 167
        super.setReadOnly(readOnly);
168 168
        save.setVisible(!readOnly);
169
        delete.setVisible(!readOnly);
169 170
        cancel.setCaption(readOnly ? "Close" : "Cancel");
170 171
    }
171 172

  
......
591 592
    public P presenter() {
592 593
        return getPresenter();
593 594
    }
595

  
594 596
}
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPresenter.java
12 12
import org.springframework.security.core.context.SecurityContextHolder;
13 13

  
14 14
import eu.etaxonomy.cdm.api.application.CdmRepository;
15
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction;
15 16
import eu.etaxonomy.vaadin.ui.navigation.NavigationManager;
16 17

  
17 18
/**
......
176 177
        this.navigationManager = navigationManager;
177 178
    }
178 179

  
180
    protected boolean checkFromOwnView(AbstractEditorAction event) {
181
        return getView() == event.getSourceView();
182
    }
183

  
179 184
}

Also available in: Unified diff