Example usage for com.vaadin.ui Alignment BOTTOM_LEFT

List of usage examples for com.vaadin.ui Alignment BOTTOM_LEFT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment BOTTOM_LEFT.

Prototype

Alignment BOTTOM_LEFT

To view the source code for com.vaadin.ui Alignment BOTTOM_LEFT.

Click Source Link

Usage

From source file:org.hip.vif.forum.groups.ui.AbstractQuestionView.java

License:Open Source License

private VerticalLayout createQuestionLayout(final Question inQuestion, final String inTitle,
        final HorizontalLayout inTitleView, final CodeList inCodeList, final IMessages inMessages) {
    final VerticalLayout outLayout = new VerticalLayout();
    outLayout.setWidth("100%"); //$NON-NLS-1$

    // question title and state
    inTitleView.setStyleName("vif-title-bar"); //$NON-NLS-1$

    final Label lLabel = new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-title", inTitle), //$NON-NLS-1$
            ContentMode.HTML);//from  ww w. j  a v a 2  s . co  m
    inTitleView.addComponent(RiplaViewHelper.makeUndefinedWidth(lLabel)); //$NON-NLS-1$
    final String lState = getState(BeanWrapperHelper.getString(QuestionHome.KEY_STATE, inQuestion), inCodeList,
            inMessages);
    final Label lNote = new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-note", lState), //$NON-NLS-1$
            ContentMode.HTML);
    lNote.setWidth("100%"); //$NON-NLS-1$
    inTitleView.addComponent(RiplaViewHelper.makeUndefinedWidth(lNote));
    inTitleView.setComponentAlignment(lNote, Alignment.BOTTOM_LEFT);
    inTitleView.setExpandRatio(lLabel, 1);
    inTitleView.setExpandRatio(lNote, 6);

    outLayout.addComponent(inTitleView);

    addProperQuestion(inQuestion, inMessages, outLayout);
    return outLayout;
}

From source file:org.hip.vif.web.layout.VIFFooter.java

License:Open Source License

private void populateLayout(final HorizontalLayout inLayout, final String inFooterText) {
    final Label lFooterText = new Label(inFooterText, ContentMode.HTML); //$NON-NLS-1$
    inLayout.addComponent(lFooterText);//from   w  ww  . j av  a  2  s.c  om
    inLayout.setComponentAlignment(lFooterText, Alignment.BOTTOM_LEFT);
}

From source file:org.icrisat.gdms.ui.GDMSMain.java

