aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/util/Log.java
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com/vaadin/tests/util/Log.java')
-rw-r--r--uitest/src/com/vaadin/tests/util/Log.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/util/Log.java b/uitest/src/com/vaadin/tests/util/Log.java
new file mode 100644
index 0000000000..7a58a4c80c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/util/Log.java
@@ -0,0 +1,63 @@
+package com.vaadin.tests.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class Log extends VerticalLayout {
+ List<Label> eventLabels = new ArrayList<Label>();
+ private boolean numberLogRows = true;
+ private int nextLogNr = 1;
+
+ public Log(int nr) {
+ for (int i = 0; i < nr; i++) {
+ Label l = createEventLabel();
+ l.setId("Log_row_" + i);
+ eventLabels.add(l);
+ addComponent(l);
+ }
+ setId("Log");
+ setCaption("Events:");
+ }
+
+ /**
+ * Clears the rows and reset the row number to zero.
+ */
+ public Log clear() {
+ for (Label l : eventLabels) {
+ l.setValue("&nbsp;");
+ }
+ nextLogNr = 0;
+ return this;
+ }
+
+ public Log log(String event) {
+ int nr = eventLabels.size();
+ for (int i = nr - 1; i > 0; i--) {
+ eventLabels.get(i).setValue(eventLabels.get(i - 1).getValue());
+ }
+ String msg = event;
+ if (numberLogRows) {
+ msg = nextLogNr + ". " + msg;
+ nextLogNr++;
+ }
+ eventLabels.get(0).setValue(msg);
+ System.out.println(event);
+ return this;
+ }
+
+ private Label createEventLabel() {
+ Label l = new Label("&nbsp;", ContentMode.XHTML);
+ l.setWidth(null);
+ return l;
+ }
+
+ public Log setNumberLogRows(boolean numberLogRows) {
+ this.numberLogRows = numberLogRows;
+ return this;
+ }
+
+}