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.opencms.ui.dialogs.history.diff.CmsShowVersionButtons.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)
 *//*w w w  .  j av a2  s .  c om*/
public Optional<Component> diff(CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2) {

    Panel panel = new Panel("");
    panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    HorizontalLayout hl = new HorizontalLayout();
    panel.setContent(hl);
    hl.addComponent(createButton(cms, v1));
    hl.addComponent(createButton(cms, v2));
    VerticalLayout outerContainer = new VerticalLayout();
    outerContainer.addComponent(hl);
    outerContainer.setComponentAlignment(hl, Alignment.MIDDLE_RIGHT);
    outerContainer.setMargin(true);
    hl.setSpacing(true);
    return Optional.fromNullable((Component) outerContainer);
}

From source file:org.opencms.ui.dialogs.history.diff.CmsTextDiff.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 w w  w  .  j a va  2s  .  co  m
public Optional<Component> diff(CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2)
        throws CmsException {

    CmsResource resource1 = A_CmsAttributeDiff.readResource(cms, v1);
    String encoding = CmsLocaleManager.getResourceEncoding(cms, resource1);
    I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource1);
    if ((type instanceof CmsResourceTypeXmlContent) || (type instanceof CmsResourceTypePlain)
            || (type instanceof CmsResourceTypeJsp) || (type instanceof CmsResourceTypeXmlPage)
            || (type instanceof CmsResourceTypePointer) || (type instanceof CmsResourceTypeBinary)) {
        CmsResource resource2 = A_CmsAttributeDiff.readResource(cms, v2);

        String path1 = resource1.getRootPath();
        String path2 = resource2.getRootPath();

        CmsFile file1 = cms.readFile(resource1);
        CmsFile file2 = cms.readFile(resource2);

        byte[] content1 = file1.getContents();
        byte[] content2 = file2.getContents();

        String originalSource = null;
        String copySource = null;

        I_CmsTextExtractor textExtractor = null;
        // only if both files have contents
        if ((content1.length > 0) && (content2.length > 0)) {
            if (path1.endsWith(".pdf") && path2.endsWith(".pdf")) {
                textExtractor = CmsExtractorPdf.getExtractor();
            } else if (path1.endsWith(".doc") && path2.endsWith(".doc")) {
                textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();
            } else if (path1.endsWith(".xls") && path2.endsWith(".xls")) {
                textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();
            } else if (path1.endsWith(".rtf") && path2.endsWith(".rtf")) {
                textExtractor = CmsExtractorRtf.getExtractor();
            } else if (path1.endsWith(".ppt") && path2.endsWith(".ppt")) {
                textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();
            }
        }
        if (textExtractor != null) {
            try {
                // extract the content
                originalSource = textExtractor.extractText(content1).getContent();
                copySource = textExtractor.extractText(content2).getContent();
            } catch (Exception e) {
                // something goes wrong on extracting content
                // set the content to null, so the content dialog will not be shown
                originalSource = null;
                copySource = null;
                LOG.error(e.getMessage(), e);
            }
        } else if ((type instanceof CmsResourceTypePlain) || (type instanceof CmsResourceTypeJsp)
                || (type instanceof CmsResourceTypePointer)) {
            try {
                originalSource = new String(content1, encoding);
                copySource = new String(content2, encoding);
            } catch (UnsupportedEncodingException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        if ((copySource == null) || (originalSource == null)) {
            return Optional.absent();
        }
        try {
            CmsTextDiffPanel diffPanel = new CmsTextDiffPanel(originalSource, copySource, false, true);
            diffPanel.setWidth("100%");
            Panel panel = new Panel(
                    CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_TEXT_COMPARISON_CAPTION_0));
            panel.setWidth("100%");
            VerticalLayout vl = new VerticalLayout();
            vl.setMargin(true);
            vl.addComponent(diffPanel);

            panel.setContent(vl);
            return Optional.<Component>fromNullable(panel);
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return Optional.absent();
        }
    } else {
        return Optional.absent();
    }
}