void buildMainView() {
    _mainLayout.setSizeFull();//from   www  . j av a  2 s  .co m

    _lblLoginMessage = new Label("");
    _lblLoginMessage.setStyleName(Reindeer.LABEL_H2);

    HorizontalLayout topMenuLayout = getTopMenu();
    CssLayout headerImageLayout = getHeader();

    VerticalLayout topLayout = new VerticalLayout();
    topLayout.addComponent(headerImageLayout);
    topLayout.addComponent(topMenuLayout);
    topLayout.setComponentAlignment(topMenuLayout, Alignment.TOP_RIGHT);
    topLayout.addComponent(_lblLoginMessage);
    topLayout.setComponentAlignment(_lblLoginMessage, Alignment.TOP_RIGHT);
    topLayout.setMargin(false, true, true, true);
    _mainLayout.addComponent(topLayout);

    CssLayout mainCSSLayout = new CssLayout();
    mainCSSLayout.setMargin(false, true, true, true);
    mainCSSLayout.setSizeFull();

    _tabsheet = new TabSheet();
    _tabsheet.setSizeFull();

    mainCSSLayout.addComponent(_tabsheet);
    _mainLayout.addComponent(mainCSSLayout);
    _mainLayout.setExpandRatio(mainCSSLayout, 1);

    buildWelcomeScreen = buildWelcomeScreen();
    buildAboutScreen = buildAboutScreen();
    buildUploadDataWindow = new UploadComponent(this);
    buildUploadDataWindow.setImmediate(true);
    buildUploadDataWindow.setEnabled(false);
    buildUploadDataWindow.addListener(this);
    buildUploadDataWindow.setWidth("100%");

    buildRetrieveWindow = new RetrieveComponent(this);
    buildRetrieveWindow.setImmediate(true);
    buildRetrieveWindow.setEnabled(false);
    buildRetrieveWindow.addListener(this);
    buildRetrieveWindow.setWidth("100%");

    buildDeleteWindow = new DeleteComponent(this);
    buildDeleteWindow.setImmediate(true);
    buildDeleteWindow.setEnabled(false);
    buildDeleteWindow.addListener(this);
    buildRetrieveWindow.setWidth("100%");

    _tabsheet.addComponent(buildWelcomeScreen);
    _tabsheet.addComponent(buildAboutScreen);
    _tabsheet.addComponent(buildUploadDataWindow);
    _tabsheet.addComponent(buildRetrieveWindow);
    _tabsheet.addComponent(buildDeleteWindow);

    /*if (null == _gdmsModel.getLoggedInUser()){
       buildUploadDataWindow.setEnabled(false);
       buildRetrieveWindow.setEnabled(false);
       buildDeleteWindow.setEnabled(false);
    } else {
       buildUploadDataWindow.setEnabled(true);
       buildRetrieveWindow.setEnabled(true);
       buildDeleteWindow.setEnabled(true);
    }*/

    if (null == _gdmsModel.getLoggedInUser()) {
        _tabsheet.getTab(1).setEnabled(false);
        _tabsheet.getTab(2).setEnabled(false);
        _tabsheet.getTab(3).setEnabled(false);
    } else {
        _tabsheet.getTab(1).setEnabled(true);
        _tabsheet.getTab(2).setEnabled(true);
        _tabsheet.getTab(3).setEnabled(true);
    }

    _tabsheet.addListener(new SelectedTabChangeListener() {

        private static final long serialVersionUID = 1L;

        public void selectedTabChange(SelectedTabChangeEvent event) {
            User loggedInUser = _gdmsModel.getLoggedInUser();
            //System.out.println("loggedInUser:"+loggedInUser);
            if (null == loggedInUser) {
                if (!(buildWelcomeScreen == _tabsheet.getSelectedTab())) {
                    getMainWindow().showNotification("Please login inorder to Upload, Retrieve or Delete data.",
                            Notification.TYPE_HUMANIZED_MESSAGE);
                    return;
                }
            } else {
                if (event.getTabSheet().getSelectedTab().getCaption() == "Upload") {
                    updateUploadTabComponent();
                } else if (event.getTabSheet().getSelectedTab().getCaption() == "Retrieve") {
                    updateRetrieveTabComponent();
                } else if (event.getTabSheet().getSelectedTab().getCaption() == "View") {
                    updateDeleteTabComponent();
                }
            }

        }

    });

    CssLayout bottomPanelLayout = getBottomPanelLayout();
    VerticalLayout bottomContactLayout = new VerticalLayout();
    bottomContactLayout.addComponent(bottomPanelLayout);
    bottomContactLayout.setComponentAlignment(bottomPanelLayout, Alignment.BOTTOM_LEFT);
    bottomContactLayout.setMargin(false, true, false, true);
}

From source file:org.ikasan.dashboard.ui.IkasanUI.java

License:BSD License

