Example usage for com.vaadin.ui BrowserFrame BrowserFrame

List of usage examples for com.vaadin.ui BrowserFrame BrowserFrame

Introduction

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

Prototype

public BrowserFrame(String caption, Resource source) 

Source Link

Document

Creates a new browser frame with the given caption and content.

Usage

From source file:annis.gui.LoginWindow.java

License:Apache License

@Override
public void attach() {
    super.attach();

    this.loginURL = (String) VaadinSession.getCurrent().getAttribute(LOGIN_URL_KEY);

    Resource loginRes;/*from w w w .j  a  v  a  2  s  . co  m*/
    if (loginURL == null || loginURL.isEmpty()) {
        loginRes = new ExternalResource(Helper.getContext() + "/login");
    } else {
        loginRes = new ExternalResource(loginURL);
    }

    BrowserFrame frame = new BrowserFrame("login", loginRes);
    frame.setWidth("100%");
    frame.setHeight("100%");

    setContent(frame);

    String loginMaximizedRaw = (String) getSession().getAttribute(LOGIN_MAXIMIZED_KEY);
    if (Boolean.parseBoolean(loginMaximizedRaw)) {
        setWindowMode(WindowMode.MAXIMIZED);
    }
}

From source file:cb_server.LogInWindow.java

License:Open Source License

private LogInWindow() {

    super("Get API Key"); // Set window caption

    this.setWidth(50, Unit.PERCENTAGE);
    this.setHeight(80, Unit.PERCENTAGE);

    center();//from   ww w . j  a  v  a  2s.co m

    URL url;
    try {

        String oAuthUrl = CB_Api.getGcAuthUrl();

        url = new URL(oAuthUrl);

        ExternalResource extRes = new ExternalResource(url);

        extRes.getURL();

        BrowserFrame browser = new BrowserFrame("", extRes);

        browser.setWidth(100, Unit.PERCENTAGE);
        browser.setHeight(100, Unit.PERCENTAGE);

        content = new VerticalLayout();
        content.setWidth(100, Unit.PERCENTAGE);
        content.setHeight(100, Unit.PERCENTAGE);
        setContent(content);

        //         browser.addListener(eventType, target, method);

        content.addComponent(browser);
    } catch (MalformedURLException e) {

        e.printStackTrace();
    }
}

From source file:com.esofthead.mycollab.module.project.view.bug.BugAdvertisementViewImpl.java

License:Open Source License

public BugAdvertisementViewImpl() {
    this.setWidth("100%");
    this.setHeight("512px");
    URL url = null;/*  w w  w .  j  av  a 2s .com*/
    try {
        url = new URL(AppContext.getSiteUrl() + "assets/ads/bug/bugAds.html");
    } catch (MalformedURLException e) {
        throw new MyCollabException(e);
    }
    BrowserFrame browser = new BrowserFrame("", new ExternalResource(url));
    browser.setWidth("100%");
    browser.setHeight("100%");

    this.addComponent(browser);
}

From source file:com.hack23.cia.web.impl.ui.application.views.admin.system.pagemode.AdminMonitoringPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ADMIN" })
@Override// w w  w.j  a v a  2s  . c o  m
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();

    final String pageId = getPageId(parameters);

    getMenuItemFactory().createMainPageMenuBar(menuBar);

    final BrowserFrame browser = new BrowserFrame(ADMIN_MONITORING,
            new ExternalResource(MONITORING_CONTEXT_PATH));
    browser.setSizeFull();

    content.addComponent(browser);
    content.setExpandRatio(browser, ContentRatio.FULL_SIZE);

    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_MONITORING_VIEW,
            ApplicationEventGroup.ADMIN, NAME, null, pageId);

    return content;

}

From source file:com.hivesys.dashboard.view.search.TextualView.java

