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:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java

public LoginView() {
    System.out.println("LOAD LLOGIN");
    setSizeFull();// w w  w  .j  a v a2s.  c o m
    Component loginForm = buildLoginForm();
    addComponent(loginForm);
    setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);

    Notification notification = new Notification("Welcome to Dashboard Demo");
    notification.setDescription(
            "<span>This application is not real, it only demonstrates an application built with the <a href=\"https://vaadin.com\">Vaadin framework</a>.</span> <span>No username or password is required, just click the <b>Sign In</b> button to continue.</span>");
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("tray dark small closable login-help");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(20000);
    notification.show(Page.getCurrent());
}

From source file:com.wintindustries.pfserver.uploads.PFUploadUnit.java

public void upload() {
    final ProgressIndicator pi = new ProgressIndicator();
    pi.setCaption(html5File.getFileName());
    progress.setCaption(html5File.getFileName());
    getprogressBarsLayout().addComponent(pi);
    final FileBuffer receiver = createReceiver();
    html5File.setStreamVariable(new StreamVariable() {

        private String name;
        private String mime;

        public OutputStream getOutputStream() {
            return receiver.receiveUpload(name, mime);
        }//from w w w  . j  av  a2s .c  om

        public boolean listenProgress() {
            return true;
        }

        public void onProgress(StreamVariable.StreamingProgressEvent event) {
            float p = (float) event.getBytesReceived() / (float) event.getContentLength();
            pi.setValue(p);
            progress.setProgress(p);
        }

        public void streamingStarted(StreamVariable.StreamingStartEvent event) {
            name = event.getFileName();
            mime = event.getMimeType();
            progress.setProgressState(progress.kUPLOADPROGRESS_UPLOADING);

        }

        public void streamingFinished(StreamVariable.StreamingEndEvent event) {
            getprogressBarsLayout().removeComponent(pi);
            handleFile(receiver.getFile(), html5File.getFileName(), html5File.getType(),
                    html5File.getFileSize());
            receiver.setValue(null);
            progress.setProgressState(progress.kUPLOADPROGRESS_DONE);
        }

        public void streamingFailed(StreamVariable.StreamingErrorEvent event) {
            getprogressBarsLayout().removeComponent(pi);
            progress.setProgressState(progress.kUPLOADPROGRESS_ERROR);
            progress.setErrmsg(event.toString());
            Notification note = new Notification("Upload Failed", event.toString(),
                    Notification.Type.ERROR_MESSAGE);
            note.show(Page.getCurrent());

        }

        public boolean isInterrupted() {
            return false;
        }
    });
}

From source file:com.wintindustries.pfserver.uploads.PFUploadUnit.java

