| /***************************************************************************** |
| * Copyright (c) 2011 CEA LIST. |
| * |
| * 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: |
| * |
| * CEA LIST - Initial API and implementation |
| * |
| *****************************************************************************/ |
| package org.eclipse.papyrus.gmf.diagram.common.provider; |
| |
| import java.util.List; |
| |
| import org.eclipse.gef.EditPart; |
| import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart; |
| import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; |
| |
| /** |
| * Non diagram-specific class generated by GMF Tooling. |
| */ |
| public class DiagramEditorUtil { |
| |
| public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) { |
| diagramPart.getDiagramGraphicalViewer().deselectAll(); |
| |
| EditPart firstPrimary = null; |
| for (EditPart nextPart : editParts) { |
| diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart); |
| if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) { |
| firstPrimary = nextPart; |
| } |
| } |
| |
| if (!editParts.isEmpty()) { |
| diagramPart.getDiagramGraphicalViewer().reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0)); |
| } |
| } |
| } |