| /******************************************************************************* |
| * 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 - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.addons.provider; |
| |
| import java.text.DecimalFormat; |
| |
| import org.eclipse.apogy.addons.TrajectoryPickingTool; |
| import org.eclipse.emf.common.notify.AdapterFactory; |
| |
| public class TrajectoryPickingToolCustomItemProvider extends TrajectoryPickingToolItemProvider { |
| public TrajectoryPickingToolCustomItemProvider(AdapterFactory adapterFactory) { |
| super(adapterFactory); |
| } |
| |
| private final DecimalFormat decimalFormat = new DecimalFormat("0.00"); |
| |
| @Override |
| public String getText(Object object) { |
| TrajectoryPickingTool trajectoryPickingTool = (TrajectoryPickingTool) object; |
| String label = null; |
| |
| if (trajectoryPickingTool.getName() != null && trajectoryPickingTool.getName().length() > 0) { |
| label = trajectoryPickingTool.getName(); |
| } else { |
| label = getString("_UI_TrajectoryPickingTool_type"); |
| } |
| |
| // Adds Simple3DTool Text. |
| label += " ("; |
| String simpleToolText = getSimple3DToolText(trajectoryPickingTool); |
| if (simpleToolText.length() > 0) { |
| label += simpleToolText + ", "; |
| } |
| |
| label += "Total Lenght : " + this.decimalFormat.format(trajectoryPickingTool.getTotalLength()) + "m"; |
| |
| if (trajectoryPickingTool.getActivePath() != null) { |
| String distanceText = this.decimalFormat.format(trajectoryPickingTool.getActivePath().getLength()) + " m"; |
| label += ", Active Path Lenght : " + distanceText; |
| // |
| // String pathId = trajectoryPickingTool.getActivePath().getNodeId(); |
| // if(pathId != null && pathId.length() > 0) |
| // { |
| // label += ", " + pathId; |
| // } |
| } |
| |
| label += ")"; |
| |
| return label; |
| } |
| |
| } |