@Override
protected void handleFile(File file, String fileName, String mimeType, long length) {
    Notification note = new Notification(fileName + " Uploaded", Notification.Type.TRAY_NOTIFICATION);
    note.show(Page.getCurrent());

    // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

From source file:com.yoncabt.ebr.ui.ReportStatusWindow.java

private Grid makeGrid() {
    Grid ret = new Grid();
    ret.setId("reportsGrid");
    ret.addColumn("uuid", String.class);
    ret.addColumn("data source", String.class);
    ret.addColumn("report", String.class);
    ret.addColumn("ext", String.class);
    ret.addColumn("started", String.class);
    ret.addColumn("ended", String.class);
    ret.addColumn("iptal", String.class)
            .setRenderer(new ButtonRenderer((ClickableRenderer.RendererClickEvent e) -> {
                String uuid = (String) grid.getContainerDataSource().getItem(e.getItemId())
                        .getItemProperty("uuid").getValue();
                reportWS.cancel(uuid);/*from w  ww.j a  v  a  2  s .  c  o  m*/
                Notification.show(uuid + " durduruldu");
            }));
    ret.addColumn("gster", String.class)
            .setRenderer(new ButtonRenderer((ClickableRenderer.RendererClickEvent e) -> {
                String uuid = (String) grid.getContainerDataSource().getItem(e.getItemId())
                        .getItemProperty("uuid").getValue();
                if (reportWS.status(uuid) == Status.FINISH) {
                    Page.getCurrent().open("/ebr/ws/1.0/output/" + uuid, "_new", false);
                } else {
                    Notification.show("Bitmi bir rapor yok");
                }
            }));
    ret.addColumn("durum", String.class);
    ret.addColumn("exception", String.class);
    ret.setSizeFull();
    return ret;
}

From source file:com.yoncabt.ebr.ui.ReportWindow.java

private void fillTheGridJRXML(ReportRequest request, EBRConnection con) throws SQLException, IOException {
    ReportTask task = reportService.request(request);
    if (task.getException() != null) {
        Notification.show("Hata", Notification.Type.ERROR_MESSAGE);
    } else {/*from w w  w . j  av a2  s . c om*/
        Page.getCurrent().open("/ebr/ws/1.0/output/" + request.getUuid(), "_blank");
    }
}

From source file:de.catma.ui.CatmaApplication.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    backgroundService = new UIBackgroundService(true);

    storeParameters(request.getParameterMap());

    Page.getCurrent().setTitle("CATMA 5.0 " + MINORVERSION);

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();// w ww .j  a  va2s  . co m

    menuPanel = new Panel();
    menuPanel.addStyleName("menuPanel");
    mainLayout.addComponent(menuPanel);

    contentPanel = new Panel();
    contentPanel.setHeight("100%");
    contentPanel.addStyleName("contentPanel");

    defaultContentPanelLabel = new Label("Please log in to get started");
    defaultContentPanelLabel.addStyleName("defaultContentPanelLabel");
    contentPanel.setContent(defaultContentPanelLabel);

    mainLayout.addComponent(contentPanel);
    mainLayout.setExpandRatio(contentPanel, 1.0f);

    menuLayout = new HorizontalLayout();
    menuLayout.setMargin(true);
    menuLayout.setSpacing(true);

    logoResource = new ThemeResource("catma-logo.png");
    Link logoImage = new Link(null, new ExternalResource("http://www.catma.de"));
    logoImage.setIcon(logoResource);
    logoImage.setTargetName("_blank");
    menuLayout.addComponent(logoImage);

    MenuFactory menuFactory = new MenuFactory();
    try {

        initTempDirectory();
        tagManager = new TagManager();

        repositoryManagerView = new RepositoryManagerView(
                new RepositoryManager(this, tagManager, RepositoryProperties.INSTANCE.getProperties()));

        tagManagerView = new TagManagerView(tagManager);

        taggerManagerView = new TaggerManagerView();

        analyzerManagerView = new AnalyzerManagerView();

        visualizationManagerView = new VisualizationManagerView();

        menu = menuFactory.createMenu(menuLayout, contentPanel,
                new MenuFactory.MenuEntryDefinition("Repository Manager", repositoryManagerView),
                new MenuFactory.MenuEntryDefinition("Tag Type Manager", tagManagerView),
                new MenuFactory.MenuEntryDefinition("Tagger", taggerManagerView),
                new MenuFactory.MenuEntryDefinition("Analyzer", analyzerManagerView),
                new MenuFactory.MenuEntryDefinition("Visualizer", visualizationManagerView));
        addPropertyChangeListener(CatmaApplicationEvent.userChange, menu.userChangeListener);

        Link latestFeaturesLink = new Link("Latest Features",
                new ExternalResource("http://www.catma.de/latestfeatures"));
        latestFeaturesLink.setTargetName("_blank");
        menuLayout.addComponent(latestFeaturesLink);
        menuLayout.setComponentAlignment(latestFeaturesLink, Alignment.TOP_RIGHT);
        menuLayout.setExpandRatio(latestFeaturesLink, 1.0f);

        Link aboutLink = new Link("About", new ExternalResource("http://www.catma.de"));
        aboutLink.setTargetName("_blank");
        menuLayout.addComponent(aboutLink);
        menuLayout.setComponentAlignment(aboutLink, Alignment.TOP_RIGHT);

        Link termsOfUseLink = new Link("Terms of Use", new ExternalResource("http://www.catma.de/termsofuse"));
        termsOfUseLink.setTargetName("_blank");
        menuLayout.addComponent(termsOfUseLink);
        menuLayout.setComponentAlignment(termsOfUseLink, Alignment.TOP_RIGHT);

        Link manualLink = new Link("Manual", new ExternalResource(request.getContextPath() + "/manual/"));
        manualLink.setTargetName("_blank");
        menuLayout.addComponent(manualLink);
        menuLayout.setComponentAlignment(manualLink, Alignment.TOP_RIGHT);

        Link helpLink = new Link("Helpdesk", new ExternalResource("http://www.catma.de/helpdesk/"));
        helpLink.setTargetName("_blank");
        menuLayout.addComponent(helpLink);
        menuLayout.setComponentAlignment(helpLink, Alignment.TOP_RIGHT);
        helpLink.setVisible(false);

        btHelp = new Button(FontAwesome.QUESTION_CIRCLE);
        btHelp.addStyleName("help-button");
        btHelp.addStyleName("application-help-button");

        menuLayout.addComponent(btHelp);

        btHelp.addClickListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {

                if (uiHelpWindow.getParent() == null) {
                    UI.getCurrent().addWindow(uiHelpWindow);
                } else {
                    UI.getCurrent().removeWindow(uiHelpWindow);
                }

            }
        });

        LoginLogoutCommand loginLogoutCommand = new LoginLogoutCommand(menu, repositoryManagerView);
        Button btloginLogout = new Button("Sign in", event -> loginLogoutCommand.menuSelected(null));
        btloginLogout.setStyleName(BaseTheme.BUTTON_LINK);
        btloginLogout.addStyleName("application-loginlink");

        loginLogoutCommand.setLoginLogoutButton(btloginLogout);

        menuLayout.addComponent(btloginLogout);
        menuLayout.setComponentAlignment(btloginLogout, Alignment.TOP_RIGHT);
        menuLayout.setWidth("100%");

        menuPanel.setContent(menuLayout);

        setContent(mainLayout);

        if (getParameter(Parameter.USER_IDENTIFIER) != null) {
            btloginLogout.click();
        }

        setPollInterval(10000);

        if ((getParameter(Parameter.AUTOLOGIN) != null) && (getUser() == null)) {
            getPage().setLocation(repositoryManagerView.createAuthenticationDialog().createLogInClick(this,
                    RepositoryPropertyKey.CATMA_oauthAuthorizationCodeRequestURL.getValue(),
                    RepositoryPropertyKey.CATMA_oauthAccessTokenRequestURL.getValue(),
                    RepositoryPropertyKey.CATMA_oauthClientId.getValue(),
                    RepositoryPropertyKey.CATMA_oauthClientSecret.getValue(), URLEncoder.encode("/", "UTF-8")));
        }

    } catch (Exception e) {
        showAndLogError("The system could not be initialized!", e);
    }

}

