Revision af10794f
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java | ||
---|---|---|
16 | 16 |
import java.util.Set; |
17 | 17 |
import java.util.Stack; |
18 | 18 |
|
19 |
import org.apache.log4j.Level; |
|
19 | 20 |
import org.apache.log4j.Logger; |
20 | 21 |
import org.vaadin.spring.events.EventScope; |
21 | 22 |
|
... | ... | |
43 | 44 |
import com.vaadin.ui.GridLayout; |
44 | 45 |
import com.vaadin.ui.GridLayout.OutOfBoundsException; |
45 | 46 |
import com.vaadin.ui.GridLayout.OverlapsException; |
47 |
import com.vaadin.ui.HasComponents; |
|
46 | 48 |
import com.vaadin.ui.HorizontalLayout; |
47 | 49 |
import com.vaadin.ui.Label; |
48 | 50 |
import com.vaadin.ui.Layout; |
... | ... | |
65 | 67 |
import eu.etaxonomy.vaadin.mvp.event.EditorSaveEvent; |
66 | 68 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
67 | 69 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason; |
70 |
import eu.etaxonomy.vaadin.util.PropertyIdPath; |
|
68 | 71 |
|
69 | 72 |
/** |
70 | 73 |
* |
... | ... | |
521 | 524 |
return fieldGroup.getField(propertyId); |
522 | 525 |
} |
523 | 526 |
|
527 |
public PropertyIdPath boundPropertyIdPath(Field<?> field){ |
|
528 |
|
|
529 |
PropertyIdPath propertyIdPath = null; |
|
530 |
Object propertyId = fieldGroup.getPropertyId(field); |
|
531 |
|
|
532 |
if(propertyId == null){ |
|
533 |
// not found in the editor field group. Maybe the field is bound to a nested fieldgroup? |
|
534 |
// 1. find the NestedFieldGroup implementations from the field up to the editor |
|
535 |
logger.setLevel(Level.DEBUG); |
|
536 |
PropertyIdPath nestedPropertyIds = new PropertyIdPath(); |
|
537 |
Field parentField = field; |
|
538 |
HasComponents parentComponent = parentField.getParent(); |
|
539 |
logger.debug("field: " + parentField.getClass().getSimpleName()); |
|
540 |
while(parentComponent != null){ |
|
541 |
logger.debug("parentComponent: " + parentComponent.getClass().getSimpleName()); |
|
542 |
if(NestedFieldGroup.class.isAssignableFrom(parentComponent.getClass()) && AbstractField.class.isAssignableFrom(parentComponent.getClass())){ |
|
543 |
Object propId = ((NestedFieldGroup)parentComponent).getFieldGroup().getPropertyId(parentField); |
|
544 |
if(propId != null){ |
|
545 |
logger.debug("propId: " + propId.toString()); |
|
546 |
nestedPropertyIds.addParent(propId); |
|
547 |
} |
|
548 |
logger.debug("parentField: " + parentField.getClass().getSimpleName()); |
|
549 |
parentField = (Field)parentComponent; |
|
550 |
} else if(parentComponent == this) { |
|
551 |
// we reached the editor itself |
|
552 |
Object propId = fieldGroup.getPropertyId(parentField); |
|
553 |
if(propId != null){ |
|
554 |
logger.debug("propId: " + propId.toString()); |
|
555 |
nestedPropertyIds.addParent(propId); |
|
556 |
} |
|
557 |
propertyIdPath = nestedPropertyIds; |
|
558 |
break; |
|
559 |
} |
|
560 |
parentComponent = parentComponent.getParent(); |
|
561 |
} |
|
562 |
// 2. check the NestedFieldGroup binding the field is direct or indirect child component of the editor |
|
563 |
// NO lONGER NEEDED |
|
564 |
// parentComponent = parentField.getParent(); // get component containing the last parent field found |
|
565 |
// while(true){ |
|
566 |
// if(parentComponent == getFieldLayout()){ |
|
567 |
// propertyIdPath = nestedPropertyIds; |
|
568 |
// break; |
|
569 |
// } |
|
570 |
// parentComponent = parentComponent.getParent(); |
|
571 |
// } |
|
572 |
} else { |
|
573 |
propertyIdPath = new PropertyIdPath(propertyId); |
|
574 |
} |
|
575 |
return propertyIdPath; |
|
576 |
} |
|
577 |
|
|
524 | 578 |
protected void addComponent(Component component) { |
525 | 579 |
fieldLayout.addComponent(component); |
526 | 580 |
applyDefaultComponentStyles(component); |
Also available in: Unified diff
consistent popup opening, using boundTargetField to identify field to be updated