com.vaadin.ui.Label

Here are the examples of the java api com.vaadin.ui.Label taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

32 Examples 7

19 Source : ProgressIndicatorWindow.java
with Apache License 2.0
from opensecuritycontroller

/**
 * A modal window which shows a busy cursor
 */
@SuppressWarnings("serial")
public clreplaced ProgressIndicatorWindow extends Window {

    private Label currentStatus;

    public ProgressIndicatorWindow() {
        center();
        setVisible(true);
        setResizable(false);
        setDraggable(false);
        setImmediate(true);
        setModal(true);
        setClosable(false);
        setCaption("Loading");
        VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        layout.setWidth("100%");
        this.currentStatus = new Label();
        this.currentStatus.addStyleName(StyleConstants.TEXT_ALIGN_CENTER);
        this.currentStatus.setSizeFull();
        this.currentStatus.setImmediate(true);
        ProgressBar progressBar = new ProgressBar();
        progressBar.setSizeFull();
        progressBar.setIndeterminate(true);
        progressBar.setImmediate(true);
        progressBar.setVisible(true);
        layout.addComponent(progressBar);
        layout.addComponent(this.currentStatus);
        layout.setComponentAlignment(this.currentStatus, Alignment.MIDDLE_CENTER);
        layout.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
        setContent(layout);
    }

    public void updateStatus(String status) {
        this.currentStatus.setCaption(status);
        UI.getCurrent().push();
    }
}

19 Source : DeleteUserWindow.java
with Apache License 2.0
from opensecuritycontroller

@Override
public void populateForm() {
    Label delete = new Label(this.CAPTION + " - " + this.userView.getParentContainer().gereplacedem(this.userView.getParenreplacedemId()).gereplacedemProperty("loginName").getValue().toString());
    this.form.addComponent(delete);
}

19 Source : DeleteManagerConnectorWindow.java
with Apache License 2.0
from opensecuritycontroller

@Override
public void populateForm() {
    Label delete = new Label(this.CAPTION + " - " + this.mcView.getParentContainer().gereplacedem(this.mcView.getParenreplacedemId()).gereplacedemProperty("name").getValue().toString());
    this.form.addComponent(delete);
}

19 Source : DeleteApplianceWindow.java
with Apache License 2.0
from opensecuritycontroller

@Override
public void populateForm() {
    Label delete = new Label(this.CAPTION + " - " + this.applianceView.getParentContainer().gereplacedem(this.applianceView.getParenreplacedemId()).gereplacedemProperty("model").getValue().toString());
    this.form.addComponent(delete);
}

19 Source : DeleteApplianceSoftwareVersionWindow.java
with Apache License 2.0
from opensecuritycontroller

@Override
public void populateForm() {
    Label delete = new Label(this.CAPTION + " - " + this.applianceView.getChildContainer().gereplacedem(this.applianceView.getChildItemId()).gereplacedemProperty("swVersion").getValue().toString());
    this.form.addComponent(delete);
}

19 Source : PageInformationComponent.java
with Apache License 2.0
from opensecuritycontroller

@SuppressWarnings("serial")
public clreplaced PageInformationComponent extends CustomComponent {

    private Label replacedleLabel;

    private Label contentLabel;

    /**
     * By default the visibility is set to false. If replacedle text is specified, visibility is triggered if the text
     * is not null
     */
    public PageInformationComponent() {
        setCompositionRoot(buildMainLayout());
        setVisible(false);
    }

    /**
     * Sets the text to show. If the text preplaceded in is null, it hides the component
     *
     * @param replacedleText
     *            the text or null
     */
    public void setInfoText(String replacedleText, String contentText) {
        this.replacedleLabel.setValue(replacedleText);
        this.contentLabel.setValue(contentText);
        if (replacedleText != null) {
            setVisible(true);
        } else {
            setVisible(false);
        }
    }

    private Component buildMainLayout() {
        // top-level component properties
        setWidth("100.0%");
        setHeight("-1px");
        setStyleName(StyleConstants.PAGE_INFO_COMPONENT_COMMON);
        // infoLabel
        this.replacedleLabel = new Label();
        initializeLabel(this.replacedleLabel);
        final Button collapseButton = new Button();
        collapseButton.setStyleName(Reindeer.BUTTON_LINK);
        collapseButton.setIcon(new ThemeResource(StyleConstants.EXPAND_IMAGE));
        collapseButton.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                PageInformationComponent.this.contentLabel.setVisible(!PageInformationComponent.this.contentLabel.isVisible());
                if (PageInformationComponent.this.contentLabel.isVisible()) {
                    collapseButton.setIcon(new ThemeResource(StyleConstants.COLLAPSE_IMAGE));
                } else {
                    collapseButton.setIcon(new ThemeResource(StyleConstants.EXPAND_IMAGE));
                }
            }
        });
        HorizontalLayout replacedleLayout = new HorizontalLayout();
        initializeLayout(replacedleLayout);
        replacedleLayout.setStyleName(StyleConstants.PAGE_INFO_replacedLE_LAYOUT);
        replacedleLayout.addComponent(this.replacedleLabel);
        replacedleLayout.addComponent(collapseButton);
        replacedleLayout.setExpandRatio(this.replacedleLabel, 1.0f);
        this.contentLabel = new Label();
        initializeLabel(this.contentLabel);
        this.contentLabel.setVisible(false);
        this.contentLabel.setStyleName(StyleConstants.PAGE_INFO_CONTENT_LABEL);
        this.contentLabel.setContentMode(ContentMode.HTML);
        VerticalLayout mainLayout = new VerticalLayout();
        initializeLayout(mainLayout);
        mainLayout.addComponent(replacedleLayout);
        mainLayout.addComponent(this.contentLabel);
        return mainLayout;
    }

    private void initializeLabel(Label label) {
        label.setImmediate(true);
        label.setWidth("100%");
        label.setHeight("-1px");
    }

    private void initializeLayout(AbstractOrderedLayout layout) {
        layout.setImmediate(false);
        layout.setWidth("100%");
        layout.setHeight("-1px");
        layout.setMargin(false);
    }
}

19 Source : LabelField.java
with Apache License 2.0
from ijazfx

/**
 * A field which represents the value always in a label, so it is not editable.
 * <p>
 * The use case is a non editable value in a form, e.g. an id.
 * <p>
 * The creation of the label text can be controlled via a
 * {@link org.vaadin.viritin.fields.CaptionGenerator}.
 *
 * @author Daniel Nordhoff-Vergien
 *
 * @param <T>
 *            the type of the enreplacedy
 */
public clreplaced LabelField<T> extends CustomField<T> {

    private static final long serialVersionUID = -3079451926367430515L;

    private final Clreplaced<T> type;

    private static clreplaced ToStringCaptionGenerator<T> implements CaptionGenerator<T> {

        private static final long serialVersionUID = 1149675718238329960L;

        @Override
        public String getCaption(T option) {
            if (option == null) {
                return "";
            } else {
                return option.toString();
            }
        }
    }

    public LabelField(Clreplaced<T> type, String caption) {
        super();
        this.type = type;
        setCaption(caption);
    }

    private CaptionGenerator<T> captionGenerator = new ToStringCaptionGenerator<>();

    private Label label = new RichText();

    public LabelField(Clreplaced<T> type) {
        super();
        this.type = type;
    }

    public LabelField() {
        this.type = (Clreplaced<T>) String.clreplaced;
    }

    public LabelField<T> withFullWidth() {
        setWidth("100%");
        return this;
    }

    public LabelField<T> withWidth(float width, Unit unit) {
        setWidth(width, unit);
        return this;
    }

    public LabelField<T> withWidth(String width) {
        setWidth(width);
        return this;
    }

    public LabelField<T> withCaption(String caption) {
        setCaption(caption);
        return this;
    }

    public LabelField<T> withValue(T newFieldValue) {
        setValue(newFieldValue);
        return this;
    }

    @Override
    protected Component initContent() {
        updateLabel();
        return label;
    }

    protected void updateLabel() {
        String caption;
        if (captionGenerator != null) {
            caption = captionGenerator.getCaption(getValue());
        } else {
            caption = getValue().toString();
        }
        label.setValue(caption);
    }

    @Override
    protected void setInternalValue(T newValue) {
        super.setInternalValue(newValue);
        updateLabel();
    }

    @Override
    public Clreplaced<? extends T> getType() {
        return type;
    }

    /**
     * Sets the CaptionGenerator for creating the label value.
     *
     * @param captionGenerator the caption generator used to format the displayed property
     */
    public void setCaptionGenerator(CaptionGenerator<T> captionGenerator) {
        this.captionGenerator = captionGenerator;
        updateLabel();
    }

    public void setLabel(Label label) {
        this.label = label;
    }

    public Label getLabel() {
        return label;
    }
}

