Revision fa315d14
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java | ||
---|---|---|
53 | 53 |
public class RegistrationWorkingSetService implements IRegistrationWorkingSetService { |
54 | 54 |
|
55 | 55 |
public static final List<String> REGISTRATION_INIT_STRATEGY = Arrays.asList(new String []{ |
56 |
"blockedBy", |
|
56 |
"blockedBy.typeDesignations",
|
|
57 | 57 |
// typeDesignation |
58 | 58 |
"typeDesignations.typeStatus", |
59 | 59 |
"typeDesignations.typifiedNames.typeDesignations", // important !! |
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java | ||
---|---|---|
28 | 28 |
import com.vaadin.ui.CssLayout; |
29 | 29 |
import com.vaadin.ui.GridLayout; |
30 | 30 |
import com.vaadin.ui.Label; |
31 |
import com.vaadin.ui.Layout; |
|
32 | 31 |
import com.vaadin.ui.Link; |
33 | 32 |
import com.vaadin.ui.Panel; |
34 | 33 |
import com.vaadin.ui.themes.ValoTheme; |
... | ... | |
111 | 110 |
public RegistrationItem(RegistrationWorkingSet workingSet, AbstractView<?> parentView) { |
112 | 111 |
super(GRID_COLS, GRID_ROWS); |
113 | 112 |
init(); |
113 |
blockedByButton.setVisible(false); |
|
114 | 114 |
setWorkingSet(workingSet, parentView); |
115 | 115 |
} |
116 | 116 |
|
... | ... | |
228 | 228 |
private void createBlockingRelationsContent(){ |
229 | 229 |
|
230 | 230 |
if(blockingRelationsPanel == null && !regDto.getBlockedBy().isEmpty()){ |
231 |
blockingRelationsPanel = new Panel("blocked by"); |
|
232 |
Layout blockingRelations = new CssLayout(); |
|
233 |
blockingRelations.setWidth(100, Unit.PERCENTAGE); |
|
234 |
blockingRelationsPanel.setContent(blockingRelations); |
|
235 |
for(RegistrationDTO blockRegDto : regDto.getBlockedBy()){ |
|
236 |
RegistrationItem blockRegItem = new RegistrationItem(blockRegDto, parentView); |
|
237 |
blockingRelations.addComponent(blockRegItem); |
|
238 |
} |
|
239 |
blockingRelationsPanel.setWidth(100, Unit.PERCENTAGE); |
|
231 |
blockingRelationsPanel = new RegistrationItemsPanel(parentView, "blocked by", regDto.getBlockedBy()); |
|
240 | 232 |
addComponent(blockingRelationsPanel, 0, 4, GRID_COLS - 1, 4); |
241 | 233 |
} |
242 | 234 |
|
... | ... | |
277 | 269 |
getMessageButton().setCaptionAsHtml(true); |
278 | 270 |
} |
279 | 271 |
|
280 |
if(regDto != null && !regDto.getBlockedBy().isEmpty()){
|
|
272 |
if(regDto != null && !regDto.isBlocked()){
|
|
281 | 273 |
getBlockedByButton().setEnabled(true); |
282 | 274 |
getBlockedByButton().addStyleName("blocked"); |
283 | 275 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemsPanel.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.component.registration; |
|
10 |
|
|
11 |
import java.util.Collection; |
|
12 |
|
|
13 |
import com.vaadin.ui.CssLayout; |
|
14 |
import com.vaadin.ui.Layout; |
|
15 |
import com.vaadin.ui.Panel; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
|
18 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author a.kohlbecker |
|
22 |
* @since Feb 6, 2018 |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class RegistrationItemsPanel extends Panel { |
|
26 |
|
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
private static final long serialVersionUID = -3763419770580196601L; |
|
32 |
|
|
33 |
public RegistrationItemsPanel(AbstractView<?> parentView, String caption, Collection<RegistrationDTO> regDtos){ |
|
34 |
|
|
35 |
super(caption); |
|
36 |
|
|
37 |
Layout container = new CssLayout(); |
|
38 |
container.setWidth(100, Unit.PERCENTAGE); |
|
39 |
setContent(container); |
|
40 |
for(RegistrationDTO dto : regDtos){ |
|
41 |
RegistrationItem item = new RegistrationItem(dto, parentView); |
|
42 |
container.addComponent(item); |
|
43 |
} |
|
44 |
setWidth(100, Unit.PERCENTAGE); |
|
45 |
} |
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationDTO.java | ||
---|---|---|
359 | 359 |
} |
360 | 360 |
} |
361 | 361 |
|
362 |
public boolean isBlocked() { |
|
363 |
return reg.getBlockedBy() != null && !reg.getBlockedBy().isEmpty(); |
|
364 |
} |
|
365 |
|
|
362 | 366 |
/** |
363 | 367 |
* @return the blockedBy |
364 | 368 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java | ||
---|---|---|
25 | 25 |
import com.vaadin.spring.annotation.SpringView; |
26 | 26 |
import com.vaadin.ui.Alignment; |
27 | 27 |
import com.vaadin.ui.Button; |
28 |
import com.vaadin.ui.Component; |
|
28 |
import com.vaadin.ui.Button.ClickEvent; |
|
29 |
import com.vaadin.ui.Button.ClickListener; |
|
29 | 30 |
import com.vaadin.ui.CssLayout; |
30 | 31 |
import com.vaadin.ui.GridLayout; |
31 | 32 |
import com.vaadin.ui.HorizontalLayout; |
... | ... | |
44 | 45 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem; |
45 | 46 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup; |
46 | 47 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup.TypeDesignationWorkingSetButton; |
48 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemsPanel; |
|
47 | 49 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStateLabel; |
48 | 50 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles; |
49 | 51 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.EditorActionContext; |
... | ... | |
222 | 224 |
|
223 | 225 |
grid.setRows(grid.getRows() + 1); |
224 | 226 |
|
227 |
RegistrationItemEditButtonGroup regItemButtonGroup = new RegistrationItemEditButtonGroup(dto); |
|
228 |
Integer registrationEntityID = dto.getId(); |
|
229 |
Stack<EditorActionContext> context = new Stack<EditorActionContext>(); |
|
230 |
context.push(new EditorActionContext( |
|
231 |
new TypedEntityReference<>(Registration.class, registrationEntityID), |
|
232 |
this) |
|
233 |
); |
|
234 |
|
|
235 |
if(regItemButtonGroup.getNameButton() != null){ |
|
236 |
regItemButtonGroup.getNameButton().getButton().addClickListener(e -> { |
|
237 |
Integer nameId = regItemButtonGroup.getNameButton().getId(); |
|
238 |
getViewEventBus().publish(this, new TaxonNameEditorAction( |
|
239 |
EditorActionType.EDIT, |
|
240 |
nameId, |
|
241 |
e.getButton(), |
|
242 |
this, |
|
243 |
context |
|
244 |
) |
|
245 |
); |
|
246 |
}); |
|
247 |
} |
|
248 |
|
|
249 |
for(TypeDesignationWorkingSetButton workingsetButton : regItemButtonGroup.getTypeDesignationButtons()){ |
|
250 |
workingsetButton.getButton().addClickListener(e -> { |
|
251 |
TypedEntityReference baseEntityRef = workingsetButton.getBaseEntity(); |
|
252 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
|
253 |
getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction( |
|
254 |
EditorActionType.EDIT, |
|
255 |
baseEntityRef, |
|
256 |
workingsetType, |
|
257 |
registrationEntityID, |
|
258 |
e.getButton(), |
|
259 |
this, |
|
260 |
context |
|
261 |
) |
|
262 |
); |
|
263 |
}); |
|
264 |
} |
|
265 |
|
|
266 |
regItemButtonGroup.getAddTypeDesignationButton().addClickListener( |
|
267 |
e -> chooseNewTypeRegistrationWorkingset(dto.getId()) |
|
268 |
); |
|
269 |
|
|
270 |
|
|
225 | 271 |
CssLayout buttonGroup = new CssLayout(); |
226 | 272 |
buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); |
227 | 273 |
|
274 |
Button blockingRegistrationButton = new Button(FontAwesome.WARNING); |
|
275 |
blockingRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY); |
|
276 |
if(!dto.isBlocked()){ |
|
277 |
blockingRegistrationButton.setEnabled(false); |
|
278 |
} else { |
|
279 |
blockingRegistrationButton.addClickListener(new ClickListener() { |
|
280 |
|
|
281 |
private static final long serialVersionUID = 2846082434479085292L; |
|
282 |
RegistrationItemsPanel blockedByPanel = null; |
|
283 |
@Override |
|
284 |
public void buttonClick(ClickEvent event) { |
|
285 |
if(blockedByPanel == null){ |
|
286 |
blockedByPanel = new RegistrationItemsPanel(RegistrationWorksetViewBean.this, "Blocked by", dto.getBlockedBy()); |
|
287 |
regItemButtonGroup.addComponent(blockedByPanel); |
|
288 |
} |
|
289 |
} |
|
290 |
}); |
|
291 |
} |
|
292 |
buttonGroup.addComponent(blockingRegistrationButton); |
|
293 |
|
|
228 | 294 |
Button messageButton = new Button(FontAwesome.COMMENT); |
229 | 295 |
messageButton.setStyleName(ValoTheme.BUTTON_TINY); // + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND); |
230 | 296 |
if(dto.getMessages().isEmpty()){ |
... | ... | |
263 | 329 |
PermissionDebugUtils.addGainPerEntityPermissionButton(buttonGroup, Registration.class, dto.getId(), |
264 | 330 |
EnumSet.of(CRUD.UPDATE), RegistrationStatus.PREPARATION.name()); |
265 | 331 |
|
266 |
Component regItem; |
|
267 |
|
|
268 |
RegistrationItemEditButtonGroup editButtonGroup = new RegistrationItemEditButtonGroup(dto); |
|
269 |
Integer registrationEntityID = dto.getId(); |
|
270 |
Stack<EditorActionContext> context = new Stack<EditorActionContext>(); |
|
271 |
context.push(new EditorActionContext( |
|
272 |
new TypedEntityReference<>(Registration.class, registrationEntityID), |
|
273 |
this) |
|
274 |
); |
|
275 |
|
|
276 |
if(editButtonGroup.getNameButton() != null){ |
|
277 |
editButtonGroup.getNameButton().getButton().addClickListener(e -> { |
|
278 |
Integer nameId = editButtonGroup.getNameButton().getId(); |
|
279 |
getViewEventBus().publish(this, new TaxonNameEditorAction( |
|
280 |
EditorActionType.EDIT, |
|
281 |
nameId, |
|
282 |
e.getButton(), |
|
283 |
this, |
|
284 |
context |
|
285 |
) |
|
286 |
); |
|
287 |
}); |
|
288 |
} |
|
289 |
|
|
290 |
for(TypeDesignationWorkingSetButton workingsetButton : editButtonGroup.getTypeDesignationButtons()){ |
|
291 |
workingsetButton.getButton().addClickListener(e -> { |
|
292 |
TypedEntityReference baseEntityRef = workingsetButton.getBaseEntity(); |
|
293 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
|
294 |
getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction( |
|
295 |
EditorActionType.EDIT, |
|
296 |
baseEntityRef, |
|
297 |
workingsetType, |
|
298 |
registrationEntityID, |
|
299 |
e.getButton(), |
|
300 |
this, |
|
301 |
context |
|
302 |
) |
|
303 |
); |
|
304 |
}); |
|
305 |
} |
|
306 |
|
|
307 |
editButtonGroup.getAddTypeDesignationButton().addClickListener( |
|
308 |
e -> chooseNewTypeRegistrationWorkingset(dto.getId()) |
|
309 |
); |
|
310 |
regItem = editButtonGroup; |
|
311 |
|
|
312 |
|
|
313 | 332 |
grid.addComponent(stateLabel, 0, row); |
314 | 333 |
grid.setComponentAlignment(stateLabel, Alignment.TOP_LEFT); |
315 |
grid.addComponent(regItem, 1, row); |
|
334 |
grid.addComponent(regItemButtonGroup, 1, row);
|
|
316 | 335 |
grid.addComponent(buttonGroup, 2, row); |
317 | 336 |
grid.setComponentAlignment(buttonGroup, Alignment.TOP_LEFT); |
318 | 337 |
} |
Also available in: Unified diff
ref #7195 showing blocking registrations in RegistrationWorkingsetEditor