Example usage for com.vaadin.server VaadinService getCurrent

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

Introduction

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

Prototype

public static VaadinService getCurrent() 

Source Link

Document

Gets the currently used Vaadin service.

Usage

From source file:com.gnts.pem.txn.synd.SyndBuilding.java

License:Open Source License

private void updateEvaluationDetails() {
    try {//from   w  w w  .j  ava  2  s.c  o m
        boolean valid = false;
        TPemCmEvalDetails evalobj = new TPemCmEvalDetails();
        evalNumber = tfEvaluationNumber.getValue();
        customer = tfCustomerName.getValue();
        propertyType = "BUILDING";
        String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

        File file = new File(
                basepath + "/WEB-INF/PEM-DOCS/" + evalNumber + "_" + customer + "_" + propertyType + ".doc");
        FileInputStream fin = new FileInputStream(file);
        byte fileContent[] = new byte[(int) file.length()];
        fin.read(fileContent);
        fin.close();
        evalobj.setDocId(headerid);
        evalobj.setEvalDoc(fileContent);
        evalobj.setDocStatus(Common.DOC_PENDING);
        evalobj.setDocDate(dfDateofValuation.getValue());
        evalobj.setEvalNo(tfEvaluationNumber.getValue());
        evalobj.setEvalDate(dfDateofValuation.getValue());
        evalobj.setValuationBy(tfValuatedBy.getValue());
        MPemCmBank bankid = new MPemCmBank();
        bankid.setBankId(selectedBankid);
        evalobj.setBankId(bankid);
        evalobj.setDoctype(screenName);
        evalobj.setCompanyId(selectCompanyid);
        evalobj.setBankBranch((String) tfBankBranch.getValue());
        evalobj.setEvalPurpose(tfEvaluationPurpose.getValue());
        evalobj.setEvalDate(dfDateofValuation.getValue());
        evalobj.setCheckedBy(tfVerifiedBy.getValue());
        evalobj.setCheckedDt(dfVerifiedDate.getValue());
        evalobj.setInspectionDt(dfDateofValuation.getValue());
        evalobj.setInspectionBy(tfValuatedBy.getValue());
        evalobj.setLastUpdateDt(new Date());
        evalobj.setLastUpdtedBy(loginusername);
        evalobj.setCustName(tfCustomerName.getValue());

        if (tfDynamicEvaluation1.getValue() != null && tfDynamicEvaluation1.getValue().trim().length() > 0) {
            evalobj.setCustomLbl1(tfDynamicEvaluation1.getCaption());
            evalobj.setCustomValue1(tfDynamicEvaluation1.getValue());
        }
        if (tfDynamicEvaluation2.getValue() != null && tfDynamicEvaluation2.getValue().trim().length() > 0) {
            evalobj.setCustomValue2(tfDynamicEvaluation2.getCaption());
            evalobj.setCustomValue2(tfDynamicEvaluation2.getValue());
        }
        try {
            BigDecimal totalAbstract = new BigDecimal(0.00);
            BigDecimal test = new BigDecimal("0.00");
            BigDecimal test1 = new BigDecimal("0.00");
            BigDecimal test2 = new BigDecimal("0.00");
            BigDecimal test3 = new BigDecimal("0.00");
            BigDecimal test4 = new BigDecimal("0.00");
            BigDecimal test5 = new BigDecimal("0.00");
            try {
                test = new BigDecimal(
                        uiflowdata.getTotalExtraItem().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));

            } catch (Exception e) {
                test = new BigDecimal("0.00");
            }
            try {
                test1 = new BigDecimal(
                        tfFairMarketRate.getValue().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));
            } catch (Exception e) {
                test1 = new BigDecimal("0.00");
            }
            try {
                test2 = new BigDecimal(
                        uiflowdata.getTotalAdditional().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));
            } catch (Exception e) {
                test2 = new BigDecimal("0.00");
            }
            try {
                test3 = new BigDecimal(
                        uiflowdata.getTotalMiscellaneous().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));

            } catch (Exception e) {
                test3 = new BigDecimal("0.00");
            }
            try {
                test4 = new BigDecimal(
                        uiflowdata.getTotalServices().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));
            } catch (Exception e) {
                test4 = new BigDecimal("0.00");
            }
            try {
                test5 = new BigDecimal(
                        uiflowdata.getTotalValuation().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));
            } catch (Exception e) {
                test5 = new BigDecimal("0.00");
            }
            totalAbstract = totalAbstract.add(test).add(test1).add(test2).add(test3).add(test4).add(test5);

            uiflowdata.setTotalAbstractvalue(XMLUtil.IndianFormat(new BigDecimal(totalAbstract.toString())));
            String numberOnly = totalAbstract.toString().replaceAll("[^\\d.]", "");
            if (numberOnly.trim().length() == 0) {
                numberOnly = "0";
            }
            evalobj.setPropertyValue(Double.valueOf(numberOnly));
            uiflowdata.setEvalDtls(evalobj);

            uiflowdata.setAmountInWords(beanEvaluation.getAmountInWords(numberOnly));
            if (tfEvaluationNumber.isValid() && tfBankBranch.isValid() && tfEvaluationPurpose.isValid()
                    && dfDateofValuation.isValid()) {

                if (count == 0) {
                    beanEvaluation.saveorUpdateEvalDetails(evalobj);

                    valid = true;
                }
                lblNotificationIcon.setIcon(new ThemeResource("img/success_small.png"));
                lblSaveNotification.setValue("Successfully Submitted");
            }

            if (valid) {
                /*populateAndConfig(false);
                resetAllFieldsFields();*/
                btnSubmit.setEnabled(false);
            } else {
                btnSubmit.setComponentError(new UserError("Form is invalid"));
            }
        } catch (Exception e) {

        }

    } catch (Exception e) {
        lblNotificationIcon.setIcon(new ThemeResource("img/failure.png"));
        lblSaveNotification.setValue("Submit failed, please check the data and try again ");
        logger.info("Error on SaveApproveReject Status function--->" + e);
    }
}

