1
|
/**
|
2
|
* Copyright (C) 2015 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.component;
|
10
|
|
11
|
import com.vaadin.annotations.AutoGenerated;
|
12
|
import com.vaadin.ui.Alignment;
|
13
|
import com.vaadin.ui.CustomComponent;
|
14
|
import com.vaadin.ui.HorizontalLayout;
|
15
|
import com.vaadin.ui.Label;
|
16
|
import com.vaadin.ui.ProgressBar;
|
17
|
|
18
|
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinUtilities;
|
19
|
|
20
|
/**
|
21
|
* @author cmathew
|
22
|
* @since 15 Apr 2015
|
23
|
*
|
24
|
*/
|
25
|
public class CdmProgressComponent extends CustomComponent {
|
26
|
|
27
|
/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
|
28
|
|
29
|
@AutoGenerated
|
30
|
private HorizontalLayout mainLayout;
|
31
|
@AutoGenerated
|
32
|
private ProgressBar progressIndicator;
|
33
|
@AutoGenerated
|
34
|
private Label progressLabel;
|
35
|
/**
|
36
|
* The constructor should first build the main layout, set the
|
37
|
* composition root and then do any custom initialization.
|
38
|
*
|
39
|
* The constructor will not be automatically regenerated by the
|
40
|
* visual editor.
|
41
|
*/
|
42
|
public CdmProgressComponent() {
|
43
|
buildMainLayout();
|
44
|
setCompositionRoot(mainLayout);
|
45
|
mainLayout.setVisible(false);
|
46
|
}
|
47
|
|
48
|
public void setProgress(String progressText) {
|
49
|
mainLayout.setVisible(true);
|
50
|
CdmVaadinUtilities.setEnabled(mainLayout, true, null);
|
51
|
progressLabel.setValue(progressText);
|
52
|
progressIndicator.setIndeterminate(true);
|
53
|
}
|
54
|
|
55
|
public void setProgress(String progressText, float progress) {
|
56
|
mainLayout.setVisible(true);
|
57
|
CdmVaadinUtilities.setEnabled(mainLayout, true, null);
|
58
|
progressLabel.setValue(progressText);
|
59
|
progressIndicator.setValue(progress);
|
60
|
if(progress == 1.0) {
|
61
|
mainLayout.setVisible(false);
|
62
|
}
|
63
|
}
|
64
|
|
65
|
@AutoGenerated
|
66
|
private HorizontalLayout buildMainLayout() {
|
67
|
// common part: create layout
|
68
|
mainLayout = new HorizontalLayout();
|
69
|
mainLayout.setImmediate(false);
|
70
|
mainLayout.setWidth("240px");
|
71
|
mainLayout.setHeight("29px");
|
72
|
mainLayout.setMargin(false);
|
73
|
mainLayout.setSpacing(true);
|
74
|
|
75
|
// top-level component properties
|
76
|
setWidth("240px");
|
77
|
setHeight("29px");
|
78
|
|
79
|
// progressLabel
|
80
|
progressLabel = new Label();
|
81
|
progressLabel.setImmediate(false);
|
82
|
progressLabel.setWidth("-1px");
|
83
|
progressLabel.setHeight("-1px");
|
84
|
progressLabel.setValue("Label");
|
85
|
mainLayout.addComponent(progressLabel);
|
86
|
mainLayout.setComponentAlignment(progressLabel, new Alignment(33));
|
87
|
|
88
|
// progressIndicator
|
89
|
progressIndicator = new ProgressBar();
|
90
|
progressIndicator.setImmediate(false);
|
91
|
progressIndicator.setWidth("-1px");
|
92
|
progressIndicator.setHeight("-1px");
|
93
|
mainLayout.addComponent(progressIndicator);
|
94
|
mainLayout.setExpandRatio(progressIndicator, 1.0f);
|
95
|
mainLayout.setComponentAlignment(progressIndicator, new Alignment(48));
|
96
|
|
97
|
return mainLayout;
|
98
|
}
|
99
|
|
100
|
}
|