Example usage for com.vaadin.ui Button setCaptionAsHtml

List of usage examples for com.vaadin.ui Button setCaptionAsHtml

Introduction

In this page you can find the example usage for com.vaadin.ui Button setCaptionAsHtml.

Prototype

public void setCaptionAsHtml(boolean captionAsHtml) 

Source Link

Document

Sets whether the caption is rendered as HTML.

Usage

From source file:de.symeda.sormas.ui.task.TaskGridComponent.java

License:Open Source License

public HorizontalLayout createAssigneeFilterBar() {
    HorizontalLayout assigneeFilterLayout = new HorizontalLayout();
    assigneeFilterLayout.setMargin(false);
    assigneeFilterLayout.setSpacing(true);
    assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE);
    assigneeFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    HorizontalLayout buttonFilterLayout = new HorizontalLayout();
    buttonFilterLayout.setSpacing(true);
    {//from www . j  a  v  a2s .  com
        Button allTasks = new Button(I18nProperties.getCaption(Captions.all),
                e -> processAssigneeFilterChange(null));
        CssStyles.style(allTasks, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
        allTasks.setCaptionAsHtml(true);
        buttonFilterLayout.addComponent(allTasks);
        statusButtons.put(allTasks, I18nProperties.getCaption(Captions.all));

        Button officerTasks = new Button(I18nProperties.getCaption(Captions.taskOfficerTasks),
                e -> processAssigneeFilterChange(OFFICER_TASKS));
        initializeStatusButton(officerTasks, buttonFilterLayout, OFFICER_TASKS,
                I18nProperties.getCaption(Captions.taskOfficerTasks));
        Button myTasks = new Button(I18nProperties.getCaption(Captions.taskMyTasks),
                e -> processAssigneeFilterChange(MY_TASKS));
        initializeStatusButton(myTasks, buttonFilterLayout, MY_TASKS,
                I18nProperties.getCaption(Captions.taskMyTasks));

        // Default filter for lab users (that don't have any other role) is "My tasks"
        if ((UserProvider.getCurrent().hasUserRole(UserRole.LAB_USER)
                || UserProvider.getCurrent().hasUserRole(UserRole.EXTERNAL_LAB_USER))
                && UserProvider.getCurrent().getUserRoles().size() == 1) {
            activeStatusButton = myTasks;
        } else {
            activeStatusButton = allTasks;
        }
    }
    assigneeFilterLayout.addComponent(buttonFilterLayout);

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(
                    I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowArchived)));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                tasksView.navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }
        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE);

            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getTaskController()
                        .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    assigneeFilterLayout.addComponent(actionButtonsLayout);
    assigneeFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    assigneeFilterLayout.setExpandRatio(actionButtonsLayout, 1);

    return assigneeFilterLayout;
}

From source file:info.magnolia.vaadin.periscope.Periscope.java

License:Open Source License

private Component createSpeechButton() {
    final Button startStopButton = new Button();
    startStopButton.addStyleName("record-button");
    startStopButton.setCaptionAsHtml(true);
    startStopButton.setCaption("<span class=\"ion-mic-a\"></span>");
    startStopButton.setClickShortcut(ShortcutAction.KeyCode.R, ShortcutAction.ModifierKey.SHIFT,
            ShortcutAction.ModifierKey.ALT);

    final AtomicBoolean isRecording = new AtomicBoolean(false);

    speechRecognizer.addSpeechResultListener(transcript -> {
        input.setValue(transcript);//from  w ww .  j a v  a2  s.  c  o  m
        this.consumeQuery(transcript, true);

        startStopButton.removeStyleName("recording");
        isRecording.set(false);
    });

    startStopButton.addClickListener((Button.ClickListener) event -> {
        if (isRecording.get()) {
            return;
        }

        speechRecognizer.record();

        startStopButton.addStyleName("recording");
        isRecording.set(true);
    });

    final VerticalLayout speechWrapper = new VerticalLayout(startStopButton, speechRecognizer);
    speechWrapper.addStyleName("speech-recognition");
    return speechWrapper;
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * construye una opcin del men// ww w  . j  a va2 s .  c o m
 *
 */
private void addMenu(AbstractArea area, MenuEntry e) {

    Button b = null;

    if (e instanceof AbstractMenu) {
        b = new Button(e.getName(), new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                setAreaActual(area);
                setMenuActual(e);
                Page.getCurrent().open("#!" + getApp().getAreaId(area) + "/" + getApp().getMenuId(e) + "/menu",
                        (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName());
            }
        });
        b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">"
                + ((AbstractMenu) e).getEntries().size() + "</span>");
    }

    if (e instanceof AbstractAction) {

        b = new Button(e.getName(), new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                setAreaActual(area);
                setMenuActual(e);
                ((AbstractAction) e).setModifierPressed(event.isAltKey() || event.isCtrlKey()).run();
            }
        });

    }

    if (b != null) {
        b.setCaptionAsHtml(true);
        b.setPrimaryStyleName(ValoTheme.MENU_ITEM);

        //b.setIcon(testIcon.get());  // sin iconos en el men
        menuItemsLayout.addComponent(b);

        botonesMenu.put(e, b);

    }

}