19 Source : LabelField.java
with Apache License 2.0
from ijazfx

public void setLabel(Label label) {
    this.label = label;
}

19 Source : BadgeWrapper.java
with Apache License 2.0
from ijazfx

public clreplaced BadgeWrapper extends CssLayout {

    public static final String NOTIFICATIONS_BADGE_ID = "notifications";

    private String badgeId;

    private Label badge;

    public BadgeWrapper(Component component) {
        setWidth("100%");
        setPrimaryStyleName("gx-badge-wrapper");
        this.badgeId = null;
        badge = new Label();
        badge.setStyleName("gx-badge");
        clearBadgeValue();
        addComponents(component, badge);
    }

    public void clearBadgeValue() {
        badge.setCaption(null);
        badge.setVisible(false);
    }

    public void badgeUp(int count) {
        if (Strings.isNullOrEmpty(badge.getCaption())) {
            setBadgeValue(count + "");
        } else {
            try {
                String oldValue = badge.getCaption();
                Integer badge = Integer.parseInt(oldValue);
                badge += count;
                setBadgeValue(badge + "");
            } catch (Exception ex) {
                setBadgeValue("1");
            }
        }
    }

    public void setBadgeValue(String value) {
        badge.setCaption(value);
        badge.setVisible(value != null);
    }
}

18 Source : InternalCertReplacementUploader.java
with Apache License 2.0
from opensecuritycontroller

@Override
protected void layout(Panel panel) {
    Label warningLabel = new Label(getString(KEYPAIR_UPLOAD_WARN_RESTART));
    this.verLayout.addComponent(warningLabel);
    super.layout(panel);
}

18 Source : ElementCollectionField.java
with Apache License 2.0
from ijazfx

/**
 * Creates the header for given property. By default a simple Label is used.
 * Override this method to style it or to replace it with something more
 * complex.
 *
 * @param property the property for which header is to be created.
 * @return the component used for header
 */
protected Component createHeader(Object property) {
    Label header = new Label(getPropertyHeader(property.toString()));
    header.setWidthUndefined();
    return header;
}

18 Source : AbstractDashboardView.java
with Apache License 2.0
from ijazfx