From source file:com.gnts.pem.txn.synd.SyndConstruction.java

License:Open Source License

private void updateEvaluationDetails() {
    try {/*from   www  . j  a v a 2s . com*/
        boolean valid = false;
        TPemCmEvalDetails evalobj = new TPemCmEvalDetails();
        evalNumber = tfEvaluationNumber.getValue();
        customer = tfCustomerName.getValue();
        propertyType = "CONSTRUCTION";
        String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
        File file = new File(
                basepath + "/WEB-INF/PEM-DOCS/" + evalNumber + "_" + customer + "_" + propertyType + ".doc");
        FileInputStream fin = new FileInputStream(file);
        byte fileContent[] = new byte[(int) file.length()];
        fin.read(fileContent);
        fin.close();
        evalobj.setDocId(headerid);
        evalobj.setEvalDoc(fileContent);
        evalobj.setDocStatus(Common.DOC_PENDING);
        evalobj.setDocDate(dfDateofValuation.getValue());
        evalobj.setEvalNo(tfEvaluationNumber.getValue());
        evalobj.setEvalDate(dfDateofValuation.getValue());
        evalobj.setValuationBy(tfValuatedBy.getValue());
        MPemCmBank bankid = new MPemCmBank();
        bankid.setBankId(selectedBankid);
        evalobj.setBankId(bankid);
        evalobj.setDoctype(screenName);
        evalobj.setCompanyId(selectCompanyid);
        evalobj.setBankBranch((String) tfBankBranch.getValue());
        evalobj.setEvalPurpose(tfEvaluationPurpose.getValue());
        evalobj.setEvalDate(dfDateofValuation.getValue());
        evalobj.setCheckedBy(tfVerifiedBy.getValue());
        evalobj.setCheckedDt(dfVerifiedDate.getValue());
        evalobj.setInspectionDt(dfDateofValuation.getValue());
        evalobj.setInspectionBy(tfValuatedBy.getValue());
        evalobj.setLastUpdateDt(new Date());
        evalobj.setLastUpdtedBy(loginusername);
        evalobj.setCustName(tfCustomerName.getValue());

        if (tfDynamicEvaluation1.getValue() != null && tfDynamicEvaluation1.getValue().trim().length() > 0) {
            evalobj.setCustomLbl1(tfDynamicEvaluation1.getCaption());
            evalobj.setCustomValue1(tfDynamicEvaluation1.getValue());
        }
        if (tfDynamicEvaluation2.getValue() != null && tfDynamicEvaluation2.getValue().trim().length() > 0) {
            evalobj.setCustomValue2(tfDynamicEvaluation2.getCaption());
            evalobj.setCustomValue2(tfDynamicEvaluation2.getValue());
        }

        BigDecimal construction = new BigDecimal(0.00);
        BigDecimal totalFair = new BigDecimal(0.00);
        BigDecimal fairMarket = new BigDecimal(0.00);
        BigDecimal totalRealizable = new BigDecimal(0.00);
        BigDecimal totalDistress = new BigDecimal(0.00);
        BigDecimal totalGuide = new BigDecimal(0.00);
        BigDecimal test = new BigDecimal("0.00");
        BigDecimal test1 = new BigDecimal("0.00");
        BigDecimal test2 = new BigDecimal("0.00");
        BigDecimal test3 = new BigDecimal("0.00");
        BigDecimal test4 = new BigDecimal("0.00");

        try {
            test = new BigDecimal(
                    tfCostConstruction.getValue().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));

        } catch (Exception e) {
            test = new BigDecimal("0.00");

        }
        try {
            test1 = new BigDecimal(
                    tfFairMarketRate.getValue().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));

        } catch (Exception e) {

            test1 = new BigDecimal("0.00");
        }

        try {
            test4 = new BigDecimal(
                    tfGuidelineRate.getValue().replaceFirst("\\.0+$", "").replaceAll("[^0-9]", ""));

        } catch (Exception e) {

            test4 = new BigDecimal("0.00");
        }
        try {
            construction = construction.add(test);
            fairMarket = fairMarket.add(test1);
            totalFair = totalFair.add(test1).add(construction);
            uiflowdata.setTotalExtraItem(XMLUtil.IndianFormat(new BigDecimal(totalFair.toString())));

            totalGuide = totalGuide.add(test4);
            uiflowdata.setTotalServices(XMLUtil.IndianFormat(new BigDecimal(totalGuide.toString())));

            uiflowdata.setTotalAbstractvalue(XMLUtil.IndianFormat(new BigDecimal(totalFair.toString())));
            String numberOnly = totalFair.toString().replaceAll("[^\\d.]", "");
            if (numberOnly.trim().length() == 0) {
                numberOnly = "0";
            }
            evalobj.setPropertyValue(Double.valueOf(numberOnly));
            uiflowdata.setEvalDtls(evalobj);
            uiflowdata.setAmountInWords(beanEvaluation.getAmountInWords(numberOnly));
            String numberOnly1 = tfGuidelineRate.getValue().replaceAll("[^0-9]", "");
            uiflowdata.setAmountWordsGuideline(beanEvaluation.getAmountInWords(numberOnly1));
            if (tfEvaluationNumber.isValid() && tfBankBranch.isValid() && tfEvaluationPurpose.isValid()
                    && dfDateofValuation.isValid()) {

                if (count == 0) {
                    beanEvaluation.saveorUpdateEvalDetails(evalobj);

                    valid = true;
                }
                lblNotificationIcon.setIcon(new ThemeResource("img/success_small.png"));
                lblSaveNotification.setValue("Submitted Successfully");
            }

            if (valid) {
                /*populateAndConfig(false);
                resetAllFieldsFields();*/
                btnSubmit.setEnabled(false);
            } else {
                btnSubmit.setComponentError(new UserError("Form is invalid"));
            }
        } catch (Exception e) {

            logger.info("Error-->" + e);
        }

        lblNotificationIcon.setIcon(new ThemeResource("img/success_small.png"));
        lblSaveNotification.setValue("Successfully Submitted");
    } catch (Exception e) {
        lblNotificationIcon.setIcon(new ThemeResource("img/failure.png"));
        lblSaveNotification.setValue("Submit failed, please check the data and try again ");
        logger.info("Error on SaveApproveReject Status function--->" + e);
    }
}

