Example usage for com.vaadin.ui Embedded Embedded

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

Introduction

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

Prototype

public Embedded(String caption, Resource source) 

Source Link

Document

Creates a new Embedded object whose contents is loaded from given resource.

Usage

From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java

License:Apache License

/**
 * Default constructor.// ww  w .j  av a2  s.  c o m
 */
public BuildingControlPanel() {
    site = ((AgoControlSiteUI) UI.getCurrent()).getSite();
    siteContext = site.getSiteContext();
    entityManager = siteContext.getObject(EntityManager.class);

    layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.setStyleName(Reindeer.LAYOUT_WHITE);

    final Label title = new Label("Control Panel");
    title.setIcon(getSite().getIcon("inventory"));
    title.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(title);
    layout.setExpandRatio(title, 0);

    elementLayout = new VerticalLayout();
    elementLayout.setSpacing(true);
    elementLayout.setMargin(false);
    layout.addComponent(elementLayout);
    layout.setExpandRatio(elementLayout, 1);

    roomIcon = site.getIcon("room");
    deviceIcon = site.getIcon("device");
    temperatureIcon = site.getIcon("temperature");
    brightnessIcon = site.getIcon("brightness");
    humidityIcon = site.getIcon("humidity");
    eventIcon = site.getIcon("event");

    setCompositionRoot(layout);

    // the Refresher polls automatically
    final Refresher refresher = new Refresher();
    refresher.setRefreshInterval(200);
    refresher.addListener(new Refresher.RefreshListener() {
        @Override
        public void refresh(final Refresher refresher) {
            while (!recordsQueue.isEmpty()) {
                final List<Record> records = recordsQueue.remove();
                if (records.size() > 0) {
                    final Record record = records.get(0);
                    final RecordSet recordSet = record.getRecordSet();
                    final Element element = recordSet.getElement();

                    final GridLayout recordsLayout = recordsLayouts.get(element.getElementId());
                    if (recordsLayout == null) {
                        continue;
                    }

                    final int columnIndex = recordSet.getType().ordinal();
                    final int rowIndex = 0;
                    if (recordsLayout.getComponent(columnIndex, rowIndex) != null) {
                        continue;
                    }

                    final VerticalLayout recordLayout = new VerticalLayout();
                    recordLayout.setSpacing(true);
                    final Resource recordIcon;
                    switch (recordSet.getType()) {
                    case TEMPERATURE:
                        recordIcon = temperatureIcon;
                        break;
                    case BRIGHTNESS:
                        recordIcon = brightnessIcon;
                        break;
                    case HUMIDITY:
                        recordIcon = humidityIcon;
                        break;
                    default:
                        recordIcon = eventIcon;
                        break;
                    }

                    final Embedded embedded = new Embedded(null, recordIcon);
                    recordLayout.addComponent(embedded);
                    recordLayout.setExpandRatio(embedded, 0.1f);
                    embedded.setWidth(32, Unit.PIXELS);
                    embedded.setHeight(32, Unit.PIXELS);

                    final Label label = new Label();
                    recordLayout.addComponent(label);
                    recordLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);

                    final String recordUnit = recordSet.getUnit();
                    final String displayUnit = DisplayValueConversionUtil.getDisplayUnit(recordSet.getType(),
                            recordUnit);

                    final double displayValue = DisplayValueConversionUtil.convertValue(recordSet.getType(),
                            recordUnit, displayUnit, record.getValue());

                    final String displayValueString = DisplayValueConversionUtil.formatDouble(displayValue);

                    label.setValue(displayValueString + " " + displayUnit);
                    label.setDescription(record.getCreated().toString());

                    recordsLayout.addComponent(recordLayout, columnIndex, rowIndex);
                }
            }
        }
    });
    addExtension(refresher);

}

From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java

License:Apache License

/**
 * Invoked when view is entered./*  w  ww .j ava2s .c o  m*/
 * @param parameters the parameters
 */
