/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.ui.apps.user;

import org.opencms.main.OpenCms;
import org.opencms.security.CmsDefaultPasswordGenerator;
import org.opencms.security.I_CmsPasswordGenerator;
import org.opencms.ui.CmsVaadinUtils;
import org.opencms.ui.apps.Messages;
import org.opencms.ui.components.CmsBasicDialog;
import org.opencms.ui.components.CmsButtonFormRow;
import org.opencms.ui.components.OpenCmsTheme;

import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;

/**
 * Dialog to generate a random password.<p>
 */
public class CmsGeneratePasswordDialog extends CmsBasicDialog {

    /**Vaadin serial id. */
    private static final long serialVersionUID = -7522845215366141986L;

    /**
     * public constructor.<p>
     *
     * @param passwordFetcher fetcher to send result to
     * @param close runnable
     */
    public CmsGeneratePasswordDialog(final I_CmsPasswordFetcher passwordFetcher, final Runnable close) {

        setWidth("500px");
        FormLayout layout = new FormLayout();
        layout.addStyleName(OpenCmsTheme.FORMLAYOUT_WORKPLACE_MAIN);
        layout.setMargin(true);
        layout.setSpacing(true);
        //        layout.setWidth("400px");
        final TextField passwordField = new TextField();
        passwordField.setValue(getRandomPassword());
        CmsButtonFormRow<TextField> row = new CmsButtonFormRow<TextField>(
            passwordField,
            VaadinIcons.REFRESH,
            new Runnable() {

                public void run() {

                    passwordField.setValue(getRandomPassword());
                }
            },
            CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_GEN_PASSWORD_REFRESH_0));
        Label label = new Label(CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_GEN_PASSWORD_TEXT_0));
        label.setWidth("100%");
        layout.addComponent(label);
        row.setWidth("100%");
        layout.addComponent(row);
        setContent(layout);
        Button closeButton = new Button(CmsVaadinUtils.messageCancel());
        closeButton.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = -8994698147835117427L;

            public void buttonClick(ClickEvent event) {

                close.run();

            }
        });

        Button okButton = new Button(CmsVaadinUtils.messageOk());
        okButton.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = -1375411076842792728L;

            public void buttonClick(ClickEvent event) {

                passwordFetcher.fetchPassword(passwordField.getValue());
                close.run();
            }
        });
        addButton(okButton);
        addButton(closeButton);
    }

    /**
     * Gets random password from password handler.<p>
     *
     * @return String
     */
    public static String getRandomPassword() {

        if (OpenCms.getPasswordHandler() instanceof I_CmsPasswordGenerator) {
            return ((I_CmsPasswordGenerator)OpenCms.getPasswordHandler()).getRandomPassword();
        }
        return CmsDefaultPasswordGenerator.getRandomPWD();
    }
}

@@ -1669,16 +1669,19 @@
 .vaadin.
+v7.
 ui.Label
@@ -1700,16 +1700,19 @@
 .vaadin.
+v7.
 ui.TextF
@@ -2249,24 +2249,57 @@
 rmLayout();%0A
+        layout.setWidth(%22100%25%22);%0A
         layo
@@ -2966,24 +2966,25 @@
 EFRESH_0));%0A
+%0A
         Labe

Fix small UI issue related to vaadin8