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