Example usage for com.vaadin.ui CssLayout CssLayout

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

Introduction

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

Prototype

public CssLayout() 

Source Link

Document

Constructs an empty CssLayout.

Usage

From source file:net.pkhsolutions.pecsapp.ui.components.PagePanel.java

License:Open Source License

public PagePanel(@NotNull PageModel model) {
    this.model = Objects.requireNonNull(model);
    addStyleName("page-panel");
    setSizeFull();//from ww  w  .  j  a v  a 2  s . com
    page = new CssLayout();
    page.addStyleName("page");
    setContent(page);
    model.getLayout().addValueChangeListener(this::updateLayout);
    updateLayout(null);
}

From source file:net.pkhsolutions.pecsapp.ui.components.PagePanel.java

License:Open Source License

private void updateLayout(Property.ValueChangeEvent event) {
    final PageLayout layout = Objects.requireNonNull(model.getLayout().getValue());
    if (layout.getOrientation().equals(PageOrientation.PORTRAIT)) {
        page.setWidth(layout.getPageSize().getWidthMm(), Unit.MM);
        page.setHeight(layout.getPageSize().getHeightMm(), Unit.MM);
    } else {//  w ww . ja v a  2s.c  om
        page.setWidth(layout.getPageSize().getHeightMm(), Unit.MM);
        page.setHeight(layout.getPageSize().getWidthMm(), Unit.MM);
    }
    page.removeAllComponents();
    final float rowHeight = page.getHeight() / layout.getRows();
    final float cellWidth = page.getWidth() / layout.getColumns();
    rows = new CssLayout[layout.getRows()];
    cells = new PictureLayout[layout.getRows()][layout.getColumns()];
    for (int i = 0; i < layout.getRows(); ++i) {
        CssLayout row = new CssLayout();
        row.addStyleName("page-row");
        row.setWidth("100%");
        row.setHeight(rowHeight, page.getHeightUnits());
        page.addComponent(row);
        rows[i] = row;
        for (int j = 0; j < layout.getColumns(); ++j) {
            PictureLayout cell = new PictureLayout(model.getPictureModel(j, i));
            cell.addStyleName("page-row-cell");
            cell.setWidth(cellWidth, page.getWidthUnits());
            cell.setHeight("100%");
            row.addComponent(cell);
            cells[i][j] = cell;
        }
    }
}

From source file:nl.kpmg.lcm.ui.Application.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    getPage().setTitle("Local Catalog Manager");

    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();//from w  ww .  j av a  2 s .  com
    root.setMargin(true);
    root.setSpacing(true);
    setContent(root);

    final CssLayout navigationBar = new CssLayout();
    navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

    Label logo = new Label("LCM");
    logo.addStyleName("logo");
    logo.setWidthUndefined();

    navigationBar.addComponent(logo);
    navigationBar.addComponent(createNavigationButton("Metadata", MetadataOverviewViewImpl.VIEW_NAME));
    navigationBar.addComponent(createNotImplementedButton("Analytics"));
    navigationBar.addComponent(createNavigationButton("Transfer", TransferViewImpl.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("Administration", AdministrationViewImpl.VIEW_NAME));
    navigationBar.addComponent(createLogoutButton("Logout"));
    root.addComponent(navigationBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);
    navigator.navigateTo("login");
}

From source file:org.activiti.explorer.ui.custom.DetailPanel.java

License:Apache License

public DetailPanel() {
    setSizeFull();//from  w  ww  . j  a va 2  s .c  om
    addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL);
    setMargin(true);

    CssLayout cssLayout = new CssLayout(); // Needed for rounded corners
    cssLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL);
    cssLayout.setSizeFull();
    super.addComponent(cssLayout);

    mainPanel = new Panel();
    mainPanel.addStyleName(Reindeer.PANEL_LIGHT);
    mainPanel.setSizeFull();
    cssLayout.addComponent(mainPanel);

    // Use default layout
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setWidth(100, UNITS_PERCENTAGE);
    verticalLayout.setMargin(true);
    mainPanel.setContent(verticalLayout);
}

From source file:org.activiti.explorer.ui.custom.SkypeLabel.java

License:Apache License

/**
 * Constructs a {@link SkypeLabel} based on the given Skype id
 *//*from ww w  .j  av a 2  s .  c  o m*/
public SkypeLabel(String skypeId) {
    CssLayout layout = new CssLayout();
    setCompositionRoot(layout);

    Label label = new Label(
            "<script type='text/javascript' src='http://download.skype.com/share/skypebuttons/js/skypeCheck.js'></script>",
            Label.CONTENT_XHTML);
    layout.addComponent(label);

    Link link = new Link(null, new ExternalResource("skype:" + skypeId + "?call"));
    link.setIcon(Images.SKYPE);
    layout.addComponent(link);

    setWidth(16, UNITS_PIXELS);
    setHeight(16, UNITS_PIXELS);
}

