Search in sources :

Example 11 with Component

use of com.vaadin.ui.Component in project v-leaflet by mstahv.

the class FractionalZoom method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    leafletMap.setWidth("300px");
    leafletMap.setHeight("300px");
    leafletMap.setCenter(0, 0);
    leafletMap.setZoomLevel(2.5);
    leafletMap.addLayer(new LOpenStreetMapLayer());
    final Slider slider = new Slider("ZoomLevel");
    slider.setWidth("200px");
    slider.setMin(1);
    slider.setMax(16);
    slider.setResolution(1);
    slider.addValueChangeListener((HasValue.ValueChangeListener<Double>) event -> {
        leafletMap.setZoomLevel(event.getValue());
        Notification.show("Zoom level: " + event.getValue(), Notification.Type.TRAY_NOTIFICATION);
    });
    return new VerticalLayout(leafletMap, slider);
}
Also used : HasValue(com.vaadin.data.HasValue) Notification(com.vaadin.ui.Notification) Slider(com.vaadin.ui.Slider) VerticalLayout(com.vaadin.ui.VerticalLayout) LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) AbstractTest(org.vaadin.addonhelpers.AbstractTest) Component(com.vaadin.ui.Component) LMap(org.vaadin.addon.leaflet.LMap) Slider(com.vaadin.ui.Slider) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) VerticalLayout(com.vaadin.ui.VerticalLayout) HasValue(com.vaadin.data.HasValue)

Example 12 with Component

use of com.vaadin.ui.Component in project v-leaflet by mstahv.

the class LayerGroupTest method setup.

@Override
protected void setup() {
    super.setup();
    addMarkers = new CheckBox("Add markers");
    content.addComponentAsFirst(addMarkers);
    delete = new CheckBox("Delete on click");
    content.addComponentAsFirst(delete);
    showLayerGroupCB = new CheckBox("Show first layer (switch on/off from server side)");
    showLayerGroupCB.setValue(true);
    content.addComponentAsFirst(showLayerGroupCB);
    showLayerGroupCB.addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {

        @Override
        public void valueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue()) {
                if (!leafletMap.hasComponent(llg)) {
                    leafletMap.addComponent(llg);
                }
            } else {
                leafletMap.removeComponent(llg);
            }
        }
    });
    Button button = new Button("Delete first component from map (may also be a layer containing many components)");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Component c : leafletMap) {
                if (!(c instanceof LTileLayer)) {
                    leafletMap.removeComponent(c);
                    break;
                }
            }
        }
    });
    content.addComponentAsFirst(button);
    button = new Button("Delete first component from first layer group (may also be a layer containing many components)");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            LLayerGroup group = null;
            for (Component c : leafletMap) {
                if (c instanceof LLayerGroup) {
                    group = (LLayerGroup) c;
                    break;
                }
            }
            if (group.getComponentCount() > 0) {
                Component next = group.iterator().next();
                group.removeComponent(next);
            } else {
                Notification.show("No component in first component group");
            }
        }
    });
    content.addComponentAsFirst(button);
    button = new Button("Add polyline to first group on map (creates if does not exist)");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            LLayerGroup group = null;
            for (Component c : leafletMap) {
                if (c instanceof LLayerGroup) {
                    group = (LLayerGroup) c;
                    break;
                }
            }
            if (group == null) {
                group = new LLayerGroup();
                leafletMap.addOverlay(group, "new group");
            }
            LPolyline lPolyline = new LPolyline(new Point(60.44, 22.30), new Point(60.456, 22.304));
            lPolyline.addClickListener(listener);
            group.addComponent(lPolyline);
        }
    });
    content.addComponentAsFirst(button);
}
Also used : LTileLayer(org.vaadin.addon.leaflet.LTileLayer) LPolyline(org.vaadin.addon.leaflet.LPolyline) ClickEvent(com.vaadin.ui.Button.ClickEvent) LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) Point(org.vaadin.addon.leaflet.shared.Point) HasValue(com.vaadin.data.HasValue) LLayerGroup(org.vaadin.addon.leaflet.LLayerGroup) Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) Component(com.vaadin.ui.Component) ClickListener(com.vaadin.ui.Button.ClickListener) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener)

Example 13 with Component

use of com.vaadin.ui.Component in project v-leaflet by mstahv.

the class MapInGridDetailsRow method getTestComponent.

@Override
public Component getTestComponent() {
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    final Grid<String> grid = new Grid<>();
    grid.setSizeFull();
    // Define some columns
    grid.addColumn(r -> r).setCaption("Name");
    grid.addColumn(r -> "").setCaption("Born");
    // Add some data rows
    grid.setItems("Nicolaus Copernicus", "Galileo Galilei", "Johannes Kepler");
    grid.setDetailsGenerator((DetailsGenerator<String>) s -> {
        final LMap leafletMap = new LMap();
        final LTileLayer baselayer = new LTileLayer();
        baselayer.setAttributionString("OpenStreetMap");
        baselayer.setUrl("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png");
        leafletMap.addLayer(baselayer);
        leafletMap.setWidth("100%");
        leafletMap.setHeight("100px");
        leafletMap.setZoomLevel(3);
        LMarker leafletMarker = new LMarker(-21.54, 30.76);
        leafletMap.addComponent(leafletMarker);
        leafletMap.zoomToContent();
        return leafletMap;
    });
    grid.addItemClickListener((ItemClickListener<String>) event -> grid.setDetailsVisible(event.getItem(), !grid.isDetailsVisible(event.getItem())));
    vl.addComponent(grid);
    return vl;
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) LMarker(org.vaadin.addon.leaflet.LMarker) LMap(org.vaadin.addon.leaflet.LMap) LTileLayer(org.vaadin.addon.leaflet.LTileLayer) AbstractTest(org.vaadin.addonhelpers.AbstractTest) DetailsGenerator(com.vaadin.ui.components.grid.DetailsGenerator) Component(com.vaadin.ui.Component) Grid(com.vaadin.ui.Grid) ItemClickListener(com.vaadin.ui.components.grid.ItemClickListener) LMap(org.vaadin.addon.leaflet.LMap) LTileLayer(org.vaadin.addon.leaflet.LTileLayer) Grid(com.vaadin.ui.Grid) VerticalLayout(com.vaadin.ui.VerticalLayout) LMarker(org.vaadin.addon.leaflet.LMarker)