From source file:org.opencms.ui.dialogs.history.diff.CmsValueDiff.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   ww w .j a v  a2s . com*/
public Optional<Component> diff(final CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2)
        throws CmsException {

    CmsResource resource1 = A_CmsAttributeDiff.readResource(cms, v1);
    I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource1);
    CmsMacroResolver resolver = new CmsVersionMacroResolver(v1, v2);
    if ((type instanceof CmsResourceTypeXmlContent) || (type instanceof CmsResourceTypeXmlPage)) {
        CmsResource resource2 = A_CmsAttributeDiff.readResource(cms, v2);
        final Panel panel = new Panel(
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_CONTENT_VALUE_TABLE_CAPTION_0));

        final CmsFile file1 = cms.readFile(resource1);

        final CmsFile file2 = cms.readFile(resource2);
        VerticalLayout vl = new VerticalLayout();
        vl.setMargin(true);
        vl.setSpacing(true);
        Table table = buildValueComparisonTable(cms, panel, file1, file2, resolver);
        if (table.getContainerDataSource().size() == 0) {
            return Optional.absent();
        }
        Button fileTextCompareButton = new Button(
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_COMPARE_WHOLE_FILE_0));
        vl.addComponent(fileTextCompareButton);
        vl.setComponentAlignment(fileTextCompareButton, Alignment.MIDDLE_RIGHT);
        fileTextCompareButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void buttonClick(ClickEvent event) {

                Component diffView = buildWholeFileDiffView(cms, file1, file2);
                CmsHistoryDialog.openChildDialog(panel, diffView,
                        CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_COMPARE_WHOLE_FILE_0));
            }
        });
        vl.addComponent(table);
        panel.setContent(vl);
        Component result = panel;
        return Optional.fromNullable(result);
    } else {
        return Optional.absent();
    }
}

From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditor.java

License:Open Source License

/**
 * Creates the main component of the editor with all sub-components.
 * @return the completely filled main component of the editor.
 * @throws IOException thrown if setting the table's content data source fails.
 * @throws CmsException thrown if setting the table's content data source fails.
 *//* www. j a v  a 2 s.  c  om*/
private Component createMainComponent() throws IOException, CmsException {

    VerticalLayout mainComponent = new VerticalLayout();
    mainComponent.setSizeFull();
    mainComponent.addStyleName("o-message-bundle-editor");
    m_table = createTable();
    Panel navigator = new Panel();
    navigator.setSizeFull();
    navigator.setContent(m_table);
    navigator.addActionHandler(new CmsMessageBundleEditorTypes.TableKeyboardHandler(m_table));
    navigator.addStyleName("v-panel-borderless");

    mainComponent.addComponent(m_options.getOptionsComponent());
    mainComponent.addComponent(navigator);
    mainComponent.setExpandRatio(navigator, 1f);
    m_options.updateShownOptions(m_model.hasMasterMode(), m_model.canAddKeys());
    return mainComponent;
}

From source file:org.openeos.services.ui.vaadin.internal.VaadinWindowImpl.java

License:Apache License

@Override
protected ComponentContainer createMainContainer() {
    Panel mainPanel = new Panel();
    mainPanel.setSizeFull();/*from  www .  jav  a 2s.co  m*/
    if (!multipleLevels) {
        firstContainer = mainPanel;
    } else {
        VerticalSplitPanel vSplit = new VerticalSplitPanel();
        vSplit.setSizeFull();
        mainPanel.setContent(vSplit);
        firstContainer = new Panel();
        firstContainer.setSizeFull();
        vSplit.setFirstComponent(firstContainer);
        secondContainer = new Panel();
        secondContainer.setSizeFull();
        vSplit.setSecondComponent(secondContainer);
        vSplit.setLocked(false);
    }
    return mainPanel;
}

From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java