@Override
protected void init(VaadinRequest request) {
    VaadinSession.getCurrent().setAttribute(DashboardSessionValueConstants.TOPOLOGY_STATE_CACHE,
            this.topologyStateCache);

    addStyleName(ValoTheme.UI_WITH_MENU);

    this.mainLayout.setSizeFull();
    this.setContent(this.mainLayout);

    this.imagePanelLayout.removeAllComponents();
    this.imagePanelLayout.setHeight("70px");

    this.mainLayout.removeAllComponents();
    this.mainLayout.addComponent(imagePanelLayout, 0, 0);

    this.imagePanelLayout.setStyleName("v-header");

    this.imagePanelLayout.addComponent(this.bannerImage);
    this.bannerImage.setHeight("150%");
    this.imagePanelLayout.setExpandRatio(this.bannerImage, 0.5f);

    this.bannerLabel.setStyleName("ikasan-maroon");
    this.bannerLabel.setHeight("100%");
    this.imagePanelLayout.addComponent(this.bannerLabel);
    this.imagePanelLayout.setExpandRatio(this.bannerLabel, 0.5f);
    this.imagePanelLayout.setComponentAlignment(this.bannerLabel, Alignment.BOTTOM_LEFT);

    this.mainLayout.addComponent(navigationPanel, 0, 1);

    loadTopLevelNavigator();/*from w w w.  ja va  2  s .c  o  m*/
    buildContent();
    this.menuLayout.addMenu(this.menuContent);
    this.mainLayout.addComponent(this.menuLayout, 0, 2);

    this.mainLayout.setRowExpandRatio(2, 1);

    this.navigationPanel.resetCurrentView();
    this.navigationPanel.setToggleButton(buildToggleButton());

    for (Component component : menu.getMenuComponents().keySet()) {
        component.setVisible(false);
    }

    this.navigationPanel.setMenuComponents(menu.getMenuComponents());

    UI.getCurrent().getNavigator().navigateTo("landingView");
    this.navigationPanel.setVisible(true);
}

From source file:org.inakirj.imagerulette.screens.DiceURLSetupView.java

License:Open Source License

/**
 * Sets the layout.//from  www  .  j av  a 2  s .c o  m
 */
private void setLayout() {
    imagesLayout = new VerticalComponentGroup();
    imagesLayout.setWidth(100, Unit.PERCENTAGE);

    ImageUtils.getAllImageURL().stream().forEach(i -> {
        HorizontalLayout sliderLAyout = new HorizontalLayout();
        if (imagesLayout.getComponentCount() % 2 == 0) {
            sliderLAyout.addStyleName("dice-banner-1");
        } else {
            sliderLAyout.addStyleName("dice-banner-2");
        }
        sliderLAyout.setWidth(100, Unit.PERCENTAGE);
        Image img = new Image("", i.getSource());
        img.addStyleName("dice-image");
        img.setData(i.getData());
        Slider slider = new Slider();
        slider.addStyleName("dice-slider");
        Label total = new Label();
        total.addStyleName("size-24");// TODO is not working
        // Adding image
        sliderLAyout.addComponent(img);
        // Adding slider
        slider.setMin(0);
        slider.setMax(5);
        slider.setWidth(80, Unit.PERCENTAGE);
        slider.addValueChangeListener(s -> {
            total.setValue("x " + slider.getValue().intValue());
            enableDiceTabOrNot();
        });
        sliderLAyout.addComponent(slider);
        // Adding label
        total.setValue("x 0");
        sliderLAyout.addComponent(total);
        sliderLAyout.setExpandRatio(img, 2);
        sliderLAyout.setExpandRatio(slider, 7);
        sliderLAyout.setExpandRatio(total, 1);
        sliderLAyout.setComponentAlignment(img, Alignment.BOTTOM_LEFT);
        sliderLAyout.setComponentAlignment(slider, Alignment.BOTTOM_LEFT);
        sliderLAyout.setComponentAlignment(total, Alignment.BOTTOM_LEFT);
        // Adding layout
        imagesLayout.addComponent(sliderLAyout);
    });
    addComponent(imagesLayout);
}

From source file:org.jdal.vaadin.ui.ListPane.java

License:Apache License

public MenuItem(ComponentHolder holder) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/*from w w w . j  a v a2 s  .  c o m*/
    setContent(layout);
    Embedded e = new Embedded("", holder.getIcon());
    layout.addComponent(e);
    Label l = new Label(holder.getName());
    l.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(l);
    layout.setComponentAlignment(l, Alignment.BOTTOM_LEFT);
    layout.setComponentAlignment(e, Alignment.BOTTOM_LEFT);
    setStyleName("menuItem");
    this.component = holder.getComponent();
}

From source file:org.jpos.qi.login.LoginView.java

License:Open Source License

