Example usage for com.vaadin.ui ComponentContainer addComponent

List of usage examples for com.vaadin.ui ComponentContainer addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui ComponentContainer addComponent.

Prototype

public void addComponent(Component c);

Source Link

Document

Adds the component into this container.

Usage

From source file:org.metawidget.vaadin.ui.layout.HorizontalLayout.java

License:LGPL

public void startContainerLayout(ComponentContainer container, VaadinMetawidget metawidget) {

    com.vaadin.ui.HorizontalLayout layout = new com.vaadin.ui.HorizontalLayout();
    layout.setSpacing(true);//  ww w. j  a v  a 2 s  .  c o  m
    container.addComponent(layout);
}

From source file:org.metawidget.vaadin.ui.layout.VerticalLayout.java

License:LGPL

public void startContainerLayout(ComponentContainer container, VaadinMetawidget metawidget) {

    com.vaadin.ui.VerticalLayout layout = new com.vaadin.ui.VerticalLayout();
    layout.setSpacing(true);// w  w w  .j  a  va 2s .  c o m
    container.addComponent(layout);
}

From source file:org.openthinclient.web.pkgmngr.ui.presenter.PackageDetailsPresenter.java

public void setPackage(org.openthinclient.pkgmgr.db.Package otcPackage) {

    if (otcPackage != null) {
        view.show();// w w  w .  j a  va2s. c om
        view.setName(otcPackage.getName());
        view.setVersion(otcPackage.getVersion().toString());
        view.setDescription(otcPackage.getDescription());
        view.setShortDescription(otcPackage.getShortDescription());
        view.setSourceUrl(otcPackage.getSource().getUrl().toString());
        view.setChangeLog(otcPackage.getChangeLog());
        if (otcPackage.getLicense() != null) {
            view.setLicense(otcPackage.getLicense());
        }

        // Check available and existing packages to match package-reference of current package, sorted to use first matching package
        List<Package> installableAndExistingPackages = concat(packageManager.getInstalledPackages().stream(),
                packageManager.getInstallablePackages().stream()).sorted().collect(Collectors.toList());

        List<String> usedPackages = new ArrayList<>();
        view.addDependencies(PackageDetailsUtil.getReferencedPackageItems(otcPackage.getDepends(),
                installableAndExistingPackages, usedPackages));

        // conflicts
        if (otcPackage.getConflicts().isEmpty()) {
            view.hideConflictsTable();
        } else {
            view.addConflicts(PackageDetailsUtil.getReferencedPackageItems(otcPackage.getConflicts(),
                    installableAndExistingPackages, usedPackages));
        }

        // provides
        if (otcPackage.getProvides().isEmpty()) {
            view.hideProvidesTable();
        } else {
            view.addProvides(PackageDetailsUtil.getReferencedPackageItems(otcPackage.getProvides(),
                    installableAndExistingPackages, usedPackages));
        }

        final ComponentContainer actionBar = view.getActionBar();

        actionBar.removeAllComponents();

        if (packageManager.isInstallable(otcPackage)) {
            MButton installButton = new MButton(
                    mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_BUTTON_INSTALL_CAPTION))
                            .withIcon(VaadinIcons.DOWNLOAD).withListener((ClickListener) e -> {
                                doInstallPackage(otcPackage);
                            });
            installButton.addStyleName("package_detail_install_button");
            installButton.setEnabled(otcPackage.getLicense() == null);
            // licence-info text
            if (otcPackage.getLicense() != null) {
                actionBar.addComponent(
                        new Label(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_CONFIRM_LICENCE_INFO)));
            }
            actionBar.addComponent(installButton);

            // only if license accepted enable install button
            view.getLicenseCheckbox().setVisible(otcPackage.getLicense() != null);
            view.getLicenseCheckbox().addValueChangeListener(e -> installButton.setEnabled(e.getValue()));
        }
        if (packageManager.isInstalled(otcPackage)) {
            actionBar.addComponent(
                    new MButton(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_BUTTON_UNINSTALL_CAPTION))
                            .withIcon(VaadinIcons.TRASH).withListener((Button.ClickListener) e -> {
                                doUninstallPackage(otcPackage);
                            }));
            view.getLicenseCheckbox().setVisible(false);
        }

    } else {
        view.hide();
    }

}

From source file:org.panifex.web.vaadin.runtime.html.VaadinHtmlComponentUtil.java

License:Open Source License

/**
 * Adds the component to the container.//from  ww w .j av a 2  s  .c om
 *
 * @param htmlComp the component to be added to the container
 * @param container the container that the component to be added into
 */
