Search in sources :

Example 21 with CheckBox

use of com.vaadin.ui.CheckBox 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 22 with CheckBox

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

the class BasicTest 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);
    Button openPopup = new Button("Open popup", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            leafletMarker.openPopup();
        }
    });
    Button closePopup = new Button("Close popup", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            leafletMarker.closePopup();
        }
    });
    content.addComponentAsFirst(closePopup);
    content.addComponentAsFirst(openPopup);
    Button button = new Button("Delete first component from map");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Component next = leafletMap.iterator().next();
            leafletMap.removeComponent(next);
        }
    });
    content.addComponentAsFirst(button);
    button = new Button("Add polyline to map");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            LPolyline lPolyline = new LPolyline(new Point(60.44, 22.30), new Point(60.456, 22.304));
            lPolyline.addClickListener(listener);
            leafletMap.addComponent(lPolyline);
        }
    });
    content.addComponentAsFirst(button);
}
Also used : Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) ClickEvent(com.vaadin.ui.Button.ClickEvent) Point(org.vaadin.addon.leaflet.shared.Point) Component(com.vaadin.ui.Component) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 23 with CheckBox

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

the class PopupTest method setup.

@Override
protected void setup() {
    super.setup();
    final TextField lat = new TextField("Lat");
    lat.setValue("" + 60.4525);
    content.addComponentAsFirst(lat);
    final TextField lon = new TextField("Lon");
    lon.setValue("" + 22.301);
    content.addComponentAsFirst(lon);
    final TextField html = new TextField("html");
    content.addComponentAsFirst(html);
    final CheckBox closeButton = new CheckBox("Close button");
    content.addComponentAsFirst(closeButton);
    final CheckBox closeonclick = new CheckBox("Close on click");
    content.addComponentAsFirst(closeonclick);
    content.addComponentAsFirst(new Button("Open popup", new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Double lonValue = Double.valueOf(lon.getValue());
            Double latValue = Double.valueOf(lat.getValue());
            LPopup lPopup = new LPopup(latValue, lonValue).setContent(html.getValue());
            lPopup.setCloseButton(closeButton.getValue());
            lPopup.setCloseOnClick(closeonclick.getValue());
            leafletMap.addComponent(lPopup);
            leafletMap.zoomToContent();
            popups.add(lPopup);
            lPopup.addDetachListener(PopupTest.this);
        }
    }));
    content.addComponentAsFirst(new Button("Remove first", new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popups.remove(0).close();
        }
    }));
}
Also used : Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) TextField(com.vaadin.ui.TextField) LPopup(org.vaadin.addon.leaflet.LPopup) ClickListener(com.vaadin.ui.Button.ClickListener) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener)

Example 24 with CheckBox

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

the class JtsPointFieldTest method getTestComponent.

// private Polygon polygon;
@Override
public Component getTestComponent() {
    content.setMargin(true);
    display.setContentMode(ContentMode.PREFORMATTED);
    display.setCaption("Pojo state:");
    display.setValue(pojo.toString());
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    VerticalLayout editorform = new VerticalLayout();
    editorform.setSizeFull();
    editorform.setSpacing(true);
    editorform.setCaption("Edit JTS pojo:");
    TabSheet jtsFields = new TabSheet(point);
    jtsFields.setCaption("JTS fiels:");
    jtsFields.setSizeFull();
    editorform.addComponents(new HorizontalLayout(name, date), jtsFields);
    editorform.setExpandRatio(jtsFields, 1);
    final Binder<JtsPojo> beanBinder = new Binder<>(JtsPojo.class);
    beanBinder.readBean(pojo);
    beanBinder.bindInstanceFields(this);
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.addComponent(new Button("Save", (ClickListener) event -> {
        try {
            beanBinder.writeBean(pojo);
            display.setValue(pojo.toString());
        } catch (ValidationException e) {
            System.err.println("Validation errors:" + Arrays.toString(e.getBeanValidationErrors().toArray()));
        }
    }));
    CheckBox roCheckBox = new CheckBox("Read only", false);
    roCheckBox.addValueChangeListener(event -> beanBinder.setReadOnly(event.getValue()));
    buttonLayout.addComponent(roCheckBox);
    buttonLayout.addComponent(new Button("Assign new empty bean", (ClickListener) event -> {
        pojo = new JtsPojo();
        beanBinder.readBean(pojo);
        display.setValue(pojo.toString());
    }));
    buttonLayout.addComponent(new Button("Assign bean with preset data", (ClickListener) event -> {
        pojo = new JtsPojo();
        pojo.setPoint(JTSUtil.toPoint(new org.vaadin.addon.leaflet.shared.Point(61, 22)));
        beanBinder.readBean(pojo);
        display.setValue(pojo.toString());
    }));
    editorform.addComponent(buttonLayout);
    horizontalLayout.addComponents(editorform, display);
    horizontalLayout.setExpandRatio(editorform, 1);
    horizontalLayout.setExpandRatio(display, 1);
    return horizontalLayout;
}
Also used : ValidationException(com.vaadin.data.ValidationException) Point(org.locationtech.jts.geom.Point) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Binder(com.vaadin.data.Binder) Button(com.vaadin.ui.Button) TabSheet(com.vaadin.ui.TabSheet) CheckBox(com.vaadin.ui.CheckBox) VerticalLayout(com.vaadin.ui.VerticalLayout) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 25 with CheckBox