@SuppressWarnings("serial")
public abstract clreplaced AbstractDashboardView extends Panel implements TRView {

    public static final String VIEW_NAME = "dashboard";

    public static final String EDIT_ID = "dashboard-edit";

    public static final String replacedLE_ID = "dashboard-replacedle";

    private Label replacedleLabel;

    private CssLayout dashboardPanels;

    private MVerticalLayout root;

    private boolean isBuilt;

    private Component sparkline;

    public AbstractDashboardView() {
        if (!isSpringView()) {
            postConstruct();
        }
    }

    protected boolean isSpringView() {
        return this.getClreplaced().getAnnotation(SpringView.clreplaced) != null;
    }

    @PostConstruct
    private void postConstruct() {
        postInitialize();
    }

    public AbstractDashboardView build() {
        if (!isBuilt) {
            addStyleName(ValoTheme.PANEL_BORDERLESS);
            setSizeFull();
            DashboardEventBus.sessionInstance().register(this);
            root = new MVerticalLayout();
            root.setSizeFull();
            root.addStyleName("dashboard-view");
            setContent(root);
            Responsive.makeResponsive(root);
            root.addComponent(buildHeader());
            List<Spark> sparks = sparks();
            if (sparks != null && !sparks.isEmpty()) {
                sparkline = buildSparkline(sparks);
                root.addComponent(sparkline);
            }
            Component content = buildContent();
            root.addComponent(content);
            root.setExpandRatio(content, 1);
            // All the open sub-windows should be closed whenever the root
            // layout
            // gets clicked.
            root.addLayoutClickListener(new LayoutClickListener() {

                @Override
                public void layoutClick(final LayoutClickEvent event) {
                    DashboardEventBus.sessionInstance().post(new CloseOpenWindowsEvent());
                }
            });
            postBuild();
            isBuilt = true;
        }
        return this;
    }

    private Component buildSparkline(List<Spark> sparks) {
        CssLayout sparksLayout = new CssLayout();
        sparksLayout.addStyleName("sparks");
        sparksLayout.setWidth("100%");
        Responsive.makeResponsive(sparksLayout);
        if (sparks != null) {
            sparks.forEach(spark -> {
                Component sparkComponent = spark.build().getWrappedComponent();
                sparksLayout.addComponent(sparkComponent);
            });
        }
        return sparksLayout;
    }

    protected void postBuild() {
    }

    private Component buildDashlet(final Component content) {
        final CssLayout slot = new CssLayout();
        slot.setWidth("100%");
        slot.addStyleName("dashboard-panel-slot");
        CssLayout card = new CssLayout();
        card.setWidth("100%");
        card.addStyleName(ValoTheme.LAYOUT_CARD);
        MHorizontalLayout toolbar = new MHorizontalLayout();
        toolbar.addStyleName("dashboard-panel-toolbar");
        toolbar.setWidth("100%");
        Label caption = new Label(content.getCaption());
        caption.addStyleName(ValoTheme.LABEL_H4);
        caption.addStyleName(ValoTheme.LABEL_COLORED);
        caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
        content.setCaption(null);
        MenuBar tools = new MenuBar();
        tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
        MenuItem max = tools.addItem("", FontAwesome.EXPAND, new Command() {

            @Override
            public void menuSelected(final MenuItem selectedItem) {
                if (!slot.getStyleName().contains("max")) {
                    selectedItem.setIcon(FontAwesome.COMPRESS);
                    toggleMaximized(slot, true);
                } else {
                    slot.removeStyleName("max");
                    selectedItem.setIcon(FontAwesome.EXPAND);
                    toggleMaximized(slot, false);
                }
            }
        });
        max.setStyleName("icon-only");
        MenuItem root = tools.addItem("", FontAwesome.ELLIPSIS_V, null);
        root.addItem("Configure", new Command() {

            @Override
            public void menuSelected(final MenuItem selectedItem) {
                Notification.show("Not implemented in this demo");
            }
        });
        root.addSeparator();
        root.addItem("Close", new Command() {

            @Override
            public void menuSelected(final MenuItem selectedItem) {
                Notification.show("Not implemented in this demo");
            }
        });
        toolbar.addComponents(caption, tools);
        toolbar.setExpandRatio(caption, 1);
        toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);
        card.addComponents(toolbar, content);
        slot.addComponent(card);
        return slot;
    }

    private Component buildHeader() {
        MHorizontalLayout header = new MHorizontalLayout();
        header.addStyleName("viewheader");
        replacedleLabel = new Label(dashboardreplacedle());
        replacedleLabel.setId(replacedLE_ID);
        replacedleLabel.setSizeUndefined();
        replacedleLabel.addStyleName(ValoTheme.LABEL_H1);
        replacedleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
        header.addComponent(replacedleLabel);
        MHorizontalLayout tools = new MHorizontalLayout();
        tools.addStyleName("toolbar");
        header.addComponent(tools);
        return header;
    }

    protected void postInitialize() {
    }

    protected abstract String dashboardreplacedle();

    private Component buildContent() {
        dashboardPanels = new CssLayout();
        dashboardPanels.addStyleName("dashboard-panels");
        Responsive.makeResponsive(dashboardPanels);
        if (dashlets() != null) {
            dashlets().forEach(dashlet -> {
                dashboardPanels.addComponent(dashlet.getWrappedComponent());
            });
        }
        return dashboardPanels;
    }

    @Override
    public void enter(final ViewChangeEvent event) {
        build();
    }

    private void toggleMaximized(final Component panel, final boolean maximized) {
        for (Iterator<Component> it = root.iterator(); it.hasNext(); ) {
            it.next().setVisible(!maximized);
        }
        dashboardPanels.setVisible(true);
        for (Iterator<Component> it = dashboardPanels.iterator(); it.hasNext(); ) {
            Component c = it.next();
            c.setVisible(!maximized);
        }
        if (maximized) {
            panel.setVisible(true);
            panel.addStyleName("max");
        } else {
            panel.removeStyleName("max");
        }
    }

    public static clreplaced Dashlet {

        private Component wrappedComponent;

        private MPanel contentPanel;

        private MPanel maximizedContentPanel;

        private String[] styles;

        private String replacedle;

        private boolean paddingEnabled;

        public Dashlet(final Component content) {
            this(content, new String[0]);
        }

        public Dashlet(final Component content, String... styles) {
            this.contentPanel = new MPanel(content).withCaption(content.getCaption()).withStyleName(ValoTheme.PANEL_BORDERLESS).withFullWidth().withFullHeight();
            this.styles = styles;
        }

        public Dashlet(final Component content, final Component maximizedContent) {
            this(content, maximizedContent, new String[0]);
        }

        public Dashlet(final Component content, final Component maximizedContent, String... styles) {
            this.contentPanel = new MPanel(content).withCaption(content.getCaption()).withStyleName(ValoTheme.PANEL_BORDERLESS).withFullWidth().withFullHeight();
            this.maximizedContentPanel = new MPanel(maximizedContent).withCaption(maximizedContent.getCaption()).withStyleName(ValoTheme.PANEL_BORDERLESS).withFullWidth().withFullHeight();
            maximizedContentPanel.setVisible(false);
            this.styles = styles;
        }

        public Dashlet withreplacedle(String replacedle) {
            this.replacedle = replacedle;
            return this;
        }

        public Dashlet withStyle(String... styles) {
            this.styles = styles;
            return this;
        }

        public Dashlet withPadding(boolean paddingEnabled) {
            this.paddingEnabled = paddingEnabled;
            return this;
        }

        public Dashlet build() {
            final CssLayout slot = new CssLayout();
            slot.setWidth("100%");
            slot.setStyleName("dashboard-panel-slot");
            CssLayout card = new CssLayout();
            card.setWidth("100%");
            card.setStyleName("dashboard-panel");
            card.addStyleName(ValoTheme.LAYOUT_CARD);
            MHorizontalLayout toolbar = new MHorizontalLayout();
            toolbar.addStyleName("dashboard-panel-toolbar");
            toolbar.setWidth("100%");
            String caption = replacedle != null ? replacedle : contentPanel.getCaption();
            Label captionLabel = new Label(caption);
            captionLabel.addStyleName(ValoTheme.LABEL_H4);
            captionLabel.addStyleName(ValoTheme.LABEL_COLORED);
            captionLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
            // content.setCaption(null);
            MenuBar tools = new MenuBar();
            tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
            MenuItem max = tools.addItem("", FontAwesome.EXPAND, new Command() {

                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (!slot.getStyleName().contains("max")) {
                        selectedItem.setIcon(FontAwesome.COMPRESS);
                        toggleMaximized(slot, true);
                    } else {
                        slot.removeStyleName("max");
                        selectedItem.setIcon(FontAwesome.EXPAND);
                        toggleMaximized(slot, false);
                    }
                }
            });
            max.setStyleName("icon-only");
            MenuItem root = tools.addItem("", FontAwesome.ELLIPSIS_V, null);
            buildMenuItems(root);
            if (!root.hasChildren()) {
                tools.removeItem(root);
            }
            toolbar.addComponents(captionLabel, tools);
            toolbar.setExpandRatio(captionLabel, 1);
            toolbar.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT);
            card.addComponent(toolbar);
            if (contentPanel != null) {
                if (paddingEnabled) {
                    contentPanel.addStyleName("dashlet-content");
                } else {
                    contentPanel.addStyleName("dashlet-content-nopadding");
                }
                card.addComponent(contentPanel);
            }
            if (maximizedContentPanel != null) {
                if (paddingEnabled) {
                    maximizedContentPanel.addStyleName("dashlet-content");
                } else {
                    maximizedContentPanel.addStyleName("dashlet-content-nopadding");
                }
                maximizedContentPanel.addStyleName("dashlet-content");
                card.addComponent(maximizedContentPanel);
            }
            slot.addComponent(card);
            wrappedComponent = slot;
            if (styles != null) {
                for (String style : styles) {
                    wrappedComponent.addStyleName(style);
                }
            }
            return this;
        }

        private void toggleMaximized(final Component panel, final boolean maximized) {
            if (contentPanel != null && maximizedContentPanel != null) {
                contentPanel.setVisible(!maximized);
                maximizedContentPanel.setVisible(maximized);
            }
            for (Iterator<Component> it = panel.getParent().iterator(); it.hasNext(); ) {
                it.next().setVisible(!maximized);
            }
            panel.getParent().setVisible(true);
            for (Iterator<Component> it = panel.getParent().iterator(); it.hasNext(); ) {
                Component c = it.next();
                c.setVisible(!maximized);
            }
            if (maximized) {
                panel.setVisible(true);
                panel.addStyleName("max");
                DashboardEventBus.sessionInstance().post(new DashboardEvent.DashletMaximized(this));
            } else {
                panel.removeStyleName("max");
                DashboardEventBus.sessionInstance().post(new DashboardEvent.DashletMinimized(this));
            }
        }

        protected void buildMenuItems(MenuItem root) {
        // root.addItem("Configure", new Command() {
        // @Override
        // public void menuSelected(final MenuItem selectedItem) {
        // Notification.show("Not implemented in this demo");
        // }
        // });
        // root.addSeparator();
        // root.addItem("Close", new Command() {
        // @Override
        // public void menuSelected(final MenuItem selectedItem) {
        // Notification.show("Not implemented in this demo");
        // }
        // });
        }

        public Component getWrappedComponent() {
            if (wrappedComponent == null) {
                build();
            }
            return wrappedComponent;
        }
    }

    public static clreplaced Spark {

        private Component wrappedComponent;

        private Component content;

        private String[] styles;

        private String replacedle;

        public Spark(final Component content) {
            this(content, new String[0]);
        }

        public Spark(final Component content, String... styles) {
            this.content = content;
            this.styles = styles;
        }

        public Spark withStyle(String... styles) {
            this.styles = styles;
            return this;
        }

        public Spark build() {
            final CssLayout card = new CssLayout();
            card.setWidthUndefined();
            card.setStyleName("spark");
            if (styles != null) {
                for (String style : styles) {
                    card.addStyleName(style);
                }
            }
            card.addComponent(content);
            this.wrappedComponent = card;
            return this;
        }

        public Component getWrappedComponent() {
            if (wrappedComponent == null) {
                build();
            }
            return wrappedComponent;
        }
    }

    protected abstract List<Dashlet> dashlets();

    protected List<Spark> sparks() {
        return null;
    }

    @Subscribe
    public void onDashletMinimized(DashboardEvent.DashletMinimized event) {
        if (sparkline != null) {
            sparkline.setVisible(true);
        }
    }

    @Subscribe
    public void onDashletMaximized(DashboardEvent.DashletMaximized event) {
        if (sparkline != null) {
            sparkline.setVisible(false);
        }
    }
}

17 Source : WindowUtil.java
with Apache License 2.0
from opensecuritycontroller

/**
 * Returns a simple window with the specified caption and content(which can be HTML) with an OK and Cancel Buttons.
 * The cancel button defaults to closing the window.
 * This behaviour can be modified by calling @link {@link VmidcWindow#getComponentModel()} and setting a different
 * listener to the cancel button
 *
 * @param caption
 *            the caption
 * @param content
 *            the content
 * @return the handle to window object
 */
public static VmidcWindow<OkCancelButtonModel> createAlertWindow(String caption, String content) {
    final VmidcWindow<OkCancelButtonModel> alertWindow = new VmidcWindow<OkCancelButtonModel>(new OkCancelButtonModel());
    alertWindow.setCaption(caption);
    alertWindow.getComponentModel().setCancelClickedListener(new ClickListener() {

        /**
         */
        private static final long serialVersionUID = 98853982893459323L;

        @Override
        public void buttonClick(ClickEvent event) {
            alertWindow.close();
        }
    });
    Label contentLabel = new Label(content);
    contentLabel.setContentMode(ContentMode.HTML);
    FormLayout form = new FormLayout();
    form.setMargin(true);
    form.setSizeUndefined();
    form.addComponent(contentLabel);
    alertWindow.setContent(form);
    return alertWindow;
}