private HorizontalLayout createTitle() {
    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");
    labels.setMargin(new MarginInfo(false, false, true, false));
    labels.addStyleName("labels");

    Label title = new Label(app.getMessage("login.title"));
    title.setSizeUndefined();/* w  w  w.  ja  v  a  2  s.  c  o m*/
    title.addStyleName(ValoTheme.LABEL_H4);
    title.addStyleName(ValoTheme.LABEL_COLORED);
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.BOTTOM_LEFT);

    Embedded logo = new Embedded("", QIResources.JPOS_LOGO);
    logo.setHeight("80px");
    labels.addComponent(logo);
    labels.setComponentAlignment(logo, Alignment.TOP_RIGHT);

    return labels;
}

From source file:org.jumpmind.metl.ui.views.admin.LoggingPanel.java

License:Open Source License

public LoggingPanel(ApplicationContext context, TabbedPanel tabbedPanel) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;
    this.backgroundRefresherService = context.getBackgroundRefresherService();
    if (LogUtils.isFileEnabled()) {
        logFile = new File(LogUtils.getLogFilePath());
    }// w w  w.  j ava2 s.co  m
    setSizeFull();
    setSpacing(true);
    setMargin(true);

    HorizontalLayout topPanelLayout = new HorizontalLayout();
    topPanelLayout.setWidth(100, Unit.PERCENTAGE);
    topPanelLayout.setSpacing(true);

    Button refreshButton = new Button("Refresh");
    refreshButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            refresh();
        }
    });
    topPanelLayout.addComponent(refreshButton);
    topPanelLayout.setComponentAlignment(refreshButton, Alignment.BOTTOM_LEFT);

    bufferSize = new TextField();
    bufferSize.setImmediate(true);
    bufferSize.setWidth(5, Unit.EM);
    bufferSize.setValue("1000");
    bufferSize.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            refresh();
        }
    });
    topPanelLayout.addComponent(bufferSize);

    filter = new TextField();
    filter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    filter.setInputPrompt("Filter");
    filter.setIcon(FontAwesome.SEARCH);
    filter.setNullRepresentation("");
    filter.setImmediate(true);
    filter.setTextChangeEventMode(TextChangeEventMode.LAZY);
    filter.setTextChangeTimeout(200);
    filter.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            refresh();
        }
    });
    topPanelLayout.addComponent(filter);
    topPanelLayout.setComponentAlignment(filter, Alignment.BOTTOM_LEFT);

    autoRefreshOn = new CheckBox("Auto Refresh");
    autoRefreshOn.setValue(true);
    autoRefreshOn.setImmediate(true);
    topPanelLayout.addComponent(autoRefreshOn);
    topPanelLayout.setComponentAlignment(autoRefreshOn, Alignment.BOTTOM_LEFT);

    Label spacer = new Label();
    topPanelLayout.addComponent(spacer);
    topPanelLayout.setExpandRatio(spacer, 1);

    if (logFile != null && logFile.exists()) {
        Button downloadButton = new Button("Download log file");
        downloadButton.addStyleName(ValoTheme.BUTTON_LINK);
        downloadButton.addStyleName(ValoTheme.BUTTON_SMALL);

        FileDownloader fileDownloader = new FileDownloader(getLogFileResource());
        fileDownloader.extend(downloadButton);
        topPanelLayout.addComponent(downloadButton);
        topPanelLayout.setComponentAlignment(downloadButton, Alignment.BOTTOM_RIGHT);
    }

    addComponent(topPanelLayout);

    logPanel = new Panel("Log Output");
    logPanel.setSizeFull();
    logView = new Label("", ContentMode.HTML);
    logView.setSizeUndefined();
    logPanel.setContent(logView);
    addComponent(logPanel);
    setExpandRatio(logPanel, 1);
    refresh();
    backgroundRefresherService.register(this);
}

From source file:org.jumpmind.metl.ui.views.deploy.EditAgentPanel.java

License:Open Source License

