Adding setting tab

The following example shows some possibilities about the SDK configuration framework.

XML definition

In the following definition, three scopes are defined: server, project, process-catalog.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <tab name="sample-server" scope="server">
        <class qualifiedName="com.axemble.vdoc.configuration.TestDataTestServerConfigurationSDKEditor" />
        <section name="settings" label="service.library.createFolder.section.settings.label">
            <fields>
            <field name="sampleServerBoolean" label="sample-server.sampleServerBoolean.label" description="" ctrl="checkbox" boolean-value="true" throw-events="true"/>
                <field name="sampleServerText" label="sampleServerText" description="" ctrl="text" />
                <field name="sampleServerList" label="sampleServerList" description="" ctrl="textselectlist" mode="write" throw-events="true"
                    string-value="sampleServerListOptionOne" allowreset="never">
                    <options>
                        <option key="sampleServerListOptionOne" labelid="sampleServerListOptionOne" />
                        <option key="sampleServerListOptionTwo" labelid="sampleServerListOptionTwo" />
                    </options>
                </field>
                <field name="sampleServerDate" label="sampleServerDate" description="" ctrl="date" />
                <field name="sampleServerUser" label="sampleServerUser" description="" ctrl="user" />
                
            </fields>
        </section>
        <custom>
            <customElement1 attribute1="attributeValue1"/>
        </custom>
    </tab>
    <tab name="sample-catalog" scope="process-catalog">
        <class qualifiedName="com.axemble.vdoc.configuration.TestDataTestCatalogConfigurationSDKEditor" />
        <section name="settings" label="service.library.createFolder.section.settings.label">
            <fields>
                <field name="sampleCatalogText" ctrl="text" label="sampleCatalogText"/>
                <field name="sampleCatalogBoolean" label="sample-server.sampleServerBoolean.label" description="" ctrl="checkbox" boolean-value="true" throw-events="true"/>
            </fields>
        </section>
        <section name="advanced">
            <fields>
                <field name="sampleCatalogDate" ctrl="date" />
                <field name="sampleCatalogUser" ctrl="user" />
            </fields>
        </section>
    </tab>
</configuration>

BaseConfigurationEditor implementation

TestDataTestServerConfigurationSDKEditor implementation

The onAfterLoad() method is implemented to initialize and hide some fields.

package com.axemble.vdoc.configuration;

import java.io.IOException;

import com.axemble.commons.xml.DomWriter;
import com.axemble.vdoc.sdk.configuration.base.BaseConfigurationEditor;
import com.axemble.vdp.utils.StringUtils;


public class TestDataTestServerConfigurationSDKEditor extends BaseConfigurationEditor
{
    private static final long serialVersionUID = 1L;

    public TestDataTestServerConfigurationSDKEditor()
    {

    }

    @Override
    public boolean onAfterLoad()
    {

        // hide fields (getResourceController())
        // if sampleServerBoolean is check then sampleServerDate and sampleServerUser field will be hidden.
        boolean advanced = ( getResource().getValue( "sampleServerBoolean" ) == null ) ? false : (boolean)getResource().getValue( "sampleServerBoolean" );
        getConfigurationSection().getEntryByName( "sampleServerDate" ).setHidden( advanced );
        getResourceController().getDefaultWidget( "sampleServerUser" ).setHidden( advanced );

        // Set field to an initial value (getResource())
        if ( StringUtils.isEmpty( (String)getResource().getValue( "sampleServerText" ) ) )
        {
            getDocument().getAbstractFieldByName( "sampleServerText" ).setValue( "Initial value" );
        }

        return super.onAfterLoad();
    }
}

TestDataTestCatalogConfigurationSDKEditor implementation

package com.axemble.vdoc.configuration;

import java.io.IOException;

import com.axemble.commons.xml.DomWriter;
import com.axemble.vdoc.sdk.configuration.base.BaseConfigurationEditor;
import com.axemble.vdp.ui.framework.components.events.ChangeEvent;
import com.axemble.vdp.ui.framework.components.listeners.ChangeListener;
import com.axemble.vdp.ui.framework.document.AbstractField;
import com.axemble.vdp.utils.StringUtils;

public class TestDataTestCatalogConfigurationSDKEditor extends BaseConfigurationEditor
{
    private static final long serialVersionUID = 1L;

    public TestDataTestCatalogConfigurationSDKEditor()
    {

    }

    @Override
    public boolean onAfterLoad()
    {

        //initialize default value (getResource())
        if ( StringUtils.isEmpty( (String)getResource().getValue( "sampleCatalogText" ) ) )
        {
            getDocument().getAbstractFieldByName( "sampleCatalogText" ).setValue( "Bla bla" );
        }

        AbstractField booleanField = getDocument().getAbstractFieldByName( "sampleCatalogBoolean" );
        hideAdvancedSection( ( booleanField.getValue() != null ) ? (boolean)booleanField.getValue() : false );

        booleanField.addChangeListener( new ChangeListener()
        {
            private static final long serialVersionUID = -2491203551267196556L;

            @Override
            public void onChange( ChangeEvent event )
            {
                boolean hide = (boolean)( (AbstractField)event.getSource() ).getValue();
                hideAdvancedSection( hide );
            }
        } );

        return super.onAfterLoad();
    }
    void hideAdvancedSection( boolean hide )
    {
        if ( getConfigurationSection().getSubSectionByName( "advanced" ) != null )
            getConfigurationSection().getSubSectionByName( "advanced" ).setHidden( hide );
    }

}