Example usage for com.vaadin.ui Embedded setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(float width, Unit unit) 

Source Link

Usage

From source file:com.expressui.core.util.UrlUtil.java

License:Open Source License

/**
 * Only used by sample application to track usage statistics
 *
 * @param container container for adding the embedded iframe to
 *//*from   w w  w.  jav  a  2  s. c  o  m*/
public static void addTrackingUrl(AbstractComponentContainer container, String tag) {
    try {
        URL url = new URL(EXPRESSUI_TEST_PAGE + tag);
        Embedded browser = new Embedded(null, new ExternalResource(url));
        browser.setType(Embedded.TYPE_BROWSER);
        browser.setWidth(0, Sizeable.UNITS_PIXELS);
        browser.setHeight(0, Sizeable.UNITS_PIXELS);
        container.addComponent(browser);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.expressui.sample.view.HomePage.java

License:Open Source License

@Override
public void onDisplay() {
    try {/* w  ww. j av a 2s  . c o m*/
        URL url = new URL("http://www.expressui.com/");
        Embedded browser = new Embedded("", new ExternalResource(url));
        browser.setType(Embedded.TYPE_BROWSER);
        browser.setWidth(100, Sizeable.UNITS_PERCENTAGE);
        browser.setHeight(15000, Sizeable.UNITS_PIXELS);
        setCompositionRoot(browser);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }

    getMainApplication().showTrayMessage("<h3>Feature Tip:</h3>" + "<ul>"
            + "<li>This illustrates how to embed any external page into ExpressUI" + "</ul>");
}

From source file:com.jorambarrez.PropertyPanel.java

License:Apache License

protected void initTrashIcon() {
    Embedded trashIcon = new Embedded(null, Images.MODELER_TRASH);
    trashIcon.setWidth(63, UNITS_PIXELS);
    trashIcon.setHeight(61, UNITS_PIXELS);
    trashIcon.setType(Embedded.TYPE_IMAGE);

    VerticalLayout trashLayout = new VerticalLayout();
    trashLayout.setWidth(120, UNITS_PIXELS);
    trashLayout.setHeight(120, UNITS_PIXELS);
    trashLayout.addComponent(trashIcon);
    trashLayout.setComponentAlignment(trashIcon, Alignment.MIDDLE_CENTER);

    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(trashLayout);
    dragAndDropWrapper.setDragStartMode(DragStartMode.NONE);
    dragAndDropWrapper.setSizeUndefined();
    addComponent(dragAndDropWrapper);/*from   w  ww . java  2 s  .  co  m*/
    setComponentAlignment(dragAndDropWrapper, Alignment.BOTTOM_CENTER);

    dragAndDropWrapper.setDropHandler(new DropHandler() {
        private static final long serialVersionUID = 1L;

        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        public void drop(DragAndDropEvent event) {
            WrapperTransferable wrapperTransferable = (WrapperTransferable) event.getTransferable();
            Node srcNode = (Node) wrapperTransferable.getSourceComponent();

            // TODO: use eventrouter!
            ModelerApp.get().getFlowEditor().removeNode(srcNode);
        }
    });
}

From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java

License:Apache License

protected void populateSubTasks(List<HistoricTaskInstance> subTasks) {
    for (final HistoricTaskInstance subTask : subTasks) {
        // icon//from  www  .ja va  2 s .  c  o  m
        Embedded icon = new Embedded(null, Images.TASK_22);
        icon.setWidth(22, UNITS_PIXELS);
        icon.setWidth(22, UNITS_PIXELS);
        subTaskGrid.addComponent(icon);

        // Link to subtask
        Button subTaskLink = new Button(subTask.getName());
        subTaskLink.addStyleName(Reindeer.BUTTON_LINK);
        subTaskLink.addListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {
                ViewToolManager.getMainView().showTaskPage(subTask.getId());
            }
        });
        subTaskGrid.addComponent(subTaskLink);
        subTaskGrid.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT);
    }
}

From source file:com.klwork.explorer.ui.task.SubTaskComponent.java

License:Apache License