public void UpdateSearchPane(String searchString) {
    css.removeAllComponents();/*from  w  w w  . j a  v  a 2  s .c o m*/

    SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString);
    logResponse(response);
    SearchHits results = response.getHits();

    Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>",
            ContentMode.HTML);
    css.addComponent(labelResultSummary);

    for (SearchHit hit : results) {
        CssLayout cssResult = new CssLayout();
        cssResult.setStyleName("search-result");

        try {
            String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId());
            String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId());

            String highlight = "";
            HighlightField objhighlight = hit.highlightFields().get("file");
            if (objhighlight != null) {
                for (Text fgmt : objhighlight.getFragments()) {
                    highlight += fgmt.string() + "<br>";
                }
            }

            Button lblfileName = new Button(filename);
            lblfileName.addClickListener((Button.ClickEvent event) -> {
                if (boxviewID != null) {
                    String url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                    if (url != null || !url.equals("")) {
                        url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                        BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url));
                        VerticalLayout vlayout = new VerticalLayout(bframe);

                        final Window w = new Window();
                        w.setSizeFull();
                        w.setModal(true);
                        w.setWindowMode(WindowMode.MAXIMIZED);
                        w.setContent(vlayout);
                        vlayout.setSizeFull();
                        vlayout.setMargin(true);
                        w.setResizable(false);
                        w.setDraggable(false);

                        UI.getCurrent().addWindow(w);
                        bframe.setSizeFull();
                        return;
                    }
                    Notification.show("Preview not available for this document!");
                }
            });
            lblfileName.setPrimaryStyleName("filename");

            Label lblHighlight = new Label(highlight, ContentMode.HTML);
            lblHighlight.setStyleName("highlight");

            cssResult.addComponent(lblfileName);
            cssResult.addComponent(lblHighlight);

            css.addComponent(cssResult);
            css.addComponent(new Label("<br>", ContentMode.HTML));

        } catch (SQLException ex) {
        }

    }

}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.layouteditor.LayoutEditorViewImpl.java

License:Open Source License

@Override
public void setArticleUrl(String url) {
    layout.removeAllComponents();/*from  w w  w  .j  av  a  2s  .co  m*/
    BrowserFrame editor = new BrowserFrame(null, new ExternalResource(url));
    editor.setWidth("650px");
    editor.setHeight("100%");
    layout.addComponent(editor);
}

From source file:com.nfl.poc.editor.app.NFLEditorViewImpl.java

License:Open Source License

public NFLEditorViewImpl() {
    root.setSizeFull();/* www  .j  a  va  2 s  .c  o m*/
    // Vaadin Iframe component
    BrowserFrame editor = new BrowserFrame(null, new ExternalResource("nfl-editor"));
    editor.setSizeFull();
    root.addComponent(editor);
}

From source file:com.peergreen.webconsole.scope.web.documentation.PeergreenDocumentation.java

License:Open Source License

@PostConstruct
public void init() {
    setMargin(true);//from   ww w  . jav  a2s  . c  om
    setSpacing(true);
    BrowserFrame browser = new BrowserFrame("", new ExternalResource(
            "http://docs.peergreen.com/peergreen_server/latest/reference/xhtml-single/user-guide.xhtml"));
    browser.setSizeFull();
    addComponent(browser);
    setExpandRatio(browser, 1.5f);
}

From source file:com.peergreen.webconsole.scope.web.website.PeergreenWebSite.java

License:Open Source License

@PostConstruct
public void init() {
    setMargin(true);//from   ww  w.ja v  a  2s  . c o m
    setSpacing(true);
    BrowserFrame browser = new BrowserFrame("", new ExternalResource("http://www.peergreen.com/"));
    browser.setSizeFull();
    addComponent(browser);
    setExpandRatio(browser, 1.5f);
}

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

License:Open Source License

/**
 * Precondition: {DatasetView#table} has to be initialized. e.g. with
 * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the
 * Layout of this view./*from  ww  w.j a  v  a 2 s .  c om*/
 */
