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);
}
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);
}
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;
}
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;
}
}
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;
}
Aggregations