17 Source : WindowUtil.java
with Apache License 2.0
from opensecuritycontroller

/**
 * Returns a Delete window using provided Content and Caption.It will have a Force Delete check box along with
 * Cancel and Ok Buttons.
 * The cancel button defaults to closing the window. You can customize behavior of OK,Cancel and Force Delete
 * components by calling @link {@link VmidcWindow#getComponentModel()} and setting a different
 * listener to that component
 *
 * @param caption
 *            Window's Caption
 * @param content
 *            Window's Content
 * @return
 *         Window Object
 */
public static VmidcWindow<OkCancelValidateButtonModel> createValidateWindow(String caption, String content) {
    final VmidcWindow<OkCancelValidateButtonModel> validateWindow = new VmidcWindow<OkCancelValidateButtonModel>(new OkCancelValidateButtonModel());
    validateWindow.setCaption(caption);
    validateWindow.getComponentModel().setCancelClickedListener(new ClickListener() {

        /**
         */
        private static final long serialVersionUID = -1166844267835596823L;

        @Override
        public void buttonClick(ClickEvent event) {
            validateWindow.close();
        }
    });
    Label contentLabel = new Label(content);
    contentLabel.setContentMode(ContentMode.HTML);
    FormLayout form = new FormLayout();
    form.setMargin(true);
    form.setSizeUndefined();
    form.addComponent(contentLabel);
    validateWindow.setContent(form);
    return validateWindow;
}

17 Source : UploadInfoWindow.java
with Apache License 2.0
from opensecuritycontroller

