Project

General

Profile

Revision a7612c19

IDa7612c19f7272069354d69c68e3385220e6af556
Parent 532d021f
Child e46361bb

Added by Andreas Kohlbecker over 1 year ago

fix #7949 Reference combobox with begins and anywhere search mode

View differences:

src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProviderFactory.java
51 51
        referenceOrderHints.add(new OrderHint("issn", SortOrder.ASCENDING));
52 52
        referenceOrderHints.add(new OrderHint("isbn", SortOrder.ASCENDING));
53 53
        TypifiedEntityFilterablePagingProvider<Reference> pagingProvider = new TypifiedEntityFilterablePagingProvider<Reference>(
54
                repo.getReferenceService(), MatchMode.ANYWHERE, referenceOrderHints, labelProvider);
54
                repo.getReferenceService(), MatchMode.BEGINNING, referenceOrderHints, labelProvider);
55 55
        pagingProvider.setInitStrategy(initStrategy);
56 56

  
57 57
        return pagingProvider;
src/main/java/eu/etaxonomy/cdm/service/TypifiedEntityFilterablePagingProvider.java
82 82
        entityPagingProvider.setInitStrategy(initStrategy);
83 83
    }
84 84

  
85
    public void setMatchMode(MatchMode matchMode){
86
        entityPagingProvider.setMatchMode(matchMode);
87
    }
88

  
85 89
}
src/main/java/eu/etaxonomy/cdm/vaadin/theme/EditValoTheme.java
21 21

  
22 22
    public static final String PANEL_CONTENT_PADDING_LEFT = "padding-left";
23 23

  
24
    public static final String OPTIONGROUP_CAPTION_FIX = "optiongroup-caption-fix";
25

  
24 26
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java
28 28
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
29 29
import eu.etaxonomy.cdm.persistence.dao.common.Restriction.Operator;
30 30
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
31
import eu.etaxonomy.cdm.persistence.query.MatchMode;
31 32
import eu.etaxonomy.cdm.ref.TypedEntityReference;
32 33
import eu.etaxonomy.cdm.service.CdmFilterablePagingProviderFactory;
33 34
import eu.etaxonomy.cdm.service.ReferenceLabelProvider;
......
62 63
    @Autowired
63 64
    protected CdmFilterablePagingProviderFactory pagingProviderFactory;
64 65

  
66
    private TypifiedEntityFilterablePagingProvider<Reference> referencePagingProvider;
67

  
65 68
    public StartRegistrationPresenter (){
66 69
        super();
67 70
    }
......
75 78

  
76 79
        super.handleViewEntered();
77 80

  
78
        TypifiedEntityFilterablePagingProvider<Reference> pagingProvider =
79
                pagingProviderFactory.referenceEntityReferencePagingProvider(
80
                        new ReferenceLabelProvider(ReferenceLabelProvider.LabelType.BIBLIOGRAPHIC),
81
                        ReferenceLabelProvider.INIT_STRATEGY
82
                        );
81
        referencePagingProvider = pagingProviderFactory.referenceEntityReferencePagingProvider(
82
                new ReferenceLabelProvider(ReferenceLabelProvider.LabelType.BIBLIOGRAPHIC),
83
                ReferenceLabelProvider.INIT_STRATEGY
84
                );
83 85
        TypedEntityCaptionGenerator<Reference> titleCacheGenrator = new TypedEntityCaptionGenerator<Reference>();
84
        pagingProvider.addRestriction(new Restriction("type", Operator.AND_NOT, null, ReferenceType.Section, ReferenceType.Journal, ReferenceType.PrintSeries));
86
        referencePagingProvider.addRestriction(new Restriction("type", Operator.AND_NOT, null, ReferenceType.Section, ReferenceType.Journal, ReferenceType.PrintSeries));
85 87
        getView().getReferenceCombobox().setCaptionGenerator(titleCacheGenrator);
86
        getView().getReferenceCombobox().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize());
88
        getView().getReferenceCombobox().loadFrom(referencePagingProvider, referencePagingProvider, referencePagingProvider.getPageSize());
89
    }
90

  
91
    /**
92
     * @param value
93
     * @return
94
     */
95
    public void updateReferenceSearchMode(MatchMode value) {
96
        if(referencePagingProvider != null && value != null){
97
            referencePagingProvider.setMatchMode(value);
98
            getView().getReferenceCombobox().refresh();
99
        }
87 100
    }
88 101

  
89 102
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationViewBean.java
24 24
import com.vaadin.ui.CssLayout;
25 25
import com.vaadin.ui.HorizontalLayout;
26 26
import com.vaadin.ui.Label;
27
import com.vaadin.ui.OptionGroup;
27 28
import com.vaadin.ui.VerticalLayout;
28 29
import com.vaadin.ui.themes.ValoTheme;
29 30

  
30 31
import eu.etaxonomy.cdm.model.reference.Reference;
32
import eu.etaxonomy.cdm.persistence.query.MatchMode;
31 33
import eu.etaxonomy.cdm.ref.TypedEntityReference;
32 34
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
33 35
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction;
34 36
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
37
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
35 38
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
36 39
import eu.etaxonomy.vaadin.event.EditorActionType;
37 40

  
......
53 56

  
54 57
    private LazyComboBox<TypedEntityReference<Reference>> referenceCombobox;
55 58

  
59
    private OptionGroup searchModeOptions = new OptionGroup("Search mode");
60

  
56 61
    private Button newPublicationButton;
57 62

  
58 63
    private Button removeNewPublicationButton;
......
104 109
            continueButton.setEnabled(isValueSelected);
105 110
        });
106 111

  
112
        searchModeOptions.addItems(MatchMode.BEGINNING, MatchMode.ANYWHERE);
113
        searchModeOptions.setValue(MatchMode.BEGINNING);
114
        searchModeOptions.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
115
        searchModeOptions.addStyleName(EditValoTheme.OPTIONGROUP_CAPTION_FIX);
116
        searchModeOptions.addValueChangeListener(e -> getPresenter().updateReferenceSearchMode((MatchMode)e.getProperty().getValue()));
117

  
107 118
        newPublicationButton = new Button("New");
108 119
        newPublicationButton.addClickListener( e -> getViewEventBus().publish(this,
109 120
                new ReferenceEditorAction(EditorActionType.ADD, newPublicationButton, null, this)
......
128 139
        labelLeft.setWidth(ELEMENT_WIDTH);
129 140
        labelRight.setWidth(ELEMENT_WIDTH);
130 141

  
131
        CssLayout leftContainer = new CssLayout(labelLeft, referenceCombobox);
142
        CssLayout leftContainer = new CssLayout(labelLeft, referenceCombobox, searchModeOptions);
132 143
        CssLayout rightContainer = new CssLayout(labelRight, newPublicationButton, removeNewPublicationButton, newPublicationLabel);
133 144
        leftContainer.setWidth(ELEMENT_WIDTH);
134 145
        rightContainer.setWidth(ELEMENT_WIDTH);
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss
222 222
    .v-panel-padding-left .v-panel-content {
223 223
        padding-left: round($v-unit-size / 4);
224 224
    }
225
    
226
     .v-select-optiongroup-optiongroup-caption-fix {
227
        margin-left: round($v-unit-size / 4);
228
     }
225 229

  
226 230
    // ===== workflow ==== // 
227 231
    

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)