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:com.lizardtech.expresszip.ui.FindLayersPresenter.java

License:Apache License

private void addClusteredVectorLayer() {
    if (clusterLayer != null) {
        findLayersMap.removeLayer(clusterLayer);
    }//from  w  ww  .jav a 2  s  .  c  o m
    clusterLayer = new VectorLayer();
    clusterLayer.setSelectionMode(SelectionMode.SIMPLE);
    clusterLayer.addListener(new org.vaadin.vol.VectorLayer.VectorSelectedListener() {

        @Override
        public void vectorSelected(org.vaadin.vol.VectorLayer.VectorSelectedEvent event) {
            Vector[] vectors = event.getVectors();
            if (null == vectors)
                return;

            if (null != popup) {
                findLayersMap.removeComponent(popup);
            }
            popup = new Popup();
            findLayersMap.addPopup(popup);
            CssLayout cssLayout = new CssLayout();
            VerticalLayout verticalLayout = new VerticalLayout();
            Panel panel = new Panel();
            panel.setStyleName(Runo.PANEL_LIGHT);
            panel.setContent(verticalLayout);
            int height = Math.min(400, (vectors.length + 1) * 32 + 10);
            panel.setHeight(height + "px");
            cssLayout.addComponent(panel);
            popup.addComponent(cssLayout);

            TreeTable popupTable = findLayersView.getPopupTable();
            popupTable.removeAllItems();
            verticalLayout.addComponent(popupTable);

            List<ExpressZipLayer> layers = new ArrayList<ExpressZipLayer>();
            for (Vector selected : vectors) {
                final ExpressZipLayer layer = (ExpressZipLayer) selected.getData();
                findLayersView.addLayerItem(layer, popupTable);
                layers.add(layer);
            }
            Bounds b = MapModel.getBoundsForLayers(layers, MapModel.EPSG4326);
            popup.setLat((b.getMinLat() + b.getMaxLat()) / 2.0d);
            popup.setLon((b.getMaxLon() + b.getMinLon()) / 2.0d);
        }

    });

    clusterLayer.addListener(new org.vaadin.vol.VectorLayer.VectorUnSelectedListener() {

        @Override
        public void vectorUnSelected(VectorUnSelectedEvent event) {
            if (null != popup) {
                findLayersMap.removeComponent(popup);
                popup = null;
            }
        }
    });

    clusterLayer.setImmediate(true);
    findLayersMap.addLayer(clusterLayer);
}

From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java

License:Apache License