public final synchronized void enter(final String parameters) {
    if (recordReaderThread != null) {
        recordReaderExitRequested = true;
        recordReaderThread.interrupt();
        try {
            recordReaderThread.join();
        } catch (final InterruptedException e) {
            LOGGER.debug("Record reader thread death wait interrupted.");
        }
    }
    elementLayout.removeAllComponents();
    recordsLayouts.clear();
    recordsQueue.clear();
    recordReaderExitRequested = false;

    final Company company = siteContext.getObject(Company.class);
    if (company == null || parameters == null || parameters.length() == 0) {
        return;
    }

    final String buildingId = parameters;
    final List<Element> elements = ElementDao.getElements(entityManager, company);

    boolean started = false;
    for (final Element element : elements) {
        if (element.getElementId().equals(buildingId)) {
            started = true;
            continue;
        }
        if (!started) {
            continue;
        }
        if (element.getTreeDepth() == 0) {
            break;
        }

        final HorizontalLayout elementLayout = new HorizontalLayout();
        this.elementLayout.addComponent(elementLayout);
        elementLayout.setSpacing(true);

        final Resource elementIcon;
        switch (element.getType()) {
        case ROOM:
            elementIcon = roomIcon;
            break;
        case DEVICE:
            elementIcon = deviceIcon;
            break;
        default:
            elementIcon = deviceIcon;
            break;
        }

        final Embedded embedded = new Embedded(null, elementIcon);
        elementLayout.addComponent(embedded);
        elementLayout.setExpandRatio(embedded, 0.1f);
        embedded.setWidth(32, Unit.PIXELS);
        embedded.setHeight(32, Unit.PIXELS);

        final Label label = new Label();
        elementLayout.addComponent(label);
        elementLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
        label.setValue(element.toString());

        final GridLayout recordLayout = new GridLayout();
        recordLayout.setSpacing(true);
        recordLayout.setColumns(4);
        recordLayout.setRows(1);

        this.elementLayout.addComponent(recordLayout);
        recordsLayouts.put(element.getElementId(), recordLayout);

    }

    recordReaderThread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                final EntityManager threadEntityManager = ((EntityManagerFactory) getSite().getSiteContext()
                        .getObject(EntityManagerFactory.class)).createEntityManager();
                for (final Element element : elements) {
                    final List<RecordSet> recordSets = RecordSetDao.getRecordSets(threadEntityManager, element);
                    if (recordsLayouts.containsKey(element.getElementId())) {
                        for (final RecordSet recordSet : recordSets) {
                            recordsQueue.put(RecordDao.getRecords(threadEntityManager, recordSet, 1));
                            if (recordReaderExitRequested) {
                                break;
                            }
                        }
                    }
                }

                Thread.sleep(10);
            } catch (InterruptedException e) {
            }
        }
    });
    recordReaderThread.start();

}

From source file:org.agocontrol.site.viewlet.dashboard.BuildingSelectPanel.java

License:Apache License

/**
 * Default constructor.//from w w w . j a va 2 s .c  o  m
 */
public BuildingSelectPanel() {
    site = ((AgoControlSiteUI) UI.getCurrent()).getSite();
    siteContext = site.getSiteContext();
    entityManager = siteContext.getObject(EntityManager.class);
    buildingIcon = site.getIcon("building");

    layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setStyleName(Reindeer.LAYOUT_WHITE);

    final Label title = new Label("Select Building");
    //title.setIcon(getSite().getIcon("inventory"));
    title.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(title);
    layout.setExpandRatio(title, 0);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    layout.addComponent(titleLayout);
    titleLayout.setSpacing(true);
    titleLayout.setSizeFull();

    final Embedded embedded = new Embedded(null, buildingIcon);
    titleLayout.addComponent(embedded);
    titleLayout.setExpandRatio(embedded, 0.1f);
    embedded.setWidth(32, Unit.PIXELS);
    embedded.setHeight(32, Unit.PIXELS);

    buildingComboBox = new ComboBox();
    titleLayout.addComponent(buildingComboBox);
    titleLayout.setComponentAlignment(buildingComboBox, Alignment.MIDDLE_LEFT);
    titleLayout.setExpandRatio(buildingComboBox, 0.9f);
    //buildingComboBox.setWidth(100, Unit.PERCENTAGE);
    buildingComboBox.setNullSelectionAllowed(false);
    buildingComboBox.setNewItemsAllowed(false);
    buildingComboBox.setTextInputAllowed(false);
    buildingComboBox.setImmediate(true);
    buildingComboBox.setBuffered(false);

    buildingComboBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            final Element building = (Element) buildingComboBox.getValue();
            if (building != null && !building.getElementId().equals(selectedBuildingId)) {
                UI.getCurrent().getNavigator().navigateTo("default/" + building.getElementId());
            }
        }
    });

    setCompositionRoot(layout);
}

