@@ -19,6 +19,7 @@ var ClassView = function (parent, container) {
1919 this . MAX_PAPER_SCALE = 4 ;
2020
2121 this . CLASS_DOC_PATH = "/csp/documatic/%25CSP.Documatic.cls" ;
22+ this . SYMBOL_12_WIDTH = 6.6 ;
2223
2324 this . init ( ) ;
2425
@@ -127,7 +128,8 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
127128 nameClickHandler : function ( ) {
128129 self . openClassDoc ( name , classMetaData [ "NAMESPACE" ] ) ;
129130 }
130- }
131+ } ,
132+ SYMBOL_12_WIDTH : self . SYMBOL_12_WIDTH
131133 } ) ;
132134
133135 this . objects . push ( classInstance ) ;
@@ -139,6 +141,61 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
139141
140142ClassView . prototype . render = function ( data ) {
141143
144+ var self = this ,
145+ number = lib . countProperties ( data [ "classes" ] ) ;
146+
147+ if ( number < 30 ) return this . confirmRender ( data ) ;
148+
149+ var c = document . createElement ( "div" ) ,
150+ c1 = document . createElement ( "h3" ) ,
151+ cS = document . createElement ( "h6" ) ,
152+ c2 = document . createElement ( "div" ) ,
153+ load = document . createElement ( "div" ) ,
154+ lt = document . createElement ( "div" ) ,
155+ spinner = document . createElement ( "div" ) ,
156+ bOk = document . createElement ( "button" ) ,
157+ bOff = document . createElement ( "button" ) ;
158+
159+ c1 . textContent = "Warning!" ;
160+ cS . textContent = "There are a huge number of classes to render (over " + ( number - ( number % 10 ) )
161+ + " elements)"
162+ + ( function ( n ) { var s = n < 40 ?"." :"!" , c = 0 ; while ( n > 50 ) { s += "!" ; n -= 10 + c ++ ; } return s ; } ) ( number )
163+ + " Rendering may take a lot of time." ;
164+
165+ bOk . textContent = "Render this!" ;
166+ bOk . style . color = "red" ;
167+ bOff . textContent = "No, thanks" ;
168+ load . style . textAlign = "center" ;
169+ spinner . className = "spinner" ;
170+ lt . innerHTML = "<br/><br/><br/><br/>Rendering, please wait..." ;
171+ lt . style . textAlign = "center" ;
172+
173+ bOk . addEventListener ( "click" , function ( ) {
174+ c . appendChild ( load ) ;
175+ c1 . parentNode . removeChild ( c1 ) ;
176+ cS . parentNode . removeChild ( cS ) ;
177+ c2 . parentNode . removeChild ( c2 ) ;
178+ setTimeout ( function ( ) {
179+ self . confirmRender ( data ) ; self . cacheUMLExplorer . UI . removeMessage ( ) ;
180+ } , 25 ) ;
181+ } ) ;
182+ bOff . addEventListener ( "click" , function ( ) {
183+ self . cacheUMLExplorer . UI . removeMessage ( ) ;
184+ } ) ;
185+
186+ c . appendChild ( c1 ) ;
187+ c . appendChild ( cS ) ;
188+ c . appendChild ( c2 ) ;
189+ c2 . appendChild ( bOk ) ;
190+ c2 . appendChild ( bOff ) ;
191+ load . appendChild ( lt ) ;
192+ load . appendChild ( spinner ) ;
193+ this . cacheUMLExplorer . UI . displayMessage ( c , false ) ;
194+
195+ } ;
196+
197+ ClassView . prototype . confirmRender = function ( data ) {
198+
142199 var self = this , p , pp , className ,
143200 uml = joint . shapes . uml , relFrom , relTo ,
144201 classes = { } , connector ;
@@ -349,4 +406,20 @@ ClassView.prototype.init = function () {
349406 self . zoom ( null ) ;
350407 } ) ;
351408
409+ this . SYMBOL_12_WIDTH = ( function ( ) {
410+ var e = document . createElementNS ( "http://www.w3.org/2000/svg" , "text" ) ,
411+ s = document . createElementNS ( "http://www.w3.org/2000/svg" , "svg" ) ,
412+ w ;
413+ s . appendChild ( e ) ;
414+ s . setAttribute ( "xmlns" , "http://www.w3.org/2000/svg" ) ;
415+ s . setAttribute ( "version" , "1.1" ) ;
416+ e . setAttribute ( "font-family" , "monospace" ) ;
417+ e . setAttribute ( "font-size" , "12" ) ;
418+ e . textContent = "aBcDeFgGhH" ;
419+ document . body . appendChild ( s ) ;
420+ w = e . getBBox ( ) . width / 10 ;
421+ s . parentNode . removeChild ( s ) ;
422+ return w ;
423+ } ) ( ) ;
424+
352425} ;
0 commit comments