public FindLayersViewComponent() {

    treeTable = new ExpressZipTreeTable();
    popupTable = new ExpressZipTreeTable();
    configureTable(treeTable);/*from  w  ww. j  ava  2 s .c  o m*/

    popupSelectionListener = new Property.ValueChangeListener() {
        private static final long serialVersionUID = 625365970493526725L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // the current popup selection
            Set<ExpressZipLayer> popupSelection = (Set<ExpressZipLayer>) event.getProperty().getValue();

            // get the tree's current selection
            HashSet<ExpressZipLayer> treeSelection = new HashSet<ExpressZipLayer>(
                    (Set<ExpressZipLayer>) treeTable.getValue());

            // remove all items in common with popup
            treeSelection.removeAll(popupTable.getItemIds());

            // set the treeTable selection to the union
            Set<ExpressZipLayer> unionSelection = new HashSet<ExpressZipLayer>();
            unionSelection.addAll(popupSelection);
            unionSelection.addAll(treeSelection);
            treeTable.setValue(unionSelection);
        }
    };
    popupTable.addListener(popupSelectionListener);

    treeTable.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 6236114836521221107L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            Set<ExpressZipLayer> highlightedLayers = (Set<ExpressZipLayer>) event.getProperty().getValue();
            for (FindLayersViewListener listener : listeners) {
                listener.layerHighlightedEvent(highlightedLayers);
            }

            // reset selection of popup table
            popupTable.removeListener(popupSelectionListener);

            // intersection of treeTable's selection and popupTable items
            Set<ExpressZipLayer> popupSelection = new HashSet<ExpressZipLayer>();
            popupSelection.addAll(highlightedLayers);
            popupSelection.retainAll(popupTable.getItemIds());
            popupTable.setValue(popupSelection);

            popupTable.addListener(popupSelectionListener);
        }
    });
    configureTable(popupTable);

    filter = new Filter(this);
    filterButtonListener = new FilterListeners();
    axisSelectedListener = new AxisSelected();
    listeners = new ArrayList<FindLayersViewListener>();
    btnNext = new ExpressZipButton("Next", Style.STEP);
    btnBack = new ExpressZipButton("Back", Style.STEP);

    btnAddFilter = new ExpressZipButton("Add Filter", Style.ACTION);
    btnAddFilter.addStyleName("filter-flow");

    hshFilterButtons = new HashMap<Button, FilterObject>();
    cssLayers = new CssLayout();

    basemapSelector = new ComboBox();
    basemapSelector.setWidth(100.0f, UNITS_PERCENTAGE);
    basemapSelector.setTextInputAllowed(false);
    basemapSelector.setImmediate(true);
    basemapSelector.setNullSelectionAllowed(false);
    basemapSelector.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -7358667131762099215L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue();
            boolean enableCheckbox = false;
            if (l instanceof WebMapServiceLayer) {
                for (ExpressZipLayer local : mapModel.getLocalBaseLayers()) {
                    if (l.toString().equals(local.getName())) {
                        enableCheckbox = true;
                        break;
                    }
                }
            }
            includeBasemap.setEnabled(enableCheckbox);
            if (!enableCheckbox) {
                includeBasemap.setValue(false);
            }

            if (mapModel.getBaseLayerTerms(l) != null && !mapModel.getBaseLayerTermsAccepted(l)) {
                final Window modal = new Window("Terms of Use");
                modal.setModal(true);
                modal.setClosable(false);
                modal.setResizable(false);
                modal.getContent().setSizeUndefined(); // trick to size around content
                Button bOK = new ExpressZipButton("OK", Style.ACTION, new ClickListener() {
                    private static final long serialVersionUID = -2872178665349848542L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue();
                        mapModel.setBaseLayerTermsAccepted(l);
                        for (FindLayersViewListener listener : listeners)
                            listener.baseMapChanged(l);
                        ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal);
                    }
                });
                Button bCancel = new ExpressZipButton("Cancel", Style.ACTION, new ClickListener() {
                    private static final long serialVersionUID = -3044064554876422836L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        basemapSelector.select(mapModel.getBaseLayers().get(0));
                        ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal);
                    }
                });
                HorizontalLayout buttons = new HorizontalLayout();
                buttons.setSpacing(true);
                buttons.addComponent(bOK);
                buttons.addComponent(bCancel);
                Label termsText = new Label(mapModel.getBaseLayerTerms(l));
                termsText.setContentMode(Label.CONTENT_XHTML);
                VerticalLayout vlay = new VerticalLayout();
                vlay.addComponent(termsText);
                vlay.addComponent(buttons);
                vlay.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);
                vlay.setWidth(400, UNITS_PIXELS);
                modal.getContent().addComponent(vlay);
                ((ExpressZipWindow) getApplication().getMainWindow()).addWindow(modal);
            } else {
                for (FindLayersViewListener listener : listeners)
                    listener.baseMapChanged(l);
            }
        }
    });

    includeBasemap = new CheckBox();
    includeBasemap.setDescription("Include this basemap in the exported image.");
    includeBasemap.setWidth(64f, UNITS_PIXELS);

    HorizontalLayout basemapLayout = new HorizontalLayout();
    basemapLayout.setWidth(100f, UNITS_PERCENTAGE);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSizeFull();
    setSizeFull();

    Label step = new Label("Step 1: Select Layers");
    step.addStyleName("step");
    layout.addComponent(step);

    layout.addComponent(treeTable);
    layout.setSpacing(true);
    treeTable.setSizeFull();
    layout.setExpandRatio(treeTable, 1f);

    layout.addComponent(new Panel(BASEMAP, basemapLayout));
    basemapLayout.addComponent(basemapSelector);
    basemapLayout.setExpandRatio(basemapSelector, 1f);
    basemapLayout.addComponent(includeBasemap);

    layout.addComponent(cssLayers);
    cssLayers.addComponent(btnAddFilter);

    HorizontalLayout backSubmitLayout = new HorizontalLayout();
    backSubmitLayout.setWidth("100%");
    backSubmitLayout.addComponent(btnBack);
    backSubmitLayout.addComponent(btnNext);
    backSubmitLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_LEFT);
    backSubmitLayout.setComponentAlignment(btnNext, Alignment.BOTTOM_RIGHT);

    VerticalLayout navLayout = new VerticalLayout();
    navLayout.addComponent(backSubmitLayout);
    navLayout.setSpacing(true);

    ThemeResource banner = new ThemeResource("img/ProgressBar1.png");
    navLayout.addComponent(new Embedded(null, banner));

    layout.addComponent(navLayout);
    layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER);

    btnNext.addListener(this);
    btnNext.setEnabled(false);
    btnBack.setEnabled(false); // always disabled
    btnAddFilter.addListener(this);

    layout.addStyleName("findlayers");
    setCompositionRoot(layout);
}