From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java

License:Apache License

/**
 * Factory method to create an embeddable icon.
 * //from w w w.j  a v a2 s .  c  om
 * @param name
 *            the name of the icon to use (is also used as tooltip text);
 * @param res
 *            the resource denoting the actual icon.
 * @return an embeddable icon, never <code>null</code>.
 */
protected Embedded createIcon(String name, Resource res) {
    Embedded embedded = new Embedded(name, res);
    embedded.setType(Embedded.TYPE_IMAGE);
    embedded.setDescription(name);
    embedded.setHeight(ICON_HEIGHT + "px");
    embedded.setWidth(ICON_WIDTH + "px");
    return embedded;
}

From source file:org.bitpimp.VaadinCurrencyConverter.MyVaadinApplication.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    // Set the window or tab title
    getPage().setTitle("Yahoo Currency Converter");

    // Create the content root layout for the UI
    final FormLayout content = new FormLayout();
    content.setMargin(true);//ww w  . j  a va 2  s. c om
    final Panel panel = new Panel(content);
    panel.setWidth("500");
    panel.setHeight("400");
    final VerticalLayout root = new VerticalLayout();
    root.addComponent(panel);
    root.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    root.setSizeFull();
    root.setMargin(true);

    setContent(root);

    content.addComponent(new Embedded("",
            new ExternalResource("https://vaadin.com/vaadin-theme/images/vaadin/vaadin-logo-color.png")));
    content.addComponent(new Embedded("",
            new ExternalResource("http://images.wikia.com/logopedia/images/e/e4/YahooFinanceLogo.png")));

    // Display the greeting
    final Label heading = new Label("<b>Simple Currency Converter " + "Using YQL/Yahoo Finance Service</b>",
            ContentMode.HTML);
    heading.setWidth(null);
    content.addComponent(heading);

    // Build the set of fields for the converter form
    final TextField fromField = new TextField("From Currency", "AUD");
    fromField.setRequired(true);
    fromField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false));
    content.addComponent(fromField);

    final TextField toField = new TextField("To Currency", "USD");
    toField.setRequired(true);
    toField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false));
    content.addComponent(toField);

    final TextField resultField = new TextField("Result");
    resultField.setEnabled(false);
    content.addComponent(resultField);

    final TextField timeField = new TextField("Time");
    timeField.setEnabled(false);
    content.addComponent(timeField);

    final Button submitButton = new Button("Submit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // Do the conversion
            final String result = converter.convert(fromField.getValue().toUpperCase(),
                    toField.getValue().toUpperCase());
            if (result != null) {
                resultField.setValue(result);
                timeField.setValue(new Date().toString());
            }
        }
    });
    content.addComponent(submitButton);

    // Configure the error handler for the UI
    UI.getCurrent().setErrorHandler(new DefaultErrorHandler() {
        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            // Find the final cause
            String cause = "<b>The operation failed :</b><br/>";
            Throwable th = Throwables.getRootCause(event.getThrowable());
            if (th != null)
                cause += th.getClass().getName() + "<br/>";

            // Display the error message in a custom fashion
            content.addComponent(new Label(cause, ContentMode.HTML));

            // Do the default error handling (optional)
            doDefault(event);
        }
    });
}

From source file:org.bubblecloud.ilves.component.flow.AbstractFlowlet.java

