]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/proconf/g3d/tools/OEPathSelectionListener.java
Naming fixes.
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / proconf / g3d / tools / OEPathSelectionListener.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.tools;\r
12 \r
13 import java.util.ArrayList;\r
14 import java.util.Iterator;\r
15 import java.util.List;\r
16 \r
17 import org.eclipse.jface.viewers.ISelectionChangedListener;\r
18 import org.eclipse.jface.viewers.IStructuredSelection;\r
19 import org.eclipse.jface.viewers.SelectionChangedEvent;\r
20 import org.simantics.layer0.utils.viewpoints.TraversalPath;\r
21 import org.simantics.proconf.browsing.MutableCachedGraphTreeNode;\r
22 \r
23 /**\r
24  * SelectionListener for OntologyExplorer\r
25  * \r
26  * Returns Selection as TraversalPath\r
27  * \r
28  * @author Marko Luukkainen\r
29  *\r
30  */\r
31 public abstract class OEPathSelectionListener implements ISelectionChangedListener{\r
32         @SuppressWarnings("unchecked")\r
33         public void selectionChanged(SelectionChangedEvent event) {\r
34                 IStructuredSelection s = (IStructuredSelection)event.getSelection();\r
35                 List<TraversalPath> paths = new ArrayList<TraversalPath>();\r
36                 Iterator<MutableCachedGraphTreeNode> i = s.iterator();\r
37                 while(i.hasNext()) {\r
38                         MutableCachedGraphTreeNode node = i.next();\r
39                         TraversalPath path = (TraversalPath)node.getObject();\r
40                         paths.add(path);\r
41                 }       \r
42                 pathSelectionUpdated(paths);\r
43         }\r
44         \r
45         protected abstract void pathSelectionUpdated(List<TraversalPath> paths);\r
46 }\r