From source file:com.gnts.pem.txn.synd.SyndFlat.java

License:Open Source License

private void updateEvaluationDetails() {

    try {//ww w .j a v a  2s  .c o m
        boolean valid = false;
        TPemCmEvalDetails evalobj = new TPemCmEvalDetails();
        evalNumber = tfEvaluationNumber.getValue();
        customer = tfCustomerName.getValue();
        propertyType = "FLAT";
        String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
        File file = new File(
                basepath + "/WEB-INF/PEM-DOCS/" + evalNumber + "_" + customer + "_" + propertyType + ".doc");
        FileInputStream fin = new FileInputStream(file);
        byte fileContent[] = new byte[(int) file.length()];
        fin.read(fileContent);
        fin.close();
        evalobj.setDocId(headerid);
        evalobj.setEvalDoc(fileContent);
        evalobj.setDocStatus(Common.DOC_PENDING);
        evalobj.setEvalNo(tfEvaluationNumber.getValue());
        evalobj.setValuationBy(tfValuatedBy.getValue());
        MPemCmBank bankid = new MPemCmBank();
        bankid.setBankId(selectedBankid);
        evalobj.setBankId(bankid);
        evalobj.setDoctype(screenName);
        evalobj.setCompanyId(selectCompanyid);
        evalobj.setBankBranch((String) slBankBranch.getValue());
        evalobj.setEvalPurpose(tfEvaluationPurpose.getValue());
        evalobj.setEvalDate(dfDateofValuation.getValue());
        evalobj.setCheckedBy(tfVerifiedBy.getValue());
        evalobj.setCheckedDt(dfVerifiedDate.getValue());
        evalobj.setInspectionDt(dfDateofValuation.getValue());
        evalobj.setInspectionBy(tfValuatedBy.getValue());
        evalobj.setLastUpdateDt(new Date());
        evalobj.setLastUpdtedBy(loginusername);
        evalobj.setCustName(tfCustomerName.getValue());
        if (tfDynamicEvaluation1.getValue() != null && tfDynamicEvaluation1.getValue().trim().length() > 0) {
            evalobj.setCustomLbl1(tfDynamicEvaluation1.getCaption());
            evalobj.setCustomValue1(tfDynamicEvaluation1.getValue());
        }
        if (tfDynamicEvaluation2.getValue() != null && tfDynamicEvaluation2.getValue().trim().length() > 0) {
            evalobj.setCustomValue2(tfDynamicEvaluation2.getCaption());
            evalobj.setCustomValue2(tfDynamicEvaluation2.getValue());
        }
        uiflowdata.setEvalDtls(evalobj);
        String numberOnly = tfCostOfConstAsAtSite.getValue().replaceAll("[^\\d.]", "");
        uiflowdata.setAmountInWords(beanEvaluation.getAmountInWords(numberOnly));
        if (numberOnly.trim().length() == 0) {
            numberOnly = "0";
        }
        evalobj.setPropertyValue(Double.valueOf(numberOnly));

        if (tfEvaluationNumber.isValid() && slBankBranch.isValid() && tfEvaluationPurpose.isValid()
                && dfDateofValuation.isValid()) {

            if (count == 0) {
                beanEvaluation.saveorUpdateEvalDetails(evalobj);

                valid = true;
            }
            lblNotificationIcon.setIcon(new ThemeResource("img/success_small.png"));
            lblSaveNotification.setValue("Submitted Successfully");
        }

        if (valid) {
            /*populateAndConfig(false);
            resetAllFieldsFields();*/
            btnSubmit.setEnabled(false);
        } else {
            btnSubmit.setComponentError(new UserError("Form is invalid"));
        }
    } catch (Exception e) {
        lblNotificationIcon.setIcon(new ThemeResource("img/failure.png"));
        lblSaveNotification.setValue("Submit failed, please check the data and try again ");
        logger.info("Error on SaveApproveReject Status function--->" + e);
    }
}

