using instanceof to get Object type and parent type?
Is it possible to somehow && instanceof to check if the selected object is of type Target and is a child of type Asset. The issue is I have 2 editors for the same Object based on what type their parent is. Here is my listener
Code:
treeViewer.addOpenListener(new IOpenListener() {
public void open(final OpenEvent event) {
Object firstElement = ((IStructuredSelection)event.getSelection()).getFirstElement();
if (firstElement instanceof Target){
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("NOVLayout.edittargetview");
} catch (PartInitException e) {
e.printStackTrace();
}
System.out.println("Open target editor");
}
)};
I want it to be something along the lines of firstElement instanceof Target && firstElement.getParent() instanceof Asset
I'm not sure if I can do this though. Does the selected object have a way to know what type of node its parent is?