Revision ae69029f
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java | ||
---|---|---|
29 | 29 |
import com.vaadin.server.AbstractErrorMessage.ContentMode; |
30 | 30 |
import com.vaadin.server.ErrorMessage.ErrorLevel; |
31 | 31 |
import com.vaadin.server.FontAwesome; |
32 |
import com.vaadin.server.GenericFontIcon; |
|
32 | 33 |
import com.vaadin.server.UserError; |
33 | 34 |
import com.vaadin.shared.ui.MarginInfo; |
34 | 35 |
import com.vaadin.ui.AbstractComponentContainer; |
... | ... | |
58 | 59 |
|
59 | 60 |
import eu.etaxonomy.cdm.database.PermissionDeniedException; |
60 | 61 |
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix; |
61 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction; |
|
62 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.EditorActionContext; |
|
62 |
import eu.etaxonomy.cdm.vaadin.event.EditorActionContext; |
|
63 |
import eu.etaxonomy.cdm.vaadin.event.EditorActionContextFormat; |
|
64 |
import eu.etaxonomy.cdm.vaadin.event.EditorActionContextFormatter; |
|
63 | 65 |
import eu.etaxonomy.vaadin.component.NestedFieldGroup; |
64 | 66 |
import eu.etaxonomy.vaadin.component.SwitchableTextField; |
65 | 67 |
import eu.etaxonomy.vaadin.event.FieldReplaceEvent; |
... | ... | |
106 | 108 |
|
107 | 109 |
private CssLayout toolBarButtonGroup = new CssLayout(); |
108 | 110 |
|
111 |
private Label contextBreadcrumbsLabel = new Label(); |
|
112 |
|
|
109 | 113 |
private Label statusMessageLabel = new Label(); |
110 | 114 |
|
111 | 115 |
Set<String> statusMessages = new HashSet<>(); |
... | ... | |
139 | 143 |
|
140 | 144 |
toolBar.addStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); |
141 | 145 |
toolBar.setWidth(100, Unit.PERCENTAGE); |
146 |
contextBreadcrumbsLabel.setId("context-breadcrumbs"); |
|
147 |
contextBreadcrumbsLabel.setWidthUndefined(); |
|
148 |
contextBreadcrumbsLabel.setContentMode(com.vaadin.shared.ui.label.ContentMode.HTML); |
|
149 |
toolBar.addComponent(contextBreadcrumbsLabel); |
|
142 | 150 |
toolBarButtonGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); |
143 | 151 |
toolBarButtonGroup.setWidthUndefined(); |
144 | 152 |
toolBar.addComponent(toolBarButtonGroup); |
... | ... | |
718 | 726 |
statusMessageLabel.addStyleName(ValoTheme.LABEL_COLORED); |
719 | 727 |
} |
720 | 728 |
|
729 |
private void updateContextBreadcrumbs() { |
|
730 |
|
|
731 |
List<EditorActionContext> contextInfo = new ArrayList<>(getEditorActionContext()); |
|
732 |
String breadcrumbs = ""; |
|
733 |
EditorActionContextFormatter formatter = new EditorActionContextFormatter(); |
|
734 |
|
|
735 |
GenericFontIcon operationPrefixIcon = new GenericFontIcon("IcoMoon", 0xe902); |
|
736 |
GenericFontIcon operationSuffxIcon = new GenericFontIcon("IcoMoon", 0xe901); |
|
737 |
|
|
738 |
int cnt = 0; |
|
739 |
for(EditorActionContext cntxt : contextInfo){ |
|
740 |
cnt++; |
|
741 |
boolean isLast = cnt == contextInfo.size(); |
|
742 |
boolean isFirst = cnt == 1; |
|
743 |
|
|
744 |
boolean doClass = false; // will be removed in future |
|
745 |
boolean classNameForMissingPropertyPath = true; // !doClass; |
|
746 |
boolean doProperties = true; |
|
747 |
boolean doCreateOrNew = !isFirst; |
|
748 |
String contextmarkup = formatter.format( |
|
749 |
cntxt, |
|
750 |
new EditorActionContextFormat(doClass, doProperties, classNameForMissingPropertyPath, doCreateOrNew, |
|
751 |
EditorActionContextFormat.TargetInfoType.FIELD_CAPTION, (isLast ? "active" : "")) |
|
752 |
); |
|
753 |
// if(!isLast){ |
|
754 |
// contextmarkup += " " + FontAwesome.ANGLE_RIGHT.getHtml() + " "; |
|
755 |
// } |
|
756 |
if(isLast){ |
|
757 |
contextmarkup = "<li><span class=\"crumb active\">" + contextmarkup + "</span></li>"; |
|
758 |
} else { |
|
759 |
contextmarkup = "<li><span class=\"crumb\">" + contextmarkup + "</span></li>"; |
|
760 |
} |
|
761 |
breadcrumbs += contextmarkup; |
|
762 |
} |
|
763 |
contextBreadcrumbsLabel.setValue("<ul class=\"breadcrumbs\">" + breadcrumbs + "</ul>"); |
|
764 |
} |
|
765 |
|
|
721 | 766 |
// ------------------------ data binding ------------------------ // |
722 | 767 |
|
723 | 768 |
protected void bindDesign(Component component) { |
... | ... | |
733 | 778 |
fieldGroup.setItemDataSource(beanToEdit); |
734 | 779 |
afterItemDataSourceSet(); |
735 | 780 |
getPresenter().adaptToUserPermission(beanToEdit); |
781 |
updateContextBreadcrumbs(); |
|
736 | 782 |
isBeanLoaded = true; |
737 | 783 |
} |
738 | 784 |
|
... | ... | |
817 | 863 |
if(getBean() == null){ |
818 | 864 |
throw new RuntimeException("getContext() is only possible after the bean is loaded"); |
819 | 865 |
} |
820 |
context.push(new AbstractEditorAction.EditorActionContext(getBean(), this));
|
|
866 |
context.push(new EditorActionContext(getBean(), this)); |
|
821 | 867 |
isContextUpdated = true; |
822 | 868 |
} |
823 | 869 |
return context; |
... | ... | |
828 | 874 |
* |
829 | 875 |
* @param context the context to set |
830 | 876 |
*/ |
831 |
public void setParentEditorActionContext(Stack<EditorActionContext> context) { |
|
877 |
public void setParentEditorActionContext(Stack<EditorActionContext> context, Field<?> targetField) {
|
|
832 | 878 |
if(context != null){ |
833 | 879 |
this.context.addAll(context); |
834 | 880 |
} |
881 |
if(targetField != null){ |
|
882 |
this.context.get(context.size() - 1).setTargetField(targetField); |
|
883 |
} |
|
835 | 884 |
} |
836 | 885 |
|
837 | 886 |
protected AbstractField<String> replaceComponent(String propertyId, AbstractField<String> oldField, AbstractField<String> newField, int column1, int row1, int column2, |
Also available in: Unified diff
fix #7846 editor context information shown as breadcrumbs in the toolbar of popup editors