From source file:com.m1kah.ui.TodoUi.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    layout = new CssLayout();
    layout.setStyleName("main");
    initHeading();//from   www . j a v  a  2 s  . c o m
    layout.addComponent(createTodoComponent());
    setContent(layout);
    setId("todoapp");
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * @param audioFile//from  w w  w .j a v  a  2 s  .  c o  m
 * @return
 */
private CssLayout addDetails(AudioFile audioFile) {
    CssLayout details = new CssLayout();
    details.setWidth("100%");

    Label title = new Label("<h3>" + audioFile.getArtist() + "&ndash;" + audioFile.getTitle() + "</h3>",
            ContentMode.HTML);
    details.addComponent(title);
    title.setSizeUndefined();

    TabSheet tabs = new TabSheet();
    tabs.addStyleName(Runo.TABSHEET_SMALL);
    tabs.setWidth("100%");
    tabs.setHeight("180px");
    details.addComponent(tabs);

    FormLayout formLayout = new FormLayout();
    tabs.addTab(formLayout, "Info");

    Label text = new Label(audioFile.getTitle());
    text.setCaption("Title:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getArtist());
    text.setCaption("Artist:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getAlbum());
    text.setCaption("Album:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getGenre());
    text.setCaption("Genre:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getPrice() + "$");
    text.setCaption("Price");
    formLayout.addComponent(text);

    formLayout = new FormLayout();
    tabs.addTab(formLayout, "Decription");
    text = new Label(audioFile.getAbout());
    formLayout.addComponent(text);

    formLayout = new FormLayout();
    tabs.addTab(formLayout, "Lyrics");
    text = new Label(audioFile.getLyrics());
    formLayout.addComponent(text);

    return details;
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method builds audio library for current filter.
 * // w  w  w  .j av a 2  s  .  com
 * @param grid
 *            The object to locate the audio covers.
 * @param filter
 *            The filter to extract need music files.
 */
private void buildAudioLibrary(GridLayout grid, String filter) {
    AudioCollection audio = new AudioCollection();

    for (final AudioFile audioFile : audio.getAudioCollection(filter)) {

        CssLayout select = new CssLayout();
        select.addStyleName(Runo.CSSLAYOUT_SELECTABLE);

        CssLayout musicFile = new CssLayout();
        musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW);
        musicFile.addComponent(createImageCover(audioFile.getCover()));
        select.addComponent(musicFile);

        musicFile.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 5789650754220216969L;

            @Override
            public void layoutClick(LayoutClickEvent event) {
                buildInformationPanel(audioFile);
            }
        });

        grid.addComponent(select);
        grid.setComponentAlignment(select, Alignment.MIDDLE_CENTER);
    }

    Label text = new Label("Note: This track are on Crative Common license.");
    text.addStyleName(Runo.LABEL_SMALL);
    text.setWidth("90%");
    grid.addComponent(text);
    grid.setComponentAlignment(text, Alignment.MIDDLE_CENTER);

}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * @param audioFile//from  w w  w  . j  a  v  a 2s.  c  om
 */
protected void buildInformationPanel(AudioFile audioFile) {
    if (bottom == null) {
        this.bottom = new HorizontalLayout();
        bottom.setWidth("100%");
        content.addComponent(bottom);

        VerticalLayout side = new VerticalLayout();
        side.setMargin(true);
        side.setSpacing(true);
        side.setWidth("170px");
        bottom.addComponent(side);

        CssLayout musicFile = new CssLayout();
        musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW);
        musicFile.addComponent(createPlayImage(audioFile, audioFile.getCover()));
        side.addComponent(musicFile);

        side.addComponent(setFavorite());
        side.addComponent(setRate());

        Component details = addDetails(audioFile);
        bottom.addComponent(details);
        bottom.setExpandRatio(details, 1);

    } else {
        bottom.removeAllComponents();
        content.removeComponent(bottom);
        this.bottom = null;
        buildInformationPanel(audioFile);
    }

}

From source file:com.m4gik.views.component.LicenseScreen.java

/**
 * Method builds license layout with texts.
 * //from   w ww  .j a  va 2  s  . c  o  m
 * @return The VerticalLayout with texts.
 * 
 * @see com.m4gik.views.component.ViewScreen#build()
 */
@Override
public Layout build() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setCaption("Welcome");

    Panel welcome = new Panel("License");
    welcome.setSizeFull();
    welcome.addStyleName(Runo.PANEL_LIGHT);
    layout.addComponent(welcome);
    layout.setExpandRatio(welcome, 1);

    CssLayout margin = new CssLayout();
    // margin.setMargin(true);
    margin.setWidth("100%");
    welcome.setContent(margin);

    Label title = new Label("Music player");
    title.addStyleName(Runo.LABEL_H1);
    // margin.addComponent(title);

    HorizontalLayout texts = new HorizontalLayout();
    texts.setSpacing(true);
    texts.setWidth("100%");
    margin.addComponent(texts);

    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);

    layout.addComponent(new Label("<hr />", Label.CONTENT_XHTML));

    return layout;
}