protected void populateSubTasks(List<HistoricTaskInstance> subTasks) {
    if (subTasks.size() > 0) {
        for (final HistoricTaskInstance subTask : subTasks) {
            // icon
            Embedded icon = null;

            if (subTask.getEndTime() != null) {//?
                icon = new Embedded(null, Images.TASK_FINISHED_22);
            } else {
                icon = new Embedded(null, Images.TASK_22);
            }/*from   w ww .ja  va 2 s .  co m*/
            icon.setWidth(22, UNITS_PIXELS);
            icon.setWidth(22, UNITS_PIXELS);
            subTaskLayout.addComponent(icon);

            // Link to subtask
            Button subTaskLink = new Button(subTask.getName());
            subTaskLink.addStyleName(Reindeer.BUTTON_LINK);
            subTaskLink.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    //ExplorerApp.get().getViewManager().showTaskPage(subTask.getId());
                }
            });
            subTaskLayout.addComponent(subTaskLink);
            subTaskLayout.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT);

            if (subTask.getEndTime() == null) {
                // Delete icon only appears when task is not finished yet
                Embedded deleteIcon = new Embedded(null, Images.DELETE);
                deleteIcon.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
                deleteIcon.addListener(new DeleteSubTaskClickListener(subTask, this));
                subTaskLayout.addComponent(deleteIcon);
                subTaskLayout.setComponentAlignment(deleteIcon, Alignment.MIDDLE_RIGHT);
            } else {
                // Next line of grid
                subTaskLayout.newLine();
            }
        }
    } else {
        Label noSubTasksLabel = new Label(i18nManager.getMessage(Messages.TASK_NO_SUBTASKS));
        noSubTasksLabel.setSizeUndefined();
        noSubTasksLabel.addStyleName(Reindeer.LABEL_SMALL);
        subTaskLayout.addComponent(noSubTasksLabel);
    }

}

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void initPicture() {
    StreamResource imageresource = new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 1L;

        public InputStream getStream() {
            return picture.getInputStream();
        }/*from  w  w w  .j  a  v a2  s . co  m*/
    }, user.getId());
    imageresource.setCacheTime(0);

    Embedded picture = new Embedded(null, imageresource);
    picture.setType(Embedded.TYPE_IMAGE);
    picture.setHeight(200, UNITS_PIXELS);
    picture.setWidth(200, UNITS_PIXELS);
    picture.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);

    imageLayout.addComponent(picture);
    imageLayout.setWidth(picture.getWidth() + 5, picture.getWidthUnits());

    // Change picture button
    if (isCurrentLoggedInUser) {
        Upload changePictureButton = initChangePictureButton();
        imageLayout.addComponent(changePictureButton);
        imageLayout.setComponentAlignment(changePictureButton, Alignment.MIDDLE_CENTER);
    }
}

From source file:com.openhris.commons.UploadImage.java

public UploadImage(Panel imagePanel, Embedded avatar, String employeeId) {
    this.imagePanel = imagePanel;
    this.avatar = avatar;
    this.employeeId = employeeId;

    imagePanel = new Panel("Upload Component");
    imagePanel.setWidth("400px");
    addComponent(imagePanel);/* w ww.  jav  a2s. c o  m*/

    // Create the Upload component.
    upload = new Upload("Upload the Image file here", receiver);
    // Use a custom button caption instead of plain "Upload".
    upload.setButtonCaption("Upload Now");

    // Listen for events regarding the success of upload. 
    upload.addListener((Upload.StartedListener) this);
    upload.addListener((Upload.SucceededListener) this);
    upload.addListener((Upload.FailedListener) this);

    panel.setWidth("100%");
    panel.addComponent(new Label("Click 'Choose file' to " + "select a file and then click 'Upload Now'. "
            + "image should have the same width and height so "
            + "that image will not look deformed when viewed."));

    imagePanel.addComponent(upload);
    imagePanel.addComponent(panel);

    avatar = new Embedded();
    avatar.setImmediate(true);
    avatar.setWidth(90, Sizeable.UNITS_PIXELS);
    avatar.setHeight(90, Sizeable.UNITS_PIXELS);
    imagePanel.addComponent(avatar);
}

From source file:com.rdonasco.common.vaadin.view.utils.EmbeddedResourceBuilder.java

License:Apache License

