Project

General

Profile

Revision 9f8c87ee

ID9f8c87ee6fc1ef2d2405b86b30467e2456c4fb59
Parent 3e9b93db
Child 6f0224b6

Added by Patrick Plitzner over 2 years ago

ref #5458 Implement update of distribution editor via settings window

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/SettingsConfigWindow.java
9 9
*/
10 10
package eu.etaxonomy.cdm.vaadin.view.dbstatus;
11 11

  
12
import java.sql.SQLException;
13

  
12 14
import com.vaadin.data.Container;
15
import com.vaadin.data.Property.ValueChangeEvent;
16
import com.vaadin.data.Property.ValueChangeListener;
17
import com.vaadin.server.VaadinSession;
13 18
import com.vaadin.ui.AbstractLayout;
14 19
import com.vaadin.ui.Alignment;
15 20
import com.vaadin.ui.Button;
21
import com.vaadin.ui.Button.ClickEvent;
22
import com.vaadin.ui.Button.ClickListener;
16 23
import com.vaadin.ui.ComboBox;
17 24
import com.vaadin.ui.CustomComponent;
18 25
import com.vaadin.ui.HorizontalLayout;
26
import com.vaadin.ui.Notification;
19 27
import com.vaadin.ui.Tree;
20 28
import com.vaadin.ui.TwinColSelect;
29
import com.vaadin.ui.UI;
21 30
import com.vaadin.ui.VerticalLayout;
22 31
import com.vaadin.ui.Window;
23 32

  
33
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
24 34
import eu.etaxonomy.cdm.model.common.TermVocabulary;
35
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
25 36
import eu.etaxonomy.cdm.vaadin.container.TaxonNodeContainer;
37
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.DistributionTablePresenter;
26 38
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings.SettingsPresenter;
27 39

  
28 40
/**
......
41 53
    private Button okButton;
42 54
    private Button cancelButton;
43 55
    private final SettingsPresenter presenter;
56
	private Window window;
44 57
    
45 58
    /**
46 59
     * The constructor should first build the main layout, set the
......
51 64
     */
52 65
    public SettingsConfigWindow() {
53 66
        buildMainLayout();
54
//        setCompositionRoot(mainLayout);
55 67
        presenter = new SettingsPresenter();
56 68
        init();
57 69
    }
......
63 75
        classificationBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
64 76
        classificationBox.setContainerDataSource(taxonNodeContainer);
65 77
        classificationBox.setValue(presenter.getChosenTaxonNode().getClassification().getRootNode());
78
        classificationBox.addValueChangeListener(new ValueChangeListener() {
79
			@Override
80
			public void valueChange(ValueChangeEvent event) {
81
				TaxonNode parentNode = (TaxonNode) event.getProperty().getValue();
82
				taxonTree.setContainerDataSource(new TaxonNodeContainer(parentNode));
83
			}
84
		});
85
        taxonTree.setContainerDataSource(new TaxonNodeContainer((TaxonNode) classificationBox.getValue()));
66 86
        taxonTree.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
67
        taxonTree.setContainerDataSource(taxonNodeContainer);
68 87
        taxonTree.setValue(presenter.getChosenTaxonNode());
69 88
        distAreaBox.setContainerDataSource(distributionContainer);
70 89
        distAreaBox.setValue(chosenArea);
71 90
        distStatusSelect.setContainerDataSource(presenter.getDistributionStatusContainer());
91
        
92
        okButton.addClickListener(new ClickListener() {
93
			
94
			@Override
95
			public void buttonClick(ClickEvent event) {
96
				TaxonNode taxonNode;
97
				TermVocabulary<DefinedTermBase> term = null;
98
				taxonNode = (TaxonNode) taxonTree.getValue();
99
				if(taxonNode==null){
100
					taxonNode = (TaxonNode) classificationBox.getValue();
101
				}
102
				term = (TermVocabulary<DefinedTermBase>) distAreaBox.getValue();
103
				if(taxonNode==null){
104
					Notification.show("Please choose a classification and/or taxon", Notification.Type.HUMANIZED_MESSAGE);
105
					return;
106
				}
107
				if(term==null){
108
					Notification.show("Please choose a distribution area", Notification.Type.HUMANIZED_MESSAGE);
109
					return;
110
				}
111

  
112
			    VaadinSession.getCurrent().setAttribute("taxonNodeUUID", taxonNode.getUuid());
113
			    VaadinSession.getCurrent().setAttribute("selectedTerm", term.getUuid());
114

  
115
			    DistributionTableView dtv = new DistributionTableView();
116
			    try {
117
					new DistributionTablePresenter(dtv);
118
				} catch (SQLException e) {
119
					e.printStackTrace();
120
				}
121
			    UI.getCurrent().getNavigator().addView("table", dtv);
122
			    //navigate to table view
123
			    window.close();
124
		        UI.getCurrent().getNavigator().navigateTo("table");				
125
			}
126
		});
127
        cancelButton.addClickListener(new ClickListener() {
128
			
129
			@Override
130
			public void buttonClick(ClickEvent event) {
131
				window.close();
132
			}
133
		});
72 134
    }
73 135

  
74 136
    public Window createWindow(){
75
        Window window = new Window();
137
        window = new Window();
76 138
        window.setModal(true);
77 139
        window.setWidth("60%");
78 140
        window.setHeight("80%");

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)