public clreplaced UploadInfoWindow extends Window implements Upload.FailedListener, Upload.SucceededListener, Upload.FinishedListener, Upload.StartedListener, Upload.ProgressListener {

    private static final Logger log = LoggerFactory.getLogger(UploadInfoWindow.clreplaced);

    /**
     */
    private static final long serialVersionUID = 1L;

    private final ProgressBar progressBar = new ProgressBar();

    private final Label bytesProcessed = new Label();

    private final Label file = new Label();

    private final Button cancelButton;

    @SuppressWarnings("serial")
    public UploadInfoWindow(final Upload upload) {
        super("Upload Status");
        addStyleName("upload-info");
        center();
        setResizable(false);
        setDraggable(false);
        setImmediate(true);
        setWidth("320px");
        final FormLayout uploadInfoForm = new FormLayout();
        setContent(uploadInfoForm);
        setModal(true);
        setClosable(false);
        uploadInfoForm.setMargin(true);
        this.file.setCaption("File name");
        uploadInfoForm.addComponent(this.file);
        this.progressBar.setCaption("Progress");
        this.progressBar.addStyleName("progressBar");
        this.progressBar.setVisible(false);
        uploadInfoForm.addComponent(this.progressBar);
        this.bytesProcessed.setVisible(false);
        uploadInfoForm.addComponent(this.bytesProcessed);
        upload.addStartedListener(this);
        upload.addProgressListener(this);
        upload.addFailedListener(this);
        upload.addSucceededListener(this);
        upload.addFinishedListener(this);
        upload.setErrorHandler(new ErrorHandler() {

            @Override
            public void error(com.vaadin.server.ErrorEvent event) {
                log.warn("Upload failed: " + event.getThrowable().getMessage());
            }
        });
        this.cancelButton = new Button("Cancel");
        this.cancelButton.addClickListener(new Button.ClickListener() {

            /**
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                upload.interruptUpload();
            }
        });
        this.cancelButton.setVisible(false);
        this.cancelButton.setStyleName("small");
        uploadInfoForm.addComponent(this.cancelButton);
    }

    @Override
    public void uploadStarted(final StartedEvent event) {
        this.progressBar.setValue(0f);
        this.progressBar.setVisible(true);
        this.bytesProcessed.setVisible(true);
        this.file.setValue(event.getFilename());
        this.cancelButton.setVisible(true);
    }

    @Override
    public void uploadFailed(final FailedEvent event) {
        close();
    }

    @Override
    public void uploadSucceeded(final SucceededEvent event) {
        close();
    }

    @Override
    public void uploadFinished(final FinishedEvent event) {
        this.progressBar.setVisible(false);
        this.bytesProcessed.setVisible(false);
        this.cancelButton.setVisible(false);
    }

    @Override
    public void updateProgress(final long readBytes, final long contentLength) {
        if (contentLength == -1) {
            this.progressBar.setIndeterminate(true);
        } else {
            this.progressBar.setIndeterminate(false);
            this.progressBar.setValue(new Float(readBytes / (float) contentLength));
            this.bytesProcessed.setValue("Processed: " + WindowUtil.convertBytesToReadableSize(readBytes) + " of " + WindowUtil.convertBytesToReadableSize(contentLength));
        }
    }
}

17 Source : AbstractDashboardPanel.java
with Apache License 2.0
from ijazfx

@SuppressWarnings("serial")
public abstract clreplaced AbstractDashboardPanel extends MVerticalLayout {

    private MHorizontalLayout toolbar;

    private MVerticalLayout componentLayout;

    private MHorizontalLayout header;

    private Label replacedleLabel;

    private MButton notificationButton;

    private BadgeWrapper notificationBadge;

    public AbstractDashboardPanel() {
        if (!isSpringComponent()) {
            postConstruct();
        }
    }

    protected boolean isSpringComponent() {
        return this.getClreplaced().getAnnotation(SpringComponent.clreplaced) != null || this.getClreplaced().getAnnotation(SpringView.clreplaced) != null;
    }

    @PostConstruct
    private void postConstruct() {
        setSizeFull();
        setStyleName("dashboard-panel");
        Component header = buildHeader();
        super.addComponent(header);
        super.setExpandRatio(header, 0.0f);
        header.setVisible(shouldShowHeader());
        componentLayout = buildComponentLayout();
        super.addComponent(componentLayout);
        super.setExpandRatio(componentLayout, 1.0f);
        postInitialize();
    }

    protected boolean shouldShowHeader() {
        return false;
    }

    protected boolean shouldShowActionButton() {
        return false;
    }

    private MVerticalLayout buildComponentLayout() {
        MVerticalLayout layout = new MVerticalLayout().withMargin(true).withSpacing(true);
        layout.setSizeFull();
        layout.addStyleName("viewlayout");
        return layout;
    }

    private Component buildHeader() {
        header = new MHorizontalLayout();
        header.setDefaultComponentAlignment(Alignment.TOP_LEFT);
        header.addStyleName("viewheader");
        Responsive.makeResponsive(header);
        replacedleLabel = new Label(localizedSingularValue(panelreplacedle()));
        replacedleLabel.setWidth("100%");
        replacedleLabel.addStyleName(ValoTheme.LABEL_H1);
        replacedleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
        header.addComponent(replacedleLabel);
        Component toolbar = buildToolbar();
        header.addComponent(toolbar);
        header.setWidth("100%");
        header.setExpandRatio(replacedleLabel, 1);
        return header;
    }

    private Component buildToolbar() {
        toolbar = new MHorizontalLayout();
        toolbar.addStyleName("toolbar");
        toolbar.setVisible(true);
        notificationButton = new MButton().withStyleName(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_BORDERLESS).withIcon(FontAwesome.BELL);
        notificationButton.addClickListener(event -> {
            UI.getCurrent().getNavigator().navigateTo("notifications");
        });
        notificationBadge = new BadgeWrapper(notificationButton);
        notificationBadge.setId(BadgeWrapper.NOTIFICATIONS_BADGE_ID);
        GxAuthenticatedUser user = DashboardUtils.getLoggedInUser();
        if (user != null && user.getUnreadNotificationCount() > 0) {
            notificationBadge.setBadgeValue(user.getUnreadNotificationCount() + "");
        } else {
            notificationBadge.clearBadgeValue();
        }
        toolbar.addComponent(notificationBadge);
        toolbar.setComponentAlignment(notificationBadge, Alignment.MIDDLE_RIGHT);
        notificationBadge.setVisible(shouldShowNotifications());
        DashboardEventBus.sessionInstance().register(this);
        return toolbar;
    }

    protected boolean shouldShowNotifications() {
        return true;
    }

    protected abstract String panelreplacedle();

    protected abstract void postInitialize();

    protected void addButtons(Button... buttons) {
        toolbar.setVisible(true);
        for (Button button : buttons) {
            toolbar.addComponent(button);
        }
    }

    protected void addComponentsToToolbar(Component... components) {
        toolbar.setVisible(true);
        for (Component component : components) {
            toolbar.addComponent(component);
        }
    }

    public void addComponentWithExpandRatio(Component component, float expandRatio) {
        componentLayout.addComponent(component);
        componentLayout.setExpandRatio(component, expandRatio);
    }

    @Override
    public void addComponent(Component component) {
        componentLayout.addComponent(component);
    }

    protected String localizedSingularValue(String key) {
        return VaadinUtils.localizedSingularValue(key);
    }

    protected String localizedPluralValue(String key) {
        return VaadinUtils.localizedSingularValue(key);
    }

    protected void localizeRecursively(Component component) {
        VaadinUtils.localizeRecursively(component);
    }

    protected String localizedSingularValue(Locale locale, String key) {
        return VaadinUtils.localizedSingularValue(key);
    }

    protected String localizedPluralValue(Locale locale, String key) {
        return VaadinUtils.localizedSingularValue(key);
    }

    protected void localizeRecursively(Locale locale, Component component) {
        VaadinUtils.localizeRecursively(component);
    }

    public void setPanelreplacedle(String panelreplacedle) {
        if (replacedleLabel != null) {
            if (panelreplacedle != null)
                replacedleLabel.setValue(panelreplacedle);
            else
                replacedleLabel.setValue(panelreplacedle());
        }
    }

    @Subscribe
    public void onBadgeUpdateEvent(DashboardEvent.BadgeUpdateEvent event) {
        if (event.getBadgeId().equals(notificationBadge.getId())) {
            UI ui = DashboardUtils.getCurrentUI(event.getUser());
            if (ui != null && ui.isAttached()) {
                ui.access(() -> {
                    String value = event.getBadgeValue();
                    if (value == null || value.equals("0")) {
                        notificationBadge.clearBadgeValue();
                    } else {
                        notificationBadge.setBadgeValue(value);
                    }
                    ui.push();
                });
            }
        }
    }
}

16 Source : PageInformationComponent.java
with Apache License 2.0
from opensecuritycontroller

private void initializeLabel(Label label) {
    label.setImmediate(true);
    label.setWidth("100%");
    label.setHeight("-1px");
}

16 Source : CRUDBaseView.java
with Apache License 2.0
from opensecuritycontroller

// Returns ToolBar UI
private HorizontalLayout createParentToolbar(List<ToolbarButtons> parentCRUDButtons) {
    this.parentToolbar = new HorizontalLayout();
    this.parentToolbar.addStyleName("buttonToolbar");
    this.parentToolbar.setWidth("100%");
    Label filler = new Label();
    for (ToolbarButtons button : parentCRUDButtons) {
        if (button == null) {
            continue;
        }
        if (button.getAlignment() == HorizontalAlignment.RIGHT && this.parentToolbar.getComponentIndex(filler) == -1) {
            this.parentToolbar.addComponent(filler);
            this.parentToolbar.setExpandRatio(filler, 1.0f);
        }
        Button buttonComponent = ViewUtil.buildToolbarButton(this.parentToolbar, button, this.buttonClickListener);
        if (button == ToolbarButtons.ADD || button == ToolbarButtons.SHOW_PENDING_ACKNOWLEDGE_ALERTS || button == ToolbarButtons.SHOW_ALL_ALERTS) {
            buttonComponent.setEnabled(true);
        }
    // TODO: Future. Later use the following code to support Parent Table drill down
    }
    if (this.parentToolbar.getComponentIndex(filler) == -1) {
        this.parentToolbar.addComponent(filler);
        this.parentToolbar.setExpandRatio(filler, 1.0f);
    }
    return this.parentToolbar;
}

16 Source : GxMeetingHost.java
with Apache License 2.0
from ijazfx

private Component getRoomComponent() {
    roomPanel = new CardCollectionPanel<GxMeetingUser>() {

        @Override
        protected void layoutCard(MPanel cardPanel, GxMeetingUser item) {
            cardPanel.setId(getVideoTagId(item.getUserId()) + "_container");
            cardPanel.setStyleName("hidden");
            cardPanel.removeStyleName("card-item");
            if (!item.getUserId().equals(user.getUserId())) {
                GxMeetingUserCardComponent component = new GxMeetingUserCardComponent(item);
                cardPanel.setContent(component.rebuild());
                cardPanel.setWidth("200px");
            }
        }
    };
    roomPanel.setSizeFull();
    CssLayout roomLayout = new CssLayout();
    roomLayout.setSizeFull();
    roomLayout.addComponent(roomPanel);
    Label localVideo = new Label();
    localVideo.setWidthUndefined();
    localVideo.setContentMode(ContentMode.HTML);
    String localVideoHtml = "<video id=\"localVideo\" width=\"200px\" height=\"150px\" autoplay muted></video>";
    localVideo.setValue(localVideoHtml);
    roomLayout.addComponent(localVideo);
    meetingContainer = new BeanItemContainer<>(GxMeetingUser.clreplaced);
    roomPanel.setCollectionContainer(meetingContainer);
    return roomLayout;
}

15 Source : WindowUtil.java
with Apache License 2.0
from opensecuritycontroller

/**
 * Returns a Delete window using provided Content and Caption.It will have a Force Delete check box along with
 * Cancel and Ok Buttons.
 * The cancel button defaults to closing the window. You can customize behavior of OK,Cancel and Force Delete
 * components by calling @link {@link VmidcWindow#getComponentModel()} and setting a different
 * listener to that component
 *
 * @param caption
 *            Window's Caption
 * @param content
 *            Window's Content
 * @return
 *         Window Object
 */
public static VmidcWindow<OkCancelForceDeleteModel> createForceDeleteWindow(String caption, String content) {
    final VmidcWindow<OkCancelForceDeleteModel> deleteWindow = new VmidcWindow<OkCancelForceDeleteModel>(new OkCancelForceDeleteModel());
    // Creating the Force Delete Warning Window
    ValueChangeListener forceDeleteValueChangeListener = new ValueChangeListener() {

        /**
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            OkCancelForceDeleteModel forceDeleteModel = deleteWindow.getComponentModel();
            if (forceDeleteModel.getForceDeleteCheckBoxValue()) {
                final VmidcWindow<OkCancelButtonModel> alertWindow = WindowUtil.createAlertWindow("Force Delete", VmidcMessages.getString(VmidcMessages_.FORCE_DELETE_WARNING));
                ViewUtil.addWindow(alertWindow);
                alertWindow.getComponentModel().setOkClickedListener(new ClickListener() {

                    /**
                     */
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        alertWindow.close();
                    }
                });
                alertWindow.getComponentModel().setCancelClickedListener(new ClickListener() {

                    /**
                     */
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        OkCancelForceDeleteModel forceDeleteModel = deleteWindow.getComponentModel();
                        forceDeleteModel.setForceDeleteValue(false);
                        alertWindow.close();
                    }
                });
            }
        }
    };
    if (deleteWindow.getComponentModel() instanceof OkCancelForceDeleteModel) {
        OkCancelForceDeleteModel forceDeleteModel = deleteWindow.getComponentModel();
        forceDeleteModel.setForceDeleteValueChangeListener(forceDeleteValueChangeListener);
    }
    // Creating the Force Delete Window
    deleteWindow.setCaption(caption);
    deleteWindow.getComponentModel().setCancelClickedListener(new ClickListener() {

        /**
         */
        private static final long serialVersionUID = -651121508110914210L;

        @Override
        public void buttonClick(ClickEvent event) {
            deleteWindow.close();
        }
    });
    Label contentLabel = new Label(content);
    contentLabel.setContentMode(ContentMode.HTML);
    FormLayout form = new FormLayout();
    form.setMargin(true);
    form.setSizeUndefined();
    form.addComponent(contentLabel);
    deleteWindow.setContent(form);
    return deleteWindow;
}

