blob: b2c464c1dcd278aacc31c604bc9091227e786bf7 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*/
package org.eclipse.osbp.vaaclipse.addons.login;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.osbp.user.User;
import org.eclipse.osbp.vaaclipse.publicapi.authentication.AuthenticationConstants;
import com.vaadin.ui.Button;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class AuthenticationProvider {
@Inject
private IEventBroker eventBroker;
private Window dialog;
private TextField userName;
@PostConstruct
public void setup() {
userName = new TextField("userName");
Button b = new Button("Login", e -> login());
VerticalLayout vl = new VerticalLayout(userName, b);
vl.setSpacing(true);
vl.setMargin(true);
dialog = new Window("Login", vl);
UI.getCurrent().addWindow(dialog);
dialog.center();
}
private void login() {
dialog.close();
eventBroker.send(AuthenticationConstants.Events.Authentication.name,
new User(userName.getValue()));
}
}