public Embedded createEmbedded() throws InvalidBuilderParameter {
    if (null == application) {
        throw new InvalidBuilderParameter("application not set");
    }//from  w  w w .  jav  a2  s  .c  o  m
    if (null == name) {
        throw new InvalidBuilderParameter("name not set");
    }
    Embedded embedded = null;
    if (null != bytes) {
        embedded = createUsingStreamSource();
    } else if (null != resourceId) {
        embedded = createUsingResourceId();
    } else {
        throw new InvalidBuilderParameter("bytes or resource ID is not set");
    }
    embedded.setDescription(description);
    embedded.setAlternateText(alternateText);
    if (null != height) {
        embedded.setHeight(height, units);
    }
    if (null != width) {
        embedded.setWidth(width, units);
    }

    return embedded;
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java

License:Open Source License

/**
 * Konkrete Ausprogrammierung der Darstellung eines einzelnen Projekts.
 * Ein Projekt wird durch ein VerticalLayout dargestellt, das ein Label
 * mit dem Projektname enthlt. Auerdem bekommt es einen ClickListener,
 * um ein Projekt als selektiert zu kennzeichnen und die Details zum Projekt
 * anzuzeigen./*from   w w  w  .j  a va 2s.  com*/
 * 
 * @author Christian Scherer, Mirko Gpfrich, Marco Glaser
 * @param project
 *            das darzustellende Projekt und der aktuelle Index der Liste
 * @param i
 *            der Index der zu erstellenden Komponente (besonders fuer den
 *            Loeschbutton relevant)
 * @return ein VerticalLayout Objekt, das zur Eingliederung in das UI dient
 */
private VerticalLayout generateSingleProjectUI(Project project, int i) {

    final Project proj = project;
    final int a = i;
    //erzeugt eine Panel fr ein Projekt
    singleProject = new VerticalLayout();
    HorizontalLayout container = new HorizontalLayout();
    container.setSizeFull();
    if (i == 0) {
        singleProject.setStyleName("singleProjectSelected");
        presenter.projectSelected(project);
    } else {
        singleProject.setStyleName("singleProject");
    }
    Embedded icon = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418828714_editor_open_folder-128.png"));
    icon.setHeight(40, UNITS_PIXELS);
    icon.setWidth(40, UNITS_PIXELS);
    Label gap1 = new Label();
    Label gap2 = new Label();
    Label gap3 = new Label();
    gap1.setWidth("15px");
    gap2.setWidth("15px");
    gap3.setSizeFull();
    Label projectName = new Label(project.getName());
    projectName.setWidth(Sizeable.SIZE_UNDEFINED, 0);
    projectName.setHeight(Sizeable.SIZE_UNDEFINED, 0);
    projectName.setStyleName("projectName");

    //Legt ein Layout fr das Projekt-Panel fest
    //panelContent.setSizeFull();
    container.addComponent(gap1);
    container.addComponent(icon);
    container.addComponent(gap2);
    container.addComponent(projectName);
    container.addComponent(gap3);
    container.setExpandRatio(gap3, 1.0f);

    singleProject.addComponent(container);
    singleProject.setWidth(100, UNITS_PERCENTAGE);
    singleProject.setHeight(70, UNITS_PIXELS);
    container.setComponentAlignment(icon, Alignment.MIDDLE_CENTER);
    container.setComponentAlignment(projectName, Alignment.MIDDLE_CENTER);

    singleProject.addListener(new LayoutClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void layoutClick(LayoutClickEvent event) {
            presenter.projectSelected(proj);
            switchProjectsStyle(a);

            eventBus.fireEvent(new SelectProjectEvent());
        }

    });

    //      singleProject.addListener(this);
    //      projectListPanel.addComponent(singleProject);
    logger.debug("Einzelnes Projektelement erzeugt");

    return singleProject;
}

From source file:edu.vcu.csbc.vahmpexplorer.main.VaHMPExplorer.java

public Component createToolBar(boolean loggedIn) {
    HorizontalLayout h = new HorizontalLayout();
    h.setMargin(true);/*from  w  ww  .ja  v a2  s. c  om*/
    h.setWidth("100%");

    Embedded headerImg = new Embedded(null, new ThemeResource("../vahmpexplorer/img/header.png"));
    headerImg.setWidth(311, Embedded.UNITS_PIXELS);
    headerImg.setHeight(45, Embedded.UNITS_PIXELS);
    headerImg.setType(Embedded.TYPE_IMAGE);
    headerImg.setStyleName(BaseTheme.BUTTON_LINK);
    headerImg.setDescription("Version " + HelpMessages.VERSION);
    h.addComponent(headerImg);

    if (loggedIn) {
        Panel panel = new Panel();
        Label loggedInUser = new Label(
                "Welcome: " + user.getFirstName() + " " + user.getLastName() + " (" + user.getLogin() + ")");
        changePassword = new Button("Change Password");
        changePassword.setStyleName(BaseTheme.BUTTON_LINK);
        changePassword.addListener((Button.ClickListener) this);

        logout = new Button("Logout");
        logout.setStyleName(BaseTheme.BUTTON_LINK);
        logout.addListener((Button.ClickListener) this);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        hl.addComponent(changePassword);
        hl.addComponent(logout);

        panel.addComponent(loggedInUser);
        panel.addComponent(hl);
        h.addComponent(panel);
        h.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT);
    }
    PopupView help = new PopupView(new MainHelpPopup());
    h.addComponent(help);
    h.setComponentAlignment(help, Alignment.MIDDLE_RIGHT);
    h.setComponentAlignment(headerImg, Alignment.MIDDLE_LEFT);
    return h;
}