Project

General

Profile

Revision f5d57f6d

IDf5d57f6d5a9687987160fc358e5cb2ab30f8b638
Parent af91f565
Child b2063ede

Added by Patrick Plitzner over 4 years ago

ref #5458 Code cleanup

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java
3 3
import java.sql.SQLException;
4 4
import java.util.ArrayList;
5 5
import java.util.Arrays;
6
import java.util.HashSet;
7 6
import java.util.List;
8 7
import java.util.UUID;
9 8

  
10
import com.vaadin.annotations.AutoGenerated;
11
import com.vaadin.data.Container;
12 9
import com.vaadin.data.Item;
13 10
import com.vaadin.data.Property;
14 11
import com.vaadin.data.Property.ValueChangeEvent;
......
27 24
import com.vaadin.ui.ComboBox;
28 25
import com.vaadin.ui.Component;
29 26
import com.vaadin.ui.CustomComponent;
30
import com.vaadin.ui.Field;
31 27
import com.vaadin.ui.Notification;
32 28
import com.vaadin.ui.PopupView;
33 29
import com.vaadin.ui.PopupView.PopupVisibilityEvent;
......
38 34

  
39 35
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
40 36
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
41
import eu.etaxonomy.cdm.model.description.Feature;
42 37
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
43 38
import eu.etaxonomy.cdm.model.taxon.Taxon;
44 39
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
......
49 44
public class DistributionTableView<E> extends CustomComponent implements IDistributionTableComponent, View{
50 45

  
51 46
    private static final long serialVersionUID = 1L;
52
    @AutoGenerated
53
	private AbsoluteLayout mainLayout;
54 47
    private HorizontalToolbar toolbar;
55
	@AutoGenerated
56 48
	private Table table;
57 49

  
58 50
	private Taxon currentTaxon;
......
61 53

  
62 54
	private DistributionTableComponentListener listener;
63 55

  
64
	protected List<Field> fields = new ArrayList<Field>();
65

  
66
	List<String> columnList;
67
	ArrayList<String> headerList;
56
	private List<String> columnList;
57
	private ArrayList<String> headerList;
68 58

  
69 59
	/**
70 60
	 * The constructor should first build the main layout, set the
......
74 64
	 * visual editor.
75 65
	 */
76 66
	public DistributionTableView() {
77
		buildMainLayout();
67
		AbsoluteLayout mainLayout = initLayout();
78 68
		setCompositionRoot(mainLayout);
79 69
		createEditClickListener();
80 70

  
81 71
	}
82 72

  
83
	@Override
84
	public void addListener(DistributionTableComponentListener listener) {
85
	   this.listener = listener;
86
	}
87

  
88
	@AutoGenerated
89
	private AbsoluteLayout buildMainLayout() {
90
		// common part: create layout
91
		mainLayout = new AbsoluteLayout();
73
	private AbsoluteLayout initLayout() {
74
		AbsoluteLayout mainLayout = new AbsoluteLayout();
92 75
		mainLayout.setImmediate(false);
93 76
		mainLayout.setWidth("100%");
94 77
		mainLayout.setHeight("100%");
95

  
96
		// top-level component properties
78
		
97 79
		setWidth("100.0%");
98 80
		setHeight("100.0%");
81

  
99 82
		//Horizontal Toolbar
100 83
		toolbar = new HorizontalToolbar();
101 84
		mainLayout.addComponent(toolbar, "top:0.0px;right:0.0px;");
102

  
103
		// table_1
85
		
86
		// table
104 87
		table = new Table();
105 88
		table.setImmediate(false);
106 89
		table.setWidth("100.0%");
107 90
		table.setHeight("100.0%");
108 91
		mainLayout.addComponent(table, "top:75px;right:0.0px;");
109

  
110 92
		return mainLayout;
111 93
	}
112 94

  
113
    /* (non-Javadoc)
114
     * @see com.vaadin.navigator.View#enter(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent)
115
     */
95
	@Override
96
	public void addListener(DistributionTableComponentListener listener) {
97
	   this.listener = listener;
98
	}
99

  
116 100
    @Override
117 101
    public void enter(ViewChangeEvent event) {
118 102
        // TODO Auto-generated method stub
......
135 119

  
136 120
		headerList = new ArrayList<String>(Arrays.asList(new String[]{"Taxon","Rang"}));
137 121
		headerList.addAll(listener.getAbbreviatedTermList());
138
//		table.setColumnHeaders(headerList.toArray(new String[headerList.size()]));//new String[]{"Taxon", "Rang"});// ,"Deutschland"
139 122

  
140 123
		table.setColumnCollapsingAllowed(true);
141 124
		table.setSelectable(true);
......
155 138
			@Override
156 139
			public void buttonClick(ClickEvent event) {
157 140
				try{
158
					HashSet<Feature> featureSet = new HashSet<Feature>(Arrays.asList(Feature.DESCRIPTION(), Feature.DISTRIBUTION()));
159
				if(currentTaxon != null){
160
					List<DescriptionElementBase> listDescriptions = listener.listDescriptionElementsForTaxon(currentTaxon, null);
161
					DetailWindow dw = new DetailWindow(currentTaxon, listDescriptions);
162
					Window window = dw.createWindow();
163
					getUI().addWindow(window);
164
				}else{
165
					Notification.show("Please select a Taxon.", Notification.Type.HUMANIZED_MESSAGE);
166
				}
141
					if(currentTaxon != null){
142
						List<DescriptionElementBase> listDescriptions = listener.listDescriptionElementsForTaxon(currentTaxon, null);
143
						DetailWindow dw = new DetailWindow(currentTaxon, listDescriptions);
144
						Window window = dw.createWindow();
145
						getUI().addWindow(window);
146
					}else{
147
						Notification.show("Please select a Taxon.", Notification.Type.HUMANIZED_MESSAGE);
148
					}
167 149
				}catch(Exception e){
168 150
					Notification.show("Unexpected Error, \n\n Please log in again!", Notification.Type.WARNING_MESSAGE);
169 151
				}
......
286 268
	        @Override
287 269
	        public Object generateCell(Table source, Object itemId, Object columnId) {
288 270
	            Property containerProperty = source.getContainerProperty(itemId, columnId);
289
	            Object item = itemId;
290 271
	            Object value = null;
291 272
	            if(containerProperty != null){
292 273
	                value = containerProperty.getValue();
293 274
	            }
294
	            Container containerDataSource = source.getContainerDataSource();
295 275
	            final UUID uuid = UUID.fromString(table.getItem(itemId).getItemProperty("uuid").getValue().toString());
296 276
	            final ComboBox box = new ComboBox("Occurrence Status: ", listener.getPresenceAbsenceContainer());
297 277
	            final String area = columnId.toString();

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)