From source file:de.catma.ui.CatmaApplication.java

License:Open Source License

public void showAndLogError(String message, Throwable e) {
    logger.log(Level.SEVERE, "[" + getUser() + "]" + message, e);

    if (message == null) {
        message = "internal error";
    }/*from  ww w  .  j  ava 2s  .  c  om*/
    if (Page.getCurrent() != null) {
        HTMLNotification.show("Error",
                "An error has occurred!<br />"
                        + "We've been notified about this error and it will be fixed soon.<br />"
                        + "The underlying error message is:<br />" + message + "<br />" + e.getMessage(),
                Type.ERROR_MESSAGE);
    }
}

From source file:de.fatalix.app.view.login.LoginView.java

private void showNotification(Notification notification, String style) {
    // keep the notification visible a little while after moving the
    // mouse, or until clicked
    notification.setPosition(Position.TOP_CENTER);
    notification.setStyleName(ValoTheme.NOTIFICATION_BAR);
    notification.setDelayMsec(2000);//from   w  w w  . j av  a 2s  . c  o  m
    notification.show(Page.getCurrent());
}

From source file:de.gedoplan.webclients.vaadin.LoginUi.java

@Override
protected void init(VaadinRequest request) {
    TextField name = new TextField(Messages.login_name.value());
    name.focus();//  w  w w .j a  v  a 2s.com
    PasswordField password = new PasswordField(Messages.login_password.value());
    Button login = new Button(Messages.login_submit.value(), e -> {
        try {
            JaasAccessControl.login(name.getValue(), password.getValue());
            Page.getCurrent().setLocation(Konstanten.VAADIN_UI_PATH);
        } catch (ServletException ex) {
            Notification.show(Messages.login_invalid.value(), Notification.Type.ERROR_MESSAGE);
        }
    });
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    FormLayout fieldLayout = new FormLayout(name, password, login);
    fieldLayout.setMargin(true);
    fieldLayout.setSpacing(true);
    Panel loginPanel = new Panel(Messages.login_title.value(), fieldLayout);
    loginPanel.setSizeUndefined();
    VerticalLayout page = new VerticalLayout();
    page.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    page.addComponent(loginPanel);
    page.setSizeFull();
    setContent(page);
}

From source file:de.gedoplan.webclients.vaadin.VaadinDemoUi.java

@Override
protected void init(VaadinRequest request) {
    if (!accessControl.isUserSignedIn()) {
        close();//from w w  w.  j  av a 2s. co m
        Page.getCurrent().setLocation(Konstanten.VAADIN_LOGIN_PATH);
        return;
    }
    VerticalLayout page = new VerticalLayout();
    setContent(page);
    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();
    page.addComponents(createMenu(), content, createFooter());
    page.setExpandRatio(content, 1);
    page.setSizeFull();

    navigator = new Navigator(this, content);
    navigator.addProvider(cDIViewProvider);
    navigator.setErrorView(ErrorView.class);
}