Example usage for com.vaadin.ui Embedded TYPE_BROWSER

List of usage examples for com.vaadin.ui Embedded TYPE_BROWSER

Introduction

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

Prototype

int TYPE_BROWSER

To view the source code for com.vaadin.ui Embedded TYPE_BROWSER.

Click Source Link

Document

Browser ("iframe") type.

Usage

From source file:org.milleni.dunning.ui.customer.form.CustomProcessInstanceDetailPanel.java

License:Apache License

protected void addProcessImage() {
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
            .getDeployedProcessDefinition(processDefinition.getId());

    // Only show when graphical notation is defined
    if (processDefinitionEntity != null) {

        boolean didDrawImage = false;

        if (ExplorerApp.get().isUseJavascriptDiagram()) {
            try {

                final InputStream definitionStream = repositoryService.getResourceAsStream(
                        processDefinition.getDeploymentId(), processDefinition.getResourceName());
                XMLInputFactory xif = XMLInputFactory.newInstance();
                XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
                BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

                if (bpmnModel.getFlowLocationMap().size() > 0) {

                    int maxX = 0;
                    int maxY = 0;
                    for (String key : bpmnModel.getLocationMap().keySet()) {
                        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
                        double elementX = graphicInfo.getX() + graphicInfo.getWidth();
                        if (maxX < elementX) {
                            maxX = (int) elementX;
                        }//from   w  w w  . jav a 2 s  .  co m
                        double elementY = graphicInfo.getY() + graphicInfo.getHeight();
                        if (maxY < elementY) {
                            maxY = (int) elementY;
                        }
                    }

                    Panel imagePanel = new Panel(); // using panel for scrollbars
                    imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
                    imagePanel.setWidth(100, UNITS_PERCENTAGE);
                    imagePanel.setHeight(100, UNITS_PERCENTAGE);
                    URL explorerURL = ExplorerApp.get().getURL();
                    URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(),
                            explorerURL.getPath().replace("/ui", "")
                                    + "diagram-viewer/index.html?processDefinitionId="
                                    + processDefinition.getId() + "&processInstanceId="
                                    + processInstance.getId());
                    Embedded browserPanel = new Embedded("", new ExternalResource(url));
                    browserPanel.setType(Embedded.TYPE_BROWSER);
                    browserPanel.setWidth(maxX + 350 + "px");
                    browserPanel.setHeight(maxY + 220 + "px");

                    HorizontalLayout panelLayoutT = new HorizontalLayout();
                    panelLayoutT.setSizeUndefined();
                    imagePanel.setContent(panelLayoutT);
                    imagePanel.addComponent(browserPanel);

                    panelLayout.addComponent(imagePanel);

                    didDrawImage = true;
                }

            } catch (Exception e) {
                LOGGER.error("Error loading process diagram component", e);
            }
        }

        if (didDrawImage == false && processDefinitionEntity.isGraphicalNotationDefined()) {

            StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder()
                    .buildStreamResource(processInstance, repositoryService, runtimeService);

            if (diagram != null) {
                Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
                header.addStyleName(ExplorerLayout.STYLE_H3);
                header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
                header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
                panelLayout.addComponent(header);

                Embedded embedded = new Embedded(null, diagram);
                embedded.setType(Embedded.TYPE_IMAGE);
                embedded.setSizeUndefined();

                Panel imagePanel = new Panel(); // using panel for scrollbars
                imagePanel.setScrollable(true);
                imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
                imagePanel.setWidth(100, UNITS_PERCENTAGE);
                imagePanel.setHeight(100, UNITS_PERCENTAGE);

                HorizontalLayout panelLayoutT = new HorizontalLayout();
                panelLayoutT.setSizeUndefined();
                imagePanel.setContent(panelLayoutT);
                imagePanel.addComponent(embedded);

                panelLayout.addComponent(imagePanel);
            }
        }
    }
}

From source file:org.opennms.features.topology.api.support.InfoWindow.java

