| /******************************************************************************* |
| * Copyright (c) 2016, 2019 Chalmers | University of Gothenburg, rt-labs and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation |
| * Chalmers | University of Gothenburg - additional features, updated API |
| *******************************************************************************/ |
| package org.eclipse.capra.ui.zest; |
| |
| import org.eclipse.capra.core.adapters.TracePersistenceAdapter; |
| import org.eclipse.capra.core.handlers.IArtifactHandler; |
| import org.eclipse.capra.core.helpers.ArtifactHelper; |
| import org.eclipse.capra.core.helpers.ExtensionPointHelper; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; |
| import org.eclipse.jface.viewers.LabelProvider; |
| |
| /** |
| * |
| * This class provides labels for the nodes and edges for the graph to be |
| * displayed in the zest view. |
| * |
| */ |
| public class TraceNodeLabelProvider extends LabelProvider { |
| |
| @Override |
| public String getText(Object element) { |
| TracePersistenceAdapter persistenceAdapter = ExtensionPointHelper.getTracePersistenceAdapter().get(); |
| EObject artifactModel = persistenceAdapter.getArtifactWrappers(new ResourceSetImpl()); |
| ArtifactHelper artifactHelper = new ArtifactHelper(artifactModel); |
| IArtifactHandler<?> handler = artifactHelper.getHandler(element).get(); |
| return handler.withCastedHandler(element, (h, o) -> h.getDisplayName(o)).orElseGet(element::toString); |
| } |
| |
| // TODO Add labels for the edges |
| |
| } |