Project

General

Profile

Download (3.49 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.vaadin.view;
2

    
3
import com.vaadin.annotations.AutoGenerated;
4
import com.vaadin.event.ShortcutListener;
5
import com.vaadin.event.ShortcutAction.KeyCode;
6
import com.vaadin.navigator.View;
7
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
8
import com.vaadin.ui.Alignment;
9
import com.vaadin.ui.Button;
10
import com.vaadin.ui.Button.ClickEvent;
11
import com.vaadin.ui.Button.ClickListener;
12
import com.vaadin.ui.CustomComponent;
13
import com.vaadin.ui.Panel;
14
import com.vaadin.ui.TextArea;
15
import com.vaadin.ui.UI;
16
import com.vaadin.ui.VerticalLayout;
17

    
18
import eu.etaxonomy.cdm.vaadin.ui.NavigatorTestUI;
19

    
20
public class NaviTestView extends CustomComponent implements View {
21

    
22
	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
23

    
24
	@AutoGenerated
25
	private VerticalLayout mainLayout;
26
	@AutoGenerated
27
	private Panel panel;
28
	@AutoGenerated
29
	private VerticalLayout panelVLayout;
30
	@AutoGenerated
31
	private Button button;
32
	@AutoGenerated
33
	private TextArea textArea;
34
	/**
35
	 * The constructor should first build the main layout, set the
36
	 * composition root and then do any custom initialization.
37
	 *
38
	 * The constructor will not be automatically regenerated by the
39
	 * visual editor.
40
	 */
41
	public NaviTestView() {
42
		buildMainLayout();
43
		setCompositionRoot(mainLayout);		
44
		button.addClickListener(new ClickListener() {
45

    
46
			@Override
47
			public void buttonClick(ClickEvent event) {
48
				UI.getCurrent().getNavigator().navigateTo(NavigatorTestUI.SECOND_VIEW);
49
				
50
			}
51
			
52
		});
53
		button.setClickShortcut(KeyCode.ENTER, null);
54
	}
55

    
56
	public void setText(String text) {
57
		textArea.setValue(text);
58
	}
59
	
60
	public void removeButton() {
61
		panelVLayout.removeComponent(button);
62
	}
63
	
64
	@Override
65
	public void enter(ViewChangeEvent event) {
66
		// TODO Auto-generated method stub
67
		
68
	}
69

    
70
	@AutoGenerated
71
	private VerticalLayout buildMainLayout() {
72
		// common part: create layout
73
		mainLayout = new VerticalLayout();
74
		mainLayout.setImmediate(false);
75
		mainLayout.setWidth("100%");
76
		mainLayout.setHeight("100%");
77
		mainLayout.setMargin(true);
78
		mainLayout.setSpacing(true);
79
		
80
		// top-level component properties
81
		setWidth("100.0%");
82
		setHeight("100.0%");
83
		
84
		// panel
85
		panel = buildPanel();
86
		mainLayout.addComponent(panel);
87
		mainLayout.setComponentAlignment(panel, new Alignment(48));
88
		
89
		return mainLayout;
90
	}
91

    
92
	@AutoGenerated
93
	private Panel buildPanel() {
94
		// common part: create layout
95
		panel = new Panel();
96
		panel.setImmediate(false);
97
		panel.setWidth("-1px");
98
		panel.setHeight("-1px");
99
		
100
		// panelVLayout
101
		panelVLayout = buildPanelVLayout();
102
		panel.setContent(panelVLayout);
103
		
104
		return panel;
105
	}
106

    
107
	@AutoGenerated
108
	private VerticalLayout buildPanelVLayout() {
109
		// common part: create layout
110
		panelVLayout = new VerticalLayout();
111
		panelVLayout.setImmediate(false);
112
		panelVLayout.setWidth("-1px");
113
		panelVLayout.setHeight("-1px");
114
		panelVLayout.setMargin(true);
115
		panelVLayout.setSpacing(true);
116
		
117
		// textArea
118
		textArea = new TextArea();
119
		textArea.setImmediate(false);
120
		textArea.setWidth("214px");
121
		textArea.setHeight("-1px");
122
		panelVLayout.addComponent(textArea);
123
		panelVLayout.setComponentAlignment(textArea, new Alignment(48));
124
		
125
		// button
126
		button = new Button();
127
		button.setCaption("Click Me to navigate to next view");
128
		button.setImmediate(true);
129
		button.setWidth("-1px");
130
		button.setHeight("-1px");
131
		panelVLayout.addComponent(button);
132
		panelVLayout.setComponentAlignment(button, new Alignment(48));
133
		
134
		return panelVLayout;
135
	}
136

    
137
}
    (1-1/1)