From source file:org.activiti.explorer.ui.custom.TaskListHeader.java

License:Apache License

protected void initInputField() {
    // Csslayout is used to style inputtext as rounded
    CssLayout csslayout = new CssLayout();
    csslayout.setHeight(24, UNITS_PIXELS);
    csslayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(csslayout);/*from  w w  w . java2s .c  o m*/

    inputField = new TextField();
    inputField.setWidth(100, UNITS_PERCENTAGE);
    inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
    inputField.setInputPrompt(i18nManager.getMessage(Messages.TASK_CREATE_NEW));
    inputField.focus();
    csslayout.addComponent(inputField);

    layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(csslayout, 1.0f);
}

From source file:org.activiti.explorer.ui.mainlayout.MainLayout.java

License:Apache License

protected void initHeader() {
    header = new CssLayout();
    header.addStyleName(ExplorerLayout.STYLE_HEADER);
    header.setWidth(100, UNITS_PERCENTAGE);
    addComponent(header);
}

From source file:org.activiti.explorer.ui.mainlayout.MainLayout.java

License:Apache License

protected void initFooter() {
    footer = new CssLayout();
    footer.setWidth(100, UNITS_PERCENTAGE);
    footer.addStyleName(ExplorerLayout.STYLE_MAIN_FOOTER);
    addComponent(footer);//from   www .  j  a va 2  s.  c  o m

    Label footerLabel = new Label();
    footerLabel.setContentMode(Label.CONTENT_XHTML);
    footerLabel.setValue(i18nManager.getMessage(Messages.FOOTER_MESSAGE));
    footerLabel.setWidth(100, UNITS_PERCENTAGE);
    footer.addComponent(footerLabel);
}

From source file:org.activiti.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);

    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {// w w  w .j av  a  2  s  .c  o  m
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);

    descriptionLayout.addListener(new LayoutClickListener() {
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);

                // textarea
                final TextArea descriptionTextArea = new TextArea();
                descriptionTextArea.setNullRepresentation("");
                descriptionTextArea.setWidth(100, UNITS_PERCENTAGE);
                descriptionTextArea.setValue(task.getDescription());
                editLayout.addComponent(descriptionTextArea);

                // ok button
                Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                editLayout.addComponent(okButton);
                editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

                // replace
                descriptionLayout.replaceComponent(descriptionLabel, editLayout);

                // When OK is clicked -> update task data + ui
                okButton.addListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update data
                        task.setDescription(descriptionTextArea.getValue().toString());
                        taskService.saveTask(task);

                        // Update UI
                        descriptionLabel.setValue(task.getDescription());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}

From source file:org.activiti.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initTaskForm() {
    // Check if task requires a form
    TaskFormData formData = formService.getTaskFormData(task.getId());
    if (formData != null && formData.getFormProperties() != null && !formData.getFormProperties().isEmpty()) {
        taskForm = new FormPropertiesForm();
        taskForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.TASK_COMPLETE));
        taskForm.setCancelButtonCaption(i18nManager.getMessage(Messages.TASK_RESET_FORM));
        taskForm.setFormHelp(i18nManager.getMessage(Messages.TASK_FORM_HELP));
        taskForm.setFormProperties(formData.getFormProperties());

        taskForm.addListener(new FormPropertiesEventListener() {

            private static final long serialVersionUID = -3893467157397686736L;

            @Override/*w w  w . java 2s . c  om*/
            protected void handleFormSubmit(FormPropertiesEvent event) {
                Map<String, String> properties = event.getFormProperties();
                formService.submitTaskFormData(task.getId(), properties);
                notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }

            @Override
            protected void handleFormCancel(FormPropertiesEvent event) {
                // Clear the form values 
                taskForm.clear();
            }
        });
        // Only if current user is task's assignee
        taskForm.setEnabled(isCurrentUserAssignee());

        // Add component to page
        centralLayout.addComponent(taskForm);
    } else {
        // Just add a button to complete the task
        // TODO: perhaps move to a better place

        CssLayout buttonLayout = new CssLayout();
        buttonLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
        buttonLayout.setWidth(100, UNITS_PERCENTAGE);
        centralLayout.addComponent(buttonLayout);

        completeButton = new Button(i18nManager.getMessage(Messages.TASK_COMPLETE));

        completeButton.addListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                // If no owner, make assignee owner (will go into archived then)
                if (task.getOwner() == null) {
                    task.setOwner(task.getAssignee());
                    taskService.setOwner(task.getId(), task.getAssignee());
                }

                taskService.complete(task.getId());
                notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }
        });

        completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner());
        buttonLayout.addComponent(completeButton);
    }
}