From source file:com.mcparland.john.ComponentCollection.java

License:Apache License

/**
 * @return/*from   w w w . ja  v a  2 s  . co m*/
 */
private Layout createLayout() {
    final CssLayout layout = new CssLayout() {
        public String getCss(Component c) {
            return "display: inline-block;";
        }
    };
    return layout;
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();/*  w  ww.  j a  v a  2  s .c  o m*/
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField("Username", "admin"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField("Password"));
    password.setWidth(15, Unit.EM);
    password.setDescription("Write anything");
    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);

    buttons.addComponent(login = new Button("Login"));
    login.setDisableOnClick(true);
    login.addClickListener(new Button.ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                login();
            } finally {
                login.setEnabled(true);
            }
        }
    });
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    buttons.addComponent(forgotPassword = new Button("Forgot password?"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            showNotification(new Notification("Hint: Try anything"));
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    return loginForm;
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private CssLayout buildLoginInformation() {
    CssLayout loginInformation = new CssLayout();
    loginInformation.setStyleName("login-information");
    Label loginInfoText = new Label("<h1>Login Information</h1>"
            + "Log in as &quot;admin&quot; to have full access. Log in with any other username to have read-only access. For all users, any password is fine",
            ContentMode.HTML);//from   www  . j a v a 2 s .  com
    loginInformation.addComponent(loginInfoText);
    return loginInformation;
}