Project

General

Profile

Revision c90de46b

IDc90de46b39ed4ea47d34e3565ccd7dd4704a34c4
Parent 8992bc7f
Child c52b7e11

Added by Alexander Oppermann almost 6 years ago

Added a classification selector view for vaadin client.

View differences:

.gitattributes
2074 2074
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/service/Utils.java -text
2075 2075
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/VaadinConfigurer.java -text
2076 2076
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/VaadinUI.java -text
2077
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/ClassificationSelectionForm.java -text
2077 2078
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/DemoTaxonTable.java -text
2078 2079
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/DetailWindow.java -text
2079 2080
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/HorizontalToolbar.java -text
......
2082 2083
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/service/AuthenticationService.java -text
2083 2084
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/disabled/DefaultView.java -text
2084 2085
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/redlist/views/BfnView.java -text
2086
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/redlist/views/ClassificationSelectorView.java -text
2085 2087
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/redlist/views/DashBoardView.java -text
2086 2088
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/redlist/views/ErrorView.java -text
2087 2089
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/redlist/views/LoginView.java -text
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/ClassificationSelectionForm.java
1
package eu.etaxonomy.cdm.remote.vaadin.components;
2

  
3
import java.util.Arrays;
4
import java.util.List;
5

  
6
import javax.annotation.PostConstruct;
7

  
8
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.context.annotation.Scope;
10
import org.springframework.security.core.AuthenticationException;
11
import org.springframework.stereotype.Component;
12

  
13
import com.vaadin.data.Container;
14
import com.vaadin.data.util.IndexedContainer;
15
import com.vaadin.data.validator.StringLengthValidator;
16
import com.vaadin.event.ShortcutAction.KeyCode;
17
import com.vaadin.server.Page;
18
import com.vaadin.server.VaadinSession;
19
import com.vaadin.shared.ui.label.ContentMode;
20
import com.vaadin.ui.Button;
21
import com.vaadin.ui.Button.ClickEvent;
22
import com.vaadin.ui.ComboBox;
23
import com.vaadin.ui.FormLayout;
24
import com.vaadin.ui.Label;
25
import com.vaadin.ui.Notification;
26
import com.vaadin.ui.PasswordField;
27
import com.vaadin.ui.TextField;
28

  
29
import eu.etaxonomy.cdm.api.service.IClassificationService;
30
import eu.etaxonomy.cdm.model.taxon.Classification;
31
import eu.etaxonomy.cdm.remote.vaadin.service.AuthenticationService;
32
import eu.etaxonomy.cdm.remote.vaadin.uiset.redlist.views.BfnView;
33
import eu.etaxonomy.cdm.remote.vaadin.uiset.redlist.views.ClassificationSelectorView;
34

  
35
/**
36
 * 
37
 * 
38
 * Yet another component, which creates a simple form layout. It makes use of the 
39
 * AuthenticationController.
40
 * 
41
 * 
42
 * @author a.oppermann
43
 *
44
 */
