/******************************************************************************* * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. * 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: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.proconf.g3d.tools; import java.util.Iterator; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.simantics.db.Resource; import org.simantics.proconf.browsing.providers.TreeObject; import org.simantics.proconf.g3d.common.StructuredResourceSelection; /** * SelectionListener for OntologyExplorer * * Returns selection as StrcturedResourceSelection * * @author Marko Luukkainen * */ public abstract class OESelectionListener implements ISelectionChangedListener { @SuppressWarnings("unchecked") public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection s = (IStructuredSelection)event.getSelection(); StructuredResourceSelection sel = new StructuredResourceSelection(); Iterator i = s.iterator(); while(i.hasNext()) { TreeObject node = i.next(); sel.add((Resource)node.getAdapter(Resource.class)); } resourceSelectionUpdated(sel); } protected abstract void resourceSelectionUpdated(StructuredResourceSelection selection); }