This is an old revision of the document!


Wizard Sample

This sample demonstrates simple wizard.

Live example

UML Model

None.

Business Logic Code

None.

GUI Code

package rs.sol.sampleapps.wizard;
 
import rs.sol.soloist.helpers.init.Initializer;
import rs.sol.soloist.helpers.init.InitializerFailedException;
import rs.sol.soloist.server.builtindomains.builtindatatypes.Boolean;
import rs.sol.soloist.server.builtindomains.builtindatatypes.Text;
import rs.sol.soloist.server.guiconfiguration.components.GUIApplicationComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUIButtonComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUIDialogComponent;
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.layout.FlowLayout;
import rs.sol.soloist.server.server.SoloistServiceServlet;
 
public enum WizardSample implements Initializer {
 
	INSTANCE;
 
	@Override
	public void init() throws InitializerFailedException {
		GUIApplicationComponent application = new GUIApplicationComponent();
		application.name.set(Text.fromString("WizardSample"));
		SoloistServiceServlet.registerApplication(application);
 
		GUIPanelComponent root = GUIPanelComponent.createFlow(application);
 
		GUILabelComponent title = GUILabelComponent.create(root, "Wizard");
		title.styleName.set(Text.fromString("titleStyle"));
 
		GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root);
		topPanel.styleName.set(Text.fromString("topPanel"));
 
		GUIPanelComponent blackScreen = GUIPanelComponent.createFlow(root); // background panel which is shown when wizard dialog pops up, aids visual effect
		blackScreen.styleName.set(Text.fromString("blackScreen"));
 
		GUIDialogComponent dialog = new GUIDialogComponent();
		dialog.modal.set(Boolean.TRUE);
		dialog.application.set(root.getApplication());
		dialog.caption.set(Text.fromString("SOLoist Wizard"));
 
		GUIPanelComponent dialogPanel = GUIPanelComponent.createFlow(dialog);
		dialogPanel.styleName.set(Text.fromString("dialogPanel"));
 
		Wizard wizard = new Wizard(dialogPanel, dialog, blackScreen);
 
		// panels which will be shown as steps in wizard
		GUIPanelComponent p1 = new GUIPanelComponent();
		p1.layout.set(new FlowLayout());
		GUIPanelComponent p2 = new GUIPanelComponent();
		p2.layout.set(new FlowLayout());
		GUIPanelComponent p3 = new GUIPanelComponent();
		p3.layout.set(new FlowLayout());
 
		// content can arbitrarily complex
		GUILabelComponent.create(p1, "1").styleName.set(Text.fromString("largeText"));
		GUILabelComponent.create(p2, "2").styleName.set(Text.fromString("largeText"));
		GUILabelComponent.create(p3, "3").styleName.set(Text.fromString("largeText"));
 
		// add pages to wizard in order
		wizard.addPage(p1);
		wizard.addPage(p2);
		wizard.addPage(p3);
 
		// generate wizard GUI
		wizard.generate();
 
		GUIButtonComponent cmdStart = GUIButtonComponent.create(topPanel, "Start wizard");
 
		GUIComponentBinding.create(cmdStart.click, wizard.getBufferDarkenBackground().send);
		GUIComponentBinding.create(cmdStart.click, wizard.getFirstChild().showInParent);
		GUIComponentBinding.create(cmdStart.click, wizard.getFirstButtonChild().showInParent);
 
		GUIComponentBinding.create(cmdStart.click, dialog.show);
		GUIComponentBinding.create(cmdStart.result, dialogPanel.input);
 
		GUIComponentBinding.create(cmdStart.result, p1.input);
		GUIComponentBinding.create(cmdStart.result, p2.input);
		GUIComponentBinding.create(cmdStart.result, p3.input);
    }
 
}
package rs.sol.sampleapps.wizard;
 
import java.util.ArrayList;
import java.util.List;
 
import rs.sol.soloist.server.builtindomains.builtindatatypes.Boolean;
import rs.sol.soloist.server.builtindomains.builtindatatypes.Text;
import rs.sol.soloist.server.guiconfiguration.components.GUIButtonComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUIDeckComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUIDialogComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent;
import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding;
import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIBufferComponent;
import rs.sol.soloist.server.uml.concepts.runtime.ISlot;
 
public class Wizard {
 
