Example usage for com.vaadin.ui CssLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:org.escidoc.browser.ui.maincontent.ContainerView.java

License:Open Source License

/**
 * Building the Header Element that shows the title of the Container
 *//*from w  ww.ja v a2  s. c  om*/
private void bindNameToHeader(CssLayout cssLayout) {
    final Label headerContext = new Label(ViewConstants.RESOURCE_NAME_CONTAINER + resourceProxy.getName());
    headerContext.setStyleName("h1 fullwidth floatleft");
    headerContext.setWidth("80%");
    headerContext.setDescription(ViewConstants.DESC_HEADER);
    cssLayout.addComponent(headerContext);
}

From source file:org.escidoc.browser.ui.maincontent.ContextRightPanel.java

License:Open Source License

@SuppressWarnings("serial")
private Panel buildAdminDescription() {
    final Panel admDescriptors = new Panel();
    admDescriptors.setWidth("100%");
    admDescriptors.setHeight("100%");
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();/*from   w  ww  .j av  a 2  s.  c  om*/
    final CssLayout cssLayout = new CssLayout();
    buildPanelHeader(cssLayout, ViewConstants.ADMIN_DESCRIPTION);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");
    if (contextController.canUpdateContext()) {
        final Button addResourceButton = new Button();
        addResourceButton.setStyleName(BaseTheme.BUTTON_LINK);
        addResourceButton.addStyleName("floatright paddingtop3");
        addResourceButton.setWidth("20px");
        addResourceButton.setIcon(ICON);
        addResourceButton.addListener(new ClickListener() {
            @Override
            public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                new OnContextAdminDescriptor(router, contextController).adminDescriptorForm();
            }
        });
        cssLayout.addComponent(addResourceButton);
    }
    vl.addComponent(cssLayout);

    VerticalLayout vl2 = new VerticalLayout();
    final AdminDescriptors admDesc = resourceProxy.getAdminDescription();
    final AdminDescriptorsTable adminDescriptorTable = new AdminDescriptorsTable(contextController, admDesc,
            router);
    adminDescriptorTable.buildTable();
    vl2.addComponent(adminDescriptorTable);
    vl.addComponent(vl2);
    vl.setExpandRatio(vl2, 9);
    admDescriptors.setContent(vl);
    return admDescriptors;
}

From source file:org.escidoc.browser.ui.maincontent.ContextRightPanel.java

License:Open Source License

@SuppressWarnings("serial")
private Panel buildOrganizationUnit() {
    final Panel pnlOrgUnit = new Panel();
    pnlOrgUnit.setSizeFull();/*ww w.  j  a v  a2 s  . c o m*/
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();

    final CssLayout cssLayout = new CssLayout();
    buildPanelHeader(cssLayout, ViewConstants.ORGANIZATIONAL_UNIT);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    if (contextController.canAddOUs()) {
        final Button addResourceButton = new Button();
        addResourceButton.setStyleName(BaseTheme.BUTTON_LINK);
        addResourceButton.addStyleName("floatright paddingtop3");
        addResourceButton.setWidth("20px");
        addResourceButton.setIcon(ICON);
        addResourceButton.addListener(new ClickListener() {

            @Override
            public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
                final Window subwindow = new Window("A modal subwindow");
                subwindow.setModal(true);
                subwindow.setWidth("650px");
                VerticalLayout layout = (VerticalLayout) subwindow.getContent();
                layout.setMargin(true);
                layout.setSpacing(true);

                try {
                    subwindow.addComponent(new AddOrgUnitstoContext(router, resourceProxy, contextController,
                            resourceProxy.getOrganizationalUnit()));
                } catch (EscidocClientException e) {
                    contextController.showError(e);
                }
                Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() {
                    @Override
                    public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                        subwindow.getParent().removeWindow(subwindow);
                    }
                });
                layout.addComponent(close);
                layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

                router.getMainWindow().addWindow(subwindow);

            }

        });
        cssLayout.addComponent(addResourceButton);
    }
    vl.addComponent(cssLayout);

    OrganizationalUnitsTableVH orgUnitTable = new OrganizationalUnitsTableVH(contextController,
            resourceProxy.getOrganizationalUnit(), router, resourceProxy);
    orgUnitTable.buildTable();
    vl.addComponent(orgUnitTable);
    vl.setComponentAlignment(orgUnitTable, Alignment.TOP_LEFT);
    vl.setExpandRatio(orgUnitTable, 9f);

    pnlOrgUnit.setContent(vl);
    return pnlOrgUnit;
}