From source file:org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons.java

License:Open Source License

private Button createFilterButton(final Long id, final String name, final String description,
        final String color, final Object itemId) {
    /**
     * No icon displayed for "NO TAG" button.
     *//*from   ww w .j a v a  2  s  . c o m*/
    final Button button = SPUIComponentProvider.getButton("", name, description, "", false, null,
            SPUITagButtonStyle.class);
    button.setId(createButtonId(name));
    button.setCaptionAsHtml(true);
    if (id != null) {
        // Use button.getCaption() since the caption name is modified
        // according to the length
        // available in UI.
        button.setCaption(prepareFilterButtonCaption(button.getCaption(), color));
    }

    if (!StringUtils.isEmpty(description)) {
        button.setDescription(description);
    } else {
        button.setDescription(name);
    }
    button.setData(id == null ? SPUIDefinitions.NO_TAG_BUTTON_ID : itemId);

    return button;
}

From source file:org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout.java

License:Open Source License

private DragAndDropWrapper createDeleteWrapperLayout() {
    final Button dropToDelete = new Button(i18n.getMessage("label.components.drop.area"));
    dropToDelete.setCaptionAsHtml(true);
    dropToDelete.setIcon(FontAwesome.TRASH_O);
    dropToDelete.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    dropToDelete.addStyleName("drop-to-delete-button");
    dropToDelete.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
    dropToDelete.addStyleName(SPUIStyleDefinitions.DEL_ACTION_BUTTON);
    dropToDelete.addStyleName("delete-icon");

    final DragAndDropWrapper wrapper = new DragAndDropWrapper(dropToDelete);
    wrapper.setStyleName(ValoTheme.BUTTON_PRIMARY);
    wrapper.setId(getDeleteAreaId());//  w  ww . ja  v  a2s.com
    wrapper.setDropHandler(this);
    wrapper.addStyleName("delete-button-border");
    return wrapper;
}

From source file:org.lucidj.iconlist.renderer.IconListRenderer.java

License:Apache License

private void button_caption_wrap(Button b) {
    String caption = b.getCaption();
    int wrap_len = 12;

    if (caption.length() > wrap_len) {
        String[] words = caption.split("\\s");
        String twoliner = "";
        int space_left = 0;
        int lines = 0;
        caption = "";

        // Simple greedy wrapping
        for (String word : words) {
            int len = word.length();

            if (len + 1 > space_left) {
                if (lines++ == 2) {
                    twoliner = caption + "\u2026"; // Unicode ellipsis
                }//  w  w w .jav a  2  s  .c  o m
                caption += caption.isEmpty() ? word : "<br/>" + word;
                space_left = wrap_len - len;
            } else {
                caption += " " + word;
                space_left -= len + 1;
            }
        }
        b.setCaptionAsHtml(true);
        b.setCaption(twoliner.isEmpty() ? caption : twoliner);
    }
    b.setDescription(caption);
}