15 Source : VaadinAbstractLoginComponent.java
with Apache License 2.0
from ijazfx

private Component buildLabels() {
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    if (dashboardSetup().loginFormLogo() != null) {
        Image logoImage = dashboardSetup().loginFormLogo();
        logoImage.addStyleName("logo-image");
        logoImage.setHeight(logoImageHeight());
        labels.addComponent(logoImage);
    } else {
        Label welcome = new Label("Welcome");
        welcome.setSizeUndefined();
        welcome.addStyleName(ValoTheme.LABEL_H4);
        welcome.addStyleName(ValoTheme.LABEL_COLORED);
        labels.addComponent(welcome);
    }
    Label replacedle = new Label(dashboardSetup().loginFormreplacedle());
    replacedle.setSizeUndefined();
    replacedle.addStyleName(ValoTheme.LABEL_H3);
    labels.addComponent(replacedle);
    return labels;
}

14 Source : GxMeetingUserCardComponent.java
with Apache License 2.0
from ijazfx

@Override
protected void addComponentToLayout(MVerticalLayout layout, GxMeetingUser user) {
    Label video = new Label();
    video.setPrimaryStyleName("remotePeerStream");
    video.setContentMode(ContentMode.HTML);
    String html = "<span clreplaced=\"remotePeerreplacedle\">" + user.getFullName() + "</span>" + "<video id=\"" + getVideoTagId(user.getUserId()) + "\" width=\"200px\" height=\"150px\" autoplay></video>";
    video.setValue(html);
    layout.add(video);
}

14 Source : GxMeetingClient.java
with Apache License 2.0
from ijazfx

private Component getRoomComponent() {
    CssLayout roomLayout = new CssLayout();
    roomLayout.setSizeFull();
    Label hostVideo = new Label();
    hostVideo.setSizeFull();
    hostVideo.setContentMode(ContentMode.HTML);
    String hostVideoHtml = "<video id=\"remoteVideo\" width=\"100%\" height=\"100%\" autoplay></video>";
    hostVideo.setValue(hostVideoHtml);
    roomLayout.addComponent(hostVideo);
    Label localVideo = new Label();
    localVideo.setWidthUndefined();
    localVideo.setContentMode(ContentMode.HTML);
    String localVideoHtml = "<video id=\"localVideo\" width=\"200px\" height=\"150px\" autoplay muted></video>";
    localVideo.setValue(localVideoHtml);
    roomLayout.addComponent(localVideo);
    return roomLayout;
}

12 Source : MainUI.java
with Apache License 2.0
from opensecuritycontroller

private void buildHeader() {
    this.header.addStyleName("branding");
    this.header.addStyleName("header");
    // product name and information
    Label product = new Label(this.server.getProductName() + "<br> <span clreplaced='product-version'> Version: " + this.server.getVersionStr() + "</span>", ContentMode.HTML);
    product.addStyleName("product-label");
    product.setSizeUndefined();
    HorizontalLayout brandingLayout = new HorizontalLayout();
    brandingLayout.addStyleName("header-content");
    brandingLayout.addComponent(new Image(null, new ThemeResource("img/logo.png")));
    brandingLayout.addComponent(product);
    // creating home help button
    Button mainHelpButton = new Button();
    mainHelpButton.setImmediate(true);
    mainHelpButton.setStyleName(Reindeer.BUTTON_LINK);
    mainHelpButton.setDescription("Help");
    mainHelpButton.setIcon(new ThemeResource("img/headerHelp.png"));
    mainHelpButton.addClickListener(new ClickListener() {

        private String guid = "";

        @Override
        public void buttonClick(ClickEvent event) {
            ViewUtil.showHelpBrowserWindow(this.guid);
        }
    });
    HorizontalLayout helpLayout = new HorizontalLayout();
    helpLayout.addComponent(mainHelpButton);
    helpLayout.addStyleName("homeHelpButton");
    // Adding current user to header
    Label user = new Label("User: " + getCurrent().getSession().getAttribute("user").toString());
    // header banner
    HorizontalLayout userlayout = new HorizontalLayout();
    userlayout.addStyleName("user");
    userlayout.addComponent(user);
    // create Logout button next to user
    userlayout.addComponent(buildLogout());
    // Adding help button to the user layout next to logout button
    userlayout.addComponent(helpLayout);
    this.header.setWidth("100%");
    this.header.setHeight("65px");
    this.header.addComponent(brandingLayout);
    this.header.addComponent(userlayout);
    this.header.setExpandRatio(brandingLayout, 1);
    this.root.addComponent(this.header);
}

12 Source : JobsArchiverPanel.java
with Apache License 2.0
from opensecuritycontroller

