1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.browsing.ui.swt;
14 import org.eclipse.jface.wizard.IWizardPage;
15 import org.eclipse.jface.wizard.WizardPage;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18 import org.simantics.Simantics;
19 import org.simantics.browsing.ui.swt.stubs.BrowsingResource;
20 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
21 import org.simantics.databoard.Bindings;
22 import org.simantics.db.ReadGraph;
23 import org.simantics.db.Resource;
24 import org.simantics.db.exception.DatabaseException;
25 import org.simantics.db.management.ISessionContext;
26 import org.simantics.db.request.Read;
28 public class ModelledWizardPageImpl implements ModelledWizardPage {
30 final private Resource configuration;
32 public ModelledWizardPageImpl(Resource configuration) {
33 this.configuration = configuration;
36 class Page extends WizardPage {
38 final private WidgetSupport support;
40 public Page(String title, WidgetSupport support) {
41 super(title, title, null);
42 this.support = support;
46 public void createControl(Composite parent) {
50 ModelledControl modelledControl = Simantics.getSession().syncRequest(new Read<ModelledControl>() {
52 public ModelledControl perform(ReadGraph graph) throws DatabaseException {
53 BrowsingResource BRO = BrowsingResource.getInstance(graph);
54 Resource controlResource = graph.getPossibleObject(configuration, BRO.WizardPage_Control);
55 return graph.adapt(controlResource, ModelledControl.class);
59 Control control = modelledControl.create(parent, null, null, support);
63 } catch (DatabaseException e) {
73 public IWizardPage create(ISessionContext context, WidgetSupport support) throws DatabaseException {
75 String title = Simantics.getSession().syncRequest(new Read<String>() {
77 public String perform(ReadGraph graph) throws DatabaseException {
78 BrowsingResource br = BrowsingResource.getInstance(graph);
79 return graph.getPossibleRelatedValue(configuration, br.WizardPage_Title, Bindings.STRING);
83 return new Page(title, support);