1 package org.simantics.views.swt;
3 import org.eclipse.jface.wizard.IWizardPage;
4 import org.eclipse.jface.wizard.WizardPage;
5 import org.eclipse.swt.widgets.Composite;
6 import org.simantics.Simantics;
7 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
8 import org.simantics.databoard.Bindings;
9 import org.simantics.db.ReadGraph;
10 import org.simantics.db.Resource;
11 import org.simantics.db.common.request.UniqueRead;
12 import org.simantics.db.common.utils.Logger;
13 import org.simantics.db.exception.DatabaseException;
14 import org.simantics.db.management.ISessionContext;
15 import org.simantics.db.request.Read;
16 import org.simantics.views.ontology.ViewsResources;
17 import org.simantics.views.swt.client.base.SWTRoot;
19 public class ModelledWizardPageImpl implements ModelledWizardPage {
21 final private Resource configuration;
24 public ModelledWizardPageImpl(Resource configuration) {
25 this.configuration = configuration;
29 public SWTRoot getRoot() {
33 class Page extends WizardPage {
35 final private Resource runtime;
37 public Page(String title, Resource runtime) {
38 super(title, title, null);
39 this.runtime = runtime;
43 public void createControl(Composite parent) {
47 Resource control = Simantics.getSession().sync(new UniqueRead<Resource>() {
49 public Resource perform(ReadGraph graph) throws DatabaseException {
50 ViewsResources VIEW = ViewsResources.getInstance(graph);
51 return graph.getPossibleObject(configuration, VIEW.Wizard_Page_Control);
55 SWTViewLoaderProcess process = new SWTViewLoaderProcess(null, null);
56 root = process.load(control, runtime);
57 root.createControls(parent);
59 setControl(root.getSingleChild());
61 } catch (DatabaseException e) {
64 Logger.defaultLogError(e);
72 public IWizardPage create(ISessionContext context, WidgetSupport support, Resource runtime) throws DatabaseException {
74 String title = Simantics.getSession().syncRequest(new Read<String>() {
76 public String perform(ReadGraph graph) throws DatabaseException {
77 ViewsResources VIEW = ViewsResources.getInstance(graph);
78 return graph.getPossibleRelatedValue(configuration, VIEW.Wizard_Page_Title, Bindings.STRING);
82 return new Page(title, runtime);