/******************************************************************************* * Copyright (c) 2012, 2013 Association for Decentralized Information Management in * Industry THTH ry. * 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.g3d.vtk.common; import org.eclipse.core.runtime.IAdaptable; import org.simantics.db.Resource; import org.simantics.g3d.scenegraph.IG3DNode; import org.simantics.g3d.scenegraph.base.INode; import org.simantics.objmap.structural.StructuralResource; import vtk.vtkProp; public class VTKSelectionItem implements IAdaptable{ private vtkProp prop; private INode node; private DBObject resource; public VTKSelectionItem(vtkProp prop, INode node, DBObject res) { this.prop = prop; this.node = node; this.resource = res; } @Override public T getAdapter(Class adapter) { if (adapter.isAssignableFrom(Resource.class)) if (resource instanceof Resource) return adapter.cast(resource); else return null; if (adapter.isAssignableFrom(StructuralResource.class)) if (resource instanceof StructuralResource) return adapter.cast(resource); else return null; if (adapter.isAssignableFrom(vtkProp.class)) return adapter.cast(prop); if (adapter.isAssignableFrom(IG3DNode.class) && node instanceof IG3DNode) return adapter.cast(node); if (adapter.isAssignableFrom(INode.class)) return adapter.cast(node); return null; } @SuppressWarnings("rawtypes") @Override public boolean equals(Object obj) { if (obj == null) return false; if (obj.getClass() != this.getClass()) return false; VTKSelectionItem other = (VTKSelectionItem)obj; if (prop != null) if (!prop.equals(other.prop)) return false; if (node != null) if (!node.equals(other.node)) return false; if (resource != null) return resource.equals(other.resource); return true; } }