License:Apache License

@Override
public final void attach() {
    super.attach();
    this.setSizeFull();

    rootLayout = new GridLayout(1, 2);
    rootLayout.setMargin(false);//from www .  j a v a  2 s . com
    rootLayout.setSpacing(true);
    rootLayout.setSizeFull();
    rootLayout.setRowExpandRatio(0, 0f);
    rootLayout.setRowExpandRatio(1, 1f);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, true, false));
    titleLayout.setSpacing(true);

    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-" + getFlowletKey()));
    titleIcon.setWidth(32, Unit.PIXELS);
    titleIcon.setHeight(32, Unit.PIXELS);
    titleLayout.addComponent(titleIcon);

    final Label titleLabel = new Label("<h1>" + getSite().localize("view-" + getFlowletKey()) + "</h1>",
            ContentMode.HTML);
    titleLayout.addComponent(titleLabel);
    rootLayout.addComponent(titleLayout, 0, 0);

    setCompositionRoot(rootLayout);

    initialize();
}

From source file:org.bubblecloud.ilves.component.grid.ValidatingEditor.java

License:Apache License

/**
 * Constructor which initializes the form.
 * @param fieldDescriptors The field definitions.
 *//*  w  w  w.  j a  v  a2s . c  o m*/
public ValidatingEditor(final List<FieldDescriptor> fieldDescriptors) {
    this.fieldDescriptors = fieldDescriptors;

    form = new Form();
    form.setBuffered(true);
    form.setFormFieldFactory(this);
    form.setImmediate(true);
    setCompositionRoot(form);

    formLayout = new GridLayout(3, fieldDescriptors.size());
    formLayout.setSpacing(true);
    formLayout.setMargin(new MarginInfo(true, false, true, false));
    form.setLayout(formLayout);

    fieldIds = new Object[fieldDescriptors.size()];
    fields = new Field[fieldDescriptors.size()];
    fieldLabels = new Label[fieldDescriptors.size()];
    fieldIcons = new Embedded[fieldDescriptors.size()];
    for (int i = 0; i < fieldDescriptors.size(); i++) {
        final FieldDescriptor fieldDescriptor = fieldDescriptors.get(i);
        fieldIds[i] = fieldDescriptor.getId();
        fieldLabels[i] = new Label(fieldDescriptor.getLabel());
        fieldIcons[i] = new Embedded(null, noneIcon);
        fieldIcons[i].setWidth(20, Unit.PIXELS);
        fieldIcons[i].setHeight(20, Unit.PIXELS);

        formLayout.addComponent(fieldLabels[i], 0, i);
        formLayout.addComponent(fieldIcons[i], 2, i);
        formLayout.setComponentAlignment(fieldLabels[i], Alignment.MIDDLE_RIGHT);
    }
}

From source file:org.bubblecloud.ilves.ui.user.AccountFlowlet.java

License:Apache License