public static void addComponentToContainer(HtmlComponent htmlComp, ComponentContainer container) {
    Component comp = castHtmlComponent(htmlComp, Component.class);
    container.addComponent(comp);
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.PerspectiveStackRenderer.java

License:Open Source License

private void showElementRecursive(MUIElement element) {
    if (!element.isToBeRendered())
        return;/*  w  w  w  . j  a v  a  2 s .c o m*/

    if (element instanceof MPlaceholder && element.getWidget() != null) {
        MPlaceholder ph = (MPlaceholder) element;
        MUIElement ref = ph.getRef();
        ref.setCurSharedRef(ph);

        ComponentContainer phComponent = (ComponentContainer) ph.getWidget();
        Component refComponent = (Component) ph.getRef().getWidget();
        phComponent.addComponent(refComponent);

        element = ref;

        //top right folder
        MPartStack topLeftStack = HierarchyUtils.findTopLeftFolder(ph.getRef());
        if (topLeftStack != null) {
            if (ph.getTags().contains(IPresentationEngine.MAXIMIZED))
                ((StackWidget) topLeftStack.getWidget()).setState(1);
            else if (ph.getTags().contains(IPresentationEngine.MINIMIZED))
                ((StackWidget) topLeftStack.getWidget()).setState(-1);
            else
                ((StackWidget) topLeftStack.getWidget()).setState(0);
        }
    }

    if (element instanceof MContext) {
        IEclipseContext context = ((MContext) element).getContext();
        if (context != null) {
            IEclipseContext newParentContext = modelService.getContainingContext(element);
            if (context.getParent() != newParentContext) {
                context.setParent(newParentContext);
            }
        }
    }

    // Show any floating windows
    if (element instanceof MWindow && element.getWidget() != null) {
        int visCount = 0;
        for (MUIElement kid : ((MWindow) element).getChildren()) {
            if (kid.isToBeRendered() && kid.isVisible())
                visCount++;
        }
        if (visCount > 0)
            element.setVisible(true);
    }

    if (element instanceof MElementContainer<?>) {
        MElementContainer<?> container = (MElementContainer<?>) element;
        List<MUIElement> kids = new ArrayList<MUIElement>(container.getChildren());
        for (MUIElement childElement : kids) {
            showElementRecursive(childElement);
        }

        // OK, now process detached windows
        if (element instanceof MWindow) {
            for (MWindow w : ((MWindow) element).getWindows()) {
                showElementRecursive(w);
            }
        } else if (element instanceof MPerspective) {
            for (MWindow w : ((MPerspective) element).getWindows()) {
                showElementRecursive(w);
            }
        }
    }
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.SashRenderer.java

License:Open Source License

public void generateSplitPanelStructure(MPartSashContainer sash) {
    VerticalLayout layout = (VerticalLayout) sash.getWidget();
    layout.removeAllComponents();//from www  . j  a  v a2 s.co m

    ComponentContainer sashWidget = null;

    @SuppressWarnings("unchecked")
    List<MPartSashContainerElement> renderableAndVisible = (List<MPartSashContainerElement>) filterRenderableAndVisibleElements(
            sash);

    if (renderableAndVisible.isEmpty()) {
        sashWidget = new VerticalLayout();
    } else if (renderableAndVisible.size() == 1) {
        sashWidget = new VerticalLayout();
        MPartSashContainerElement child = renderableAndVisible.get(0);
        sashWidget.addComponent((Component) child.getWidget());
    } else {
        sashWidget = sash.isHorizontal() ? new SashWidgetHorizontal() : new SashWidgetVertical();
        AbstractSplitPanel currentSashWidget = (AbstractSplitPanel) sashWidget;
        currentSashWidget.setLocked(sash.getTags().contains(Tags.NO_RESIZE));
        for (int i = 0; i < renderableAndVisible.size(); i++) {
            MPartSashContainerElement child = renderableAndVisible.get(i);

            if (currentSashWidget.getFirstComponent() == null) {
                currentSashWidget.setFirstComponent((Component) child.getWidget());
            } else {
                if (i == renderableAndVisible.size() - 1) {
                    currentSashWidget.setSecondComponent((Component) child.getWidget());
                } else {
                    AbstractSplitPanel newSashWidget = sash.isHorizontal() ? new SashWidgetHorizontal()
                            : new SashWidgetVertical();
                    newSashWidget.setLocked(sash.getTags().contains(Tags.NO_RESIZE));
                    newSashWidget.setFirstComponent((Component) child.getWidget());
                    currentSashWidget.setSecondComponent(newSashWidget);
                    currentSashWidget = newSashWidget;
                }
            }
        }
    }

    sashWidget.setSizeFull();
    layout.addComponent(sashWidget);

    setWeights(sash);
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.ToolControlRenderer.java

License:Open Source License

public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
    if (!(element instanceof MToolControl))
        return;/*from  ww  w  .  j  a  v a 2 s.  co m*/

    MToolControl toolControl = (MToolControl) element;

    ComponentContainer toolControlContainer;
    if ((MElementContainer<?>) element.getParent() instanceof MTrimBar) {
        MTrimBar trimBar = (MTrimBar) (MElementContainer<?>) element.getParent();
        if (trimBar.getSide() == SideValue.LEFT || trimBar.getSide() == SideValue.RIGHT)
            toolControlContainer = new VerticalLayout();
        else
            toolControlContainer = new HorizontalLayout();
        //add the drag handler (separator)
        toolControlContainer.addComponent(GuiUtils.createSeparator(toolControl));
    } else
        toolControlContainer = new VerticalLayout();

    IEclipseContext parentContext = modelService.getContainingContext(element);

    // Create a context just to contain the parameters for injection
    IContributionFactory contributionFactory = parentContext.get(IContributionFactory.class);

    IEclipseContext localContext = EclipseContextFactory.create();

    localContext.set(Component.class, toolControlContainer);
    localContext.set(ComponentContainer.class, toolControlContainer);
    localContext.set(MToolControl.class, toolControl);

    Object tcImpl = contributionFactory.create(toolControl.getContributionURI(), parentContext, localContext);
    toolControl.setObject(tcImpl);

    for (String css : toolControl.getTags()) {
        toolControlContainer.addStyleName(css);
    }

    toolControl.setWidget(toolControlContainer);
}

From source file:pl.exsio.frameset.vaadin.navigation.menu.CssButtonsMenu.java

License:Open Source License

private void build(MenuItem menu, final int level, ComponentContainer container) {
    for (final MenuItem item : menu.getChildren()) {
        Button b = new NativeButton(t(item.getLabel()));
        b.addStyleName("menu-item-" + item.getFrame().getKey());
        b.setIcon(((VaadinFrame) item.getFrame()).getIcon());
        b.addClickListener(new Button.ClickListener() {
            @Override//from  w  w w  .j  a v  a 2  s . co  m
            public void buttonClick(Button.ClickEvent event) {
                ((FramesetUI) getUI()).getFramesetNavigator().navigateTo(item.getFrame());
                if (item.getChildren().size() > 0) {
                    CssLayout submenu = (CssLayout) item.getParam("submenu");
                    submenu.setVisible(!submenu.isVisible());
                }
            }
        });
        this.buttons.add(b);
        container.addComponent(b);
        item.addParam("button", b);
        item.addParam("container", container);
        if (item.getChildren().size() > 0) {
            CssLayout subContainer = new CssLayout() {
                {
                    addStyleName("sub-menu");
                    addStyleName("menu-level-" + level);
                    setVisible(false);
                }
            };

            this.build(item, level + 1, subContainer);
            container.addComponent(subContainer);

            item.addParam("submenu", subContainer);
        }
    }
}

From source file:ro.zg.netcell.vaadin.action.ActionsManager.java

License:Apache License

private void showProgressIndicator(ComponentContainer container) {
    if (container == null) {
        return;/*from   w  w w. j  a v  a2 s . co  m*/
    }
    container.removeAllComponents();
    GridLayout lc = new GridLayout(1, 1);
    lc.setSizeFull();
    ProgressIndicator pi = new ProgressIndicator();
    pi.setIndeterminate(true);
    lc.addComponent(pi, 0, 0);
    lc.setComponentAlignment(pi, Alignment.TOP_CENTER);
    container.addComponent(lc);
}

From source file:ro.zg.netcell.vaadin.action.application.BaseListHandler.java

License:Apache License

protected void displayList(ActionContext ac, OpenGroupsApplication app, ComponentContainer targetContainer,
        EntityList list) {/*  w w  w .  j  ava  2 s  .c o  m*/
    ComponentContainer displayArea = targetContainer;
    // Table displayArea = targetContainer;
    displayArea.removeAllComponents();
    // displayArea.removeAllItems();
    for (Entity currentEntity : list.getItemsList()) {
        // VerticalLayout entityContainer = new VerticalLayout();
        CssLayout entityContainer = new CssLayout();
        //       entityContainer.setWidth("100%");
        // entityContainer.setMargin(true);
        entityContainer.addStyleName(OpenGroupsStyles.LIST_ITEM);
        currentEntity.setEntityContainer(entityContainer);
        displayArea.addComponent(entityContainer);
        // displayArea.addItem(new Object[] {entityContainer}, null);
        getActionsManager().executeAction(ActionsManager.OPEN_SELECTED_ENTITY, currentEntity, app,
                entityContainer, false, ac);

    }
}