Project

General

Profile

Revision 3ed14411

ID3ed14411a1659f765ad3e450246a2f2a27f23037
Parent 6f0224b6
Child 6ae724c9

Added by Patrick Plitzner about 5 years ago

ref #5458 Extract duplicate code

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionSelectionPresenter.java
5 5
import java.util.Arrays;
6 6
import java.util.List;
7 7

  
8
import com.vaadin.server.VaadinSession;
9
import com.vaadin.ui.Notification;
10 8
import com.vaadin.ui.UI;
11 9

  
12 10
import eu.etaxonomy.cdm.api.service.IClassificationService;
......
19 17
import eu.etaxonomy.cdm.model.taxon.Classification;
20 18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21 19
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
20
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
22 21
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionSelectionView;
23 22
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionTableView;
24 23
import eu.etaxonomy.cdm.vaadin.view.dbstatus.IDistributionSelectionComponent;
25 24

  
26 25
public class DistributionSelectionPresenter implements IDistributionSelectionComponent.DistributionSelectionComponentListener {
27 26

  
28
	DistributionSelectionView view;
27
	private DistributionSelectionView view;
29 28

  
30 29
	public DistributionSelectionPresenter(DistributionSelectionView dsv) {
31 30
		this.view = dsv;
......
35 34

  
36 35
	@Override
37 36
	public void buttonClick(TaxonNode taxonNode, TermVocabulary<DefinedTermBase> term) throws SQLException {
38
		if(taxonNode==null){
39
			Notification.show("Please choose a classification and/or taxon", Notification.Type.HUMANIZED_MESSAGE);
40
			return;
41
		}
42
		if(term==null){
43
			Notification.show("Please choose a distribution area", Notification.Type.HUMANIZED_MESSAGE);
44
			return;
45
		}
46
	    VaadinSession.getCurrent().setAttribute("taxonNodeUUID", taxonNode.getUuid());
47
	    VaadinSession.getCurrent().setAttribute("selectedTerm", term.getUuid());
37
		DistributionTableView dtv = new DistributionTableView();
38
		new DistributionTablePresenter(dtv);
39
		UI.getCurrent().getNavigator().addView("table", dtv);
48 40

  
49
	    DistributionTableView dtv = new DistributionTableView();
50
	    new DistributionTablePresenter(dtv);
51
	    UI.getCurrent().getNavigator().addView("table", dtv);
52
	    //navigate to table view
53
        UI.getCurrent().getNavigator().navigateTo("table");
41
		DistributionEditorUtil.openDistributionView(taxonNode, term);
54 42
	}
55 43

  
56 44
	@Override
src/main/java/eu/etaxonomy/cdm/vaadin/util/DistributionEditorUtil.java
1
package eu.etaxonomy.cdm.vaadin.util;
2

  
3
import com.vaadin.server.VaadinSession;
4
import com.vaadin.ui.Notification;
5
import com.vaadin.ui.Notification.Type;
6
import com.vaadin.ui.UI;
7

  
8
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
9
import eu.etaxonomy.cdm.model.common.TermVocabulary;
10
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
11

  
12
public class DistributionEditorUtil {
13

  
14
	public static void openDistributionView(TaxonNode taxonNode, TermVocabulary<DefinedTermBase> term) {
15
		if(taxonNode==null){
16
			Notification.show("Please choose a classification and/or taxon", Notification.Type.HUMANIZED_MESSAGE);
17
			return;
18
		}
19
		if(term==null){
20
			Notification.show("Please choose a distribution area", Notification.Type.HUMANIZED_MESSAGE);
21
			return;
22
		}
23
	    VaadinSession.getCurrent().setAttribute("taxonNodeUUID", taxonNode.getUuid());
24
	    VaadinSession.getCurrent().setAttribute("selectedTerm", term.getUuid());
25
	
26
	    //navigate to table view
27
	    UI.getCurrent().getNavigator().navigateTo("table");
28
	}
29

  
30
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java
124 124
		try {
125 125
			container = listener.getSQLContainer();
126 126
		} catch (SQLException e) {
127
			Notification.show("Could not acces data base", Type.ERROR_MESSAGE);
127
			Notification.show("Error while accessing data base", Type.ERROR_MESSAGE);
128 128
			e.printStackTrace();
129 129
			return;
130 130
		}
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/SettingsConfigWindow.java
12 12
import com.vaadin.data.Container;
13 13
import com.vaadin.data.Property.ValueChangeEvent;
14 14
import com.vaadin.data.Property.ValueChangeListener;
15
import com.vaadin.server.VaadinSession;
16 15
import com.vaadin.ui.AbstractLayout;
17 16
import com.vaadin.ui.Alignment;
18 17
import com.vaadin.ui.Button;
......
21 20
import com.vaadin.ui.ComboBox;
22 21
import com.vaadin.ui.CustomComponent;
23 22
import com.vaadin.ui.HorizontalLayout;
24
import com.vaadin.ui.Notification;
25 23
import com.vaadin.ui.Tree;
26 24
import com.vaadin.ui.TwinColSelect;
27
import com.vaadin.ui.UI;
28 25
import com.vaadin.ui.VerticalLayout;
29 26
import com.vaadin.ui.Window;
30 27

  
......
33 30
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
34 31
import eu.etaxonomy.cdm.vaadin.container.TaxonNodeContainer;
35 32
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings.SettingsPresenter;
33
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
36 34

  
37 35
/**
38 36
 * @author alex
......
97 95
					taxonNode = (TaxonNode) classificationBox.getValue();
98 96
				}
99 97
				term = (TermVocabulary<DefinedTermBase>) distAreaBox.getValue();
100
				if(taxonNode==null){
101
					Notification.show("Please choose a classification and/or taxon", Notification.Type.HUMANIZED_MESSAGE);
102
					return;
103
				}
104
				if(term==null){
105
					Notification.show("Please choose a distribution area", Notification.Type.HUMANIZED_MESSAGE);
106
					return;
107
				}
108

  
109
			    VaadinSession.getCurrent().setAttribute("taxonNodeUUID", taxonNode.getUuid());
110
			    VaadinSession.getCurrent().setAttribute("selectedTerm", term.getUuid());
111

  
112
			    window.close();
113
		        UI.getCurrent().getNavigator().navigateTo("table");				
98
				DistributionEditorUtil.openDistributionView(taxonNode, term);
99
				window.close();
114 100
			}
115 101
		});
116 102
        cancelButton.addClickListener(new ClickListener() {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)