public clreplaced JobsArchiverPanel extends CustomComponent {

    private static final long serialVersionUID = 1L;

    private static final Logger log = LoggerFactory.getLogger(JobsArchiverPanel.clreplaced);

    private VerticalLayout container = null;

    private Label triggerLabel = new Label("Triggering:");

    private String lastTriggerLabelText = "Last Triggered Timestamp: ";

    private Label lastTriggerTimestampLabel = null;

    private OptionGroup freqOpt = null;

    private CheckBox autoSchedChkBox = null;

    private Label thresholdLabel = new Label("Archive Jobs/Alerts older than the last: ");

    private OptionGroup thresOpt = null;

    private IntStepper archiveThreshold = null;

    private Panel panel = new Panel();

    private Button updateButton = null;

    private Button onDemandButton = null;

    private final String TEXT_FREQ_OPT_WEEKLY = "Weekly";

    private final String ID_FREQ_OPT_WEEKLY = "WEEKLY";

    private final String TEXT_FREQ_OPT_MONTHLY = "Monthly";

    private final String ID_FREQ_OPT_MONTHLY = "MONTHLY";

    private final String TEXT_THRES_OPT_MONTHS = "Months";

    private final String ID_THRES_OPT_MONTHS = "MONTHS";

    private final String TEXT_THRES_OPT_YEARS = "Years";

    private final String ID_THRES_OPT_YEARS = "YEARS";

    private final String UPDATE_SCHED_BUTTON_LABEL = "Update Schedule";

    private final String ON_DEMAND_BUTTON_LABEL = "On Demand";

    private String ARCHIVE_STYLE = "archive-options";

    private JobsArchiveDto dto;

    private final ArchiveLayout parentLayout;

    private final ArchiveServiceApi archiveService;

    private final GetJobsArchiveServiceApi getJobsArchiveService;

    private final UpdateJobsArchiveServiceApi updateJobsArchiveService;

    public JobsArchiverPanel(ArchiveLayout parentLayout, ArchiveServiceApi archiveService, GetJobsArchiveServiceApi getJobsArchiveService, UpdateJobsArchiveServiceApi updateJobsArchiveService) {
        super();
        this.parentLayout = parentLayout;
        this.archiveService = archiveService;
        this.getJobsArchiveService = getJobsArchiveService;
        this.updateJobsArchiveService = updateJobsArchiveService;
        try {
            this.dto = populateJobsArchiveDto().getDto();
            // create frequency layout component
            VerticalLayout freqLayout = new VerticalLayout();
            freqLayout.addComponent(createLastTriggerLabel());
            freqLayout.addComponent(createAutoSchedCheckBox());
            freqLayout.addComponent(createFrequencyOptionGroup());
            freqLayout.addStyleName(StyleConstants.COMPONENT_SPACING);
            freqLayout.setSpacing(true);
            // create triggering panel component
            Panel triggerPanel = new Panel();
            triggerPanel.setWidth("50%");
            triggerPanel.setContent(freqLayout);
            // create threshold layout component
            HorizontalLayout thresLayout = new HorizontalLayout();
            thresLayout.addComponent(this.thresholdLabel);
            thresLayout.addComponent(createArchiveThreshold());
            thresLayout.addComponent(createThresholdOptionGroup());
            thresLayout.addStyleName(StyleConstants.COMPONENT_SPACING);
            thresLayout.setSpacing(true);
            // add all components to container
            this.container = new VerticalLayout();
            this.container.addStyleName(StyleConstants.COMPONENT_SPACING);
            this.container.addComponent(this.triggerLabel);
            this.container.addComponent(triggerPanel);
            this.container.addComponent(thresLayout);
            // add buttons component to container
            HorizontalLayout buttonLayout = new HorizontalLayout();
            buttonLayout.addComponent(createOnDemandScheduleButton());
            buttonLayout.addComponent(createUpdateScheduleButton());
            buttonLayout.setSpacing(true);
            this.container.addComponent(buttonLayout);
            // add container to root panel
            this.container.setSpacing(true);
            this.panel.setWidth("100%");
            this.panel.setContent(this.container);
            setCompositionRoot(this.panel);
        } catch (Exception ex) {
            log.error("Failed to init archiver panel", ex);
        }
    }

    private BaseDtoResponse<JobsArchiveDto> populateJobsArchiveDto() throws Exception {
        BaseDtoResponse<JobsArchiveDto> res = this.getJobsArchiveService.dispatch(new Request() {
        });
        return res;
    }

    Integer convertToPositiveIntegerOrNull(String strVal) {
        Integer val = null;
        try {
            val = Integer.parseInt(strVal);
        } catch (Exception ex) {
            return null;
        }
        if (val < 0) {
            return null;
        }
        return val;
    }

    private Label createLastTriggerLabel() {
        String lastTriggerTimestamp = "None";
        this.lastTriggerTimestampLabel = new Label();
        if (this.dto != null && this.dto.getLastTriggerTimestamp() != null) {
            lastTriggerTimestamp = this.dto.getLastTriggerTimestamp().toString();
        }
        this.lastTriggerTimestampLabel.setCaption(this.lastTriggerLabelText + lastTriggerTimestamp);
        return this.lastTriggerTimestampLabel;
    }

    private CheckBox createAutoSchedCheckBox() {
        this.autoSchedChkBox = new CheckBox("Auto Schedule");
        this.autoSchedChkBox.setImmediate(true);
        if (this.dto == null) {
            this.autoSchedChkBox.setValue(false);
        } else {
            boolean isAuto = this.dto.getAutoSchedule();
            this.autoSchedChkBox.setValue(isAuto);
        }
        return this.autoSchedChkBox;
    }

    private OptionGroup createFrequencyOptionGroup() {
        this.freqOpt = new OptionGroup();
        this.freqOpt.addItem(this.ID_FREQ_OPT_WEEKLY);
        this.freqOpt.sereplacedemCaption(this.ID_FREQ_OPT_WEEKLY, this.TEXT_FREQ_OPT_WEEKLY);
        this.freqOpt.addItem(this.ID_FREQ_OPT_MONTHLY);
        this.freqOpt.sereplacedemCaption(this.ID_FREQ_OPT_MONTHLY, this.TEXT_FREQ_OPT_MONTHLY);
        this.freqOpt.addStyleName(this.ARCHIVE_STYLE);
        this.freqOpt.setImmediate(true);
        if (this.dto == null) {
            this.freqOpt.select(this.ID_FREQ_OPT_MONTHLY);
        } else {
            this.freqOpt.select(this.dto.getFrequency());
        }
        return this.freqOpt;
    }

    private IntStepper createArchiveThreshold() {
        this.archiveThreshold = new IntStepper();
        if (this.dto == null) {
            this.archiveThreshold.setValue(3);
        } else {
            this.archiveThreshold.setValue(this.dto.getThresholdValue());
        }
        this.archiveThreshold.setStepAmount(1);
        this.archiveThreshold.setMinValue(1);
        this.archiveThreshold.setRequiredError("Archive threshold cannot be empty");
        return this.archiveThreshold;
    }

    private OptionGroup createThresholdOptionGroup() {
        this.thresOpt = new OptionGroup();
        this.thresOpt.addItem(this.ID_THRES_OPT_MONTHS);
        this.thresOpt.sereplacedemCaption(this.ID_THRES_OPT_MONTHS, this.TEXT_THRES_OPT_MONTHS);
        this.thresOpt.addItem(this.ID_THRES_OPT_YEARS);
        this.thresOpt.sereplacedemCaption(this.ID_THRES_OPT_YEARS, this.TEXT_THRES_OPT_YEARS);
        this.thresOpt.addStyleName(this.ARCHIVE_STYLE);
        this.thresOpt.setImmediate(true);
        if (this.dto == null) {
            this.thresOpt.select(this.ID_THRES_OPT_MONTHS);
        } else {
            this.thresOpt.select(this.dto.getThresholdUnit());
        }
        return this.thresOpt;
    }

    @SuppressWarnings("serial")
    private Button createUpdateScheduleButton() {
        this.updateButton = new Button(this.UPDATE_SCHED_BUTTON_LABEL);
        this.updateButton.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    BaseRequest<JobsArchiveDto> request = new BaseRequest<JobsArchiveDto>();
                    request.setDto(new JobsArchiveDto());
                    request.getDto().setId(JobsArchiverPanel.this.dto.getId());
                    request.getDto().setAutoSchedule(JobsArchiverPanel.this.autoSchedChkBox.getValue());
                    request.getDto().setFrequency(JobsArchiverPanel.this.freqOpt.getValue().toString());
                    request.getDto().setThresholdUnit(JobsArchiverPanel.this.thresOpt.getValue().toString());
                    request.getDto().setThresholdValue(JobsArchiverPanel.this.archiveThreshold.getValue());
                    JobsArchiverPanel.this.updateJobsArchiveService.dispatch(request);
                    JobsArchiverPanel.this.archiveService.maybeScheduleArchiveJob();
                    ViewUtil.iscNotification(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_JOBSARCHIVE_SUBMIT_SUCCESSFUL), null, Notification.Type.TRAY_NOTIFICATION);
                } catch (Exception e) {
                    log.error("Fail to update archive schedule", e);
                    ViewUtil.iscNotification(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_JOBSARCHIVE_SUBMIT_FAILED), Notification.Type.ERROR_MESSAGE);
                }
            }
        });
        return this.updateButton;
    }

    @SuppressWarnings("serial")
    private Button createOnDemandScheduleButton() {
        this.onDemandButton = new Button(this.ON_DEMAND_BUTTON_LABEL);
        this.onDemandButton.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                JobsArchiverPanel.this.onDemandButton.setEnabled(false);
                ViewUtil.iscNotification("On demand archiving started in the background", null, Notification.Type.TRAY_NOTIFICATION);
                Thread thread = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        BaseRequest<JobsArchiveDto> request = new BaseRequest<JobsArchiveDto>();
                        request.setDto(new JobsArchiveDto());
                        request.getDto().setFrequency(JobsArchiverPanel.this.freqOpt.getValue().toString());
                        request.getDto().setThresholdUnit(JobsArchiverPanel.this.thresOpt.getValue().toString());
                        request.getDto().setThresholdValue(JobsArchiverPanel.this.archiveThreshold.getValue());
                        try {
                            JobsArchiverPanel.this.archiveService.dispatch(request);
                            ViewUtil.iscNotification(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_JOBSARCHIVE_ONDEMAND_SUCCESSFUL), null, Notification.Type.TRAY_NOTIFICATION);
                            JobsArchiverPanel.this.parentLayout.buildArchivesTable();
                            JobsArchiverPanel.this.onDemandButton.setEnabled(true);
                        } catch (Exception e) {
                            ViewUtil.showError("Error starting on demand archiving", e);
                        }
                    }
                });
                thread.start();
            }
        });
        return this.onDemandButton;
    }
}

12 Source : GiftcardUI.java
with Apache License 2.0
from AxonIQ