License:Apache License

private void displayTask(UserTask task) {
    Panel mainPanel = new Panel();
    mainPanel.setStyleName("background-default");
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//from w ww . j a va2s . co m
    layout.setSpacing(true);
    layout.setWidth(100f, VerticalLayout.UNITS_PERCENTAGE);
    mainPanel.setContent(layout);
    mainPanel.setSizeFull();

    mainPanel.addComponent(createTaskTitle(task));
    mainPanel.addComponent(createTaskSummary(task));

    Component customComponent = createCustomComponent(task);
    if (customComponent != null) {
        mainPanel.addComponent(customComponent);
    }

    mainSplitPanel.setSecondComponent(mainPanel);

}

From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java

License:Apache License

private Component createTaskSummary(UserTask task) {

    //      TextField name = new TextField("Name");
    //      name.setValue(task.getName());
    //      name.setReadOnly(true);
    //      name.setWidth("100%");

    TextField priority = new TextField("Priority");
    priority.setValue(Integer.toString(task.getPriority()));
    priority.setReadOnly(true);//from   w ww  .ja v  a2  s . com

    TextField status = new TextField("Status");
    status.setValue(task.getStatus().getDescription());
    status.setReadOnly(true);

    TextArea description = new TextArea("Description");
    description.setSizeFull();
    description.setValue(task.getDescription());
    description.setReadOnly(true);
    description.setRows(3);

    ComponentContainer buttons = createSummaryButtons(task);

    VerticalLayout secondColumnFields = new VerticalLayout();
    secondColumnFields.setMargin(false);
    secondColumnFields.setSizeFull();

    secondColumnFields.addComponent(priority);
    secondColumnFields.addComponent(status);

    HorizontalLayout fieldsLayout = new HorizontalLayout();
    fieldsLayout.setSizeFull();
    fieldsLayout.setMargin(false);
    fieldsLayout.setSpacing(false);
    fieldsLayout.addComponent(description);
    fieldsLayout.addComponent(secondColumnFields);
    fieldsLayout.setExpandRatio(description, 4.0f);
    fieldsLayout.setExpandRatio(secondColumnFields, 1.0f);

    HorizontalLayout mainLayout = new HorizontalLayout();
    mainLayout.setMargin(true);
    mainLayout.setSpacing(false);
    mainLayout.setSizeFull();
    mainLayout.addComponent(fieldsLayout);
    mainLayout.addComponent(buttons);
    mainLayout.setComponentAlignment(buttons, Alignment.TOP_LEFT);
    mainLayout.setExpandRatio(fieldsLayout, 1.0f);

    Panel panel = new Panel("Summary");
    panel.setStyleName("background-transparent");
    panel.setContent(mainLayout);

    return panel;
}

From source file:org.opennms.features.jmxconfiggenerator.webui.ui.mbeans.MBeansView.java

License:Open Source License

private Panel wrapToPanel(Component component) {
    Panel panel = new Panel(component.getCaption());
    panel.setSizeFull();// w w w .j  av a 2s  .co m

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);
    layout.setSpacing(false);
    layout.setSizeFull();
    layout.addComponent(component);

    panel.setContent(layout);
    component.setCaption(null);
    return panel;
}

From source file:org.opennms.features.topology.app.internal.TopologyWidgetTestApplication.java

License:Open Source License

