Search in sources :

Example 1 with Registration

use of com.vaadin.shared.Registration in project cuba by cuba-platform.

the class AceEditor method addBlurListener.

@Override
public Registration addBlurListener(BlurListener listener) {
    Registration registration = addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod);
    getState().listenToFocusChanges = true;
    return registration;
}
Also used : Registration(com.vaadin.shared.Registration)

Example 2 with Registration

use of com.vaadin.shared.Registration in project cuba by cuba-platform.

the class AceEditor method addFocusListener.

@Override
public Registration addFocusListener(FocusListener listener) {
    Registration registration = addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod);
    getState().listenToFocusChanges = true;
    return registration;
}
Also used : Registration(com.vaadin.shared.Registration)

Example 3 with Registration

use of com.vaadin.shared.Registration in project v-leaflet by mstahv.

the class DynamicChanges method setup.

@Override
protected void setup() {
    super.setup();
    HorizontalLayout tools = new HorizontalLayout();
    Button button = new Button("Random new point");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            ArrayList<Point> arrayList = new ArrayList<Point>(Arrays.asList(polyline.getPoints()));
            arrayList.add(new Point(60 + r.nextInt(10), 20 + r.nextInt(10)));
            polyline.setPoints(arrayList.toArray(new Point[0]));
        }
    });
    tools.addComponent(button);
    button = new Button("Zoom to polyline");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            leafletMap.zoomToExtent(new Bounds(polyline.getPoints()));
        }
    });
    tools.addComponent(button);
    button = new Button("Center to last point ");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Point[] points = polyline.getPoints();
            leafletMap.setCenter(points[points.length - 1]);
        }
    });
    tools.addComponent(button);
    button = new Button("Zoom to last point");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Point[] points = polyline.getPoints();
            leafletMap.zoomToExtent(new Bounds(points[points.length - 1]));
        }
    });
    tools.addComponent(button);
    button = new Button("Show current zoom");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Double zoomLevel = leafletMap.getZoomLevel();
            Notification.show("Zoomlevel is " + zoomLevel);
        }
    });
    tools.addComponent(button);
    button = new Button("Show current center point");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("Center point is " + leafletMap.getCenter());
        }
    });
    tools.addComponent(button);
    button = new Button("Show current size of the map");
    button.addClickListener((e) -> leafletMap.getSize(point -> Notification.show("Map size: " + point)));
    tools.addComponent(button);
    final LeafletMoveEndListener moveEndListener = new LeafletMoveEndListener() {

        @Override
        public void onMoveEnd(LeafletMoveEndEvent event) {
            Notification.show("Moved or zoomed", Type.TRAY_NOTIFICATION);
        }
    };
    final CheckBox checkBox = new CheckBox("Toggle move listener");
    checkBox.addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {

        @Override
        public void valueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue()) {
                registration = leafletMap.addMoveEndListener(moveEndListener);
            } else if (registration != null) {
                registration.remove();
            }
        }
    });
    tools.addComponent(checkBox);
    content.addComponentAsFirst(tools);
}
Also used : Arrays(java.util.Arrays) ClickListener(com.vaadin.ui.Button.ClickListener) ClickEvent(com.vaadin.ui.Button.ClickEvent) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener) Point(org.vaadin.addon.leaflet.shared.Point) Random(java.util.Random) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) LeafletMoveEndListener(org.vaadin.addon.leaflet.LeafletMoveEndListener) LeafletMoveEndEvent(org.vaadin.addon.leaflet.LeafletMoveEndEvent) ArrayList(java.util.ArrayList) LPolyline(org.vaadin.addon.leaflet.LPolyline) Button(com.vaadin.ui.Button) HasValue(com.vaadin.data.HasValue) Type(com.vaadin.ui.Notification.Type) LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) CheckBox(com.vaadin.ui.CheckBox) Registration(com.vaadin.shared.Registration) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Notification(com.vaadin.ui.Notification) LMap(org.vaadin.addon.leaflet.LMap) Bounds(org.vaadin.addon.leaflet.shared.Bounds) ValueChangeEvent(com.vaadin.data.HasValue.ValueChangeEvent) AbstractTest(org.vaadin.addonhelpers.AbstractTest) Component(com.vaadin.ui.Component) ClickEvent(com.vaadin.ui.Button.ClickEvent) LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) Bounds(org.vaadin.addon.leaflet.shared.Bounds) ArrayList(java.util.ArrayList) LeafletMoveEndEvent(org.vaadin.addon.leaflet.LeafletMoveEndEvent) Point(org.vaadin.addon.leaflet.shared.Point) HorizontalLayout(com.vaadin.ui.HorizontalLayout) HasValue(com.vaadin.data.HasValue) LeafletMoveEndListener(org.vaadin.addon.leaflet.LeafletMoveEndListener) Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) ClickListener(com.vaadin.ui.Button.ClickListener) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener)

Aggregations

Registration (com.vaadin.shared.Registration)3 HasValue (com.vaadin.data.HasValue)1 ValueChangeEvent (com.vaadin.data.HasValue.ValueChangeEvent)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 CheckBox (com.vaadin.ui.CheckBox)1 Component (com.vaadin.ui.Component)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Notification (com.vaadin.ui.Notification)1 Type (com.vaadin.ui.Notification.Type)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Random (java.util.Random)1 LMap (org.vaadin.addon.leaflet.LMap)1 LOpenStreetMapLayer (org.vaadin.addon.leaflet.LOpenStreetMapLayer)1 LPolyline (org.vaadin.addon.leaflet.LPolyline)1 LeafletClickEvent (org.vaadin.addon.leaflet.LeafletClickEvent)1 LeafletClickListener (org.vaadin.addon.leaflet.LeafletClickListener)1 LeafletMoveEndEvent (org.vaadin.addon.leaflet.LeafletMoveEndEvent)1