Example usage for com.vaadin.ui Embedded setType

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

Introduction

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

Prototype

public void setType(int type) 

Source Link

Document

Sets the object type.

Usage

From source file:eu.lod2.VirtuosoISPARQL.java

License:Apache License

public VirtuosoISPARQL(LOD2DemoState st) {

    // The internal state and 
    state = st;/*from   w  w  w. j a v a2 s . c om*/

    Embedded browser = new Embedded();
    try {
        URL url;
        if (state.getHostName().equals("http://localhost:8080")) {
            url = new URL("http://localhost:8890/isparql");
        } else {
            url = new URL(state.getHostName() + "/virtuoso/isparql");
        }
        ;
        browser = new Embedded("", new ExternalResource(url));
        browser.setType(Embedded.TYPE_BROWSER);
        browser.setSizeFull();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    ;

    // The composition root MUST be set
    setCompositionRoot(browser);
}

From source file:eu.lod2.VirtuosoSPARQL.java

License:Apache License

public VirtuosoSPARQL(LOD2DemoState st) {

    // The internal state and 
    state = st;/*from  w w w. ja  v  a 2 s .  c  o m*/

    final String query = "SELECT * where {?s ?p ?o.} LIMIT 20";
    String encodedQuery = "";
    String encodedGraphName = "";
    try {
        encodedQuery = URLEncoder.encode(query, "UTF-8");
        encodedGraphName = URLEncoder.encode(state.getCurrentGraph(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    ;

    Embedded browser = new Embedded();
    try {
        URL url;
        if (state.getHostName().equals("http://localhost:8080")) {
            url = new URL("http://localhost:8890/sparql");
        } else {
            url = new URL(state.getHostName() + "/virtuoso/sparql");
        }
        ;
        browser = new Embedded("", new ExternalResource(url));
        browser.setType(Embedded.TYPE_BROWSER);
        browser.setSizeFull();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    ;

    // The composition root MUST be set
    setCompositionRoot(browser);
}

From source file:gov.va.ds4p.ds4pmobileportal.ui.eHealthExchange.java

License:Open Source License

private Popover getPopoverPDF(String val, String title) {
    Popover popover = new Popover();
    popover.setModal(true);//  ww w  .  j a  va2 s.c  o  m
    popover.setClosable(true);
    popover.setWidth("700px");
    popover.setHeight("100%");
    CssLayout popLayout = new CssLayout();
    popLayout.setSizeFull();
    popLayout.setMargin(true);

    NavigationView navView = new NavigationView(popLayout);
    navView.setCaption(title);

    CssLayout layout2 = new CssLayout();
    Embedded pdf = new Embedded();
    pdf.setType(Embedded.TYPE_BROWSER);
    pdf.setMimeType("application/pdf");
    pdf.setSizeFull();
    pdf.setWidth("100%");
    pdf.setHeight("700px");

    pdf.setSource(createPdf(val));

    layout2.addComponent(pdf);

    popLayout.addComponent(layout2);

    Button close = new Button(null, new ClickListener() {

        public void buttonClick(ClickEvent event) {
            event.getButton().getWindow().getParent().removeWindow(event.getButton().getWindow());
        }
    });
    close.setIcon(new ThemeResource("../runo/icons/64/cancel.png"));
    navView.setRightComponent(close);

    popover.setContent(navView);

    return popover;
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

private void showHTML(final String htmlContent, final Application app)
        throws IllegalArgumentException, NullPointerException {
    app.getMainWindow().addWindow(new Window() {
        private static final long serialVersionUID = -2307854110750435145L;

        {//from w ww.ja va  2s . co m
            center();
            setWidth("75%");
            setHeight("600px");
            StreamResource.StreamSource source = new StreamResource.StreamSource() {
                private static final long serialVersionUID = -3745013501121916404L;

                public InputStream getStream() {
                    return new ByteArrayInputStream(htmlContent.getBytes());
                }
            };
            StreamResource resource = new StreamResource(source, "TestReport.html", app);
            Embedded e = new Embedded();
            e.setMimeType("text/html");
            e.setType(Embedded.TYPE_BROWSER);
            e.setWidth("100%");
            e.setHeight("590px");
            e.setSource(resource);
            addComponent(e);
        }
    });
}

From source file:org.accelerators.activiti.admin.ui.LoginView.java

License:Open Source License

@SuppressWarnings("serial")
public LoginView(AdminApp application) {

    // Set application reference
    this.app = application;

    // Init window caption
    app.getMainWindow().setCaption(app.getMessage(Messages.Title));

    // Set layout to full size
    setSizeFull();//ww w  . j  a v a2s .  co m

    // Set style
    this.setStyleName("login-background");

    // Add header bar
    final HorizontalLayout header = new HorizontalLayout();
    header.setHeight("50px");
    header.setWidth("100%");
    addComponent(header);
    setComponentAlignment(header, Alignment.MIDDLE_CENTER);

    // Setup grid
    GridLayout loginGrid = new GridLayout(1, 2);
    loginGrid.setWidth("250px");
    addComponent(loginGrid);
    setComponentAlignment(loginGrid, Alignment.MIDDLE_CENTER);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    loginGrid.addComponent(logoGrid, 0, 0);
    loginGrid.setComponentAlignment(logoGrid, Alignment.MIDDLE_CENTER);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/login-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("login-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add field and button layout
    VerticalLayout buttonLayout = new VerticalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(false);
    buttonLayout.setStyleName("login-form");
    loginGrid.addComponent(buttonLayout, 0, 1);
    loginGrid.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    // Add username field
    username = new TextField(app.getMessage(Messages.Username));
    username.setWidth("100%");
    buttonLayout.addComponent(username);

    // Add password field
    password = new PasswordField(app.getMessage(Messages.Password));
    password.setWidth("100%");
    buttonLayout.addComponent(password);

    // Add Login button
    buttonLayout.addComponent(login);
    buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_RIGHT);

    // Set focus to this component
    username.focus();

    // Add shortcut to login button
    login.setClickShortcut(KeyCode.ENTER);

    login.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            try {

                // Athenticate the user
                authenticate((String) username.getValue(), (String) password.getValue());

                // Switch to the main view
                app.getViewManager().switchScreen(MainView.class.getName(), new MainView(app));

            } catch (Exception e) {
                getWindow().showNotification(e.toString());
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    footer.setWidth("100%");
    addComponent(footer);

}

From source file:org.accelerators.activiti.admin.ui.MainView.java

License:Open Source License

public MainView(AdminApp application) {

    // Set application
    this.app = application;

    // Setup main layout
    setStyleName(Reindeer.LAYOUT_WHITE);
    setMargin(false);/*from   w  w  w. ja  v a  2 s .  com*/
    setSpacing(false);
    setSizeFull();

    // Add header
    GridLayout header = new GridLayout(2, 1);
    header.setWidth("100%");
    header.setHeight("34px");
    addComponent(header);

    // Add header styles
    header.addStyleName(Consts.HEADER);
    header.addStyleName("header");
    header.setSpacing(true);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    header.addComponent(logoGrid, 0, 0);
    header.setComponentAlignment(logoGrid, Alignment.MIDDLE_LEFT);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/header-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("header-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add logout button to header
    GridLayout logoutGrid = new GridLayout(2, 1);
    Label userLabel = new Label("Signed in as: " + app.getUser().toString());
    userLabel.addStyleName("user");
    logout.setStyleName(Reindeer.BUTTON_LINK);
    logout.addStyleName("logout");
    logoutGrid.addComponent(userLabel, 0, 0);
    logoutGrid.addComponent(logout, 1, 0);
    header.addComponent(logoutGrid, 1, 0);
    header.setComponentAlignment(logoutGrid, Alignment.TOP_RIGHT);

    // Create tab sheet
    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();

    // Add tab styles
    tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    tabs.addStyleName(Reindeer.LAYOUT_WHITE);

    // Add task view tab
    tabs.addTab(new UserTab(app));
    tabs.addTab(new GroupTab(app));

    // Add tab sheet to layout
    addComponent(tabs);
    setExpandRatio(tabs, 1.0F);

    // Add footer text
    Label footerText = new Label(app.getMessage(Messages.Footer));
    footerText.setSizeUndefined();
    footerText.setStyleName(Reindeer.LABEL_SMALL);
    addComponent(footerText);
    setComponentAlignment(footerText, Alignment.BOTTOM_CENTER);

}

From source file:org.activiti.administrator.AdminApp.java

License:Apache License

/**
 * Switch view/*from   w  w  w .ja  va 2 s .  c o m*/
 * 
 * @param name
 *          the name of the view class
 * @param view
 *          the view to switch to
 */
public void switchView(String name, Layout view) {

    // Add view to main layout
    mainLayout.addComponent(view, Consts.CONTENT);

    // Add logout button if user is authenticated
    if ((getUser() != null) && !getUser().toString().isEmpty()) {

        // Create logout grid with user icon, user id and logout button
        GridLayout logoutGrid = new GridLayout(3, 1);
        logoutGrid.setStyleName("logout");

        // Add user icon
        Embedded userIcon = new Embedded(null, new ThemeResource("img/user-icon.png"));
        userIcon.setType(Embedded.TYPE_IMAGE);
        userIcon.addStyleName("icon");

        // Add user id
        Label userLabel = new Label(getUser().toString());
        userLabel.addStyleName("user");

        // Add logout button
        logout.setStyleName(Reindeer.BUTTON_LINK);
        logout.addStyleName("logout");
        logout.setIcon(new ThemeResource("img/divider-white.png"));

        // Add to logout grid
        logoutGrid.addComponent(userIcon, 0, 0);
        logoutGrid.addComponent(userLabel, 1, 0);
        logoutGrid.addComponent(logout, 2, 0);

        // Add logout grid to header
        mainLayout.addComponent(logoutGrid, Consts.LOGOUT);

    } else {

        // Remove logout button
        mainLayout.removeComponent(Consts.LOGOUT);

    }

    // Switch to new view
    viewManager.switchScreen(name, mainLayout);

}

From source file:org.activiti.editor.ui.EditorProcessDefinitionInfoComponent.java

License:Apache License

protected void initImage() {
    processImageContainer = new VerticalLayout();

    Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processImageContainer.addComponent(processTitle);

    StreamSource streamSource = null;
    final byte[] editorSourceExtra = repositoryService.getModelEditorSourceExtra(modelData.getId());
    if (editorSourceExtra != null) {
        streamSource = new StreamSource() {
            private static final long serialVersionUID = 1L;

            public InputStream getStream() {
                InputStream inStream = null;
                try {
                    inStream = new ByteArrayInputStream(editorSourceExtra);
                } catch (Exception e) {
                    LOGGER.warn("Error reading PNG in StreamSource", e);
                }// w  w  w  .j a va  2s.  com
                return inStream;
            }
        };
    }

    if (streamSource != null) {
        Embedded embedded = new Embedded(null, new ImageStreamSource(streamSource, ExplorerApp.get()));
        embedded.setType(Embedded.TYPE_IMAGE);
        embedded.setSizeUndefined();

        Panel imagePanel = new Panel(); // using panel for scrollbars
        imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
        imagePanel.setWidth(100, UNITS_PERCENTAGE);
        imagePanel.setHeight(700, UNITS_PIXELS);
        HorizontalLayout panelLayout = new HorizontalLayout();
        panelLayout.setSizeUndefined();
        imagePanel.setContent(panelLayout);
        imagePanel.addComponent(embedded);

        processImageContainer.addComponent(imagePanel);
    } else {
        Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM));
        processImageContainer.addComponent(noImageAvailable);
    }
    addComponent(processImageContainer);
}

From source file:org.activiti.explorer.ui.custom.UserProfileLink.java

License:Apache License

protected void initPicture(IdentityService identityService, boolean renderPicture, final String userName) {
    if (renderPicture) {
        Picture picture = identityService.getUserPicture(userName);
        if (picture != null) {
            Resource imageResource = new StreamResource(new InputStreamStreamSource(picture.getInputStream()),
                    userName + picture.getMimeType(), ExplorerApp.get());

            Embedded image = new Embedded(null, imageResource);
            image.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
            image.setType(Embedded.TYPE_IMAGE);
            image.setHeight(30, Embedded.UNITS_PIXELS);
            image.setWidth(30, Embedded.UNITS_PIXELS);
            image.addListener(new MouseEvents.ClickListener() {
                private static final long serialVersionUID = 7341560240277898495L;

                public void click(MouseEvents.ClickEvent event) {
                    viewManager.showProfilePopup(userName);
                }/*from   www  .j av a2s.com*/
            });

            addComponent(image);
            setComponentAlignment(image, Alignment.MIDDLE_LEFT);
        } else {
            // TODO: what when no image is available?
        }
    }
}

From source file:org.activiti.explorer.ui.flow.ProcessDefinitionInfoComponent.java

License:Apache License

protected void initImage() {
    VerticalLayout processImageContainer = new VerticalLayout();

    Label processTitle = new Label(i18nManager.getMessage(Messages.FLOW_HEADER_DIAGRAM));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processImageContainer.addComponent(processTitle);

    if (processDefinition.getDiagramResourceName() != null) {
        StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder()
                .buildStreamResource(processDefinition, repositoryService);

        Embedded embedded = new Embedded("", diagram);
        embedded.setType(Embedded.TYPE_IMAGE);
        processImageContainer.addComponent(embedded);
    } else {/* ww  w  .j  ava  2  s .com*/
        Label noImageAvailable = new Label(i18nManager.getMessage(Messages.FLOW_NO_DIAGRAM));
        processImageContainer.addComponent(noImageAvailable);
    }
    addComponent(processImageContainer);
}