-/*******************************************************************************\r
- * Copyright (c) 2012 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.browsing.ui.swt;\r
-\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.Simantics;\r
-import org.simantics.browsing.ui.swt.stubs.BrowsingResource;\r
-import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.management.ISessionContext;\r
-import org.simantics.db.request.Read;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ModelledDialog implements ModelledAction {\r
-\r
- public class DialogImpl extends Dialog {\r
-\r
- private final WidgetSupport widgetSupport;\r
- private Runnable finishAction;\r
- \r
- private final String title;\r
-\r
- public DialogImpl(Shell shell, WidgetSupport support, String title) {\r
- super(shell);\r
- this.title = title;\r
- this.widgetSupport = support;\r
- }\r
-\r
- @Override\r
- protected void configureShell(Shell shell) {\r
- super.configureShell(shell);\r
- if (title != null) {\r
- shell.setText(title);\r
- }\r
- }\r
- \r
- @Override\r
- protected boolean isResizable() {\r
- return true;\r
- }\r
- \r
- @Override\r
- protected void okPressed() {\r
- if(finishAction != null) finishAction.run();\r
- super.okPressed();\r
- }\r
- \r
- protected Control createDialogArea(Composite parent) {\r
- \r
- Composite composite = (Composite)super.createDialogArea(parent);\r
- \r
- try {\r
- \r
- ModelledControl modelledControl = Simantics.getSession().syncRequest(new Read<ModelledControl>() {\r
- @Override\r
- public ModelledControl perform(ReadGraph graph) throws DatabaseException {\r
- BrowsingResource BRO = BrowsingResource.getInstance(graph);\r
- Resource controlResource = graph.getPossibleObject(configuration, BRO.Dialog_Control);\r
- return graph.adapt(controlResource, ModelledControl.class);\r
- }\r
- });\r
- \r
- ModelledAction finishAction = Simantics.getSession().syncRequest(new Read<ModelledAction>() {\r
- @Override\r
- public ModelledAction perform(ReadGraph graph) throws DatabaseException {\r
- BrowsingResource BRO = BrowsingResource.getInstance(graph);\r
- Resource actionResource = graph.getPossibleObject(configuration, BRO.Dialog_FinishAction);\r
- return graph.adapt(actionResource, ModelledAction.class);\r
- }\r
- }); \r
- \r
- this.finishAction = finishAction.create(null, null, widgetSupport);\r
- \r
- return modelledControl.create(composite, null, null, widgetSupport);\r
- \r
- } catch (DatabaseException e) {\r
- \r
- e.printStackTrace();\r
- \r
- }\r
- \r
- return composite;\r
- \r
- }\r
- \r
- @Override\r
- protected Control createContents(Composite parent) {\r
- return super.createContents(parent);\r
- }\r
- \r
- }\r
- \r
- \r
- final Resource configuration;\r
- \r
- public ModelledDialog(Resource configuration) {\r
- this.configuration = configuration;\r
- }\r
-\r
- @Override\r
- public Runnable create(IWorkbenchSite site, ISessionContext context, final WidgetSupport support) throws DatabaseException {\r
-\r
- final String title = Simantics.getSession().syncRequest(new Read<String>() {\r
-\r
- @Override\r
- public String perform(ReadGraph graph) throws DatabaseException {\r
- BrowsingResource br = BrowsingResource.getInstance(graph);\r
- return graph.getPossibleRelatedValue(configuration, br.Dialog_Title, Bindings.STRING);\r
- }\r
- \r
- });\r
- \r
- return new Runnable() {\r
-\r
- @Override\r
- public void run() {\r
- \r
- DialogImpl dialog = new DialogImpl(Display.getCurrent().getActiveShell(), support, title);\r
- dialog.create();\r
- support.update();\r
- dialog.open(); \r
- \r
- }\r
- \r
- };\r
- \r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui.swt;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchSite;
+import org.simantics.Simantics;
+import org.simantics.browsing.ui.swt.stubs.BrowsingResource;
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.db.request.Read;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ModelledDialog implements ModelledAction {
+
+ public class DialogImpl extends Dialog {
+
+ private final WidgetSupport widgetSupport;
+ private Runnable finishAction;
+
+ private final String title;
+
+ public DialogImpl(Shell shell, WidgetSupport support, String title) {
+ super(shell);
+ this.title = title;
+ this.widgetSupport = support;
+ }
+
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null) {
+ shell.setText(title);
+ }
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ @Override
+ protected void okPressed() {
+ if(finishAction != null) finishAction.run();
+ super.okPressed();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite = (Composite)super.createDialogArea(parent);
+
+ try {
+
+ ModelledControl modelledControl = Simantics.getSession().syncRequest(new Read<ModelledControl>() {
+ @Override
+ public ModelledControl perform(ReadGraph graph) throws DatabaseException {
+ BrowsingResource BRO = BrowsingResource.getInstance(graph);
+ Resource controlResource = graph.getPossibleObject(configuration, BRO.Dialog_Control);
+ return graph.adapt(controlResource, ModelledControl.class);
+ }
+ });
+
+ ModelledAction finishAction = Simantics.getSession().syncRequest(new Read<ModelledAction>() {
+ @Override
+ public ModelledAction perform(ReadGraph graph) throws DatabaseException {
+ BrowsingResource BRO = BrowsingResource.getInstance(graph);
+ Resource actionResource = graph.getPossibleObject(configuration, BRO.Dialog_FinishAction);
+ return graph.adapt(actionResource, ModelledAction.class);
+ }
+ });
+
+ this.finishAction = finishAction.create(null, null, widgetSupport);
+
+ return modelledControl.create(composite, null, null, widgetSupport);
+
+ } catch (DatabaseException e) {
+
+ e.printStackTrace();
+
+ }
+
+ return composite;
+
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ return super.createContents(parent);
+ }
+
+ }
+
+
+ final Resource configuration;
+
+ public ModelledDialog(Resource configuration) {
+ this.configuration = configuration;
+ }
+
+ @Override
+ public Runnable create(IWorkbenchSite site, ISessionContext context, final WidgetSupport support) throws DatabaseException {
+
+ final String title = Simantics.getSession().syncRequest(new Read<String>() {
+
+ @Override
+ public String perform(ReadGraph graph) throws DatabaseException {
+ BrowsingResource br = BrowsingResource.getInstance(graph);
+ return graph.getPossibleRelatedValue(configuration, br.Dialog_Title, Bindings.STRING);
+ }
+
+ });
+
+ return new Runnable() {
+
+ @Override
+ public void run() {
+
+ DialogImpl dialog = new DialogImpl(Display.getCurrent().getActiveShell(), support, title);
+ dialog.create();
+ support.update();
+ dialog.open();
+
+ }
+
+ };
+
+ }
+
+}