From source file:com.jee.client.JeeclientUI.java

@Override
protected void init(VaadinRequest request) {
    new Navigator(this, this);
    getNavigator().addView(LoginForm.NAME, LoginForm.class);
    getNavigator().addView(MainView.NAME, MainView.class);
    getNavigator().addViewChangeListener(new ViewChangeListener() {

        @Override//from  ww  w . j av  a2 s .  c  om
        public boolean beforeViewChange(ViewChangeEvent event) {
            // Check if a user has logged in
            boolean isLoggedIn = VaadinService.getCurrentRequest().getWrappedSession()
                    .getAttribute(USER_NAME_ATTRIBUTE_NAME) != null;// getSession().getAttribute(USER_NAME_ATTRIBUTE_NAME) != null;
            boolean isLoginView = event.getNewView() instanceof LoginForm;

            if (!isLoggedIn && !isLoginView) {
                // Redirect to login view always if a user has not yet
                // logged in
                getNavigator().navigateTo(LoginForm.NAME);
                return false;

            } else if (isLoggedIn && isLoginView) {
                // If someone tries to access to login view while logged in,
                // then cancel
                return false;
            }

            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {

        }
    });

    WrappedSession session = request.getWrappedSession();
    HttpSession httpSession = ((WrappedHttpSession) session).getHttpSession();
    ServletContext servletContext = httpSession.getServletContext();
    applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    messageSource = (ReloadableResourceBundleMessageSource) applicationContext.getBean("resource");
    userAdminManager = (VoucheringManager) applicationContext.getBean("userAdminManager");
    WebUtil.absolutePath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
    this.getLoadingIndicatorConfiguration().setFirstDelay(500);
    this.getLoadingIndicatorConfiguration().setSecondDelay(30000);
    this.getLoadingIndicatorConfiguration().setThirdDelay(80000);
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.UserDetailsWidgetOld.java

public UserDetailsWidgetOld() {

    setSpacing(true);// ww w.j  a  va 2  s . c  o  m
    Panel iPanel = new Panel();
    iPanel.setWidth("50px");
    iPanel.setHeight("50px");
    iPanel.setStyleName("backColorWhite");
    addComponent(iPanel);
    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

    // Image as a file resource
    FileResource resource = new FileResource(new File(basepath + "/VAADIN/themes/mytheme/img/loginPage.jpg"));

    // Show the image in the application
    Image image = new Image("", resource);
    image.setSizeFull();
    iPanel.setContent(image);

}

From source file:com.parship.roperty.ui.LoginUI.java

License:Apache License

/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 * The constructor will not be automatically regenerated by the
 * visual editor./* ww w . ja  va2s . com*/
 */
public LoginUI() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    // Set Logo
    // Find the application directory
    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
    FileResource resourceLogo = new FileResource(new File(basepath + "/WEB-INF/images/roperty-logo.png"));
    logoImage.setSource(resourceLogo);

    /* MenuBar */
    // About
    MenuBar.MenuItem about = menuBar.addItem("About Roperty", null);
    about.addItem("Visit Website", null);
    about.addItem("Team", null);

    // Debug
    MenuBar.MenuItem debug = menuBar.addItem("Debug", null);
    debug.addItem("Logout", new LogoutCommand());

    // Enter-Listener for login
    ShortcutListener enterListener = new ShortcutListener("ENTER", ShortcutAction.KeyCode.ENTER, null) {

        private static final long serialVersionUID = 1L;

        @Override
        public void handleAction(Object sender, Object target) {
            if (target == passTextField || target == userTextField) {
                buttonClick(null);
            }
        }
    };

    this.userTextField.addShortcutListener(enterListener);
    this.passTextField.addShortcutListener(enterListener);

    this.userTextField.setInputPrompt("Username");
    this.passTextField.setInputPrompt("Password");

    String prevUser = RopertyUiSession.getPreviousUserName();
    if (prevUser != null) {
        this.userTextField.setValue(prevUser);
        this.passTextField.focus();
    } else {
        this.userTextField.focus();
    }

    String rememberMe = RopertyUiSession.wasRememberMe();
    if (rememberMe != null && rememberMe.equals("true")) {
        this.keeploggedinLabel.setValue(true);
    }

    this.loginButton.addClickListener(this);

    if (UserManager.isLoggedIn()) {
        buttonClick(null);
    }

}

From source file:com.parship.roperty.ui.NavigationViewUI.java

License:Apache License

/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 * The constructor will not be automatically regenerated by the
 * visual editor.//from  ww  w  .  java2 s .com
 */
public NavigationViewUI() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    /* Menu Bar */
    // User Menu
    User currentUser = UserManager.getCurrentUser();
    if (currentUser != null) {
        String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
        FileResource resourceCloudIcon = new FileResource(
                new File(basepath + "/WEB-INF/images/icons/111-user.png"));
        MenuBar.MenuItem userMenu = mainMenuBar.addItem(currentUser.getFullName(), null);
        userMenu.setIcon(resourceCloudIcon);
        userMenu.addItem("Logout", new LogoutCommand());
    }
}

