public void addDocumentComponent ( final PageComponent pageComponent , boolean activateAfterOpen ) { String id = pageComponent . getId ( ) ; if ( ! closeAndReopenEditor && contentPane . getDocument ( id ) != null ) { contentPane . setActiveDocument ( id ) ; } else { if ( contentPane . getDocument ( id ) != null ) { contentPane . closeDocument ( id ) ; } DocumentComponent document = constructDocumentComponent ( pageComponent ) ; DocumentComponentListener lifecycleListener = constructLifecycleListener ( pageComponent ) ; document . addDocumentComponentListener ( lifecycleListener ) ; if ( contentPane . getDocument ( id ) == null ) { contentPane . openDocument ( document ) ; } if ( activateAfterOpen ) { contentPane . setActiveDocument ( id ) ; } registerDropTargetListeners ( pageComponent . getControl ( ) ) ; // This listener ensures that the focus is transfered to the workspace // itself if the number of documents becomes zero. document . addDocumentComponentListener ( new DocumentComponentAdapter ( ) { public void documentComponentClosed ( DocumentComponentEvent event ) { int count = contentPane . getDocumentCount ( ) ; if ( count == 0 ) { fireFocusGainedOnWorkspace ( ) ; } } } ) ; pageComponentMap . put ( id , pageComponent ) ; } }
Adds a document to the editor workspace . The behaviour when an editor is already open with editor identity defined by id property is determined by the closeAndReopenEditor property . If this property is true the default the editor is closed and reopened . If false the existing editor becomes the active one .