dojoibm-content-navigator

Change ICN contentViewer's tab title in split pane mode?


I need to change the "title" for each document shown in ICN Viewer, dynamically, at runtime. I'll read the new viewer tab title from the document properties.

Environment: ICN 2.0.3 CM8.5 WAS 8.5.5

Code so far:

  1. I found a PARTIAL solution by hooking "ecm.model.desktop, onChange":

     aspect.after(ecm.model.desktop, 'onChange', function() {
        var contentViewer = dijit.byId('contentViewer');
        if (contentViewer) {
           var viewerTabTitleDef = new ViewerTabTitleDef ();
           contentViewer.mainTabContainer.getChildren().forEach(function(child) {
              viewerTabTitleDef.changeTitle(viewerTabTitleDef.self,
                 child.controlButton, child.contentViewerPane.viewerItem.item);
           });
           ...
    
  2. I was able to extend this for subsequent documents opened in the same viewer, and optimized by "removing()" the handler after this initial call. Here is the complete code:

     var kill = aspect.after(ecm.model.desktop, 'onChange', function() {
    
        var contentViewer = dijit.byId('contentViewer');
        // "contentViewer" will be "unknown" unless viewer invoked
        console.log('onChange: contentViewer', contentViewer);  
    
        if (contentViewer) {
           console.log("new ViewerTabTitleDef()...");
           kill.remove();
           var viewerTabTitleDef = new ViewerTabTitleDef ();
           contentViewer.mainTabContainer.getChildren().forEach(function(child) {
               // For initially opened tabs
               console.log('initially opened: child', child);
               viewerTabTitleDef.changeTitle(viewerTabTitleDef.self, child.controlButton, child.contentViewerPane.viewerItem.item);
           });
           aspect.after(contentViewer.mainTabContainer, 'addChild', function(child) {
               // For tabs added after the viewer was opened
               console.log('subsequently opened: child', child);
               viewerTabTitleDef.changeTitle(viewerTabTitleDef, child.controlButton, child.contentViewerPane.viewerItem.item);
           }, true);
        } // end if contentViewer
    
     });  // end aspect.after(onChange desktop)
    
  3. Current problem: how can I change the label for a split tab (either vertical or horizontal)?

So far, I have NOT been able to find any event for any ICN/ECM widget or object variable that I can trigger on.


Solution

  • It seems you want to show a different tab-title (instead of the document title) in the navigator viewer whenever a doc is opened.

    How about this?

    Every document you open in the viewer is wrapped in a ecm.widget.viewer.model.ViewerItem which exposes the getHtmlName that returns the name used in the tab.

    Your solution would be to implement your own getHtmlName.

    Unfortunately though, the ViewerItem is constructed in the ecm.widget.viewer.ContentViewer#_open and then passed to the ecm.widget.viewer.ContentViewer#_openTab. So you'll either violate best practice by mingling with IBM private methods, or you'll go for a generic approach and just replace the ecm.widget.viewer.model.ViewerItem.prototype.getHtmlName.