Example usage for com.vaadin.ui Panel setContent

List of usage examples for com.vaadin.ui Panel setContent

Introduction

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

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:org.lucidj.ui.gauss.Home.java

License:Apache License

private Panel local_accounts() {
    Panel p = new Panel("Dummy Home");
    VerticalLayout content = new VerticalLayout();
    p.setContent(content);
    content.setSpacing(true);//w  w w .  j ava 2s  .  com
    content.setMargin(true);
    content.addComponent(new Label("The quick brown fox jumped over the lazy fox."));
    content.addComponent(new Button("Hello world!"));
    return (p);
}

From source file:org.lunifera.examples.vaaclipse.demo1.e4.editors.TextEditor.java

License:Open Source License

@Inject
public TextEditor(VerticalLayout container, MInputPart inputPart) {
    super(inputPart.getInputURI());

    Panel e = new Panel();
    e.setSizeFull();//w  w  w .  j  ava 2 s.com
    text = new Label(readContent(), Label.CONTENT_PREFORMATTED);
    e.setContent(text);
    container.addComponent(e);
}

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;
                        }/*w  ww.j a va 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.opencms.ui.apps.CmsAppHierarchyPanel.java

License:Open Source License

/**
 * Adds a child category panel.<p>
 *
 * @param label the label//from w ww  . j a va 2 s  .  c  o m
 * @param child the child widget
 */
public void addChild(String label, CmsAppHierarchyPanel child) {

    Panel panel = new Panel();
    panel.setCaption(label);
    panel.setContent(child);
    addComponent(panel);
}

From source file:org.opencms.ui.CmsVaadinUtils.java

License:Open Source License

/**
 * Shows an alert box to the user with the given information, which will perform the given action after the user clicks on OK.<p>
 *
 * @param title the title//from   w  w w.j a v  a 2  s. c om
 * @param message the message
 *
 * @param callback the callback to execute after clicking OK
 */
public static void showAlert(String title, String message, final Runnable callback) {

    final Window window = new Window();
    window.setModal(true);
    Panel panel = new Panel();
    panel.setCaption(title);
    panel.setWidth("500px");
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    panel.setContent(layout);
    layout.addComponent(new Label(message));
    Button okButton = new Button();
    okButton.addClickListener(new ClickListener() {

        /** The serial version id. */
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            window.close();
            if (callback != null) {
                callback.run();
            }
        }
    });
    layout.addComponent(okButton);
    layout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);
    okButton.setCaption(org.opencms.workplace.Messages.get().getBundle(A_CmsUI.get().getLocale())
            .key(org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_OK_0));
    window.setContent(panel);
    window.setClosable(false);
    window.setResizable(false);
    A_CmsUI.get().addWindow(window);

}

From source file:org.opencms.ui.components.CmsBasicDialog.java

License:Open Source License

/**
 * Creates new instance.<p>// w  ww  . j  a va 2s .  co m
 */
public CmsBasicDialog() {
    addStyleName(OpenCmsTheme.DIALOG);
    setMargin(true);
    setSpacing(true);
    setWidth("100%");

    m_mainPanel = new VerticalLayout();
    m_mainPanel.addStyleName(OpenCmsTheme.DIALOG_CONTENT);
    m_mainPanel.setSpacing(true);
    m_mainPanel.setSizeFull();

    m_contentPanel = new Panel();
    m_contentPanel.setSizeFull();
    m_contentPanel.addStyleName("v-scrollable");

    m_mainPanel.addComponent(m_contentPanel);
    m_mainPanel.setExpandRatio(m_contentPanel, 3);

    Panel panel = new Panel();
    panel.setContent(m_mainPanel);
    panel.setSizeFull();
    addComponent(panel);
    setExpandRatio(panel, 1);
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setWidth("100%");
    buttons.addStyleName(OpenCmsTheme.DIALOG_BUTTON_BAR);
    addComponent(buttons);
    m_buttonPanelLeft = new HorizontalLayout();
    m_buttonPanelLeft.setSpacing(true);
    buttons.addComponent(m_buttonPanelLeft);
    buttons.setComponentAlignment(m_buttonPanelLeft, Alignment.MIDDLE_LEFT);
    m_buttonPanelLeft.setVisible(false);
    m_buttonPanelRight = new HorizontalLayout();
    m_buttonPanelRight.setSpacing(true);
    buttons.addComponent(m_buttonPanelRight);
    buttons.setComponentAlignment(m_buttonPanelRight, Alignment.MIDDLE_RIGHT);
    enableMaxHeight();
}

From source file:org.opencms.ui.components.CmsBasicDialog.java

License:Open Source License

/**
 * Creates a resource list panel.<p>
 *
 * @param caption the caption to use/*from www .j a  v a2  s.  com*/
 * @param resources the resources
 *
 * @return the panel
 */
protected Panel createResourceListPanel(String caption, List<CmsResource> resources) {

    Panel result = new Panel(caption);
    result.addStyleName("v-scrollable");
    result.setSizeFull();
    VerticalLayout resourcePanel = new VerticalLayout();
    result.setContent(resourcePanel);
    resourcePanel.addStyleName(OpenCmsTheme.REDUCED_MARGIN);
    resourcePanel.addStyleName(OpenCmsTheme.REDUCED_SPACING);
    resourcePanel.setSpacing(true);
    resourcePanel.setMargin(true);
    for (CmsResource resource : resources) {
        resourcePanel.addComponent(new CmsResourceInfo(resource));
    }
    return result;
}

