| /******************************************************************************* |
| * 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: |
| * Pierre Allard, |
| * Regent L'Archeveque, |
| * Sebastien Gemme - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.math.provider; |
| |
| import java.text.NumberFormat; |
| |
| import org.eclipse.apogy.common.emf.edit.utils.descriptors.DoubleItemPropertyDescriptor; |
| import org.eclipse.apogy.common.math.ApogyCommonMathPackage; |
| import org.eclipse.apogy.common.math.Tuple3d; |
| import org.eclipse.emf.common.notify.AdapterFactory; |
| import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| |
| public class Tuple3dCustomItemProvider extends Tuple3dItemProvider { |
| |
| public Tuple3dCustomItemProvider(AdapterFactory adapterFactory) { |
| super(adapterFactory); |
| } |
| |
| // FIXME Not required anymore. |
| private NumberFormat formatter; |
| |
| private NumberFormat getFormatter() { |
| if (this.formatter == null) { |
| this.formatter = NumberFormat.getInstance(); |
| } |
| |
| return this.formatter; |
| } |
| |
| @Override |
| protected void addXPropertyDescriptor(Object object) { |
| this.itemPropertyDescriptors.add(new DoubleItemPropertyDescriptor( |
| ((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), getResourceLocator(), |
| getString("_UI_Tuple3d_x_feature"), |
| getString("_UI_PropertyDescriptor_description", "_UI_Tuple3d_x_feature", "_UI_Tuple3d_type"), |
| ApogyCommonMathPackage.Literals.TUPLE3D__X, true, false, false, ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
| null, null)); |
| } |
| |
| @Override |
| protected void addYPropertyDescriptor(Object object) { |
| this.itemPropertyDescriptors.add(new DoubleItemPropertyDescriptor( |
| ((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), getResourceLocator(), |
| getString("_UI_Tuple3d_y_feature"), |
| getString("_UI_PropertyDescriptor_description", "_UI_Tuple3d_y_feature", "_UI_Tuple3d_type"), |
| ApogyCommonMathPackage.Literals.TUPLE3D__Y, true, false, false, ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
| null, null)); |
| } |
| |
| @Override |
| protected void addZPropertyDescriptor(Object object) { |
| this.itemPropertyDescriptors.add(new DoubleItemPropertyDescriptor( |
| ((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), getResourceLocator(), |
| getString("_UI_Tuple3d_z_feature"), |
| getString("_UI_PropertyDescriptor_description", "_UI_Tuple3d_z_feature", "_UI_Tuple3d_type"), |
| ApogyCommonMathPackage.Literals.TUPLE3D__Z, true, false, false, ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
| null, null)); |
| } |
| |
| @Override |
| public String getText(Object object) { |
| |
| Tuple3d tuple3d = (Tuple3d) object; |
| return getString("_UI_Tuple3d_type") + " (" + getFormatter().format(tuple3d.getX()) + ", " |
| + getFormatter().format(tuple3d.getY()) + ", " + getFormatter().format(tuple3d.getZ()) + ")"; |
| } |
| |
| } |