Example usage for com.vaadin.shared.ui ContentMode PREFORMATTED

List of usage examples for com.vaadin.shared.ui ContentMode PREFORMATTED

Introduction

In this page you can find the example usage for com.vaadin.shared.ui ContentMode PREFORMATTED.

Prototype

ContentMode PREFORMATTED

To view the source code for com.vaadin.shared.ui ContentMode PREFORMATTED.

Click Source Link

Document

Textual values are displayed as preformatted text.

Usage

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VDragCaptionProvider.java

License:Apache License

public Element getDragCaptionElement(Widget w) {
    ComponentConnector component = Util.findConnectorFor(w);
    DDLayoutState state = ((DragAndDropAwareState) root.getState()).getDragAndDropState();
    DragCaptionInfo dci = state.dragCaptions.get(component);

    Document document = Document.get();

    Element dragCaptionImage = document.createDivElement();
    Element dragCaption = document.createSpanElement();

    String dragCaptionText = dci.caption;
    if (dragCaptionText != null) {
        if (dci.contentMode == ContentMode.TEXT) {
            dragCaption.setInnerText(dragCaptionText);
        } else if (dci.contentMode == ContentMode.HTML) {
            dragCaption.setInnerHTML(dragCaptionText);
        } else if (dci.contentMode == ContentMode.PREFORMATTED) {
            PreElement preElement = document.createPreElement();
            preElement.setInnerText(dragCaptionText);
            dragCaption.appendChild(preElement);
        }//from  w  ww  . j a v a 2 s .c o m
    }

    String dragIconKey = state.dragCaptions.get(component).iconKey;
    if (dragIconKey != null) {
        String resourceUrl = root.getResourceUrl(dragIconKey);
        Icon icon = component.getConnection().getIcon(resourceUrl);
        dragCaptionImage.appendChild(icon.getElement());
    }

    dragCaptionImage.appendChild(dragCaption);

    return dragCaptionImage;
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropDragCaptionDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();/*w  w  w  .ja  v  a2 s  .  c  om*/
    layout.setMargin(true);
    layout.setSpacing(true);

    DDPanel panel1 = new DDPanel("Source");
    panel1.setWidth("200px");
    panel1.setHeight("200px");
    panel1.setDragMode(LayoutDragMode.CLONE);
    panel1.setDropHandler(new DefaultPanelDropHandler());

    panel1.setDragCaptionProvider(component -> new DragCaption(
            "<u>Custom drag caption:</u><br/>" + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE,
            ContentMode.HTML));

    layout.addComponent(panel1);

    Button content = new Button("Drag me!");
    content.setSizeFull();
    panel1.setContent(content);

    DDPanel panel2 = new DDPanel("Destination");
    panel2.setWidth("200px");
    panel2.setHeight("200px");
    panel2.setDragMode(LayoutDragMode.CLONE);
    panel2.setDropHandler(new DefaultPanelDropHandler());

    panel2.setDragCaptionProvider(component -> new DragCaption(
            "Drag caption goes back! " + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE));

    layout.addComponent(panel2);

    // end-source
    Label label = new Label("In this demo you can drag the button."
            + "\nYou will see custom drag caption(with icon) provided by DragCaptionProvider");
    label.setContentMode(ContentMode.PREFORMATTED);
    return new VerticalLayout(label, layout);
}

From source file:org.jpos.qi.system.AboutView.java

License:Open Source License

public AboutView() {
    super();/*from  ww  w . ja v a 2  s.com*/
    Label html = new Label(Q2.getVersionString());
    html.setContentMode(ContentMode.PREFORMATTED);
    setMargin(true);
    addComponent(html);
}

From source file:org.jpos.qi.system.CommandRunner.java

License:Open Source License

@Override
public void setConfiguration(Element e) throws ConfigurationException {
    Element ce = e.getChild("command");
    if (ce != null)
        command = ce.getTextTrim();//  w w w  . j ava2 s  .c om

    if (command != null) {
        String viewStyle = e.getAttributeValue("viewStyle");
        String objectStyle = e.getAttributeValue("commandStyle");
        boolean clearScreen = "true".equalsIgnoreCase(e.getAttributeValue("clearScreen"));
        repeat = getRepeat(e);
        label = clearScreen ? new Label() : new XLabel();
        label.setContentMode(ContentMode.PREFORMATTED);
        if (viewStyle != null)
            addStyleName(viewStyle);
        if (objectStyle != null)
            label.addStyleName(objectStyle);
        addComponent(label);
    }
}

From source file:org.jpos.qi.system.LogListenerView.java

