Example usage for com.vaadin.server Page getCurrent

List of usage examples for com.vaadin.server Page getCurrent

Introduction

In this page you can find the example usage for com.vaadin.server Page getCurrent.

Prototype

public static Page getCurrent() 

Source Link

Document

Gets the Page to which the current uI belongs.

Usage

From source file:lifetime.component.welcome.LoginButton.java

License:Apache License

public LoginButton(String language) {
    super(Translator.getTranslation("Login", language), language, FontAwesome.KEY);
    this.text = Translator.getTranslation("Login", language);
    setDescription(text);// w  w w .j  a va 2  s .c  o  m
    setId(StyleClassName.LOGIN_BUTTON.getId());
    addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Page.getCurrent().setLocation(Location.USER.getUri());
        }
    });
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.entrypoints.RootLauncher.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {

    // currently temporary redirection to Messir Creator
    // in future this root address (http://localhost:8080/iCrash)
    // might be used for a yet non-existent GUI monitor instead...

    // Hints:/*from   w w w.  j  av  a 2 s.c  o m*/
    // currentURL = "http://localhost:8080/iCrash/"
    // MsrCreatorLauncher.creatorName = "creator"
    String currentURL = Page.getCurrent().getLocation().toString();

    int nrSlash = 0;
    int i;
    for (i = 0; i < currentURL.length(); i++) {
        if (currentURL.charAt(i) == '/')
            nrSlash++;

        if (nrSlash == 4)
            break;
    }

    String iCrashURL = currentURL.substring(0, i);
    Page.getCurrent().setLocation(iCrashURL + '/' + MsrCreatorLauncher.creatorName);
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java

License:Open Source License

public void LogoutClick(ClickEvent event) {
    ActAdministrator actAdmin = env// w w w.j a va2 s  . c  o  m
            .getActAdministrator(new DtLogin(new PtString(AdminActors.values[0].name())));
    try {
        actAdmin.oeLogout();

    } catch (Exception e) {
        e.printStackTrace();
    }

    // refresh this view, that will force redirection of the user
    // to the view, where he should go now, be it AdminLoginView or AdminAuthView
    Page.getCurrent().reload();
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java

License:Open Source License

public AdminAuthView() {

    setSizeFull();//from  w ww  .j  av a  2s  .  c o  m

    VerticalLayout header = new VerticalLayout();
    header.setSizeFull();

    HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();

    addComponents(header, content);
    setExpandRatio(header, 1);
    setExpandRatio(content, 6);

    welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>");
    welcomeText.setContentMode(ContentMode.HTML);
    welcomeText.setSizeUndefined();
    header.addComponent(welcomeText);
    header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);

    Panel controlPanel = new Panel("Administrator control panel");
    controlPanel.setSizeUndefined();

    Panel addCoordPanel = new Panel("Create a new coordinator");
    addCoordPanel.setSizeUndefined();

    Panel messagesPanel = new Panel("Administrator messages");
    messagesPanel.setWidth("580px");

    Table adminMessagesTable = new Table();

    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());

    adminMessagesTable.setColumnWidth("inputEvent", 180);
    adminMessagesTable.setSizeFull();

    VerticalLayout controlLayout = new VerticalLayout(controlPanel);
    controlLayout.setSizeFull();
    controlLayout.setMargin(false);
    controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER);

    VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel);
    coordOperationsLayout.setSizeFull();
    coordOperationsLayout.setMargin(false);
    coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER);

    /******************************************/
    coordOperationsLayout.setVisible(true); // main layout in the middle
    addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator"
    /******************************************/

    HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel);
    VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable);

    messagesExternalLayout.setSizeFull();
    messagesExternalLayout.setMargin(false);
    messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER);

    messagesInternalLayout.setMargin(false);
    messagesInternalLayout.setSizeFull();
    messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER);

    messagesPanel.setContent(messagesInternalLayout);

    TextField idCoordAdd = new TextField();
    TextField loginCoord = new TextField();
    PasswordField pwdCoord = new PasswordField();

    Label idCaptionAdd = new Label("ID");
    Label loginCaption = new Label("Login");
    Label pwdCaption = new Label("Password");

    idCaptionAdd.setSizeUndefined();
    idCoordAdd.setSizeUndefined();

    loginCaption.setSizeUndefined();
    loginCoord.setSizeUndefined();

    pwdCaption.setSizeUndefined();
    pwdCoord.setSizeUndefined();

    Button validateNewCoord = new Button("Validate");
    validateNewCoord.setClickShortcut(KeyCode.ENTER);
    validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY);

    GridLayout addCoordinatorLayout = new GridLayout(2, 4);
    addCoordinatorLayout.setSpacing(true);
    addCoordinatorLayout.setMargin(true);
    addCoordinatorLayout.setSizeFull();

    addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption,
            pwdCoord);

    addCoordinatorLayout.addComponent(validateNewCoord, 1, 3);

    addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT);

    addCoordPanel.setContent(addCoordinatorLayout);

    content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);

    content.setExpandRatio(controlLayout, 20);
    content.setExpandRatio(coordOperationsLayout, 10);
    content.setExpandRatio(messagesExternalLayout, 28);

    Button addCoordinator = new Button("Add coordinator");
    Button deleteCoordinator = new Button("Delete coordinator");

    addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE);

    VerticalLayout buttons = new VerticalLayout();

    buttons.setMargin(true);
    buttons.setSpacing(true);
    buttons.setSizeFull();

    buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    controlPanel.setContent(buttons);

    buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn);

    /******* DELETE COORDINATOR PANEL BEGIN *********/
    Label idCaptionDel = new Label("ID");
    TextField idCoordDel = new TextField();

    Panel delCoordPanel = new Panel("Delete a coordinator");

    coordOperationsLayout.addComponent(delCoordPanel);
    delCoordPanel.setVisible(false);

    coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER);
    delCoordPanel.setSizeUndefined();

    GridLayout delCoordinatorLayout = new GridLayout(2, 2);
    delCoordinatorLayout.setSpacing(true);
    delCoordinatorLayout.setMargin(true);
    delCoordinatorLayout.setSizeFull();

    Button deleteCoordBtn = new Button("Delete");
    deleteCoordBtn.setClickShortcut(KeyCode.ENTER);
    deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY);

    delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel);

    delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1);

    delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT);
    delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT);

    delCoordPanel.setContent(delCoordinatorLayout);
    /******* DELETE COORDINATOR PANEL END *********/

    /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/

    addCoordinator.addClickListener(event -> {
        if (!addCoordPanel.isVisible()) {
            delCoordPanel.setVisible(false);
            addCoordPanel.setVisible(true);
            idCoordAdd.focus();
        } else
            addCoordPanel.setVisible(false);
    });

    deleteCoordinator.addClickListener(event -> {
        if (!delCoordPanel.isVisible()) {
            addCoordPanel.setVisible(false);
            delCoordPanel.setVisible(true);
            idCoordDel.focus();
        } else
            delCoordPanel.setVisible(false);
    });

    /************************************************* MAIN BUTTONS LOGIC END *************************************************/

    /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/
    validateNewCoord.addClickListener(event -> {

        String currentURL = Page.getCurrent().getLocation().toString();
        int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName);
        String iCrashURL = currentURL.substring(0, strIndexCreator);
        String googleShebang = "#!";
        String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang;

        try {
            sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())),
                    new DtLogin(new PtString(loginCoord.getValue())),
                    new DtPassword(new PtString(pwdCoord.getValue())));

            // open new browser tab with the newly created coordinator console...
            // "_blank" instructs the browser to open a new tab instead of a new window...
            // unhappily not all browsers interpret it correctly,
            // some versions of some browsers might still open a new window instead (notably Firefox)!
            Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank");

        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordAdd.setValue("");
        loginCoord.setValue("");
        pwdCoord.setValue("");

        idCoordAdd.focus();
    });
    /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/
    /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/
    deleteCoordBtn.addClickListener(event -> {
        IcrashSystem sys = IcrashSystem.getInstance();

        try {
            sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue())));
        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordDel.setValue("");
        idCoordDel.focus();
    });
    /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminLoginView.java