public EditAgentPanel(ApplicationContext context, TabbedPanel tabbedPanel, Agent agent) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;
    this.agent = agent;
    this.backgroundRefresherService = context.getBackgroundRefresherService();

    HorizontalLayout editAgentLayout = new HorizontalLayout();
    editAgentLayout.setSpacing(true);/* ww  w .  ja v a2 s  .co  m*/
    editAgentLayout.setMargin(new MarginInfo(true, false, false, true));
    editAgentLayout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(editAgentLayout);

    final ComboBox startModeCombo = new ComboBox("Start Mode");
    startModeCombo.setImmediate(true);
    startModeCombo.setNullSelectionAllowed(false);
    AgentStartMode[] modes = AgentStartMode.values();
    for (AgentStartMode agentStartMode : modes) {
        startModeCombo.addItem(agentStartMode.name());
    }
    startModeCombo.setValue(agent.getStartMode());
    startModeCombo.addValueChangeListener(event -> {
        agent.setStartMode((String) startModeCombo.getValue());
        context.getConfigurationService().save((AbstractObject) EditAgentPanel.this.agent);
    });

    editAgentLayout.addComponent(startModeCombo);
    editAgentLayout.setComponentAlignment(startModeCombo, Alignment.BOTTOM_LEFT);

    Button parameterButton = new Button("Parameters");
    parameterButton.addClickListener(new ParameterClickListener());
    editAgentLayout.addComponent(parameterButton);
    editAgentLayout.setComponentAlignment(parameterButton, Alignment.BOTTOM_LEFT);

    HorizontalLayout buttonGroup = new HorizontalLayout();

    final TextField hostNameField = new TextField("Hostname");
    hostNameField.setImmediate(true);
    hostNameField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    hostNameField.setTextChangeTimeout(100);
    hostNameField.setWidth(20, Unit.EM);
    hostNameField.setNullRepresentation("");
    hostNameField.setValue(agent.getHost());
    hostNameField.addValueChangeListener(event -> {
        agent.setHost((String) hostNameField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });

    buttonGroup.addComponent(hostNameField);
    buttonGroup.setComponentAlignment(hostNameField, Alignment.BOTTOM_LEFT);

    Button getHostNameButton = new Button("Get Host");
    getHostNameButton.addClickListener(event -> hostNameField.setValue(AppUtils.getHostName()));
    buttonGroup.addComponent(getHostNameButton);
    buttonGroup.setComponentAlignment(getHostNameButton, Alignment.BOTTOM_LEFT);

    editAgentLayout.addComponent(buttonGroup);
    editAgentLayout.setComponentAlignment(buttonGroup, Alignment.BOTTOM_LEFT);

    Button exportButton = new Button("Export Agent Config", event -> exportConfiguration());
    editAgentLayout.addComponent(exportButton);
    editAgentLayout.setComponentAlignment(exportButton, Alignment.BOTTOM_LEFT);

    CheckBox autoRefresh = new CheckBox("Auto Refresh", Boolean.valueOf(agent.isAutoRefresh()));
    autoRefresh.setImmediate(true);
    autoRefresh.addValueChangeListener(event -> {
        agent.setAutoRefresh(autoRefresh.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(autoRefresh);
    editAgentLayout.setComponentAlignment(autoRefresh, Alignment.BOTTOM_LEFT);

    CheckBox allowTestFlowsField = new CheckBox("Allow Test Flows", Boolean.valueOf(agent.isAllowTestFlows()));
    allowTestFlowsField.setImmediate(true);
    allowTestFlowsField.addValueChangeListener(event -> {
        agent.setAllowTestFlows(allowTestFlowsField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(allowTestFlowsField);
    editAgentLayout.setComponentAlignment(allowTestFlowsField, Alignment.BOTTOM_LEFT);

    ButtonBar buttonBar = new ButtonBar();
    addComponent(buttonBar);

    addDeploymentButton = buttonBar.addButton("Add Deployment", Icons.DEPLOYMENT);
    addDeploymentButton.addClickListener(new AddDeploymentClickListener());

    editButton = buttonBar.addButton("Edit", FontAwesome.EDIT);
    editButton.addClickListener(event -> editClicked());

    enableButton = buttonBar.addButton("Enable", FontAwesome.CHAIN);
    enableButton.addClickListener(event -> enableClicked());

    disableButton = buttonBar.addButton("Disable", FontAwesome.CHAIN_BROKEN);
    disableButton.addClickListener(event -> disableClicked());

    removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O);
    removeButton.addClickListener(event -> removeClicked());

    runButton = buttonBar.addButton("Run", Icons.RUN);
    runButton.addClickListener(event -> runClicked());

    container = new BeanItemContainer<AgentDeploymentSummary>(AgentDeploymentSummary.class);
    container.setItemSorter(new TableItemSorter());

    table = new Table();
    table.setSizeFull();
    table.setCacheRate(100);
    table.setPageLength(100);
    table.setImmediate(true);
    table.setSelectable(true);
    table.setMultiSelect(true);

    table.setContainerDataSource(container);
    table.setVisibleColumns("name", "projectName", "type", "status", "logLevel", "startType",
            "startExpression");
    table.setColumnHeaders("Deployment", "Project", "Type", "Status", "Log Level", "Start Type",
            "Start Expression");
    table.addGeneratedColumn("status", new StatusRenderer());
    table.addItemClickListener(new TableItemClickListener());
    table.addValueChangeListener(new TableValueChangeListener());
    table.setSortContainerPropertyId("type");
    table.setSortAscending(true);

    addComponent(table);
    setExpandRatio(table, 1.0f);
    refresh();
    setButtonsEnabled();
    backgroundRefresherService.register(this);
}

From source file:org.lucidj.vaadinui.Login.java

License:Apache License

@Override // LoginForm
protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) {
    // Save the predefined components
    this.userNameField = userNameField;
    this.passwordField = passwordField;
    this.loginButton = loginButton;

    // Make LoginForm container full-screen
    setSizeFull();//from w w  w .  j  av a 2s  .c  o  m

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.addStyleName("login-wallpaper");

    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();
    loginPanel.setMargin(true);
    loginPanel.setSpacing(true);
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("card");

    //--------
    // HEADER
    //--------

    final HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");

    final Label title = new Label("<h3><strong>LucidJ</strong> Console</h3>", ContentMode.HTML);
    labels.addComponent(title);
    labels.setExpandRatio(title, 1);

    loginPanel.addComponent(labels);

    //--------
    // FIELDS
    //--------

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

    userNameField.setImmediate(true);
    userNameField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    final ShortcutListener username_enter_listener = new ShortcutListener("Next field (Tab)",
            ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object o, Object o1) {
            passwordField.setValue("");
            passwordField.focus();
        }
    };
    userNameField.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent textChangeEvent) {
            show_default_message();

            int new_username_length = textChangeEvent.getText().length();

            // Check for autofill
            if (userNameField.isEmpty() && new_username_length > 1 && !userNameField_filling) {
                // This is autofill
                userNameField.removeShortcutListener(username_enter_listener);
                userNameField.setCursorPosition(new_username_length);
                userNameField.setSelectionRange(0, new_username_length);
            } else {
                userNameField_filling = true;
                passwordField.setValue("");
                userNameField.addShortcutListener(username_enter_listener);
            }
        }
    });
    userNameField.addFocusListener(new FieldEvents.FocusListener() {
        @Override
        public void focus(FieldEvents.FocusEvent focusEvent) {
            // Cursor on username, Enter jump to password
            loginButton.removeClickShortcut();
            userNameField.addShortcutListener(username_enter_listener);
        }
    });
    userNameField.addBlurListener(new FieldEvents.BlurListener() {
        @Override
        public void blur(FieldEvents.BlurEvent blurEvent) {
            // Cursor on password or elsewhere, enter submits
            userNameField.removeShortcutListener(username_enter_listener);
            loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        }
    });

    passwordField.setImmediate(true);
    passwordField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    passwordField.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent textChangeEvent) {
            show_default_message();
        }
    });

    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginButton.setDisableOnClick(true);

    fields.addComponents(userNameField, passwordField, loginButton);
    fields.setComponentAlignment(loginButton, Alignment.BOTTOM_LEFT);

    loginPanel.addComponent(fields);

    //--------
    // FOOTER
    //--------

    loginPanel.addComponent(new CheckBox("Remember me", true));

    loginPanel.addComponent(message_label);
    show_default_message();

    layout.addComponent(loginPanel);
    layout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    return (layout);
}