@Override
public void initialize() {
    final GridLayout gridLayout = new GridLayout(1, 6);
    gridLayout.setRowExpandRatio(0, 0.0f);
    gridLayout.setRowExpandRatio(1, 0.0f);
    gridLayout.setRowExpandRatio(2, 0.0f);
    gridLayout.setRowExpandRatio(3, 0.0f);
    gridLayout.setRowExpandRatio(4, 0.0f);
    gridLayout.setRowExpandRatio(5, 1.0f);

    gridLayout.setSizeFull();/*  w  w  w  .  j ava  2 s.c om*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(4, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout userAccountTitle = new HorizontalLayout();
    userAccountTitle.setMargin(new MarginInfo(false, false, false, false));
    userAccountTitle.setSpacing(true);
    final Embedded userAccountTitleIcon = new Embedded(null, getSite().getIcon("view-icon-user"));
    userAccountTitleIcon.setWidth(32, Unit.PIXELS);
    userAccountTitleIcon.setHeight(32, Unit.PIXELS);
    userAccountTitle.addComponent(userAccountTitleIcon);
    final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", ContentMode.HTML);
    userAccountTitle.addComponent(userAccountTitleLabel);
    gridLayout.addComponent(userAccountTitle, 0, 0);

    final Button editUserButton = new Button("Edit User Account");
    editUserButton.setIcon(getSite().getIcon("button-icon-edit"));
    gridLayout.addComponent(editUserButton, 0, 2);
    editUserButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = ((SecurityProviderSessionImpl) getSite().getSecurityProvider())
                    .getUserFromSession();
            final UserAccountFlowlet customerView = getFlow().getFlowlet(UserAccountFlowlet.class);
            customerView.edit(entity, false);
            getFlow().forward(UserAccountFlowlet.class);
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    if (company.isOpenIdLogin()) {
        final VerticalLayout mainPanel = new VerticalLayout();
        mainPanel.setCaption("Choose OpenID Provider:");
        gridLayout.addComponent(mainPanel, 0, 1);
        final HorizontalLayout openIdLayout = new HorizontalLayout();
        mainPanel.addComponent(openIdLayout);
        openIdLayout.setMargin(new MarginInfo(false, false, true, false));
        openIdLayout.setSpacing(true);
        final String returnViewName = "openidlink";
        final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap();
        for (final String url : urlIconMap.keySet()) {
            openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName));
        }
    }

    if (SiteModuleManager.isModuleInitialized(CustomerModule.class)) {
        final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Customer.class);

        final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();
        filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name",
                new TextField(), 101, "=", String.class, ""));
        filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101,
                "=", String.class, ""));

        final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
        entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000,
                new String[] { "companyName", "lastName" }, new boolean[] { false, false }, "customerId");

        for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
            entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                    fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(),
                    fieldDefinition.isSortable());
        }

        final HorizontalLayout titleLayout = new HorizontalLayout();
        titleLayout.setMargin(new MarginInfo(true, false, false, false));
        titleLayout.setSpacing(true);
        final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-customer"));
        titleIcon.setWidth(32, Unit.PIXELS);
        titleIcon.setHeight(32, Unit.PIXELS);
        titleLayout.addComponent(titleIcon);
        final Label titleLabel = new Label("<h2>Customer Accounts</h2>", ContentMode.HTML);
        titleLayout.addComponent(titleLabel);
        gridLayout.addComponent(titleLayout, 0, 3);

        final Table table = new Table();
        table.setPageLength(5);
        entityGrid = new Grid(table, entityContainer);
        entityGrid.setFields(fieldDefinitions);
        entityGrid.setFilters(filterDefinitions);
        //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

        table.setColumnCollapsed("created", true);
        table.setColumnCollapsed("modified", true);
        table.setColumnCollapsed("company", true);
        gridLayout.addComponent(entityGrid, 0, 5);

        final HorizontalLayout customerButtonsLayout = new HorizontalLayout();
        gridLayout.addComponent(customerButtonsLayout, 0, 4);
        customerButtonsLayout.setMargin(false);
        customerButtonsLayout.setSpacing(true);

        final Button editCustomerDetailsButton = new Button("Edit Customer Details");
        customerButtonsLayout.addComponent(editCustomerDetailsButton);
        editCustomerDetailsButton.setEnabled(false);
        editCustomerDetailsButton.setIcon(getSite().getIcon("button-icon-edit"));
        editCustomerDetailsButton.addClickListener(new ClickListener() {
            /**
             * Serial version UID.
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                if (entityGrid.getSelectedItemId() == null) {
                    return;
                }
                final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
                final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
                customerView.edit(entity, false);
            }
        });

        final Button editCustomerMembersButton = new Button("Edit Customer Members");
        customerButtonsLayout.addComponent(editCustomerMembersButton);
        editCustomerMembersButton.setEnabled(false);
        editCustomerMembersButton.setIcon(getSite().getIcon("button-icon-edit"));
        editCustomerMembersButton.addClickListener(new ClickListener() {
            /**
             * Serial version UID.
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                if (entityGrid.getSelectedItemId() == null) {
                    return;
                }
                final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
                final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
                view.edit(entity.getMemberGroup(), false);
            }
        });

        final Button editCustomerAdminsButton = new Button("Edit Customer Admins");
        customerButtonsLayout.addComponent(editCustomerAdminsButton);
        editCustomerAdminsButton.setEnabled(false);
        editCustomerAdminsButton.setIcon(getSite().getIcon("button-icon-edit"));
        editCustomerAdminsButton.addClickListener(new ClickListener() {
            /**
             * Serial version UID.
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                if (entityGrid.getSelectedItemId() == null) {
                    return;
                }
                final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
                final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
                view.edit(entity.getAdminGroup(), false);
            }
        });

        table.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(final Property.ValueChangeEvent event) {
                editCustomerDetailsButton.setEnabled(table.getValue() != null);
                editCustomerMembersButton.setEnabled(table.getValue() != null);
                editCustomerAdminsButton.setEnabled(table.getValue() != null);
            }
        });

    }
}

From source file:org.bubblecloud.ilves.ui.user.privilege.PrivilegesFlowlet.java

License:Apache License

@Override
protected void initialize() {
    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, true, false));
    titleLayout.setSpacing(true);/*from w ww.j  a  v a  2s. c om*/
    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-privileges"));
    titleIcon.setWidth(32, Unit.PIXELS);
    titleIcon.setHeight(32, Unit.PIXELS);
    titleLayout.addComponent(titleIcon);
    titleLabel = new Label("<h1>" + getSite().localize("view-privileges") + "</h1>", ContentMode.HTML);
    titleLayout.addComponent(titleLabel);

    matrixLayout = new VerticalLayout();
    matrixLayout.setSpacing(true);
    matrixLayout.setMargin(false);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    saveButton = getSite().getButton("save");
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new Button.ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            saveGroupMatrix();
            saveUserMatrix();
            PrivilegeCache.flush((Company) Site.getCurrent().getSiteContext().getObject(Company.class));
        }
    });
    discardButton = getSite().getButton("discard");
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new Button.ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            refreshGroupMatrix();
            refreshUserMatrix();
        }
    });

    final CssLayout panel = new CssLayout();
    panel.addComponent(titleLayout);
    panel.addComponent(matrixLayout);
    panel.addComponent(buttonLayout);

    setCompositionRoot(panel);
}