License:Open Source License

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

    int width = getUI().getPage().getBrowserWindowWidth();
    int height = getUI().getPage().getBrowserWindowHeight();

    /*Sets the browser and window sizes based on the main window*/
    int browserWidth = (int) (sizePercentage * width), browserHeight = (int) (sizePercentage * height);
    int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion;
    setWidth(windowWidth, Unit.PIXELS);//from   ww  w.  j av  a 2  s  . co  m
    setHeight(windowHeight, Unit.PIXELS);
    setPositionX((width - windowWidth) / 2);
    setPositionY((height - windowHeight) / 2);

    /*Sets the size of the browser to fit within the sub-window*/
    infoBrowser.setType(Embedded.TYPE_BROWSER);
    infoBrowser.setWidth(browserWidth, Unit.PIXELS);
    infoBrowser.setHeight(browserHeight, Unit.PIXELS);
}

From source file:org.opennms.features.topology.netutils.internal.EventsAlarmsWindow.java

License:Open Source License

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

    int width = (int) getUI().getPage().getBrowserWindowWidth();
    int height = (int) getUI().getPage().getBrowserWindowHeight();

    /*Sets the browser and window sizes based on the main window*/
    int browserWidth = (int) (sizePercentage * width);
    int browserHeight = (int) (sizePercentage * height);
    setWidth("" + browserWidth + "px");
    setHeight("" + browserHeight + "px");
    setPositionX((width - browserWidth) / 2);
    setPositionY((height - browserHeight) / 2);
    int viewHeight = browserHeight - 76;

    /*Changes the size of the browsers to fit within the sub-window*/
    alarmsBrowser.setType(Embedded.TYPE_BROWSER);
    alarmsBrowser.setHeight(viewHeight + "px");
    eventsBrowser.setType(Embedded.TYPE_BROWSER);
    eventsBrowser.setHeight(viewHeight + "px"); //424 When I set it to this size it works but otherwise its doesn't
}

From source file:org.opennms.features.topology.netutils.internal.NodeInfoWindow.java

License:Open Source License

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

    int width = (int) getApplication().getMainWindow().getWidth();
    int height = (int) getApplication().getMainWindow().getHeight();

    /*Sets the browser and window sizes based on the main window*/
    int browserWidth = (int) (sizePercentage * width), browserHeight = (int) (sizePercentage * height);
    int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion;
    setWidth("" + windowWidth + "px");
    setHeight("" + windowHeight + "px");
    setPositionX((width - windowWidth) / 2);
    setPositionY((height - windowHeight) / 2);

    /*Sets the size of the browser to fit within the sub-window*/
    nodeInfoBrowser.setType(Embedded.TYPE_BROWSER);
    nodeInfoBrowser.setWidth("" + browserWidth + "px");
    nodeInfoBrowser.setHeight("" + browserHeight + "px");
}

From source file:org.opennms.features.topology.netutils.internal.ResourceGraphsWindow.java

License:Open Source License

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

    int width = getUI().getPage().getBrowserWindowWidth();
    int height = getUI().getPage().getBrowserWindowHeight();

    /*Sets the browser and window size based on the main window*/
    int browserWidth = (int) (sizePercentage * width), browserHeight = (int) (sizePercentage * height);
    int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion;
    setWidth("" + windowWidth + "px");
    setHeight("" + windowHeight + "px");
    setPositionX((width - windowWidth) / 2);
    setPositionY((height - windowHeight) / 2);

    /*Changes the size of the browser to fit within the sub-window*/
    rgBrowser.setType(Embedded.TYPE_BROWSER);
    rgBrowser.setWidth("" + browserWidth + "px");
    rgBrowser.setHeight("" + browserHeight + "px");
}

From source file:org.opennms.features.topology.netutils.internal.TracerouteWindow.java

License:Open Source License

/**
 * The buildEmbeddedBrowser method creates a new browser instance and adds it to the 
 * bottom layout. The browser is set to invisible by default.
 *//*  w ww .j  av  a  2s.  c  o m*/
private void buildEmbeddedBrowser() {
    resultsBrowser = new Embedded();
    resultsBrowser.setType(Embedded.TYPE_BROWSER);
    resultsBrowser.setImmediate(true);
    resultsBrowser.setVisible(false);
    bottomLayout.addComponent(resultsBrowser);
}