From source file:org.opencms.ui.dialogs.history.CmsHistoryDialog.java

License:Open Source License

/**
 * Opens the 'compare' view for the two selected versions of the resource.<p>
 *
 * @throws CmsException if something goes wrong
 *//*from   w  w  w. java  2 s.  c o  m*/
public void tryCompare() throws CmsException {

    CmsObject cms = A_CmsUI.getCmsObject();
    CheckBox check1 = m_group1.getSelected();
    CheckBox check2 = m_group2.getSelected();
    if (!canCompare(check1, check2)) {
        Notification.show(
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_SELECT_TWO_DIFFERENT_VERSIONS_0));
    } else {
        CmsHistoryResourceBean bean1 = (CmsHistoryResourceBean) (check1.getData());
        CmsHistoryResourceBean bean2 = (CmsHistoryResourceBean) (check2.getData());
        VerticalLayout diffContainer = new VerticalLayout();
        diffContainer.setSpacing(true);
        for (I_CmsDiffProvider diff : m_diffs) {
            Optional<Component> optionalDiff = diff.diff(cms, bean1, bean2);
            if (optionalDiff.isPresent()) {
                diffContainer.addComponent(optionalDiff.get());
            }
        }
        Panel panel = new Panel();
        panel.setSizeFull();
        diffContainer.setWidth("100%");
        diffContainer.setMargin(true);
        panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
        panel.setContent(diffContainer);
        openChildDialog(CmsHistoryDialog.this, panel,
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_COMPARE_0));
    }

}

From source file:org.opencms.ui.dialogs.history.diff.A_CmsAttributeDiff.java

License:Open Source License

/**
 * @see org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider#diff(org.opencms.file.CmsObject, org.opencms.gwt.shared.CmsHistoryResourceBean, org.opencms.gwt.shared.CmsHistoryResourceBean)
 *//*from www .  ja v a 2 s.  c o m*/
public Optional<Component> diff(CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2)
        throws CmsException {

    List<CmsAttributeComparison> attrCompare = getDifferences(cms, v1, v2);
    if (attrCompare.isEmpty()) {
        return Optional.absent();
    }
    List<CmsPropertyCompareBean> compareBeans = Lists.newArrayList();

    for (CmsAttributeComparison comp : attrCompare) {
        compareBeans.add(new CmsPropertyCompareBean(comp));
    }
    CmsBeanTableBuilder<CmsPropertyCompareBean> builder = CmsBeanTableBuilder
            .newInstance(CmsPropertyCompareBean.class, A_CmsUI.get().getDisplayType().toString());
    builder.setMacroResolver(new CmsVersionMacroResolver(v1, v2));
    Table table = builder.buildTable(compareBeans);
    table.setSortEnabled(false);
    table.setWidth("100%");
    table.setPageLength(Math.min(12, compareBeans.size()));
    table.setStyleName(COMPARE_TABLE_MARKER);
    VerticalLayout vl = new VerticalLayout();
    vl.setMargin(true);
    vl.addComponent(table);
    Panel panel = new Panel(getCaption());
    panel.setContent(vl);
    return Optional.fromNullable((Component) panel);
}

From source file:org.opencms.ui.dialogs.history.diff.CmsImageDiff.java

License:Open Source License

/**
 * @see org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider#diff(org.opencms.file.CmsObject, org.opencms.gwt.shared.CmsHistoryResourceBean, org.opencms.gwt.shared.CmsHistoryResourceBean)
 *///from   www .  j a  v  a  2s.c om
public Optional<Component> diff(CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2)
        throws CmsException {

    CmsResource r1 = A_CmsAttributeDiff.readResource(cms, v1);
    if (OpenCms.getResourceManager().matchResourceType(CmsResourceTypeImage.getStaticTypeName(),
            r1.getTypeId())) {
        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        String v1Param = v1.getVersion().getVersionNumber() != null ? "" + v1.getVersion().getVersionNumber()
                : "" + CmsHistoryResourceHandler.PROJECT_OFFLINE_VERSION;
        String v2Param = v2.getVersion().getVersionNumber() != null ? "" + v2.getVersion().getVersionNumber()
                : "" + CmsHistoryResourceHandler.PROJECT_OFFLINE_VERSION;

        String link1 = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms,
                CmsHistoryListUtil.getHistoryLink(cms, v1.getStructureId(), v1Param));
        String link2 = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms,
                CmsHistoryListUtil.getHistoryLink(cms, v2.getStructureId(), v2Param));
        int scaleWidth = 400;
        int scaleHeight = (2 * scaleWidth) / 3;
        final String scaleParams = "w:" + scaleWidth + ",h:" + scaleHeight + ",t:1"; // scale type 1 for thumbnails (no enlargement)
        link1 = CmsRequestUtil.appendParameter(link1, "__scale", scaleParams);
        link2 = CmsRequestUtil.appendParameter(link2, "__scale", scaleParams);
        Image img1 = new Image("", new ExternalResource(link1));
        Image img2 = new Image("", new ExternalResource(link2));
        for (Image img : new Image[] { img1, img2 }) {
            img.setWidth("" + scaleWidth + "px");
        }
        img1.setCaption("V1");
        img2.setCaption("V2");
        hl.addComponent(img1);
        hl.addComponent(img2);
        Panel result = new Panel("Image comparison");
        hl.setMargin(true);
        result.setContent(hl);
        return Optional.fromNullable((Component) result);
    } else {
        return Optional.absent();
    }

}