	private List<GUIPanelComponent> pages = new ArrayList<GUIPanelComponent>();
	private GUIDeckComponent mainDeck;
	private GUIDeckComponent buttonDeck;
	private GUIDialogComponent dialog;
	private GUIBufferComponent bufferSet;
	private GUIBufferComponent bufferRemove;
	private GUIPanelComponent blackScreen;
	private ISlot<Text> firstNextEvent;
	private ISlot<Text> lastNextEvent;
	private ISlot<Text> finishEvent;
	private GUIPanelComponent rootPanel;
 
	public Wizard(GUIPanelComponent rootPanel, GUIDialogComponent dialog, GUIPanelComponent blackScreen) {
		this.rootPanel = rootPanel;
		this.dialog = dialog;
		this.blackScreen = blackScreen;
	}
 
	public void addPage(GUIPanelComponent page) {
		pages.add(page);
	}
 
	public void generate() {
 
		bufferSet = GUIBufferComponent.create(rootPanel, false, Text.fromString("darkenBackground"));
		bufferRemove = GUIBufferComponent.create(rootPanel, false, Text.fromString("darkenBackground"));
 
		GUIComponentBinding.create(bufferSet.output, blackScreen.addStyle);
		GUIComponentBinding.create(bufferRemove.output, blackScreen.removeStyle);
 
		GUIPanelComponent mainPanel = GUIPanelComponent.createFlow(rootPanel);
		GUIPanelComponent btnPanel = GUIPanelComponent.createFlow(rootPanel);
 
		mainDeck = GUIDeckComponent.create(mainPanel);
		mainPanel.styleName.set(Text.fromString("wizardMain"));
 
		buttonDeck = GUIDeckComponent.create(btnPanel);
		btnPanel.styleName.set(Text.fromString("wizardButtons"));
 
		for (int i = 0; i < pages.size(); i++) {
			mainDeck.children.add(pages.get(i));
			GUIPanelComponent.createFlow(buttonDeck);
		}
 
		for (int i = 0; i < pages.size(); i++) {
 
			GUIPanelComponent buttonPanel = (GUIPanelComponent) buttonDeck.children.at(i);
 
			GUIButtonComponent btnCancel = GUIButtonComponent.create(buttonPanel, "Cancel");
			btnCancel.styleName.set(Text.fromString("cancelButton"));
			btnCancel.confirmationRequired.set(Boolean.TRUE);
			btnCancel.confirmationMessage.set(Text.fromString("Cancel?"));
 
			GUIComponentBinding.create(btnCancel.click, dialog.hide);
			GUIComponentBinding.create(btnCancel.click, bufferRemove.send);
 
			if (i != 0) {
				GUIButtonComponent btnPrev = GUIButtonComponent.create(buttonPanel, "< Back");
				GUIComponentBinding.create(btnPrev.click, mainDeck.children.at(i - 1).show);
				GUIComponentBinding.create(btnPrev.click, buttonDeck.children.at(i - 1).show);
				btnPrev.styleName.set(Text.fromString("previousButton"));
			}
 
			if (i == pages.size() - 1) {
				GUIButtonComponent btnFinish = GUIButtonComponent.create(buttonPanel, "Finish");
				btnFinish.styleName.set(Text.fromString("finishButton"));
				btnFinish.confirmationMessage.set(Text.fromString("Finish?"));
				btnFinish.confirmationRequired.set(Boolean.TRUE);
				GUIComponentBinding.create(btnFinish.click, dialog.hide);
				GUIComponentBinding.create(btnFinish.click, bufferRemove.send);
				finishEvent = btnFinish.click;
			} else {
				GUIButtonComponent btnNext = GUIButtonComponent.create(buttonPanel, "Next >");
				btnNext.styleName.set(Text.fromString("nextButton"));
				GUIComponentBinding.create(btnNext.click, mainDeck.children.at(i + 1).show);
				GUIComponentBinding.create(btnNext.click, buttonDeck.children.at(i + 1).show);
				if (i == 0) 
					firstNextEvent = btnNext.click;
				if (i == pages.size() - 2)
					lastNextEvent = btnNext.click;
			}
 
		}
	}
 
	public GUIBufferComponent getBufferDarkenBackground() {
		return bufferSet;
	}
 
	public GUIPanelComponent getFirstChild() {
		return (GUIPanelComponent) mainDeck.children.at(0);
	}
 
	public GUIPanelComponent getFirstButtonChild() {
		return (GUIPanelComponent) buttonDeck.children.at(0);
	}
 
	public ISlot<Text> getFirstNextEvent() {
		return firstNextEvent;
	}
 
	public ISlot<Text> getLastNextEvent() {
		return lastNextEvent;
	}
 
	public ISlot<Text> getFinishEvent() {
		return finishEvent;
	}
 
}
Print/export