Splitpanel margin

Hi when using a splitpanel (horizontal orientation), using the “setMargin(true)” function seems not to work. I would expect that components added to the (second) component are not tied to the (vertical) ‘split-bar’, but that there would be a ‘margin’ (aha!) between the split-bar and the component added to the splitpanel…

Am i seeing things wrong?


        SplitPanel forms = new SplitPanel();
        forms.setMargin(true);
        forms.setOrientation(SplitPanel.ORIENTATION_HORIZONTAL);
        filter = new MeasurementFilter();
        BeanItem filterBeanItem = new BeanItem(filter);
        FilterFieldFactory facCriterium = new FilterFieldFactory(this);
        criteriumForm = new Form();
        criteriumForm.setCaption("Criterium");
        criteriumForm.setWriteThrough(false);
        criteriumForm.setInvalidCommitted(false);
        criteriumForm.setFormFieldFactory(facCriterium);
        criteriumForm.setItemDataSource(filterBeanItem);
        forms.setFirstComponent(criteriumForm);
        
        FilterFieldFactory facTime = new FilterFieldFactory(this);
        timeForm = new Form();
        timeForm.setCaption("Time span and resolution");
        timeForm.setWriteThrough(false);
        timeForm.setInvalidCommitted(false);
        timeForm.setFormFieldFactory(facTime);
        timeForm.setItemDataSource(filterBeanItem);
        timeForm.setVisibleItemProperties( orderTime );
        forms.setSecondComponent(timeForm);
        forms.setSplitPosition(30,UNITS_EM);
        forms.setLocked(true);

In the code above the fields (DateFields) within the Form called ‘timeForm’ are really tied to the splitbar in the middle, while i don’t expect that because i have set margins to ‘true’ for the splitpanel…

Any suggestions?

Kind regards,
Jan

Yup, you are.

You’re setting the margins for the SplitPanel, and they work exactly like with other layouts, e.g. VerticalLayout, adding white-space around the component, not inside it. So the white-space extends beyond the splitpanel’s splitter and the component slots.

You should add the margins to the layouts that are contained inside the splitpanel (the two forms), and you’ll get the result you’re after.

Thanks!

my mistake…

Unfortunately, i have another issue with this piece of code.

When doing a manual commit (criteriumForm.commit()) of the criteriumForm, i always get a Validator$EmptyValueException and i don’t see what is causing that because i didn’t implement any validators, except from setting some of the fields to ‘required’.

Below is the code of the FieldFactory that i’m using for the criteriumForm (this factory is also used for the timeForm, but there, only startDate and endDate are made visible properties).

NOTE: the dateStart and dateEnd HAVE a validator that i wrote myself, but these fields are not used in the criteriumForm.


public class FilterFieldFactory extends DefaultFieldFactory {
    Select selProbe;
    Select selProbeInt;
    Select selSubnet;
    Select selCA;
    OptionGroup optionCriterium;
    FormFilter parent;
    DateField dateStart;
    DateField dateEnd;


    public FilterFieldFactory(FormFilter form) {
        this.parent = form;
        dateStart = new DateField("Start date and time");
        dateStart.setResolution(DateField.RESOLUTION_MIN);
        dateStart.setRequired(true);
        dateStart.setImmediate(true);
        dateStart.setWriteThrough(true);
        dateEnd = new DateField("End date and time");
        dateEnd.setResolution(DateField.RESOLUTION_MIN);
        dateEnd.setRequired(true);
        dateEnd.setImmediate(true);
        dateEnd.setWriteThrough(true);
        dateStart.addValidator(new DateValidator(dateEnd, DateType.START));
        dateEnd.addValidator(new DateValidator(dateStart, DateType.END));
    }

