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:
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); }); ...
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)
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.
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 thegetHtmlName
that returns the name used in the tab.Your solution would be to implement your own
getHtmlName
.Unfortunately though, the
ViewerItem
is constructed in theecm.widget.viewer.ContentViewer#_open
and then passed to theecm.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 theecm.widget.viewer.model.ViewerItem.prototype.getHtmlName
.