@Override
protected void init(VaadinRequest vaadinRequest) {
    HorizontalLayout commandBar = new HorizontalLayout();
    commandBar.setWidth("100%");
    commandBar.addComponents(issuePanel(), bulkIssuePanel(), redeemPanel());
    Grid summary = summaryGrid();
    HorizontalLayout statusBar = new HorizontalLayout();
    Label statusLabel = new Label("Status");
    statusBar.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    statusBar.addComponent(statusLabel);
    statusBar.setWidth("100%");
    VerticalLayout layout = new VerticalLayout();
    layout.addComponents(commandBar, summary, statusBar);
    layout.setExpandRatio(summary, 1f);
    layout.setSizeFull();
    setContent(layout);
    UI.getCurrent().setErrorHandler(new DefaultErrorHandler() {

        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            Throwable cause = event.getThrowable();
            logger.error("an error occured", cause);
            while (cause.getCause() != null) {
                cause = cause.getCause();
            }
            Notification.show("Error", cause.getMessage(), Notification.Type.ERROR_MESSAGE);
        }
    });
    setPollInterval(1000);
    int offset = Page.getCurrent().getWebBrowser().getTimezoneOffset();
    // offset is in milliseconds
    ZoneOffset instantOffset = ZoneOffset.ofTotalSeconds(offset / 1000);
    StatusUpdater statusUpdater = new StatusUpdater(statusLabel, instantOffset);
    updaterThread = Executors.newScheduledThreadPool(1).scheduleAtFixedRate(statusUpdater, 1000, 5000, TimeUnit.MILLISECONDS);
    setPollInterval(1000);
    getSession().getSession().setMaxInactiveInterval(30);
    addDetachListener((DetachListener) detachEvent -> {
        logger.warn("Closing UI");
        updaterThread.cancel(true);
    });
}

10 Source : VmidcWindow.java
with Apache License 2.0
from opensecuritycontroller

private HorizontalLayout submitLayout() {
    // creating generic button layout
    HorizontalLayout submitLayout = new HorizontalLayout();
    submitLayout.setMargin(true);
    submitLayout.setSpacing(true);
    submitLayout.setWidth("100%");
    submitLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
    submitLayout.setSizeFull();
    Label fillItem = new Label();
    submitLayout.addComponent(fillItem);
    submitLayout.setExpandRatio(fillItem, 1);
    List<Component> components = this.componentModel.getComponents();
    for (Component comp : components) {
        submitLayout.addComponent(comp);
    }
    return submitLayout;
}

10 Source : LoginComponent.java
with Apache License 2.0
from ijazfx

private Component buildLabels() {
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    if (dashboardSetup.loginFormLogo() != null) {
        Image logoImage = dashboardSetup.loginFormLogo();
        logoImage.addStyleName("logo-image");
        logoImage.setHeight(logoImageHeight());
        labels.addComponent(logoImage);
    } else {
        Label welcome = new Label("Welcome");
        welcome.setSizeUndefined();
        welcome.addStyleName(ValoTheme.LABEL_H4);
        welcome.addStyleName(ValoTheme.LABEL_COLORED);
        labels.addComponent(welcome);
    }
    Label replacedle = new Label(dashboardSetup.loginFormreplacedle());
    replacedle.setSizeUndefined();
    replacedle.addStyleName(ValoTheme.LABEL_H3);
    labels.addComponent(replacedle);
    return labels;
}

9 Source : InlineTextEditor.java
with Apache License 2.0
from ijazfx

private Component buildReadOnly() {
    final Label text = new Label(property);
    text.setContentMode(ContentMode.HTML);
    Button editButton = new Button(FontAwesome.EDIT);
    editButton.addStyleName(ValoTheme.BUTTON_SMALL);
    editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    editButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            setCompositionRoot(editor);
        }
    });
    CssLayout result = new CssLayout(text, editButton);
    result.addStyleName("text-editor");
    result.setSizeFull();
    result.addLayoutClickListener(new LayoutClickListener() {

        @Override
        public void layoutClick(final LayoutClickEvent event) {
            if (event.getChildComponent() == text && event.isDoubleClick()) {
                setCompositionRoot(editor);
            }
        }
    });
    return result;
}

8 Source : ViewUtil.java
with Apache License 2.0
from opensecuritycontroller

/**
 * @param caption
 *            Caption Text Representing Header
 * @param guid
 *            Help GUID for caller view
 * @return
 *         Horizontal Layout containing Caption text and Help button
 */
public static HorizontalLayout createSubHeader(String caption, String guid) {
    HorizontalLayout subHeader = new HorizontalLayout();
    subHeader.setWidth("100%");
    subHeader.setHeight("35px");
    subHeader.setSpacing(true);
    subHeader.addStyleName("toolbar");
    final Label replacedle = new Label(caption);
    replacedle.setSizeUndefined();
    subHeader.addComponent(replacedle);
    subHeader.setComponentAlignment(replacedle, Alignment.MIDDLE_LEFT);
    subHeader.setExpandRatio(replacedle, 1);
    // create help button if we have some GUID else do not add this button
    if (guid != null) {
        Button helpButton = new Button();
        helpButton.setImmediate(true);
        helpButton.setStyleName(Reindeer.BUTTON_LINK);
        helpButton.setDescription("Help");
        helpButton.setIcon(new ThemeResource("img/Help.png"));
        subHeader.addComponent(helpButton);
        helpButton.addClickListener(new HelpButtonListener(guid));
    }
    return subHeader;
}

0 Source : MainUI.java
with Apache License 2.0
from opensecuritycontroller

private void buildLoginForm() {
    addStyleName("login");
    this.loginLayout = new VerticalLayout();
    this.loginLayout.setSizeFull();
    this.loginLayout.addStyleName("login-layout");
    this.root.addComponent(this.loginLayout);
    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");
    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");
    labels.setMargin(true);
    labels.addStyleName("labels");
    loginPanel.addComponent(labels);
    Label product = new Label(this.server.getProductName());
    product.addStyleName("product-label-login");
    labels.addComponent(new Image(null, new ThemeResource("img/logo.png")));
    labels.addComponent(product);
    labels.setComponentAlignment(product, Alignment.MIDDLE_LEFT);
    labels.setExpandRatio(product, 1);
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");
    final TextField username = new TextField("Login ID");
    username.focus();
    username.setImmediate(true);
    username.setRequired(true);
    username.setRequiredError("Login ID or Preplacedword cannot be empty");
    fields.addComponent(username);
    final PreplacedwordField preplacedword = new PreplacedwordField("Preplacedword");
    preplacedword.setRequired(true);
    preplacedword.setImmediate(true);
    preplacedword.setRequiredError("Login ID or Preplacedword cannot be empty");
    fields.addComponent(preplacedword);
    final Button login = new Button("Log In");
    login.addStyleName("default");
    fields.addComponent(login);
    fields.setComponentAlignment(login, Alignment.BOTTOM_LEFT);
    final ShortcutListener enter = new ShortcutListener("Login", KeyCode.ENTER, null) {

        @Override
        public void handleAction(Object sender, Object target) {
            login.click();
        }
    };
    login.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                username.validate();
                preplacedword.validate();
                LoginRequest request = new LoginRequest();
                request.setLoginName(username.getValue().trim());
                request.setPreplacedword(preplacedword.getValue());
                LoginResponse response = MainUI.this.loginService.dispatch(request);
                if (response != null) {
                    login.removeShortcutListener(enter);
                    if (getSession() != null) {
                        getSession().setAttribute("user", username.getValue());
                    }
                    MainUI.this.root.removeComponent(MainUI.this.loginLayout);
                    buildMainView();
                }
            } catch (EmptyValueException e) {
                ViewUtil.iscNotification(e.getMessage() + ".", Notification.Type.ERROR_MESSAGE);
                username.focus();
            } catch (Exception e) {
                username.focus();
                ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    login.addShortcutListener(enter);
    loginPanel.addComponent(fields);
    this.loginLayout.addComponent(loginPanel);
    this.loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

0 Source : AbstractDashboardView.java
with Apache License 2.0
from ijazfx

private Component buildDashlet(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");
    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);
    MHorizontalLayout toolbar = new MHorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");
    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);
    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max = tools.addItem("", FontAwesome.EXPAND, new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            if (!slot.getStyleName().contains("max")) {
                selectedItem.setIcon(FontAwesome.COMPRESS);
                toggleMaximized(slot, true);
            } else {
                slot.removeStyleName("max");
                selectedItem.setIcon(FontAwesome.EXPAND);
                toggleMaximized(slot, false);
            }
        }
    });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", FontAwesome.ELLIPSIS_V, null);
    root.addItem("Configure", new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    root.addSeparator();
    root.addItem("Close", new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);
    card.addComponents(toolbar, content);
    slot.addComponent(card);
    return slot;
}