From source file:org.universAAL.ucc.controller.desktop.ToolController.java

public void buttonClick(ClickEvent event) {
    if (event.getButton() == toolWin.getuStoreButton()) {
        Embedded em = new Embedded("", new ExternalResource(createLink()));
        em.setType(Embedded.TYPE_BROWSER);
        em.setWidth("100%");
        em.setHeight("850px");
        Window w = new Window("uStore");
        w.setWidth("1250px");
        w.setHeight("800px");
        VerticalLayout v = new VerticalLayout();
        w.center();/* w w w .j a  v  a2 s  .  c  o m*/
        v.addComponent(em);
        w.setContent(v);
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(w);
    }
    if (event.getButton() == toolWin.getOpenAAL()) {
        //         Embedded em = new Embedded("", new ExternalResource(
        //               "http://wiki.openaal.org"));
        //         em.setType(Embedded.TYPE_BROWSER);
        //         em.setWidth("100%");
        //         em.setHeight("800px");
        //         Window w = new Window("openAAL");
        //         w.setWidth("1250px");
        //         w.setHeight("800px");
        //         VerticalLayout v = new VerticalLayout();
        //         w.center();
        //         v.addComponent(em);
        //         w.setContent(v);
        BrowseServicesWindow pw = new BrowseServicesWindow(app);
        PurchasedServicesController pc = new PurchasedServicesController(pw, app);
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(pw);
    }
    if (event.getButton() == toolWin.getInstallButton()) {
        // Later uncomment again only for testing commented out!
        Upload up = new Upload("", new AALServiceReceiver());
        up.setButtonCaption(res.getString("install.button"));
        up.addListener((Upload.FinishedListener) this);
        up.addListener((Upload.FailedListener) this);
        installWindow = new Window(res.getString("install.win.caption"));
        installWindow.setResizable(false);
        installWindow.center();
        installWindow.setWidth("400px");
        VerticalLayout v = new VerticalLayout();
        v.setSizeFull();
        v.setSpacing(true);
        v.setMargin(true);
        v.addComponent(up);
        installWindow.setContent(v);

        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(installWindow);
    }
    if (event.getButton() == toolWin.getLogoutButton()) {
        DesktopController.setCurrentPassword("");
        DesktopController.setCurrentUser("");
        //         if(!DesktopController.web.getSocket().isClosed()) {
        //            try {
        //               DesktopController.web.getSocket().close();
        //            } catch (IOException e) {
        //               e.printStackTrace();
        //            }
        //         }
        app.close();
    }

    if (event.getButton() == toolWin.getUninstallButton()) {
        app.getMainWindow().removeWindow(toolWin);
        List<RegisteredService> ids = new ArrayList<RegisteredService>();
        Document doc = Model.getSrvDocument();
        NodeList nodeList = doc.getElementsByTagName("service");
        for (int i = 0; i < nodeList.getLength(); i++) {
            RegisteredService srv = new RegisteredService();
            Element element = (Element) nodeList.item(i);
            System.err.println(element.getAttribute("serviceId"));
            srv.setServiceId(element.getAttribute("serviceId"));
            NodeList srvChilds = element.getChildNodes();
            for (int j = 0; j < srvChilds.getLength(); j++) {
                Node n = srvChilds.item(j);
                if (n.getNodeName().equals("application")) {
                    Element e = (Element) n;
                    srv.getAppId().add(e.getAttribute("appId"));
                }
                if (n.getNodeName().equals("bundle")) {
                    Element b = (Element) n;
                    srv.getBundleId().add(b.getAttribute("id"));
                    srv.setBundleVersion(b.getAttribute("version"));
                }
                if (n.getNodeName().equals("menuEntry")) {
                    Element e = (Element) n;
                    srv.setMenuName(e.getAttribute("entryName"));
                    srv.setIconURL(e.getAttribute("iconURL"));
                    srv.setProvider(e.getAttribute("vendor"));
                    srv.setServiceClass(e.getAttribute("serviceClass"));
                    srv.setUserID(e.getAttribute("userID"));
                }
            }
            ids.add(srv);
        }
        DeinstallWindow dw = new DeinstallWindow(ids);
        app.getMainWindow().addWindow(dw);
        DeinstallController dc = new DeinstallController(dw, app);
        //         frontend.uninstallService(Activator.getSessionKey(), "28002");
        //         frontend.getInstalledUnitsForService(Activator.getSessionKey(), "28002");
    }

    if (event.getButton() == toolWin.getPersonButton()) {
        AddNewPersonWindow apw = null;
        try {
            apw = new AddNewPersonWindow(null, null, app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(apw);
    }
    if (event.getButton() == toolWin.getConfigButton()) {
        AddNewHardwareWindow anhw = null;
        try {
            anhw = new AddNewHardwareWindow(null, null, app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(anhw);
    }
    if (event.getButton() == toolWin.getEditHW()) {
        RoomsWindow hardWare = null;
        try {
            hardWare = new RoomsWindow(app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(hardWare);

    }

    if (event.getButton() == toolWin.getEditPerson()) {
        HumansWindow hw = null;
        try {
            hw = new HumansWindow(app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(hw);
    }
    if (event.getButton() == toolWin.getEditUC()) {
        WhichBundleShouldBeConfiguredWindow uc = new WhichBundleShouldBeConfiguredWindow("Use Cases");
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(uc);

    }

}

From source file:ru.codeinside.adm.ui.AdminApp.java

License:Mozilla Public License

private Component registryTab() {
    Embedded embedded = new Embedded("", new ExternalResource("/registry"));
    embedded.setType(Embedded.TYPE_BROWSER);
    embedded.setWidth("100%");
    embedded.setHeight("100%");
    return embedded;
}

From source file:ru.codeinside.gses.webui.form.PrintPanel.java

License:Mozilla Public License

private Panel createDocumentPanel(Application app, String classId) {
    Embedded document = new Embedded(null, new FileResource(htmlFile, app));
    document.setDebugId(classId);/*from   w ww. j av  a  2 s  . com*/
    document.setType(Embedded.TYPE_BROWSER);
    document.setSizeFull();

    VerticalLayout documentLayout = new VerticalLayout();
    documentLayout.setMargin(true);
    documentLayout.setSizeFull();
    documentLayout.addComponent(document);
    documentLayout.setExpandRatio(document, 1f);

    Panel documentPanel = new Panel(documentLayout);
    documentPanel.setSizeFull();
    return documentPanel;
}

From source file:se.natusoft.osgi.aps.apsadminweb.app.gui.vaadin.TabPanel.java

License:Open Source License

/**
 * Recreates all tabs./* w w w.  j  a  v  a2 s .  co m*/
 */
public void refreshTabs() {
    List<AdminWebReg> currentAdminWebs = this.adminWebService.getRegisteredAdminWebs();

    // Remove old
    removeAllComponents();

    VerticalLayout aboutTabLayout = new VerticalLayout();
    aboutTabLayout.setStyleName("aps-tabsheet-tab");
    aboutTabLayout.setMargin(true);
    aboutTabLayout.setSizeFull();
    Label aboutText = new HTMLFileLabel("/html/about-admin-web.html", APSTheme.THEME,
            getClass().getClassLoader());
    aboutTabLayout.addComponent(aboutText);
    addTab(aboutTabLayout, "About", null).setDescription("Information about APS Admin Web tool.");

    // Add new
    for (AdminWebReg adminWebReg : currentAdminWebs) {
        VerticalLayout tabLayout = new VerticalLayout();
        tabLayout.setStyleName("aps-tabsheet-tab");
        tabLayout.setSizeFull();
        tabLayout.setMargin(false);
        tabLayout.setSpacing(false);
        Embedded adminWeb = new Embedded("", new ExternalResource(adminWebReg.getUrl() + "?adminRefresh"));
        adminWeb.setType(Embedded.TYPE_BROWSER);
        adminWeb.setSizeFull();
        tabLayout.addComponent(adminWeb);
        tabLayout.setData(adminWebReg);

        Tab tab = addTab(tabLayout, adminWebReg.getName(), null);
        tab.setDescription(adminWebReg.getDescription() + "<br/>[" + adminWebReg.getName() + ":"
                + adminWebReg.getVersion() + "]");
    }
}