From source file:org.casbah.ui.CasbahMainComponent.java

License:Open Source License

public void init() throws CasbahException {
    VerticalLayout rootLayout = new VerticalLayout();
    rootLayout.setSizeFull();/*www.j  ava 2s .  c o m*/
    Embedded banner = new Embedded(null, new ClassResource("/images/casbah.png", parentApplication));

    rootLayout.addComponent(banner);
    rootLayout.setComponentAlignment(banner, Alignment.MIDDLE_CENTER);

    tabSheet = new TabSheet();

    configView = new ConfigComponent(parentApplication, provider, casbahConfiguration);
    configView.init();
    tabSheet.addTab(configView, "Configuration", null);

    caView = new MainCAView(provider, parentApplication);
    caView.init();
    tabSheet.addTab(caView, "Certificate Authority", null);

    certView = new IssuedCertificateList(parentApplication, provider);
    certView.init();
    tabSheet.addTab(certView, "Issued Certificates", null);

    tabSheet.setWidth("1024px");

    rootLayout.addComponent(tabSheet);
    rootLayout.setComponentAlignment(tabSheet, Alignment.TOP_CENTER);

    Label footer = new Label("Copyright 2010 - Marco Sandrini - CASBaH is released under the"
            + "<a href=\"http://www.gnu.org/licenses/agpl-3.0-standalone.html\"> Affero GPL License v.3</a>"
            + " - Source Code is available through <a href=\"http://github.com/nessche/CASBaH/archives/master\">Github</a>",
            Label.CONTENT_XHTML);
    footer.setSizeUndefined();
    rootLayout.addComponent(footer);
    rootLayout.setComponentAlignment(footer, Alignment.TOP_CENTER);

    setSizeFull();
    setCompositionRoot(rootLayout);
}