1 /*******************************************************************************
\r
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
\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
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.proconf.g3d.tools;
\r
13 import java.util.Iterator;
\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
23 * SelectionListener for OntologyExplorer
\r
25 * Returns selection as StrcturedResourceSelection
\r
27 * @author Marko Luukkainen
\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
40 resourceSelectionUpdated(sel);
\r
43 protected abstract void resourceSelectionUpdated(StructuredResourceSelection selection);
\r