* the object
*/
private void linkViewWithEditor( Object o )
{
StructuredSelection structuredSelection = null;
ITreeNode wrapper = null;
if ( o instanceof AttributeType )
{
wrapper = new AttributeTypeWrapper( ( AttributeType ) o, null );
structuredSelection = new StructuredSelection( wrapper );
}
else if ( o instanceof ObjectClass )
{
wrapper = new ObjectClassWrapper( ( ObjectClass ) o, null );
structuredSelection = new StructuredSelection( wrapper );
}
else if ( o instanceof Schema )
{
wrapper = new SchemaWrapper( ( Schema ) o, null );
structuredSelection = new StructuredSelection( wrapper );
}
else
{
// If the editor isn't an attribute type editor or object class editor, we return
return;
}
Object foundItem = schemasView.getViewer().testFindItem( wrapper );
if ( foundItem != null ) // The node we are looking for is already loaded in the TreeViewer
{
schemasView.getViewer().setSelection( structuredSelection, true );
}
else
// The node we are looking for is not yet loaded in the TreeViewer, we have to find and load it.
{
ITreeNode foundElement = schemasView.findElementInTree( wrapper );
if ( foundElement != null )
{
expandFromTopToBottom( foundElement );
schemasView.getViewer().setSelection( structuredSelection );