private void buildLayout() {
    this.vert.removeAllComponents();
    this.vert.setSizeFull();

    vert.setResponsive(true);

    // Table (containing datasets) section
    VerticalLayout tableSection = new VerticalLayout();
    HorizontalLayout tableSectionContent = new HorizontalLayout();
    tableSection.setResponsive(true);
    tableSectionContent.setResponsive(true);

    // tableSectionContent.setCaption("Datasets");
    // tableSectionContent.setIcon(FontAwesome.FLASK);
    // tableSection.addComponent(new Label(String.format("This project contains %s dataset(s).",
    // numberOfDatasets)));
    tableSectionContent.setMargin(new MarginInfo(true, false, true, false));

    tableSection.addComponent(headerLabel);
    tableSectionContent.addComponent(this.table);
    vert.setMargin(new MarginInfo(false, true, false, false));

    tableSection.setMargin(new MarginInfo(true, false, false, true));
    // tableSectionContent.setMargin(true);
    // tableSection.setMargin(true);

    tableSection.addComponent(tableSectionContent);
    this.vert.addComponent(tableSection);

    table.setSizeFull();
    tableSection.setSizeFull();
    tableSectionContent.setSizeFull();

    // this.table.setSizeFull();

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setMargin(new MarginInfo(false, false, true, true));
    buttonLayout.setHeight(null);
    // buttonLayout.setWidth("100%");
    buttonLayout.setSpacing(true);
    buttonLayout.setResponsive(true);

    // final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION);

    Button checkAll = new Button("Select all datasets");
    checkAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(true);
            }
        }
    });

    Button uncheckAll = new Button("Unselect all datasets");
    uncheckAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false);
            }
        }
    });

    String content = "<p> In case of multiple file selections, Project Browser will create a tar archive.</p>"
            + "<hr>" + "<p> If you need help on extracting a tar archive file, follow the tips below: </p>"
            + "<p>" + FontAwesome.WINDOWS.getHtml() + " Windows </p>"
            + "<p> To open/extract TAR file on Windows, you can use 7-Zip, Easy 7-Zip, PeaZip.</p>" + "<hr>"
            + "<p>" + FontAwesome.APPLE.getHtml() + " MacOS </p>"
            + "<p> To open/extract TAR file on Mac, you can use Mac OS built-in utility Archive Utility,<br> or third-party freeware. </p>"
            + "<hr>" + "<p>" + FontAwesome.LINUX.getHtml() + " Linux </p>"
            + "<p> You need to use command tar. The tar is the GNU version of tar archiving utility. <br> "
            + "To extract/unpack a tar file, type: $ tar -xvf file.tar</p>";

    export.setIcon(FontAwesome.DOWNLOAD);

    PopupView tooltip = new PopupView(new helpers.ToolTip(content));
    tooltip.setHeight("44px");

    HorizontalLayout help = new HorizontalLayout();
    help.setSizeFull();
    HorizontalLayout helpContent = new HorizontalLayout();
    // helpContent.setSizeFull();

    help.setMargin(new MarginInfo(false, false, false, true));
    Label helpText = new Label("Attention: Click here before Download!");
    helpContent.addComponent(new Label(FontAwesome.QUESTION_CIRCLE.getHtml(), ContentMode.HTML));
    helpContent.addComponent(helpText);
    helpContent.addComponent(tooltip);
    helpContent.setSpacing(true);

    help.addComponent(helpContent);
    help.setComponentAlignment(helpContent, Alignment.TOP_CENTER);

    buttonLayout.addComponent(export);
    buttonLayout.addComponent(checkAll);
    buttonLayout.addComponent(uncheckAll);
    // buttonLayout.addComponent(visualize);
    buttonLayout.addComponent(this.download);

    /**
     * prepare download.
     */
    download.setEnabled(false);
    download.setResource(new ExternalResource("javascript:"));
    // visualize.setEnabled(false);

    for (final Object itemId : this.table.getItemIds()) {
        setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue());
    }

    this.table.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (!event.isDoubleClick()
                    & !((boolean) table.getItem(event.getItemId()).getItemProperty("isDirectory").getValue())) {
                String datasetCode = (String) table.getItem(event.getItemId()).getItemProperty("CODE")
                        .getValue();
                String datasetFileName = (String) table.getItem(event.getItemId()).getItemProperty("File Name")
                        .getValue();
                URL url;
                try {
                    Resource res = null;
                    Object parent = table.getParent(event.getItemId());
                    if (parent != null) {
                        String parentDatasetFileName = (String) table.getItem(parent)
                                .getItemProperty("File Name").getValue();
                        url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode,
                                parentDatasetFileName + "/" + datasetFileName);
                    } else {
                        url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName);
                    }

                    Window subWindow = new Window();
                    VerticalLayout subContent = new VerticalLayout();
                    subContent.setMargin(true);
                    subContent.setSizeFull();
                    subWindow.setContent(subContent);
                    QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent();
                    Boolean visualize = false;

                    if (datasetFileName.endsWith(".pdf")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("application/pdf");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".png")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        // streamres.setMIMEType("application/png");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".qcML")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/xml");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".alleles")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".tsv")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".GSvar")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".log")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".html")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/html");
                        res = streamres;
                        visualize = true;
                    }

                    if (visualize) {
                        // LOGGER.debug("Is resource null?: " + String.valueOf(res == null));
                        BrowserFrame frame = new BrowserFrame("", res);

                        subContent.addComponent(frame);

                        // Center it in the browser window
                        subWindow.center();
                        subWindow.setModal(true);
                        subWindow.setSizeUndefined();
                        subWindow.setHeight("75%");
                        subWindow.setWidth("75%");
                        subWindow.setResizable(false);

                        frame.setSizeFull();
                        frame.setHeight("100%");
                        // frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS);

                        // Open it in the UI
                        ui.addWindow(subWindow);
                    }

                } catch (MalformedURLException e) {
                    LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s",
                            datasetCode));
                    Notification.show(
                            "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data",
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        }
    });

    this.vert.addComponent(buttonLayout);
    this.vert.addComponent(help);

}