Selection List

Selection List is a SOLoist sample application that shows how persistent selections of a subset of objects linked over an association can be implemented by means of another (subsetting) association and the appropriate configuration of the Element Component.

The intention is to enable selection of a subset of Bank Advisers that are linked to a particular object of Person by checkboxes.

The particular object of Person whose Bank Advisers are shown in the list is fetched via a Service Access Point component. It provides the fetched object to its output pin that is wired to the input pin of the list box.

The list box is configured to render all objects linked to the slot myBankAdvisers, but to edit the (subsetting) slot successfulAdvisers.

This way, instead of using Boolean attributes as flags, a subsetting association is used to store the selection. The selection is inherently persistent.

Live example

UML Model

Business Logic Code

None.

GUI Code

package rs.sol.sampleapps;
 
import rs.sol.sampleapps.listener.ObjectSpaceInit;
import rs.sol.soloist.helpers.init.DefaultContextInit;
import rs.sol.soloist.helpers.init.Initializer;
import rs.sol.soloist.helpers.init.InitializerFailedException;
import rs.sol.soloist.server.builtindomains.builtindatatypes.Text;
import rs.sol.soloist.server.builtindomains.common.ClassifierInstanceDescriptor;
import rs.sol.soloist.server.builtindomains.common.ElementDescriptor;
import rs.sol.soloist.server.guiconfiguration.components.GUIApplicationComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUILabelComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent;
import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIEdit;
import rs.sol.soloist.server.guiconfiguration.layout.TableLayoutData;
import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindSingleInstanceSAPComponent;
import rs.sol.soloist.server.guiconfiguration.style.GUIContext;
import rs.sol.soloist.server.guiconfiguration.style.GUINavigatorFeature;
import rs.sol.soloist.server.guiconfiguration.style.GUIObjectSetting;
import rs.sol.soloist.server.guiconfiguration.style.GUIPictureFeature;
import rs.sol.soloist.server.guiconfiguration.style.GUITextFeature;
import rs.sol.soloist.server.server.SoloistServiceServlet;
 
public enum AssociationEditor implements Initializer{
 
	INSTANCE;
 
	@Override
	public void init() throws InitializerFailedException 
	{
		GUIApplicationComponent page = new GUIApplicationComponent();
		page.setName("AssociationEditor"); 
		SoloistServiceServlet.registerApplication(page);
		page.setContext(createContextAndStyles());
 
		GUIPanelComponent root = GUIPanelComponent.createFlow(page);
 
		GUILabelComponent title = GUILabelComponent.create(root, "Association Editor");
		title.setStyle("titleStyle");
 
		GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root);
		topPanel.setStyle("topPanel");
		GUIPanelComponent table = GUIPanelComponent.createTable(topPanel); // panel with table layout
 
		GUIFindSingleInstanceSAPComponent findJanneRoe = GUIFindSingleInstanceSAPComponent.create(table, 
				Person.FQ_TYPE_NAME, 
				Person.FQPropertyNames.desc, 
				(ClassifierInstanceDescriptor)ElementDescriptor.create(Text.fromString(ObjectSpaceInit.JANNE_ROE_IDENTIFIER)));
 
		GUIEdit editList = GUIEdit.createList(table, Person.PROPERTIES.successfulAdvisers, Person.PROPERTIES.myBankAdvisers);
		editList.setLayoutData(TableLayoutData.create(0, 0));
		GUIComponentBinding.create(findJanneRoe.opValue(), editList.ipElement());
		GUIComponentBinding.create(findJanneRoe.opValue(), editList.ipSlotValueElement());
 
		editList.setSize("250px", "200px");
		editList.setStyle("listEditor");
	}
 
	private GUIContext createContextAndStyles() {
		GUIContext context = new GUIContext();
		DefaultContextInit.getRoot().addContext(context);
 
		GUIObjectSetting person = GUIObjectSetting.create(context, Person.CLASSIFIER);
		GUITextFeature.createName(person, Person.PROPERTIES.name);
		GUITextFeature.createFixedSeparator(person, ":");
		GUITextFeature.createDescription(person, Person.PROPERTIES.age);
		GUIPictureFeature.createSmallIcon(person, "images/icons/person.png");
		GUINavigatorFeature.createSubnodes(person, Person.FQPropertyNames.accounts);
 
		return context;
	}
}
Print/export