From source file:org.escidoc.browser.ui.maincontent.ItemContent.java

License:Open Source License

private void initView() {
    final CssLayout cssLayout = new CssLayout();
    cssLayout.setHeight("20px");
    buildPanelHeader(cssLayout, ViewConstants.COMPONENTS);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    if (true) {//  w w  w  .ja  v  a2  s .  com
        final Button btnAddNew = new Button();
        btnAddNew.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
                Window modalWindow = new Window("Select a file to add.");
                modalWindow.setWidth("25%");
                modalWindow.setHeight("20%");
                modalWindow.setModal(true);
                modalWindow.addComponent(new ComponentUploadView(repositories, controller, itemProxy,
                        ItemContent.this, mainWindow));
                mainWindow.addWindow(modalWindow);
            }
        });
        btnAddNew.setStyleName(BaseTheme.BUTTON_LINK);
        btnAddNew.addStyleName("floatright paddingtop3");
        btnAddNew.setWidth("20px");
        btnAddNew.setIcon(ICON);
        cssLayout.addComponent(btnAddNew);
    }

    verticalLayout.addComponent(cssLayout);
    wrap(verticalLayout);
    if (controller.hasComponents()) {
        verticalLayout.addComponent(buildTable());
    } else {
        final Label lblNoComponents = new Label(
                "No components in this Item. You can drag n'drop some file from your computer to this box to add new components!");
        lblNoComponents.setWidth("90%");
        lblNoComponents.setStyleName("skybluetext");
        verticalLayout.addComponent(lblNoComponents);
    }
}

From source file:org.escidoc.browser.ui.maincontent.ItemContent.java

License:Open Source License

private void buildPanelHeader(CssLayout cssLayout, String name) {
    cssLayout.addStyleName("v-accordion-item-caption v-caption v-captiontext");
    cssLayout.setWidth("100%");
    cssLayout.setMargin(false);//from ww  w .  java2  s  .  co m

    final Label nameofPanel = new Label(name, Label.CONTENT_RAW);
    nameofPanel.setStyleName("accordion v-captiontext");
    nameofPanel.setWidth("70%");
    cssLayout.addComponent(nameofPanel);

}

From source file:org.escidoc.browser.ui.maincontent.MetadataRecsItem.java

License:Open Source License

private Panel lblMetadaRecs() {
    pnl.setSizeFull();/*from w  ww  . j  a  v a  2  s. com*/
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    final CssLayout cssLayout = new CssLayout();
    cssLayout.setHeight("20px");
    buildPanelHeader(cssLayout, ViewConstants.METADATA);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    ItemMetadataTable metadataItem = new ItemMetadataTable(itemController, router, resourceProxy, repositories);
    metadataItem.buildTable();
    if (itemController.hasAccess()) {
        final Button btnAddNew = new Button();
        btnAddNew.addListener(new AddMetaDataFileItemBehaviour(mainWindow, repositories, resourceProxy));
        btnAddNew.setStyleName(BaseTheme.BUTTON_LINK);
        btnAddNew.addStyleName("floatright paddingtop3");
        btnAddNew.setWidth("20px");
        btnAddNew.setIcon(ICON);
        cssLayout.addComponent(btnAddNew);
    }
    vl.addComponent(cssLayout);
    vl.addComponent(metadataItem);
    vl.setExpandRatio(metadataItem, 9f);
    pnl.setContent(vl);
    return pnl;
}

From source file:org.escidoc.browser.ui.maincontent.OrgUnitMetadataRecordsView.java

License:Open Source License

@SuppressWarnings("serial")
private Component buildMetaDataTab() {
    Panel innerPanel = new Panel();
    innerPanel.setSizeFull();//from  ww  w.  ja v  a  2  s .  c  o  m
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();

    final CssLayout cssLayout = new CssLayout();
    cssLayout.setHeight("20px");
    buildPanelHeader(cssLayout, ViewConstants.METADATA);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    if (canAddMetadata()) {
        final Button addNewOrgUnitBtn = new Button();
        addNewOrgUnitBtn.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                OnAddOrgUnitMetadata view = new OnAddOrgUnitMetadata(controller, router.getMainWindow());
                view.showAddWindow();
            }
        });
        addNewOrgUnitBtn.setStyleName(BaseTheme.BUTTON_LINK);
        addNewOrgUnitBtn.addStyleName("floatright paddingtop3");
        addNewOrgUnitBtn.setWidth("20px");
        addNewOrgUnitBtn.setIcon(ICON);
        cssLayout.addComponent(addNewOrgUnitBtn);
    }
    vl.addComponent(cssLayout);
    OrgUnitMetadataTable metadataTable = new OrgUnitMetadataTable(orgUnit.getMetadataRecords(), controller,
            router);
    metadataTable.buildTable();
    vl.addComponent(metadataTable);
    vl.setExpandRatio(metadataTable, 9);
    innerPanel.setContent(vl);
    return innerPanel;
}