License:Open Source License

@SuppressWarnings("unchecked")
public LogListenerView() {
    super();/*  w w  w. ja v  a 2 s  . c om*/
    qi = QI.getQI();
    sp = (Space<String, LogEvent>) SpaceFactory.getSpace();
    key = toString();
    pause = new Button();
    pause.setIcon(VaadinIcons.PAUSE);
    pause.addStyleName(ValoTheme.BUTTON_TINY);
    pause.addStyleName("qi-float-right");
    pause.addClickListener((Button.ClickListener) event -> togglePause());
    realms = new TreeMap<>();
    realmsLayout = new VerticalLayout();

    addStyleName("console");
    label = new XLabel();
    label.setStyleName("console");
    label.setWidth("100%");
    label.setContentMode(ContentMode.PREFORMATTED);

    addComponent(createSlider());
    addComponent(label);
    addComponent(pause);

    qi.addDetachListener(this);
    VaadinService.getCurrent().addSessionDestroyListener(this);
}

From source file:org.jpos.qi.system.ObjectView.java

License:Open Source License

@Override
public void setConfiguration(Element e) throws ConfigurationException {
    objConfig = e.getChild(getChildElementName());
    if (objConfig != null) {
        String viewStyle = e.getAttributeValue("viewStyle");
        String objectStyle = e.getAttributeValue("objectStyle");
        boolean clearScreen = "true".equalsIgnoreCase(e.getAttributeValue("clearScreen"));
        repeat = getRepeat(e);/*from ww  w. jav  a 2s . c  om*/
        label = clearScreen ? new Label() : new XLabel();
        label.setContentMode(ContentMode.PREFORMATTED);
        if (viewStyle != null)
            addStyleName(viewStyle);
        if (objectStyle != null)
            label.addStyleName(objectStyle);
        addComponent(label);
    }
}

From source file:org.openthinclient.web.pkgmngr.ui.view.PackageDetailsView.java

public PackageDetailsView() {

    IMessageConveyor mc = new MessageConveyor(UI.getCurrent().getLocale());

    dependencies.setDataProvider(DataProvider.ofCollection(Collections.emptyList()));
    dependencies.setSelectionMode(Grid.SelectionMode.NONE);
    dependencies.addColumn(AbstractPackageItem::getName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    dependencies.addColumn(AbstractPackageItem::getDisplayVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    dependencies.setHeight("39px");

    dependencies.setStyleGenerator(new StyleGenerator<AbstractPackageItem>() {
        @Override//from  ww w.j av a 2s. c  o  m
        public String apply(AbstractPackageItem item) {
            if (item != null && item instanceof MissingPackageItem) {
                return "highlight-red";
            }
            return null;
        }
    });

    // conflicts
    conflicts.setDataProvider(DataProvider.ofCollection(Collections.emptyList()));
    conflicts.setSelectionMode(Grid.SelectionMode.NONE);
    conflicts.addColumn(AbstractPackageItem::getName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    conflicts.addColumn(AbstractPackageItem::getDisplayVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    conflicts.setHeight("39px");

    // provides
    provides.setDataProvider(DataProvider.ofCollection(Collections.emptyList()));
    provides.setSelectionMode(Grid.SelectionMode.NONE);
    provides.addColumn(AbstractPackageItem::getName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    provides.addColumn(AbstractPackageItem::getDisplayVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    provides.setHeight("39px");

    this.changeLog.setContentMode(ContentMode.PREFORMATTED);
    this.acceptLicenseCheckbox
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_LICENSE_CHECKBOX_CAPTION));

    // unfortunately this is the only way to access tabs defined in a design file.
    // we have to use the component instance to access the tab.

    // first the main tab sheet
    mainTabSheet.getTab(tabComponentCommon)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_COMMON_CAPTION));
    tabRelations = mainTabSheet.getTab(tabComponentRelations);
    tabRelations.setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_CAPTION));
    mainTabSheet.getTab(tabComponentChangelog)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_CHANGELOG_CAPTION));
    mainTabSheet.getTab(tabComponentLicense)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_LICENSE_CAPTION));

    // second the relations tab sheet.
    tabDependencies = relationsTabSheet.getTab(dependencies);
    tabDependencies.setCaption(
            mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_DEPENDENCIES_CAPTION));
    tabProvides = relationsTabSheet.getTab(provides);
    tabProvides
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_PROVIDES_CAPTION));
    tabConflicts = relationsTabSheet.getTab(conflicts);
    tabConflicts.setCaption(
            mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_CONFLICTS_CAPTION));

    updateRelationsTabs();
}