aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/demo/sampler/CodeLabel.java
blob: fba8a8ac9fa84b019a095bfa09e3b6b61834005f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.vaadin.demo.sampler;

import com.vaadin.ui.Label;

public class CodeLabel extends Label {

    private static final String TAG = "codelabel";

    public CodeLabel() {
        setContentMode(CONTENT_PREFORMATTED);
    }

    public CodeLabel(String content) {
        super(content, CONTENT_PREFORMATTED);
    }

    @Override
    public String getTag() {
        return TAG;
    }

    @Override
    public void setContentMode(int contentMode) {
        if (contentMode != CONTENT_PREFORMATTED) {
            throw new UnsupportedOperationException(
                    "Only preformatted content supported");
        }
        super.setContentMode(CONTENT_PREFORMATTED);
    }

}