]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/proconf/g3d/tools/OESelectionListener.java
git-svn-id: https://www.simantics.org/svn/simantics/3d/trunk@22279 ac1ea38d-2e2b...
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / proconf / g3d / tools / OESelectionListener.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.Iterator;\r
14 \r
15 import org.eclipse.jface.viewers.ISelectionChangedListener;\r
16 import org.eclipse.jface.viewers.IStructuredSelection;\r
17 import org.eclipse.jface.viewers.SelectionChangedEvent;\r
18 import org.simantics.db.Resource;\r
19 import org.simantics.proconf.browsing.providers.TreeObject;\r
20 import org.simantics.proconf.g3d.common.StructuredResourceSelection;\r
21 \r
22 /**\r
23  * SelectionListener for OntologyExplorer\r
24  * \r
25  * Returns selection as StrcturedResourceSelection\r
26  * \r
27  * @author Marko Luukkainen\r
28  *\r
29  */\r
30 public abstract class OESelectionListener implements ISelectionChangedListener { \r
31         @SuppressWarnings("unchecked")\r
32         public void selectionChanged(SelectionChangedEvent event) {\r
33                 IStructuredSelection s = (IStructuredSelection)event.getSelection();\r
34                 StructuredResourceSelection sel = new StructuredResourceSelection();\r
35                 Iterator<TreeObject> i = s.iterator();\r
36                 while(i.hasNext()) {\r
37                         TreeObject node = i.next();\r
38                         sel.add((Resource)node.getAdapter(Resource.class));\r
39                 }\r
40                 resourceSelectionUpdated(sel);\r
41         }\r
42         \r
43         protected abstract void resourceSelectionUpdated(StructuredResourceSelection selection);\r
44 }\r