From source file:org.escidoc.browser.ui.maincontent.ParentsView.java

License:Open Source License

@SuppressWarnings("serial")
private Component buildParentsList() {
    // ViewConstants.PARENTS
    final Panel panel = new Panel();
    panel.setSizeFull();/*from   w  w w .ja va  2s. c om*/
    panel.setStyleName(Runo.PANEL_LIGHT);

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();

    final CssLayout cssLayout = new CssLayout();
    cssLayout.setHeight("20px");
    buildPanelHeader(cssLayout, ViewConstants.PARENTS);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    Button btnAdd = new Button();
    btnAdd.setStyleName(BaseTheme.BUTTON_LINK);
    btnAdd.addStyleName("floatright paddingtop3");
    btnAdd.setWidth("20px");
    btnAdd.setIcon(ICON);
    btnAdd.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            final Window subwindow = new Window("Manage Organizational Unit Parents");
            subwindow.setModal(true);
            subwindow.setWidth("650px");
            VerticalLayout layout = (VerticalLayout) subwindow.getContent();
            layout.setMargin(true);
            layout.setSpacing(true);

            try {
                subwindow.addComponent(new OrgUnitParentEditView(orgUnitProxy, orgUnitProxy.getParentList(),
                        router, orgUnitController));
            } catch (EscidocClientException e) {
                orgUnitController.showError(e);
            }
            Button close = new Button("Close", new Button.ClickListener() {

                @Override
                public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) {
                    (subwindow.getParent()).removeWindow(subwindow);
                }
            });
            layout.addComponent(close);
            layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

            mainWindow.addWindow(subwindow);
        }
    });
    cssLayout.addComponent(btnAdd);
    vl.addComponent(cssLayout);
    List<ResourceModel> l = orgUnitProxy.getParentList();
    OUParentTableVH parentTable = new OUParentTableVH(orgUnitProxy, router, orgUnitController);
    parentTable.buildTable();
    vl.addComponent(parentTable);
    vl.setExpandRatio(parentTable, 9f);
    // TODO here comes table
    panel.setContent(vl);
    return panel;
}

From source file:org.escidoc.browser.ui.maincontent.SearchAdvancedView.java

License:Open Source License

