| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * 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: |
| <<<<<<< HEAD |
| * Pierre Allard - initial API and implementation |
| * Regent L'Archeveque |
| * |
| ======= |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| >>>>>>> refs/heads/eclipse_pa |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.math.ui.composites; |
| |
| import org.eclipse.apogy.common.databinding.converters.DoubleToStringConverter; |
| import org.eclipse.apogy.common.databinding.converters.StringToDoubleConverter; |
| import org.eclipse.apogy.common.math.ApogyCommonMathPackage.Literals; |
| import org.eclipse.core.databinding.DataBindingContext; |
| import org.eclipse.core.databinding.UpdateValueStrategy; |
| import org.eclipse.core.databinding.observable.value.IObservableValue; |
| import org.eclipse.emf.databinding.EMFProperties; |
| import org.eclipse.emf.databinding.edit.EMFEditProperties; |
| import org.eclipse.emf.edit.domain.EditingDomain; |
| import org.eclipse.jface.databinding.swt.WidgetProperties; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.events.DisposeEvent; |
| import org.eclipse.swt.events.DisposeListener; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Text; |
| |
| public class Matrix4x4Composite extends Composite { |
| private DataBindingContext m_bindingContext; |
| private org.eclipse.apogy.common.math.Matrix4x4 matrix4x4; |
| private final Text m00Text; |
| private final Text m01Text; |
| private final Text m02Text; |
| private final Text m03Text; |
| private final Text m10Text; |
| private final Text m11Text; |
| private final Text m12Text; |
| private final Text m13Text; |
| private final Text m20Text; |
| private final Text m21Text; |
| private final Text m22Text; |
| private final Text m23Text; |
| private final Text m30Text; |
| private final Text m31Text; |
| private final Text m32Text; |
| private final Text m33Text; |
| private EditingDomain editingDomain = null; |
| |
| public Matrix4x4Composite(Composite parent, int style, EditingDomain editingDomain) { |
| this(parent, style); |
| this.editingDomain = editingDomain; |
| } |
| |
| public Matrix4x4Composite(Composite parent, int style) { |
| super(parent, style); |
| GridLayout gridLayout = new GridLayout(4, true); |
| setLayout(gridLayout); |
| |
| this.m00Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m00Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m01Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m01Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m02Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m02Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m03Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m03Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m10Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m10Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m11Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m11Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m12Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m12Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m13Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m13Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m20Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m20Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m21Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m21Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m22Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m22Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m23Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m23Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m30Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m30Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m31Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m31Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m32Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m32Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| this.m33Text = new Text(this, SWT.BORDER | SWT.SINGLE); |
| this.m33Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| |
| if (this.matrix4x4 != null) { |
| this.m_bindingContext = initCustomDataBindings(); |
| } |
| |
| // Dispose |
| addDisposeListener(new DisposeListener() { |
| @Override |
| public void widgetDisposed(DisposeEvent e) { |
| if (Matrix4x4Composite.this.m_bindingContext != null) |
| Matrix4x4Composite.this.m_bindingContext.dispose(); |
| } |
| }); |
| } |
| |
| @Override |
| protected void checkSubclass() { |
| // Disable the check that prevents subclassing of SWT components |
| } |
| |
| public org.eclipse.apogy.common.math.Matrix4x4 getMatrix4x4() { |
| return this.matrix4x4; |
| } |
| |
| public void setMatrix4x4(org.eclipse.apogy.common.math.Matrix4x4 newMatrix4x4) { |
| setMatrix4x4(newMatrix4x4, true); |
| } |
| |
| public void setMatrix4x4(org.eclipse.apogy.common.math.Matrix4x4 newMatrix4x4, boolean update) { |
| this.matrix4x4 = newMatrix4x4; |
| |
| if (update) { |
| if (this.m_bindingContext != null) { |
| this.m_bindingContext.dispose(); |
| this.m_bindingContext = null; |
| } |
| |
| if (this.matrix4x4 != null) { |
| this.m_bindingContext = initCustomDataBindings(); |
| } |
| } |
| } |
| |
| @SuppressWarnings({ "rawtypes", "unchecked" }) |
| protected DataBindingContext initCustomDataBindings() { |
| DataBindingContext bindingContext = new DataBindingContext(); |
| |
| // |
| IObservableValue m00ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m00Text); |
| IObservableValue m00ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M00).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M00).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy = new UpdateValueStrategy(); |
| strategy.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_1 = new UpdateValueStrategy(); |
| strategy_1.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m00ObserveWidget, m00ObserveValue, strategy, strategy_1); |
| |
| // |
| IObservableValue m01ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m01Text); |
| IObservableValue m01ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M01).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M01).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_2 = new UpdateValueStrategy(); |
| strategy_2.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_3 = new UpdateValueStrategy(); |
| strategy_3.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m01ObserveWidget, m01ObserveValue, strategy_2, strategy_3); |
| |
| // |
| IObservableValue m02ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m02Text); |
| IObservableValue m02ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M02).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M02).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_4 = new UpdateValueStrategy(); |
| strategy_4.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_5 = new UpdateValueStrategy(); |
| strategy_5.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m02ObserveWidget, m02ObserveValue, strategy_4, strategy_5); |
| |
| // |
| IObservableValue m03ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m03Text); |
| IObservableValue m03ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M03).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M03).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_6 = new UpdateValueStrategy(); |
| strategy_6.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_7 = new UpdateValueStrategy(); |
| strategy_7.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m03ObserveWidget, m03ObserveValue, strategy_6, strategy_7); |
| |
| // |
| IObservableValue m10ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m10Text); |
| IObservableValue m10ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M10).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M10).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_8 = new UpdateValueStrategy(); |
| strategy_8.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_9 = new UpdateValueStrategy(); |
| strategy_9.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m10ObserveWidget, m10ObserveValue, strategy_8, strategy_9); |
| |
| // |
| IObservableValue m11ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m11Text); |
| IObservableValue m11ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M11).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M11).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_10 = new UpdateValueStrategy(); |
| strategy_10.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_11 = new UpdateValueStrategy(); |
| strategy_11.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m11ObserveWidget, m11ObserveValue, strategy_10, strategy_11); |
| |
| // |
| IObservableValue m12ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m12Text); |
| IObservableValue m12ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M12).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M12).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_12 = new UpdateValueStrategy(); |
| strategy_12.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_13 = new UpdateValueStrategy(); |
| strategy_13.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m12ObserveWidget, m12ObserveValue, strategy_12, strategy_13); |
| |
| // |
| IObservableValue m13ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m13Text); |
| IObservableValue m13ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M13).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M13).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_14 = new UpdateValueStrategy(); |
| strategy_14.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_15 = new UpdateValueStrategy(); |
| strategy_15.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m13ObserveWidget, m13ObserveValue, strategy_14, strategy_15); |
| |
| // |
| IObservableValue m20ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m20Text); |
| IObservableValue m20ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M20).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M20).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_16 = new UpdateValueStrategy(); |
| strategy_16.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_17 = new UpdateValueStrategy(); |
| strategy_17.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m20ObserveWidget, m20ObserveValue, strategy_16, strategy_17); |
| |
| // |
| IObservableValue m21ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m21Text); |
| IObservableValue m21ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M21).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M21).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_18 = new UpdateValueStrategy(); |
| strategy_18.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_19 = new UpdateValueStrategy(); |
| strategy_19.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m21ObserveWidget, m21ObserveValue, strategy_18, strategy_19); |
| |
| // |
| IObservableValue m22ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m22Text); |
| IObservableValue m22ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M22).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M22).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_20 = new UpdateValueStrategy(); |
| strategy_20.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_21 = new UpdateValueStrategy(); |
| strategy_21.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m22ObserveWidget, m22ObserveValue, strategy_20, strategy_21); |
| |
| // |
| IObservableValue m23ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m23Text); |
| IObservableValue m23ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M23).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M23).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_22 = new UpdateValueStrategy(); |
| strategy_22.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_23 = new UpdateValueStrategy(); |
| strategy_23.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m23ObserveWidget, m23ObserveValue, strategy_22, strategy_23); |
| |
| // |
| IObservableValue m30ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m30Text); |
| IObservableValue m30ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M30).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M30).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_24 = new UpdateValueStrategy(); |
| strategy_24.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_25 = new UpdateValueStrategy(); |
| strategy_25.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m30ObserveWidget, m30ObserveValue, strategy_24, strategy_25); |
| |
| // |
| IObservableValue m31ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m31Text); |
| IObservableValue m31ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M31).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M31).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_26 = new UpdateValueStrategy(); |
| strategy_26.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_27 = new UpdateValueStrategy(); |
| strategy_27.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m31ObserveWidget, m31ObserveValue, strategy_26, strategy_27); |
| |
| // |
| IObservableValue m32ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m32Text); |
| IObservableValue m32ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M32).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M32).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_28 = new UpdateValueStrategy(); |
| strategy_28.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_29 = new UpdateValueStrategy(); |
| strategy_29.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m32ObserveWidget, m32ObserveValue, strategy_28, strategy_29); |
| |
| // |
| IObservableValue m33ObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(this.m33Text); |
| IObservableValue m33ObserveValue = (this.editingDomain == null |
| ? EMFProperties.value(Literals.MATRIX4X4__M33).observe(this.matrix4x4) |
| : EMFEditProperties.value(this.editingDomain, Literals.MATRIX4X4__M33).observe(this.matrix4x4)); |
| |
| UpdateValueStrategy strategy_30 = new UpdateValueStrategy(); |
| strategy_30.setConverter(new StringToDoubleConverter()); |
| |
| UpdateValueStrategy strategy_31 = new UpdateValueStrategy(); |
| strategy_31.setConverter(new DoubleToStringConverter()); |
| |
| bindingContext.bindValue(m33ObserveWidget, m33ObserveValue, strategy_30, strategy_31); |
| |
| return bindingContext; |
| } |
| } |