Project

General

Profile

Revision 5c8b52af

ID5c8b52af5ae62ecccad4d63ef7356d5b43fc4398
Parent d196eb4d
Child 54d20fb4

Added by Patrick Plitzner about 5 years ago

ref #5458 Add property formatting for distribution table

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java
31 31

  
32 32
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
33 33
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
34
import eu.etaxonomy.cdm.model.common.Language;
35
import eu.etaxonomy.cdm.model.common.Representation;
34 36
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
37
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
35 38
import eu.etaxonomy.cdm.model.taxon.Taxon;
36 39
import eu.etaxonomy.cdm.vaadin.component.DetailWindow;
37 40
import eu.etaxonomy.cdm.vaadin.component.HorizontalToolbar;
......
40 43
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.DistributionTablePresenter;
41 44
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory;
42 45
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
46
import eu.etaxonomy.cdm.vaadin.util.TermCacher;
43 47

  
44 48
public class DistributionTableView extends CustomComponent implements View{
45 49

  
......
80 84
		toolbar = new HorizontalToolbar();
81 85
		mainLayout.addComponent(toolbar, "top:0.0px;right:0.0px;");
82 86

  
83
		// table
84
		table = new Table();
87
		// table + formatting
88
		table = new Table(){
89
			private static final long serialVersionUID = -5148756917468804385L;
90

  
91
			@Override
92
			protected String formatPropertyValue(Object rowId, Object colId, Property<?> property) {
93
				String formattedValue = null;
94
				PresenceAbsenceTerm presenceAbsenceTerm = null;
95
				Object value = property.getValue();
96
				if(value instanceof String){
97
					presenceAbsenceTerm = TermCacher.getInstance().getPresenceAbsenceTerm((String) value);
98
				}
99
				if(presenceAbsenceTerm!=null){
100
					Representation representation = presenceAbsenceTerm.getRepresentation(Language.DEFAULT());
101
					if(representation!=null){
102
						if(DistributionEditorUtil.isAbbreviatedLabels()){
103
							formattedValue = representation.getAbbreviatedLabel();
104
						}
105
						else{
106
							formattedValue = representation.getLabel();
107
						}
108
					}
109
					if(formattedValue==null){
110
						formattedValue = presenceAbsenceTerm.getTitleCache();
111
					}
112
					return formattedValue;
113
				}
114
				return super.formatPropertyValue(rowId, colId, property);
115
			}
116
		};
85 117
		table.setImmediate(false);
86 118
		table.setWidth("100.0%");
87 119
		table.setHeight("100.0%");
88 120

  
89 121
        table.setColumnReorderingAllowed(true);
90 122
        table.setSortEnabled(true);
91

  
123
        
92 124
        table.setColumnCollapsingAllowed(true);
93 125
        table.setSelectable(true);
94 126
        table.setPageLength(20);
......
110 142
                    final Window popup = new Window("Choose distribution status");
111 143
                    final ListSelect termSelect = new ListSelect();
112 144
                    termSelect.setSizeFull();
145
                    termSelect.setNullSelectionAllowed(false);
113 146
                    termSelect.setContainerDataSource(PresenceAbsenceTermContainer.getInstance());
114 147
                    Button btnOk = new Button("OK", new ClickListener() {
115 148
                        private static final long serialVersionUID = -3732219609337335697L;
......
248 281
        Window window  = cw.createWindow();
249 282
        getUI().addWindow(window);
250 283
	}
251

  
284
	
252 285
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)