public SearchAdvancedView(final Router router, final EscidocServiceLocation serviceLocation) {
    this.router = router;
    this.serviceLocation = serviceLocation;
    setWidth("100.0%");
    setHeight("85%");
    setMargin(true);/*from   w w w  .  j av a  2  s  .  c o  m*/

    // CssLayout to hold the BreadCrumb
    final CssLayout cssLayout = new CssLayout();
    cssLayout.setWidth("60%");
    cssLayout.setCaption("Advanced Search");
    // Css Hack * Clear Div
    final Label lblClear = new Label();
    lblClear.setStyleName("clear");

    txtTitle = new TextField();
    txtTitle.setInputPrompt("Title");
    txtTitle.setImmediate(false);
    txtDescription = new TextField();
    txtDescription.setInputPrompt("Description");
    txtDescription.setImmediate(false);
    // Clean Divs
    cssLayout.addComponent(lblClear);

    txtCreator = new TextField();
    txtCreator.setInputPrompt("Creator");
    txtCreator.setImmediate(false);
    // DatePicker for CreationDate
    creationDate = new PopupDateField();
    creationDate.setInputPrompt("Creation date");
    creationDate.setResolution(PopupDateField.RESOLUTION_DAY);
    creationDate.setImmediate(false);

    // Dropdown for MimeType
    final String[] mimetypes = new String[] { "application/octet-stream", "text/html", "audio/aiff",
            "video/avi", "image/bmp", "application/book", "text/plain", "image/gif", "image/jpeg", "audio/midi",
            "video/quicktime", "audio/mpeg", "application/xml", "text/xml" };
    mimes = new ComboBox();

    for (final String mimetype : mimetypes) {
        mimes.addItem(mimetype);
    }
    mimes.setInputPrompt("Mime Types");
    mimes.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH);
    mimes.setImmediate(true);

    // Dropdown for Resource Type
    final String[] resourcearr = new String[] { "Context", "Container", "Item" };
    resource = new ComboBox();
    for (final String element : resourcearr) {
        resource.addItem(element);
    }
    resource.setInputPrompt("Resource Type");
    resource.setFilteringMode(Filtering.FILTERINGMODE_OFF);
    resource.setImmediate(true);

    txtFullText = new TextField();
    txtFullText.setInputPrompt("FullText");
    txtFullText.setImmediate(false);

    final Button bSearch = new Button("Search", this, "onClick");
    bSearch.setDescription("Search Tooltip");

    // Placing the elements in the design:
    txtTitle.setWidth("50%");
    txtTitle.setStyleName("floatleft paddingtop20 ");
    cssLayout.addComponent(txtTitle);

    txtDescription.setWidth("50%");
    txtDescription.setStyleName("floatright paddingtop20 ");
    cssLayout.addComponent(txtDescription);

    txtCreator.setWidth("50%");
    txtCreator.setStyleName("floatleft paddingtop20");
    cssLayout.addComponent(txtCreator);

    creationDate.setWidth("50%");
    creationDate.setStyleName("floatright");
    cssLayout.addComponent(creationDate);

    // Clean Divs
    cssLayout.addComponent(lblClear);

    mimes.setWidth("45%");
    mimes.setStyleName("floatleft");
    cssLayout.addComponent(mimes);

    resource.setWidth("45%");
    resource.setStyleName("floatright");
    cssLayout.addComponent(resource);

    txtFullText.setWidth("70%");
    txtFullText.setStyleName("floatleft");
    cssLayout.addComponent(txtFullText);

    bSearch.setStyleName("floatright");
    cssLayout.addComponent(bSearch);

    addComponent(cssLayout);
    this.setComponentAlignment(cssLayout, VerticalLayout.ALIGNMENT_HORIZONTAL_CENTER,
            VerticalLayout.ALIGNMENT_VERTICAL_CENTER);
}

From source file:org.escidoc.browser.ui.maincontent.SearchResultsView.java

License:Open Source License

private void createPaginationTblResults(final CssLayout cssLayout) throws EscidocClientException {

    ResourceProxy resourceProxy = null;//  w  w w  .  jav  a  2s  . c om

    tblPagedResults = createPagedTable(cssLayout);

    final List<SearchResultRecord> records = results.getRecords();

    final IndexedContainer container = createPagedTableItemContainer();

    // Adding items in the container
    for (final SearchResultRecord record : records) {
        final SearchResult s = record.getRecordData();
        String strResourceType = "";
        if (s.getContent() instanceof Container) {
            resourceProxy = new ContainerProxyImpl((Container) s.getContent());
            strResourceType = "Container";
        } else if (s.getContent() instanceof de.escidoc.core.resources.om.item.Item) {
            final Resource item = (de.escidoc.core.resources.om.item.Item) s.getContent();
            resourceProxy = new ItemProxyImpl((de.escidoc.core.resources.om.item.Item) item);
            strResourceType = "Item";
        } else if (s.getContent() instanceof Context) {
            final Resource resource = (Context) s.getContent();
            resourceProxy = new ContextProxyImpl((Context) resource);
            strResourceType = "Context";
        }

        final Object[] variablesForTheTab = { strResourceType, resourceProxy.getId(), resourceProxy.getId() };

        final Item item = container.addItem(variablesForTheTab);
        item.getItemProperty("Type")
                .setValue(new Label(
                        "<img src= \"/browser/VAADIN/themes/myTheme/images/" + strResourceType + ".png\" />",
                        Label.CONTENT_RAW));
        item.getItemProperty("Name").setValue(resourceProxy.getName());

        item.getItemProperty(DATE_CREATED).setValue(resourceProxy.getCreatedOn());
    }

    // Populate the table with results
    tblPagedResults.setContainerDataSource(container);
    final Label lblResults = new Label(
            "We found " + results.getNumberOfMatchingRecords() + " results for your search.");
    cssLayout.addComponent(lblResults);
    cssLayout.addComponent(tblPagedResults);
    cssLayout.addComponent(tblPagedResults.createControls());
}