45

  
46
@Component
47
@Scope("prototype")
48
public class ClassificationSelectionForm extends FormLayout{
49
	
50
    /**
51
	 * Automatically generated serial version ID
52
	 */
53
	private static final long serialVersionUID = 1L;
54
	
55
	private ComboBox box;
56
	@Autowired
57
	private IClassificationService classificationService;
58

  
59
	
60
    @PostConstruct
61
	public void PostConstruct(){
62
    	Label header = new Label("Classificaton Selection");
63
		header.setStyleName("h1");
64
		Label description = new Label("Please choose a classification and proceed with continue.",ContentMode.TEXT);
65
		
66
		List<Classification> listClassifications = classificationService.listClassifications(null, null, null, NODE_INIT_STRATEGY());
67
		box = new ComboBox();
68
		Container c = new IndexedContainer(listClassifications);
69
		box.setContainerDataSource(c);
70
		box.select(listClassifications.get(0));
71

  
72

  
73
		Button nextButton = new Button("Continue", new Button.ClickListener() {
74
			
75
			@Override
76
			public void buttonClick(ClickEvent event) {
77
				if(box.getValue() != null){
78
					VaadinSession session = VaadinSession.getCurrent();
79
					Classification classification = (Classification) box.getValue();
80
					session.setAttribute("classificationUUID", classification.getUuid());
81
					Page.getCurrent().setUriFragment("!"+ BfnView.NAME);
82
				}else{
83
					Notification.show("Please Select a Classification, in order to proceed!",Notification.Type.ERROR_MESSAGE);
84
				}				
85
			}
86
		});
87
		nextButton.setClickShortcut(KeyCode.ENTER, null);
88
		nextButton.setImmediate(true);
89
		
90
		header.setStyleName("h1");
91

  
92
		setSpacing(true);
93
		setMargin(true);
94
		setSizeUndefined();
95
		
96
		addComponent(header);
97
		addComponent(description);
98
		addComponent(box);
99
		addComponent(nextButton);
100
	}
101
    
102
    private List<String> NODE_INIT_STRATEGY(){
103
        return Arrays.asList(new String[]{
104
            "taxon.sec",
105
            "taxon.name",
106
            "classification"
107
    });}
108
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/DemoTaxonTable.java
3 3
import java.util.Arrays;
4 4
import java.util.Collection;
5 5
import java.util.List;
6
import java.util.UUID;
6 7

  
7 8
import javax.annotation.PostConstruct;
8 9

  
......
12 13
import org.springframework.stereotype.Component;
13 14

  
14 15
import com.vaadin.data.util.BeanItemContainer;
16
import com.vaadin.server.VaadinSession;
15 17
import com.vaadin.ui.Table;
16 18

  
19
import eu.etaxonomy.cdm.api.service.IClassificationService;
17 20
import eu.etaxonomy.cdm.api.service.IDescriptionService;
21
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
18 22
import eu.etaxonomy.cdm.api.service.ITaxonService;
19 23
import eu.etaxonomy.cdm.api.service.ITermService;
24
import eu.etaxonomy.cdm.model.common.CdmBase;
20 25
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
21 26
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;
27
import eu.etaxonomy.cdm.model.taxon.Classification;
22 28
import eu.etaxonomy.cdm.model.taxon.Taxon;
29
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
23 30
import eu.etaxonomy.cdm.remote.dto.vaadin.CdmTaxonTableCollection;
24 31

  
25 32
/**
......
50 57
	IDescriptionService descriptionService;
51 58
	@Autowired
52 59
	ITermService termService;
60
	@Autowired
61
	IClassificationService clService;
62
	@Autowired
63
	ITaxonNodeService taxonNodeService;
53 64

  
54 65
	Logger logger = Logger.getLogger(DemoTaxonTable.class);
55 66

  
......
61 72

  
62 73
		final BeanItemContainer<CdmTaxonTableCollection> redListContainer = new BeanItemContainer<CdmTaxonTableCollection>(CdmTaxonTableCollection.class);
63 74
		//TODO: Make use of paging
64
		Collection<Taxon> listTaxon = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY);
75
		VaadinSession session = VaadinSession.getCurrent();
76
		UUID uuid = UUID.fromString(session.getAttribute("classificationUUID").toString());
77
		Classification classification = clService.load(uuid);
78
		List<TaxonNode> listAllNodes = taxonNodeService.listAllNodesForClassification(classification, null, null);
65 79

  
66
		for(Taxon taxonBase:listTaxon){
67

  
68
			Taxon taxon = taxonBase;
80
		Collection<Taxon> listTaxon = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY);
81
		for(TaxonNode taxonNode:listAllNodes){
82
			
83
			Taxon taxon = taxonNode.getTaxon();
69 84
			List<PresenceAbsenceTermBase> termList = termService.list(PresenceAbsenceTermBase.class, null, null, null, DESCRIPTION_INIT_STRATEGY);
70 85
			List<DescriptionElementBase> listTaxonDescription = descriptionService.listDescriptionElementsForTaxon(taxon, null, null, null, null, DESCRIPTION_INIT_STRATEGY);
71 86
			CdmTaxonTableCollection tableCollection = new CdmTaxonTableCollection(taxon, listTaxonDescription, termList);
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/DetailWindow.java
34 34
		Window window = new Window();
35 35
		window.setHeight("600px");
36 36
		window.setWidth("400px");
37
		window.setCaption("Detail Window " + taxon.getName().getTitleCache());
37
		window.setCaption(taxon.getName().getTitleCache());
38 38
		window.setContent(constructDescriptionTree(taxon));
39 39
		return window;
40 40
	}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/LoginForm.java
19 19
import com.vaadin.ui.TextField;
20 20

  
21 21
import eu.etaxonomy.cdm.remote.vaadin.service.AuthenticationService;
22
import eu.etaxonomy.cdm.remote.vaadin.uiset.redlist.views.BfnView;
22
import eu.etaxonomy.cdm.remote.vaadin.uiset.redlist.views.ClassificationSelectorView;
23 23

  
24 24
/**
25 25
 * 
......
85 85
				try{
86 86
					boolean isAuthenticated = authenticationController.authenticate(userName.getValue(), passwordField.getValue());
87 87
					if(isAuthenticated){
88
						Page.getCurrent().setUriFragment("!"+ BfnView.NAME); //DashBoardView
88
						Page.getCurrent().setUriFragment("!"+ ClassificationSelectorView.NAME);//DashBoardView BfnView.NAME
89 89
					}
90 90
				}catch(AuthenticationException e){
91 91
					Notification.show("Bad credentials",Notification.Type.ERROR_MESSAGE);
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/redlist/views/ClassificationSelectorView.java
1
package eu.etaxonomy.cdm.remote.vaadin.uiset.redlist.views;
2

  
3
import java.util.Arrays;
4
import java.util.Collection;
5
import java.util.List;
6

  
7
import javax.annotation.PostConstruct;
8

  
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.context.annotation.Scope;
11
import org.springframework.stereotype.Component;
12

  
13
import ru.xpoft.vaadin.VaadinView;
14

  
15
import com.vaadin.annotations.Theme;
16
import com.vaadin.data.Container;
17
import com.vaadin.data.Item;
18
import com.vaadin.data.Property;
19
import com.vaadin.data.util.IndexedContainer;
20
import com.vaadin.navigator.View;
21
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
22
import com.vaadin.server.Page;
23
import com.vaadin.server.VaadinSession;
24
import com.vaadin.shared.ui.label.ContentMode;
25
import com.vaadin.ui.Alignment;
26
import com.vaadin.ui.Button;
27
import com.vaadin.ui.Button.ClickEvent;
28
import com.vaadin.ui.Button.ClickListener;
29
import com.vaadin.ui.ComboBox;
30
import com.vaadin.ui.CustomComponent;
31
import com.vaadin.ui.HorizontalLayout;
32
import com.vaadin.ui.Label;
33
import com.vaadin.ui.Notification;
34
import com.vaadin.ui.Panel;
35
import com.vaadin.ui.VerticalLayout;
36
import com.vaadin.ui.Window;
37

  
38
import eu.etaxonomy.cdm.api.service.IClassificationService;
39
import eu.etaxonomy.cdm.model.taxon.Classification;
40
import eu.etaxonomy.cdm.remote.vaadin.components.ClassificationSelectionForm;
41
import eu.etaxonomy.cdm.remote.vaadin.components.HorizontalToolbar;
42
import eu.etaxonomy.cdm.remote.vaadin.service.AuthenticationService;
43

  
44
@Component
45
@Scope("prototype")
46
@Theme("mytheme")
47
@VaadinView(ClassificationSelectorView.NAME)
48
public class ClassificationSelectorView extends CustomComponent implements View {
49

  
50
	private static final long serialVersionUID = 1L;
51
	public static final String NAME = "selector";
52
	@Autowired
53
	private AuthenticationService authenticationService;
54
	@Autowired
55
	private ClassificationSelectionForm classificationSelectionForm;
56
	
57
	@PostConstruct
58
	public void PostConstruct(){
59
		if(authenticationService.isAuthenticated()){
60
			VerticalLayout layout = new VerticalLayout();
61
			layout.setWidth("100%");
62
			layout.setHeight("100%");
63
			Page page = Page.getCurrent();
64

  
65
			HorizontalLayout hLayout = new HorizontalLayout();
66
			//FIXME: Quick'n'dirty hack
67
			int hh = Page.getCurrent().getBrowserWindowHeight()-300;
68
			setHeight(hh +"px");
69
			
70
			
71
			Panel panel = new Panel();
72
			panel.setSizeUndefined();
73
			panel.setContent(classificationSelectionForm);
74
			panel.setStyleName("login");
75
			
76
			layout.addComponent(hLayout);
77
			layout.addComponent(panel);
78

  
79
			layout.setSizeFull();
80
			layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
81

  
82
			setCompositionRoot(layout);
83
		}
84
	}
85
		
86

  
87
	@Override
88
	public void enter(ViewChangeEvent event) {
89
		// TODO Auto-generated method stub
90
	}
91
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)