use of com.vaadin.ui.CheckBox in project Activiti by Activiti.

the class TaskTable method getSteps.

public List<HumanStepDefinition> getSteps() {
    List<HumanStepDefinition> steps = new ArrayList<HumanStepDefinition>();
    for (Object itemId : getItemIds()) {
        Item item = getItem(itemId);
        HumanStepDefinition humanStepDefinition = new HumanStepDefinition();
        String name = (String) item.getItemProperty(ID_NAME).getValue();
        if (name != null && name.length() > 0) {
            humanStepDefinition.setName(name);
        }
        String assignee = (String) ((ComboBox) item.getItemProperty(ID_ASSIGNEE).getValue()).getValue();
        if (assignee != null && assignee.length() > 0) {
            humanStepDefinition.setAssignee(assignee);
        }
        String groups = (String) ((ComboBox) item.getItemProperty("groups").getValue()).getValue();
        List<String> candidateGroups = new ArrayList<String>();
        if (groups != null && groups.length() > 0) {
            for (String group : groups.split(",")) {
                candidateGroups.add(group.trim());
            }
        }
        humanStepDefinition.setCandidateGroups(candidateGroups);
        String description = (String) ((TextField) item.getItemProperty(ID_DESCRIPTION).getValue()).getValue();
        if (description != null && description.length() > 0) {
            humanStepDefinition.setDescription(description);
        }
        humanStepDefinition.setStartsWithPrevious((boolean) ((CheckBox) item.getItemProperty(ID_START_WITH_PREVIOUS).getValue()).booleanValue());
        FormDefinition formDefinition = taskFormModel.getForm(itemId);
        humanStepDefinition.setForm(formDefinition);
        steps.add(humanStepDefinition);
    }
    return steps;
}
Also used : Item(com.vaadin.data.Item) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) CheckBox(com.vaadin.ui.CheckBox) ArrayList(java.util.ArrayList) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition)

Aggregations

CheckBox (com.vaadin.ui.CheckBox)40 Button (com.vaadin.ui.Button)8 ClickListener (com.vaadin.ui.Button.ClickListener)7 HorizontalLayout (com.vaadin.ui.HorizontalLayout)6 ClickEvent (com.vaadin.ui.Button.ClickEvent)5 VerticalLayout (com.vaadin.ui.VerticalLayout)5 SplitCheckBox (au.com.vaadinutils.crud.splitFields.SplitCheckBox)4 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)4 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)4 TextField (com.vaadin.ui.TextField)4 Test (org.junit.Test)4 Item (com.vaadin.data.Item)3 Property (com.vaadin.data.Property)3 ComboBox (com.vaadin.ui.ComboBox)3 Component (com.vaadin.ui.Component)3 Label (com.vaadin.ui.Label)3 ArrayList (java.util.ArrayList)3 Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)2 DataLabels (com.vaadin.addon.charts.model.DataLabels)2