License:Open Source License

@Override
public void buttonClick(ClickEvent event) {

    ActAdministrator admin = env.getActAdministrator(new DtLogin(new PtString(AdminActors.values[0].name())));

    try {/*  www  .  j  a v a 2s.  c  o  m*/
        admin.oeLogin(new DtLogin(new PtString(username.getValue())),
                new DtPassword(new PtString(password.getValue())));

    } catch (Exception e) {
        e.printStackTrace();
    }

    // refreshing this view forces redirection of the user
    // to the view, where he should go now, be it AdminLoginView or AdminAuthView
    Page.getCurrent().reload();
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.CoordMobileAuthView.java

License:Open Source License

public CoordMobileAuthView(String CoordID) {

    CtCoordinator ctCoordinator = (CtCoordinator) sys
            .getCtCoordinator(new DtCoordinatorID(new PtString(CoordID)));
    ActCoordinator actCoordinator = sys.getActCoordinator(ctCoordinator);

    actCoordinator.setActorUI(UI.getCurrent());
    env.setActCoordinator(actCoordinator.getName(), actCoordinator);

    IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
    IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);

    thisCoordID = CoordID;/*from   ww w . ja va  2s.co m*/

    setResponsive(true);
    setWidth("100%");

    NavigationBar alertsBar = new NavigationBar();
    VerticalComponentGroup alertsContent = new VerticalComponentGroup();
    alertsContent.setWidth("100%");
    alertsContent.setResponsive(true);

    HorizontalLayout alertButtons1 = new HorizontalLayout();
    HorizontalLayout alertButtons2 = new HorizontalLayout();
    //alertButtons.setMargin(true);
    //alertButtons.setSpacing(true);

    alertsBar.setCaption("Coordinator " + ctCoordinator.login.toString());
    // NavigationButton logoutBtn1 = new NavigationButton("Logout");
    Button logoutBtn1 = new Button("Logout");
    alertsBar.setRightComponent(logoutBtn1);

    alertsTable = new Grid();
    alertsTable.setContainerDataSource(actCoordinator.getAlertsContainer());
    alertsTable.setColumnOrder("ID", "date", "time", "longitude", "latitude", "comment", "status");
    alertsTable.setSelectionMode(SelectionMode.SINGLE);

    alertsTable.setWidth("100%");
    alertsTable.setResponsive(true);
    //alertsTable.setSizeUndefined();

    alertsTable.setImmediate(true);

    Grid inputEventsTable1 = new Grid();
    inputEventsTable1.setContainerDataSource(actCoordinator.getMessagesDataSource());
    inputEventsTable1.setWidth("100%");
    inputEventsTable1.setResponsive(true);

    alertsContent.addComponents(alertsBar, alertButtons1, alertButtons2, alertsTable, inputEventsTable1);

    Tab alertsTab = this.addTab(alertsContent);
    alertsTab.setCaption("Alerts");

    alertStatus = new NativeSelect();
    alertStatus.setNullSelectionAllowed(false);
    alertStatus.addItems("Pending", "Valid", "Invalid");
    alertStatus.setImmediate(true);

    alertStatus.select("Pending");

    Button validateAlertBtn = new Button("Validate");
    Button invalidateAlertBtn = new Button("Invalidate");
    Button getAlertsSetBtn = new Button("Get alerts set");

    validateAlertBtn.setImmediate(true);
    invalidateAlertBtn.setImmediate(true);

    validateAlertBtn.addClickListener(event -> {
        AlertBean selectedAlertBean = (AlertBean) alertsTable.getSelectedRow();

        Integer thisAlertID = new Integer(selectedAlertBean.getID());
        PtBoolean res;
        res = sys.oeValidateAlert(new DtAlertID(new PtString(thisAlertID.toString())));
    });

    invalidateAlertBtn.addClickListener(event -> {
        AlertBean selectedAlertBean = (AlertBean) alertsTable.getSelectedRow();
        Integer thisAlertID = new Integer(selectedAlertBean.getID());
        PtBoolean res;
        res = sys.oeInvalidateAlert(new DtAlertID(new PtString(thisAlertID.toString())));
    });

    getAlertsSetBtn.addClickListener(event -> {
        if (alertStatus.getValue().toString().equals("Pending"))
            actCoordinator.oeGetAlertsSet(EtAlertStatus.pending);
        else if (alertStatus.getValue().toString().equals("Valid"))
            actCoordinator.oeGetAlertsSet(EtAlertStatus.valid);
        else if (alertStatus.getValue().toString().equals("Invalid"))
            actCoordinator.oeGetAlertsSet(EtAlertStatus.invalid);
    });

    alertButtons1.addComponents(validateAlertBtn, invalidateAlertBtn);
    alertButtons2.addComponents(getAlertsSetBtn, alertStatus);

    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    NavigationBar crisesBar = new NavigationBar();
    VerticalComponentGroup crisesContent = new VerticalComponentGroup();
    crisesContent.setWidth("100%");
    crisesContent.setResponsive(true);

    HorizontalLayout crisesButtons1 = new HorizontalLayout();
    HorizontalLayout crisesButtons2 = new HorizontalLayout();
    crisesBar.setCaption("Coordinator " + ctCoordinator.login.toString());
    //NavigationButton logoutBtn2 = new NavigationButton("Logout");
    Button logoutBtn2 = new Button("Logout");
    crisesBar.setRightComponent(logoutBtn2);

    crisesTable = new Grid();
    crisesTable.setContainerDataSource(actCoordinator.getCrisesContainer());
    crisesTable.setColumnOrder("ID", "date", "time", "type", "longitude", "latitude", "comment", "status");
    crisesTable.setSelectionMode(SelectionMode.SINGLE);

    crisesTable.setWidth("100%");
    //crisesTable.setSizeUndefined();

    crisesTable.setImmediate(true);
    crisesTable.setResponsive(true);

    Grid inputEventsTable2 = new Grid();
    inputEventsTable2.setContainerDataSource(actCoordinator.getMessagesDataSource());
    inputEventsTable2.setWidth("100%");
    inputEventsTable2.setResponsive(true);

    crisesContent.addComponents(crisesBar, crisesButtons1, crisesButtons2, crisesTable, inputEventsTable2);

    Tab crisesTab = this.addTab(crisesContent);
    crisesTab.setCaption("Crises");

    Button handleCrisesBtn = new Button("Handle");
    Button reportOnCrisisBtn = new Button("Report");
    Button changeCrisisStatusBtn = new Button("Status");
    Button closeCrisisBtn = new Button("Close");
    Button getCrisesSetBtn = new Button("Get crises set");
    crisesStatus = new NativeSelect();

    handleCrisesBtn.setImmediate(true);
    reportOnCrisisBtn.setImmediate(true);
    changeCrisisStatusBtn.setImmediate(true);
    closeCrisisBtn.setImmediate(true);
    getCrisesSetBtn.setImmediate(true);
    crisesStatus.setImmediate(true);

    crisesStatus.addItems("Pending", "Handled", "Solved", "Closed");
    crisesStatus.setNullSelectionAllowed(false);
    crisesStatus.select("Pending");

    crisesButtons1.addComponents(handleCrisesBtn, reportOnCrisisBtn, changeCrisisStatusBtn);
    crisesButtons2.addComponents(closeCrisisBtn, getCrisesSetBtn, crisesStatus);

    ////////////////////////////////////////

    Window reportCrisisSubWindow = new Window();
    reportCrisisSubWindow.setClosable(false);
    reportCrisisSubWindow.setResizable(false);
    reportCrisisSubWindow.setResponsive(true);
    VerticalLayout reportLayout = new VerticalLayout();
    reportLayout.setMargin(true);
    reportLayout.setSpacing(true);
    reportCrisisSubWindow.setContent(reportLayout);
    TextField crisisID = new TextField();
    TextField reportText = new TextField();
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    Button reportCrisisBtn = new Button("Report");
    reportCrisisBtn.setClickShortcut(KeyCode.ENTER);
    reportCrisisBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    Button cancelBtn = new Button("Cancel");
    buttonsLayout.addComponents(reportCrisisBtn, cancelBtn);
    buttonsLayout.setSpacing(true);
    reportLayout.addComponents(crisisID, reportText, buttonsLayout);

    cancelBtn.addClickListener(event -> {
        reportCrisisSubWindow.close();
        reportText.clear();
    });

    reportCrisisBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        actCoordinator.oeReportOnCrisis(new DtCrisisID(new PtString(thisCrisisID.toString())),
                new DtComment(new PtString(reportText.getValue())));

        reportCrisisSubWindow.close();
        reportText.clear();
    });

    ////////////////////////////////////////

    Window changeCrisisStatusSubWindow = new Window();
    changeCrisisStatusSubWindow.setClosable(false);
    changeCrisisStatusSubWindow.setResizable(false);
    changeCrisisStatusSubWindow.setResponsive(true);
    VerticalLayout statusLayout = new VerticalLayout();
    statusLayout.setMargin(true);
    statusLayout.setSpacing(true);
    changeCrisisStatusSubWindow.setContent(statusLayout);
    TextField crisisID1 = new TextField();

    NativeSelect crisisStatus = new NativeSelect("crisis status");
    crisisStatus.addItems("Pending", "Handled", "Solved", "Closed");
    crisisStatus.setNullSelectionAllowed(false);
    crisisStatus.select("Pending");

    HorizontalLayout buttonsLayout1 = new HorizontalLayout();
    Button changeCrisisStatusBtn1 = new Button("Change status");
    changeCrisisStatusBtn1.setClickShortcut(KeyCode.ENTER);
    changeCrisisStatusBtn1.addStyleName(ValoTheme.BUTTON_PRIMARY);
    Button cancelBtn1 = new Button("Cancel");
    buttonsLayout1.addComponents(changeCrisisStatusBtn1, cancelBtn1);
    buttonsLayout1.setSpacing(true);
    statusLayout.addComponents(crisisID1, crisisStatus, buttonsLayout1);

    cancelBtn1.addClickListener(event -> changeCrisisStatusSubWindow.close());

    changeCrisisStatusBtn1.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());

        EtCrisisStatus statusToPut = null;

        if (crisisStatus.getValue().toString().equals("Pending"))
            statusToPut = EtCrisisStatus.pending;
        if (crisisStatus.getValue().toString().equals("Handled"))
            statusToPut = EtCrisisStatus.handled;
        if (crisisStatus.getValue().toString().equals("Solved"))
            statusToPut = EtCrisisStatus.solved;
        if (crisisStatus.getValue().toString().equals("Closed"))
            statusToPut = EtCrisisStatus.closed;

        PtBoolean res = actCoordinator.oeSetCrisisStatus(new DtCrisisID(new PtString(thisCrisisID.toString())),
                statusToPut);

        changeCrisisStatusSubWindow.close();
    });

    ////////////////////////////////////////

    handleCrisesBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        PtBoolean res = actCoordinator
                .oeSetCrisisHandler(new DtCrisisID(new PtString(thisCrisisID.toString())));
    });

    reportOnCrisisBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        reportCrisisSubWindow.center();
        crisisID.setValue(thisCrisisID.toString());
        crisisID.setEnabled(false);
        reportText.focus();
        UI.getCurrent().addWindow(reportCrisisSubWindow);
    });

    changeCrisisStatusBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        changeCrisisStatusSubWindow.center();
        crisisID1.setValue(thisCrisisID.toString());
        crisisID1.setEnabled(false);
        crisisStatus.focus();
        UI.getCurrent().addWindow(changeCrisisStatusSubWindow);
    });

    closeCrisisBtn.addClickListener(event -> {
        CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow();
        Integer thisCrisisID = new Integer(selectedCrisisBean.getID());
        PtBoolean res = actCoordinator.oeCloseCrisis(new DtCrisisID(new PtString(thisCrisisID.toString())));
    });

    getCrisesSetBtn.addClickListener(event -> {
        if (crisesStatus.getValue().toString().equals("Closed"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.closed);
        if (crisesStatus.getValue().toString().equals("Handled"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.handled);
        if (crisesStatus.getValue().toString().equals("Solved"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.solved);
        if (crisesStatus.getValue().toString().equals("Pending"))
            actCoordinator.oeGetCrisisSet(EtCrisisStatus.pending);
    });

    ClickListener logoutAction = event -> {
        PtBoolean res;
        try {
            res = actCoordinator.oeLogout();
            if (res.getValue()) {
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Page.getCurrent().reload();
    };

    logoutBtn1.addClickListener(logoutAction);
    logoutBtn2.addClickListener(logoutAction);
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.CoordMobileLoginView.java

License:Open Source License

public CoordMobileLoginView(String CoordID) {
    CtCoordinator ctCoordinator = (CtCoordinator) sys
            .getCtCoordinator(new DtCoordinatorID(new PtString(CoordID)));
    ActCoordinator actCoordinator = env.getActCoordinator(ctCoordinator.login);

    actCoordinator.setActorUI(UI.getCurrent());

    env.setActCoordinator(actCoordinator.getName(), actCoordinator);

    IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
    IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);

    setCaption("Login to Coord " + ctCoordinator.login.toString());

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);/*from www  . j  a  v a  2s  . c om*/

    VerticalComponentGroup group = new VerticalComponentGroup();
    layout.addComponent(group);

    VerticalLayout loginExtLayout = new VerticalLayout();
    loginExtLayout.setSizeFull();
    group.addComponent(loginExtLayout);

    FormLayout loginIntLayout = new FormLayout();
    loginIntLayout.setSizeUndefined();
    loginExtLayout.addComponent(loginIntLayout);

    loginExtLayout.setComponentAlignment(loginIntLayout, Alignment.MIDDLE_CENTER);

    login.setInputPrompt("Coord login");
    pwd.setValue("");
    pwd.setNullRepresentation("");

    loginBtn.setClickShortcut(KeyCode.ENTER);

    loginIntLayout.addComponents(login, pwd, loginBtn);

    ///////////////////////////////////////////////////////////////////////////////////

    Grid messagesTable = new Grid();
    messagesTable.setContainerDataSource(actCoordinator.getMessagesDataSource());
    messagesTable.setSizeUndefined();

    VerticalLayout tableLayout = new VerticalLayout();
    tableLayout.setSizeFull();

    group.addComponent(tableLayout);
    tableLayout.addComponent(messagesTable);

    tableLayout.setComponentAlignment(messagesTable, Alignment.MIDDLE_CENTER);

    ///////////////////////////////////////////////////////////////////////////////////

    loginBtn.addClickListener(event -> {
        PtBoolean res;
        try {
            res = actCoordinator.oeLogin(new DtLogin(new PtString(login.getValue())),
                    new DtPassword(new PtString(pwd.getValue())));
            log.info("oeLogin returned " + res.getValue());

            if (res.getValue()) {
                log.debug("After actCoordinator.oeLogin: JUST LOGGED IN, so Coord's vpIsLogged = "
                        + ctCoordinator.vpIsLogged.getValue());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        // refreshing this view forces redirection of the user
        // to the view, where he should go now, be it CoordLoginView or CoordAuthView
        Page.getCurrent().reload();

        actCoordinator.setActorUI(UI.getCurrent());
        env.setActCoordinator(actCoordinator.getName(), actCoordinator);

        IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
        IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);
    });
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.MsrCreatorView.java

License:Open Source License

public MsrCreatorView() {

    createSysEnvBtn.setClickShortcut(KeyCode.ENTER);

    createSysEnvBtn.addClickListener(event -> {
        IcrashSystem sys = IcrashSystem.getInstance();
        IcrashEnvironment env = IcrashEnvironment.getInstance();

        DbInitialize.initializeDatabase();

        // Messir initialization routines 
        ActMsrCreator theCreator = env.getActMsrCreator();
        theCreator.oeCreateSystemAndEnvironment(new PtInteger(new Integer(textField.getValue())));

        IcrashSystem.nrComCompanies = Integer.parseInt(textField.getValue());
        IcrashSystem.comCompanyViewNames = new ArrayList<String>();

        String currentURL = Page.getCurrent().getLocation().toString();
        int strIndexCreator = currentURL.lastIndexOf(MsrCreatorLauncher.creatorName);
        String iCrashURL = currentURL.substring(0, strIndexCreator);
        String googleShebang = "#!";

        String activatorURL = iCrashURL + ActivatorLauncher.activatorPageName;
        String comCompURL = iCrashURL + ComCompanyLauncher.comCompaniesName + googleShebang;
        String adminRootURL = iCrashURL + AdministratorLauncher.adminPageName;

        // open Activator console (tab)
        Page.getCurrent().open(activatorURL, "_blank");

        // open N tabs with N comcompanies
        // EXACTLY the same algorithm of assigning ID's here, as it was done in oeCreateSystemAndEnvironment:
        for (int i = 0; i < IcrashSystem.nrComCompanies; i++) {
            IcrashSystem.comCompanyViewNames.add(String.format("%02d", i));
            Page.getCurrent().open(comCompURL + IcrashSystem.comCompanyViewNames.get(i), "_blank");
        }/*from   w ww.j  a v  a  2 s.  c om*/

        // open admin tab too
        Page.getCurrent().open(adminRootURL, "_blank");

        textField.focus();
    });
}

From source file:lv.polarisit.demosidemenu.ValoThemeUI.java

License:Apache License

@Override
protected void init(final VaadinRequest request) {
    if (request.getParameter("test") != null) {
        testMode = true;//from  w  ww  . j  a  v  a2 s  . c  o m

        if (browserCantRenderFontsConsistently()) {
            getPage().getStyles().add(".v-app.v-app.v-app {font-family: Sans-Serif;}");
        }
    }

    if (getPage().getWebBrowser().isIE() && getPage().getWebBrowser().getBrowserMajorVersion() == 9) {
        menu.setWidth("320px");
    }
    // Show .v-app-loading valo-menu-badge
    // try {
    // Thread.sleep(2000);
    // } catch (InterruptedException e) {
    // e.printStackTrace();
    // }

    if (!testMode) {
        Responsive.makeResponsive(this);
    }

    getPage().setTitle("Valo Theme Test");
    setContent(root);
    root.setWidth("100%");

    root.addMenu(buildMenu());

    navigator = new Navigator(this, viewDisplay);
    navigator.addView("MessageView", MessageView.class);
    navigator.addView("MessageView1", MessageView1.class);

    /*
    navigator.addView("labels", Labels.class);
    navigator.addView("buttons-and-links", ButtonsAndLinks.class);
    navigator.addView("textfields", TextFields.class);
    navigator.addView("datefields", DateFields.class);
    navigator.addView("comboboxes", ComboBoxes.class);
    navigator.addView("checkboxes", CheckBoxes.class);
    navigator.addView("sliders", Sliders.class);
    navigator.addView("menubars", MenuBars.class);
    navigator.addView("panels", Panels.class);
    navigator.addView("trees", Trees.class);
    navigator.addView("tables", Tables.class);
    navigator.addView("splitpanels", SplitPanels.class);
    navigator.addView("tabs", Tabsheets.class);
    navigator.addView("accordions", Accordions.class);
    navigator.addView("colorpickers", ColorPickers.class);
    navigator.addView("selects", NativeSelects.class);
    navigator.addView("calendar", CalendarTest.class);
    navigator.addView("forms", Forms.class);
    navigator.addView("popupviews", PopupViews.class);
    navigator.addView("dragging", Dragging.class);
    */
    final String f = Page.getCurrent().getUriFragment();
    if (f == null || f.equals("")) {
        navigator.navigateTo("MessageView");
    }

    //navigator.setErrorView(CommonParts.class);

    navigator.addViewChangeListener(new ViewChangeListener() {

        @Override
        public boolean beforeViewChange(final ViewChangeEvent event) {
            return true;
        }

        @Override
        public void afterViewChange(final ViewChangeEvent event) {
            for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) {
                it.next().removeStyleName("selected");
            }
            for (final Entry<String, String> item : menuItems.entrySet()) {
                if (event.getViewName().equals(item.getKey())) {
                    for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) {
                        final Component c = it.next();
                        if (c.getCaption() != null && c.getCaption().startsWith(item.getValue())) {
                            c.addStyleName("selected");
                            break;
                        }
                    }
                    break;
                }
            }
            menu.removeStyleName("valo-menu-visible");
        }
    });

}

From source file:me.uni.emuseo.view.categories.CategoryLayout.java

License:Open Source License

private void createTable() {
    categoryTable = new CategoryTable() {

        private static final long serialVersionUID = 4201722098147104008L;

        @Override/*w  w w  .  ja va  2  s  .  c o m*/
        protected void onEdit(CategoryDTO itemId) {
            CategoryDTO category = categoryService.getCategory(itemId.getCategoryId());
            CategoryPopUpWindow categoryPopUpWidow = new CategoryPopUpWindow(category, "Edytuj kategori") {
                private static final long serialVersionUID = 3776311059670953584L;

                @Override
                protected boolean onSave(CategoryDTO bean) throws InvalidBeanException {
                    categoryService.editCategory(bean);
                    pagedTableLayout.refreshPage();
                    return true;
                }
            };
            UI.getCurrent().addWindow(categoryPopUpWidow);
        }

        @Override
        protected void onDelete(final CategoryDTO itemId) {
            ConfirmationWindow confirmationWindow = new ConfirmationWindow("Usu kategori",
                    "Czy na pewno chcesz usun kategori: " + itemId.getName() + "?") {

                private static final long serialVersionUID = -39445547305022448L;

                @Override
                protected boolean onConfirm() {
                    try {
                        categoryService.deleteCategory(itemId.getCategoryId());
                        pagedTableLayout.refresh();
                        return true;
                    } catch (CannotDeleteCategoryException e) {
                        new Notification("Bd",
                                "Nie mona usun kategorii (posiada powizane eksponaty).",
                                Type.ERROR_MESSAGE, true).show(Page.getCurrent());
                    }
                    return false;
                }
            };
            UI.getCurrent().addWindow(confirmationWindow);
        }
    };
}