1 package org.simantics.views.swt.client.impl;
3 import org.eclipse.jface.layout.GridDataFactory;
4 import org.eclipse.jface.layout.GridLayoutFactory;
5 import org.eclipse.swt.browser.Browser;
6 import org.eclipse.swt.browser.LocationEvent;
7 import org.eclipse.swt.browser.LocationListener;
8 import org.eclipse.swt.widgets.Composite;
9 import org.simantics.db.layer0.variable.Variable;
10 import org.simantics.scl.runtime.function.Function1;
11 import org.simantics.utils.datastructures.map.Tuple;
12 import org.simantics.views.swt.client.base.SingleSWTViewNode;
14 public class SWTBrowser extends SingleSWTViewNode<Browser> {
16 private static final long serialVersionUID = -2704760050046054447L;
18 public String document;
19 public Variable variable;
20 public Function1<Object, Boolean> locationChanging;
22 private Tuple lastAppliedParametrization;
27 lastAppliedParametrization = null;
31 public void createControls(Composite parent) {
33 GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
34 GridLayoutFactory.fillDefaults().applyTo(parent);
36 control = new Browser(parent, style);
37 GridDataFactory.fillDefaults().grab(true, true).applyTo(control);
39 control.addLocationListener(new LocationListener() {
41 public void changing(LocationEvent event) {
42 Function1<Object, Boolean> lc = locationChanging;
47 public void changed(LocationEvent event) {
55 public void synchronizeVariable(Variable variable) {
59 public void synchronizeDocument(final String document) {
61 if(document != null) {
63 final Variable variable = SWTBrowser.this.variable;
64 if (variable == null) {
68 Tuple checkParam = new Tuple(document, variable);
69 if (checkParam.equals(lastAppliedParametrization))
72 lastAppliedParametrization = checkParam;
74 final Browser control = this.control;
77 control.setText(document);