From source file:com.snowy.MyVaadinUI.java

@Override
protected void init(VaadinRequest request) {
    //d = new data(template);
    if (Page.getCurrent().getWebBrowser().isTooOldToFunctionProperly()) {
        Page.getCurrent().setLocation("https://www.google.com/chrome/browser/");
    }//from   w  ww .j  a  v a2 s  . com
    //VaadinService.getCurrent().
    Page.getCurrent().setTitle("Connect 4");

    d = new data();
    //this.access(()->{

    //n.addView("postLogin", new PostLoginView());
    //Navigator n = this.getNavigator();
    //n.addProvider();
    //});
    /*
    final TextField name = new TextField();
    name.setCaption("Type your name here:");
            
    Button button = new Button("Click Me");
    button.addClickListener( e -> {
    layout.addComponent(new Label("Thanks " + name.getValue() 
            + ", it works!"));
    });
    */
    JavaScript.getCurrent().addFunction("closeMyApplication", new JavaScriptFunction() {
        @Override
        public void call(JsonArray arguments) {
            //Logger.getLogger(MyVaadinUI.class.getName()).info(VaadinSession.getCurrent().getCsrfToken());
            d.logout(VaadinSession.getCurrent().getCsrfToken());
            //new data().setInActive(VaadinSession.getCurrent().getCsrfToken());
            //VaadinSession.getCurrent().close();
        }

    });

    Page.getCurrent().getJavaScript().execute(
            "window.onbeforeunload = function (e) { var e = e || window.event; closeMyApplication(); return; };");
    VaadinService.getCurrent().addSessionDestroyListener(e -> {
        //Logger.getLogger(MyVaadinUI.class.getName()).info(e.getSession().getCsrfToken());
        d.logout(e.getSession().getCsrfToken());

    });

    //Navigator n = new Navigator(this,this);
    //n.addView("Main", new PostLoginView());
    //        this.setNavigator(n);
    //layout.setComponentAlignment(MainL, Alignment.TOP_CENTER);
    this.setPollInterval(1000);
    this.addPollListener((UIEvents.PollEvent e) -> {
        if (e.getUI().getContent().toString().contains("PostLoginView")) {
            PostLoginView plv = (PostLoginView) e.getUI().getContent();
            d.resetActiveIfNot();
            plv.getChatWindow().getUsersList().retrieveActiveUsers();

            plv.getChatWindow().updateChats();
            plv.getGameWindow().updateRequests();
            plv.getGameWindow().updateGames();
            plv.getGameWindow().checkForNewGames();
            //Logger.getLogger(MyVaadinUI.class.getName()).log(Level.INFO,plv.getChatWindow().getUsersList().getValue().toString());
        }

    });
    Navigator navigator = new Navigator(this, this);
    navigator.addProvider(viewProvider);

    navigator.addViewChangeListener(new ViewChangeListener() {
        @Override
        public boolean beforeViewChange(ViewChangeListener.ViewChangeEvent event) {

            if (Page.getCurrent().getLocation().getPath().equals("/")
                    || VaadinSession.getCurrent().getAttribute("token") != null) {

                return true;
            } else {

                //Notification.show(,Notification.Type.ERROR_MESSAGE);
                return false;
            }
        }

        @Override
        public void afterViewChange(ViewChangeListener.ViewChangeEvent event) {

        }

    });

    /*UI.getCurrent().setErrorHandler(new DefaultErrorHandler(){
     @Override
     public void error(com.vaadin.server.ErrorEvent event) {
         UI.getCurrent().setContent(new Label("error"));
     }
                
    });*/
    //VaadinService.createCriticalNotificationJSON("","", "", "");
    //navigator.setErrorView(navigator.getCurrentView());
    //layout.setComponentAlignment(link, Alignment.MIDDLE_CENTER);
    //setContent(new Login());

}

From source file:com.squadd.chat.ChatController.java

private void configureImages() {
    if (userFromImageFile == null) {
        String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
        FileResource resource = new FileResource(new java.io.File(basepath + "/VAADIN/images/user_icon.png"));
        userFromImageEmbedded = new Embedded("", resource);
    } else {//  w  ww  . j  a v  a 2s. c  o m
        FileResource imageResource = ResourceManager.open(userFromImageFile);
        userFromImageEmbedded = new Embedded("", imageResource);
    }
    if (userToImageFile == null) {
        String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
        FileResource resource = new FileResource(new java.io.File(basepath + "/VAADIN/images/user_icon.png"));
        userToImageEmbedded = new Embedded("", resource);
    } else {
        FileResource imageResource = ResourceManager.open(userToImageFile);
        userToImageEmbedded = new Embedded("", imageResource);
    }
    userFromImageEmbedded.setHeight("50px");
    userFromImageEmbedded.setWidth("50px");
    userToImageEmbedded.setHeight("50px");
    userToImageEmbedded.setWidth("50px");
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java

License:Open Source License

/**
 * 
 * @return
 */
private boolean isInProductionMode() {
    return VaadinService.getCurrent().getDeploymentConfiguration().isProductionMode();
}