@SuppressWarnings("serial")
@Override//from   w  w w.  jav  a2  s  .c  o m
public void init() {
    setTheme("topo_default");

    m_rootLayout = new AbsoluteLayout();
    m_rootLayout.setSizeFull();

    m_window = new Window("OpenNMS Topology");
    m_window.setContent(m_rootLayout);
    setMainWindow(m_window);

    m_uriFragUtil = new UriFragmentUtility();
    m_window.addComponent(m_uriFragUtil);
    m_uriFragUtil.addListener(this);

    m_layout = new AbsoluteLayout();
    m_layout.setSizeFull();
    m_rootLayout.addComponent(m_layout);

    if (m_showHeader) {
        HEADER_HEIGHT = 100;
        Panel header = new Panel("header");
        header.setCaption(null);
        header.setSizeUndefined();
        header.addStyleName("onmsheader");
        m_rootLayout.addComponent(header, "top: 0px; left: 0px; right:0px;");

        try {
            CustomLayout customLayout = new CustomLayout(getHeaderLayout());
            header.setContent(customLayout);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        HEADER_HEIGHT = 0;
    }

    Refresher refresher = new Refresher();
    refresher.setRefreshInterval(5000);
    getMainWindow().addComponent(refresher);

    m_graphContainer.setLayoutAlgorithm(new FRLayoutAlgorithm());

    final Property scale = m_graphContainer.getScaleProperty();

    m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, m_selectionManager,
            this);
    m_topologyComponent.setSizeFull();
    m_topologyComponent.addMenuItemStateListener(this);
    m_topologyComponent.addVertexUpdateListener(this);

    final Slider slider = new Slider(0, 1);

    slider.setPropertyDataSource(scale);
    slider.setResolution(1);
    slider.setHeight("300px");
    slider.setOrientation(Slider.ORIENTATION_VERTICAL);

    slider.setImmediate(true);

    final Button zoomInBtn = new Button();
    zoomInBtn.setIcon(new ThemeResource("images/plus.png"));
    zoomInBtn.setDescription("Expand Semantic Zoom Level");
    zoomInBtn.setStyleName("semantic-zoom-button");
    zoomInBtn.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            int szl = (Integer) m_graphContainer.getSemanticZoomLevel();
            szl++;
            m_graphContainer.setSemanticZoomLevel(szl);
            setSemanticZoomLevel(szl);
            saveHistory();
        }
    });

    Button zoomOutBtn = new Button();
    zoomOutBtn.setIcon(new ThemeResource("images/minus.png"));
    zoomOutBtn.setDescription("Collapse Semantic Zoom Level");
    zoomOutBtn.setStyleName("semantic-zoom-button");
    zoomOutBtn.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            int szl = (Integer) m_graphContainer.getSemanticZoomLevel();
            if (szl > 0) {
                szl--;
                m_graphContainer.setSemanticZoomLevel(szl);
                setSemanticZoomLevel(szl);
                saveHistory();
            }

        }
    });

    final Button panBtn = new Button();
    panBtn.setIcon(new ThemeResource("images/cursor_drag_arrow.png"));
    panBtn.setDescription("Pan Tool");
    panBtn.setStyleName("toolbar-button down");

    final Button selectBtn = new Button();
    selectBtn.setIcon(new ThemeResource("images/selection.png"));
    selectBtn.setDescription("Selection Tool");
    selectBtn.setStyleName("toolbar-button");
    selectBtn.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            selectBtn.setStyleName("toolbar-button down");
            panBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("select");
        }
    });

    panBtn.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            panBtn.setStyleName("toolbar-button down");
            selectBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("pan");
        }
    });

    VerticalLayout toolbar = new VerticalLayout();
    toolbar.setWidth("31px");
    toolbar.addComponent(panBtn);
    toolbar.addComponent(selectBtn);

    HorizontalLayout semanticLayout = new HorizontalLayout();
    semanticLayout.addComponent(zoomInBtn);
    semanticLayout.addComponent(m_zoomLevelLabel);
    semanticLayout.addComponent(zoomOutBtn);
    semanticLayout.setComponentAlignment(m_zoomLevelLabel, Alignment.MIDDLE_CENTER);

    AbsoluteLayout mapLayout = new AbsoluteLayout();

    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(slider, "top: 5px; left: 20px; z-index:1000;");
    mapLayout.addComponent(toolbar, "top: 324px; left: 12px;");
    mapLayout.addComponent(semanticLayout, "top: 380px; left: 2px;");
    mapLayout.setSizeFull();

    m_treeMapSplitPanel = new HorizontalSplitPanel();
    m_treeMapSplitPanel.setFirstComponent(createWestLayout());
    m_treeMapSplitPanel.setSecondComponent(mapLayout);
    m_treeMapSplitPanel.setSplitPosition(222, Sizeable.UNITS_PIXELS);
    m_treeMapSplitPanel.setSizeFull();

    m_commandManager.addCommandUpdateListener(this);

    menuBarUpdated(m_commandManager);
    if (m_widgetManager.widgetCount() != 0) {
        updateWidgetView(m_widgetManager);
    } else {
        m_layout.addComponent(m_treeMapSplitPanel, getBelowMenuPosition());
    }

    if (m_treeWidgetManager.widgetCount() != 0) {
        updateAccordionView(m_treeWidgetManager);
    }
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.HelpClickListener.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent clickEvent) {
    final Window window = new Window("Help");

    window.setModal(true);//from w  ww . ja  v a 2s .co m
    window.setClosable(false);
    window.setResizable(false);

    window.setWidth("55%");
    window.setHeight("80%");

    m_component.getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        {
            setMargin(true);
            setSpacing(true);
            setSizeFull();

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setSizeFull();
            horizontalLayout.setSpacing(true);

            Tree tree = new Tree();
            tree.setNullSelectionAllowed(false);
            tree.setMultiSelect(false);
            tree.setImmediate(true);

            tree.addItem("Overview");
            tree.setChildrenAllowed("Overview", false);

            tree.addItem("Installed Dashlets");
            tree.setChildrenAllowed("Installed Dashlets", true);

            final List<DashletFactory> factories = m_dashletSelector.getDashletFactoryList();

            for (DashletFactory dashletFactory : factories) {
                tree.addItem(dashletFactory.getName());
                tree.setParent(dashletFactory.getName(), "Installed Dashlets");
                tree.setChildrenAllowed(dashletFactory.getName(), false);
            }
            horizontalLayout.addComponent(tree);

            for (final Object id : tree.rootItemIds()) {
                tree.expandItemsRecursively(id);
            }

            final Panel panel = new Panel();
            panel.setSizeFull();

            horizontalLayout.addComponent(panel);
            horizontalLayout.setExpandRatio(panel, 1.0f);

            addComponent(horizontalLayout);
            setExpandRatio(horizontalLayout, 1.0f);

            tree.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                    String itemId = String.valueOf(valueChangeEvent.getProperty().getValue());

                    if ("Installed Dashlets".equals(itemId)) {
                        return;
                    }

                    if ("Overview".equals(itemId)) {
                        VerticalLayout verticalLayout = new VerticalLayout();
                        verticalLayout.setSpacing(true);
                        verticalLayout.setMargin(true);

                        verticalLayout.addComponent(new Label(getOverviewHelpHTML(), ContentMode.HTML));

                        panel.setContent(verticalLayout);
                    } else {
                        DashletFactory dashletFactory = m_dashletSelector.getDashletFactoryForName(itemId);

                        if (dashletFactory != null) {
                            if (dashletFactory.providesHelpComponent()) {
                                VerticalLayout verticalLayout = new VerticalLayout();
                                verticalLayout.setSpacing(true);
                                verticalLayout.setMargin(true);

                                Label helpTitle = new Label(
                                        "Help for Dashlet '" + dashletFactory.getName() + "'");
                                helpTitle.addStyleName("help-title");

                                verticalLayout.addComponent(helpTitle);
                                verticalLayout.addComponent(dashletFactory.getHelpComponent());

                                panel.setContent(verticalLayout);
                            }
                        }
                    }
                }
            });

            tree.select("Overview");

            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button closeButton = new Button("Close");

                    addComponent(closeButton);
                    setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT);
                    closeButton.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent clickEvent) {
                            window.close();
                        }
                    });
                }
            });
        }
    });
}