    @Override
    public Field createField(Item item, Object propertyId, Component uiContext) {
        // Identify the fields by their Property ID.
        String pid = (String) propertyId;
        if (pid.equals("probe")) {
            selProbe = new Select("Probe");
            List<Probe> probes = lookupProbeManagerBean().getAllProbes();
            Iterator<Probe> it = probes.iterator();
            while(it.hasNext()) {
                Probe probe = it.next();
                selProbe.addItem(probe);
                selProbe.setItemCaption(probe, probe.getName());
            }
            selProbe.addListener(new ValueChangeListener() {
                public void valueChange(ValueChangeEvent event) {
                    // fill probe_interface select with correct data
                    if(selProbeInt != null) {
                        selProbeInt.setEnabled(true);
                        selProbeInt.setRequired(true);
                        Probe probe = (Probe)event.getProperty().getValue();
                        List<ProbeInterface> probeInterfaces = lookupProbeInterfaceManagerBean().getAllProbeInterfacesByProbe(probe);
                        Iterator<ProbeInterface> it = probeInterfaces.iterator();
                        selProbeInt.removeAllItems();
                        while(it.hasNext()) {
                            ProbeInterface probeInterface = it.next();
                            selProbeInt.addItem(probeInterface);
                            selProbeInt.setItemCaption(probeInterface, probeInterface.getIfName() + "(" + probeInterface.getDescription()+ ")");
                        }
                    }
                }
            });
            selProbe.setImmediate(true);
            selProbe.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
            selProbe.setWriteThrough(true);
            return selProbe;
        } else if(pid.equals("probeInterface")) {
            selProbeInt = new Select("Probe interface");
            selProbeInt.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
            selProbeInt.setWriteThrough(true);
            return selProbeInt;
        } else if(pid.equals("netIpsubnet")) {
            selSubnet = new Select("Ip subnet");
            List<NetIpsubnet> netIpsubnets = lookupNetIpsubnetManagerBean().getAllNetIpsubnets();
            Iterator<NetIpsubnet> it = netIpsubnets.iterator();
            while(it.hasNext()) {
                NetIpsubnet netIpsubnet = it.next();
                selSubnet.addItem(netIpsubnet);
                selSubnet.setItemCaption(netIpsubnet, netIpsubnet.getSubnetBaseIp() + "/" + netIpsubnet.getNumNetbits());
            }
            selSubnet.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
            selProbeInt.setWriteThrough(true);
            return selSubnet;
        } else if(pid.equals("netCallagent")) {
            selCA = new Select("Softswitch");
            List<NetCallagent> netCallagents = lookupNetCallagentManagerBean().getAllNetCallagents();
            Iterator<NetCallagent> it = netCallagents.iterator();
            while(it.hasNext()) {
                NetCallagent netCallagent = it.next();
                selCA.addItem(netCallagent);
                selCA.setItemCaption(netCallagent, netCallagent.getDescription());
            }
            selCA.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
            selCA.setWriteThrough(true);
            return selCA;
        } else if(pid.equals("criterium")) {
            optionCriterium = new OptionGroup("Select filter criterium");
            optionCriterium.setMultiSelect(false);
            optionCriterium.addItem(MeasurementFilter.MeasurementFilterCriterium.PROBE);
            optionCriterium.setItemCaption(MeasurementFilter.MeasurementFilterCriterium.PROBE, "Probe");
            optionCriterium.addItem(MeasurementFilter.MeasurementFilterCriterium.IPSUBNET);
            optionCriterium.setItemCaption(MeasurementFilter.MeasurementFilterCriterium.IPSUBNET, "Ip subnet");
            optionCriterium.addItem(MeasurementFilter.MeasurementFilterCriterium.CA);
            optionCriterium.setItemCaption(MeasurementFilter.MeasurementFilterCriterium.CA, "Softswitch");
            optionCriterium.addListener(new ValueChangeListener() {
                public void valueChange(ValueChangeEvent event) {
                    enableSelect((MeasurementFilter.MeasurementFilterCriterium)event.getProperty().getValue());
                }
            });
            optionCriterium.setImmediate(true);
            optionCriterium.setWriteThrough(true);
            return optionCriterium;
        } else if(pid.equals("startDate")) {
            return dateStart;
        } else if(pid.equals("endDate")) {
            return dateEnd;
        }
        return null;
    }

    public void enableSelect(MeasurementFilter.MeasurementFilterCriterium criterium) {
        boolean probeSelected = false;
        boolean subnetSelected = false;
        boolean caSelected = false;
        switch(criterium) {
            case PROBE:
                optionCriterium.setValue(MeasurementFilter.MeasurementFilterCriterium.PROBE);
                probeSelected = true;
                break;
            case IPSUBNET:
                optionCriterium.setValue(MeasurementFilter.MeasurementFilterCriterium.IPSUBNET);
                subnetSelected = true;
                break;
            case CA:
                optionCriterium.setValue(MeasurementFilter.MeasurementFilterCriterium.CA);
                caSelected = true;
                break;
            default:
                probeSelected = true;
        }
        selProbe.setEnabled(probeSelected);
        selProbe.setRequired(probeSelected);
        selSubnet.setEnabled(subnetSelected);
        selSubnet.setRequired(subnetSelected);
        selCA.setEnabled(caSelected);
        selCA.setRequired(caSelected);
        if((probeSelected && selProbe.getValue() == null) || !probeSelected) {
            selProbeInt.setEnabled(false);
            selProbeInt.setRequired(false);
        } else if(probeSelected) {
            selProbeInt.setEnabled(true);
            selProbeInt.setRequired(true);
        }

    }