1
|
package eu.etaxonomy.cdm.vaadin.component;
|
2
|
|
3
|
import java.io.Serializable;
|
4
|
|
5
|
import com.vaadin.server.ThemeResource;
|
6
|
import com.vaadin.ui.Alignment;
|
7
|
import com.vaadin.ui.Button;
|
8
|
import com.vaadin.ui.HorizontalLayout;
|
9
|
|
10
|
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
|
11
|
|
12
|
public class HorizontalToolbar extends HorizontalLayout implements Serializable{
|
13
|
|
14
|
|
15
|
/**
|
16
|
* automatically generated ID
|
17
|
*/
|
18
|
private static final long serialVersionUID = 5344340511582993289L;
|
19
|
|
20
|
|
21
|
private final Button editButton = new Button("Edit");
|
22
|
|
23
|
private final Button saveButton = new Button("Save");
|
24
|
|
25
|
private final Button detailButton = new Button("Detail");
|
26
|
|
27
|
private final Button distributionSettingsButton = new Button("Distribution Settings");
|
28
|
|
29
|
private final Button settingsButton = new Button("Settings");
|
30
|
|
31
|
// private final Authentication authentication;
|
32
|
// private ExcelExporter exporter = new ExcelExporter();
|
33
|
|
34
|
public HorizontalToolbar() {
|
35
|
// authentication = (Authentication) VaadinSession.getCurrent().getAttribute("authentication");
|
36
|
// CdmVaadinAuthentication authentication = (CdmVaadinAuthentication) VaadinSession.getCurrent().getAttribute(CdmVaadinAuthentication.KEY);
|
37
|
// this.authentication = authentication.getAuthentication(Page.getCurrent().getLocation(), VaadinServlet.getCurrent().getServletContext().getContextPath());
|
38
|
init();
|
39
|
}
|
40
|
|
41
|
public void init() {
|
42
|
if(UserHelper.fromSession().userIsAutheticated()){
|
43
|
setMargin(true);
|
44
|
setSpacing(true);
|
45
|
setStyleName("toolbar");
|
46
|
setWidth("100%");
|
47
|
setHeight("75px");
|
48
|
|
49
|
// addComponent(editButton);
|
50
|
// addComponent(saveButton);
|
51
|
addComponent(detailButton);
|
52
|
// addComponent(exporter);
|
53
|
|
54
|
// exporter.setCaption("Export");
|
55
|
// exporter.setIcon(new ThemeResource("icons/32/document-xsl.png"));
|
56
|
|
57
|
saveButton.setIcon(new ThemeResource("icons/32/document-save.png"));
|
58
|
editButton.setIcon(new ThemeResource("icons/32/document-edit.png"));
|
59
|
detailButton.setIcon(new ThemeResource("icons/32/document-txt.png"));
|
60
|
settingsButton.setIcon(new ThemeResource("icons/32/settings_1.png"));
|
61
|
distributionSettingsButton.setIcon(new ThemeResource("icons/32/settings_1.png"));
|
62
|
|
63
|
// SecurityContext context = (SecurityContext)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("context");
|
64
|
// SecurityContext context = SecurityContextHolder.getContext();
|
65
|
|
66
|
HorizontalLayout rightLayout = new HorizontalLayout();
|
67
|
rightLayout.addComponent(settingsButton);
|
68
|
rightLayout.addComponent(distributionSettingsButton);
|
69
|
|
70
|
addComponent(rightLayout);
|
71
|
setComponentAlignment(rightLayout, Alignment.MIDDLE_RIGHT);
|
72
|
setExpandRatio(rightLayout, 1);
|
73
|
}
|
74
|
}
|
75
|
|
76
|
public Button getSettingsButton(){
|
77
|
return settingsButton;
|
78
|
}
|
79
|
|
80
|
public Button getDistributionSettingsButton() {
|
81
|
return distributionSettingsButton;
|
82
|
}
|
83
|
|
84
|
public Button getEditButton() {
|
85
|
return editButton;
|
86
|
}
|
87
|
|
88
|
public Button getSaveButton() {
|
89
|
return saveButton;
|
90
|
}
|
91
|
|
92
|
public Button getDetailButton() {
|
93
|
return detailButton;
|
94
|
}
|
95
|
}
|