Example 14 with Component

use of com.vaadin.ui.Component in project VaadinUtils by rlsutton1.

the class BaseCrudView method selectFirstFieldAndShowTab.

protected void selectFirstFieldAndShowTab() {
    for (Field<?> field : fieldGroup.getFields()) {
        Component childField = field;
        for (int i = 0; i < 10; i++) {
            Component parentField = childField.getParent();
            if (parentField instanceof TabSheet) {
                ((TabSheet) parentField).setSelectedTab(childField);
                break;
            }
            if (parentField == null) {
                // out of luck, didn't find a parent tab
                break;
            }
            childField = parentField;
        }
        field.focus();
        break;
    }
}
Also used : TabSheet(com.vaadin.ui.TabSheet) Component(com.vaadin.ui.Component)

Example 15 with Component

use of com.vaadin.ui.Component in project opennms by OpenNMS.

the class TopologyUI method getTabSheet.

/**
 * Gets a {@link TabSheet} view for all widgets in this manager.
 *
 * @return TabSheet
 */
private Component getTabSheet(WidgetManager manager, WidgetContext widgetContext) {
    // Use an absolute layout for the bottom panel
    AbsoluteLayout bottomLayout = new AbsoluteLayout();
    bottomLayout.setSizeFull();
    tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    for (IViewContribution viewContrib : manager.getWidgets()) {
        // Create a new view instance
        final Component view = viewContrib.getView(m_applicationContext, widgetContext);
        try {
            m_graphContainer.getSelectionManager().addSelectionListener((SelectionListener) view);
        } catch (ClassCastException e) {
        }
        try {
            ((SelectionNotifier) view).addSelectionListener(m_graphContainer.getSelectionManager());
        } catch (ClassCastException e) {
        }
        try {
            m_graphContainer.addChangeListener((GraphContainer.ChangeListener) view);
        } catch (ClassCastException e) {
        }
        // Icon can be null
        tabSheet.addTab(view, viewContrib.getTitle(), viewContrib.getIcon());
        // components to the tab bar
        try {
            Component[] extras = ((HasExtraComponents) view).getExtraComponents();
            if (extras != null && extras.length > 0) {
                // For any extra controls, add a horizontal layout that will float
                // on top of the right side of the tab panel
                final HorizontalLayout extraControls = new HorizontalLayout();
                extraControls.setHeight(32, Unit.PIXELS);
                extraControls.setSpacing(true);
                // Add the extra controls to the layout
                for (Component component : extras) {
                    extraControls.addComponent(component);
                    extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT);
                }
                // Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls
                tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {

                    private static final long serialVersionUID = 6370347645872323830L;

                    @Override
                    public void selectedTabChange(SelectedTabChangeEvent event) {
                        final TabSheet source = (TabSheet) event.getSource();
                        if (source == tabSheet) {
                            // If the first tab was selected...
                            if (source.getSelectedTab() == view) {
                                extraControls.setVisible(true);
                            } else {
                                extraControls.setVisible(false);
                            }
                        }
                    }
                });
                // Place the extra controls on the absolute layout
                bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100");
            }
        } catch (ClassCastException e) {
        }
        view.setSizeFull();
    }
    // Add the tabsheet to the layout
    bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;");
    return bottomLayout;
}
Also used : HasExtraComponents(org.opennms.features.topology.api.HasExtraComponents) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout) GraphContainer(org.opennms.features.topology.api.GraphContainer) SelectionNotifier(org.opennms.features.topology.api.SelectionNotifier) SelectedTabChangeEvent(com.vaadin.ui.TabSheet.SelectedTabChangeEvent) TabSheet(com.vaadin.ui.TabSheet) IViewContribution(org.opennms.features.topology.api.IViewContribution) SelectedTabChangeListener(com.vaadin.ui.TabSheet.SelectedTabChangeListener) LayoutHintComponent(org.opennms.features.topology.app.internal.ui.LayoutHintComponent) BreadcrumbComponent(org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent) Component(com.vaadin.ui.Component)

Aggregations

Component (com.vaadin.ui.Component)96 HorizontalLayout (com.vaadin.ui.HorizontalLayout)11 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)10 VerticalLayout (com.vaadin.ui.VerticalLayout)10 Button (com.vaadin.ui.Button)9 Label (com.vaadin.ui.Label)9 Test (org.junit.Test)8 Window (com.haulmont.cuba.gui.components.Window)6 CssLayout (com.vaadin.ui.CssLayout)6 List (java.util.List)6 WebWindow (com.haulmont.cuba.web.gui.WebWindow)5 Item (com.vaadin.data.Item)5 ClickEvent (com.vaadin.ui.Button.ClickEvent)5 ClickListener (com.vaadin.ui.Button.ClickListener)5 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)4 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)4 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)4 CubaFileUpload (com.haulmont.cuba.web.toolkit.ui.CubaFileUpload)4 com.vaadin.ui (com.vaadin.ui)4 com.haulmont.cuba.web.toolkit.ui (com.haulmont.cuba.web.toolkit.ui)3