Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/nonpublic/ExtendedFamilyManager.java

Diff revisions: vs.
  @@ -1,122 +1,122 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client.nonpublic;
3 -
4 - import org.litesoft.GWT.client.*;
5 - import org.litesoft.logger.*;
6 -
7 - import com.google.gwt.core.client.*;
8 -
9 - import java.util.*;
10 -
11 - import static org.litesoft.GWT.client.nonpublic.NativeExtendedFamilyManagerSupport.*;
12 -
13 - public class ExtendedFamilyManager {
14 - public static final Logger LOGGER = LoggerFactory.getLogger( ExtendedFamilyManager.class );
15 -
16 - /**
17 - * Ancestors: 0 - Parent, 1 - GrandParent, 2 - ...
18 - */
19 - private static List<JavaScriptObject> sAncestorWinHandles = new ArrayList<JavaScriptObject>();
20 -
21 - public static void initialize( boolean pAllowUsToBeGrandPoobah ) {
22 - buildAncestry();
23 - CookieNet.initialize( pAllowUsToBeGrandPoobah );
24 - }
25 -
26 - public static boolean buildAncestry() {
27 - buildCurrentlyActiveDirectAncestry();
28 - int zCurrentAncestors = sAncestorWinHandles.size() - 1;
29 - if ( zCurrentAncestors != -1 ) {
30 - JavaScriptObject zAncestorHandle = LLgetAncestor( zCurrentAncestors );
31 - for ( int i = 0; true; i++ ) {
32 - LOGGER.debug.log( "getAncestorIndexedWinHandle( ", zCurrentAncestors, ", ", i, " )" );
33 - JavaScriptObject zHandle = getAncestorIndexedWinHandle( zAncestorHandle, i );
34 - if ( zHandle == null ) {
35 - break;
36 - }
37 - registerAncestor( zHandle );
38 - }
39 - }
40 - return !sAncestorWinHandles.isEmpty();
41 - }
42 -
43 - private static JavaScriptObject LLgetAncestor( int pIndex ) {
44 - if ( ((0 <= pIndex) && (pIndex < sAncestorWinHandles.size())) ) {
45 - JavaScriptObject zAncestorWinHandle = sAncestorWinHandles.get( pIndex );
46 - if ( zAncestorWinHandle != null ) {
47 - LOGGER.debug.log( "getAncestor( ", pIndex, " ): Returned!" );
48 - return zAncestorWinHandle;
49 - }
50 - }
51 - LOGGER.debug.log( "getAncestor( ", pIndex, " ): null" );
52 - return null;
53 - }
54 -
55 - private static void notifyAncestryOfNewDecendent( String pWinName, JavaScriptObject pWinHandle ) {
56 - for ( int i = 0; i < sAncestorWinHandles.size(); i++ ) {
57 - JavaScriptObject zAncestorWinHandle = sAncestorWinHandles.get( i );
58 - String zError = notifyNewDecendent( zAncestorWinHandle, pWinName, pWinHandle );
59 - if ( zError.length() == 0 ) {
60 - return; // Success!
61 - }
62 - LOGGER.debug.log( "Ancestor( ", i, " ): ", zError );
63 - }
64 - }
65 -
66 - ///////////////////////////////////////////////////////////////////////////////////////////////////////////
67 -
68 - private static Map<String, String> sFutureChildren = new HashMap<String, String>();
69 -
70 - private static void registerFutureChild( String pWinName, String pUrl ) {
71 - sFutureChildren.put( pWinName, pUrl );
72 - }
73 -
74 - public static void openChildWindow( String pWinName, String pUrl ) {
75 - registerFutureChild( pWinName, pUrl );
76 - JavaScriptObject zNewWinHandle = openNewWindow( "ServerApp?NewWindowPage", //
77 - pWinName, //
78 - UtilsGwt.CHROMELESS_OVERFLOW );
79 - report( "openNewWindow", pWinName, zNewWinHandle );
80 - }
81 -
82 - private static void report( String pMethod, String pWinName, JavaScriptObject pWinHandle ) {
83 - if ( LOGGER.debug.isEnabled() ) {
84 - StringBuilder sb = new StringBuilder().append( pMethod ).append( "( '" ).append( pWinName ).append( "' ): " );
85 - if ( pWinHandle == null ) {
86 - sb.append( "null" );
87 - } else {
88 - sb.append( "State: " ).append( NativeExtendedFamilyManagerSupport.getWindowState( pWinHandle ) );
89 - // sb.append( " X: " ).append( getWindowPosX( pWinHandle ) );
90 - // sb.append( " Y: " ).append( getWindowPosY( pWinHandle ) );
91 - }
92 - LOGGER.debug.log( sb.toString() );
93 - }
94 - }
95 -
96 - // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv called from NativeExtendedFamilyManagerSupport vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
97 -
98 - public static JavaScriptObject getAncestor( Integer pIndex ) {
99 - return LLgetAncestor( (pIndex != null) ? pIndex : -1 );
100 - }
101 -
102 - protected static void registerAncestor( JavaScriptObject pWinHandle ) {
103 - sAncestorWinHandles.add( pWinHandle );
104 - LOGGER.debug.log( "registerAncestor: ", sAncestorWinHandles.size() );
105 - }
106 -
107 - protected static void registerNewChildWindow( String pWinName, JavaScriptObject pWinHandle ) {
108 - report( "regNewChild", pWinName, pWinHandle );
109 - }
110 -
111 - protected static String ackNewChildWindow( String pWinName, JavaScriptObject pWinHandle ) {
112 - report( "ackNewChild", pWinName, pWinHandle );
113 - notifyAncestryOfNewDecendent( pWinName, pWinHandle );
114 - String zUrl = sFutureChildren.remove( pWinName );
115 - return (zUrl != null) ? zUrl : "ServerApp?RealPage";
116 - }
117 -
118 - protected static void newDecendentWindow( String pWinName, JavaScriptObject pWinHandle ) {
119 - report( "ackNewDecendent", pWinName, pWinHandle );
120 - notifyAncestryOfNewDecendent( pWinName, pWinHandle );
121 - }
122 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client.nonpublic;
3 +
4 + import org.litesoft.GWT.client.*;
5 + import org.litesoft.logger.*;
6 +
7 + import com.google.gwt.core.client.*;
8 +
9 + import java.util.*;
10 +
11 + import static org.litesoft.GWT.client.nonpublic.NativeExtendedFamilyManagerSupport.*;
12 +
13 + public class ExtendedFamilyManager {
14 + public static final Logger LOGGER = LoggerFactory.getLogger( ExtendedFamilyManager.class );
15 +
16 + /**
17 + * Ancestors: 0 - Parent, 1 - GrandParent, 2 - ...
18 + */
19 + private static List<JavaScriptObject> sAncestorWinHandles = new ArrayList<JavaScriptObject>();
20 +
21 + public static void initialize( boolean pAllowUsToBeGrandPoobah ) {
22 + buildAncestry();
23 + CookieNet.initialize( pAllowUsToBeGrandPoobah );
24 + }
25 +
26 + public static boolean buildAncestry() {
27 + buildCurrentlyActiveDirectAncestry();
28 + int zCurrentAncestors = sAncestorWinHandles.size() - 1;
29 + if ( zCurrentAncestors != -1 ) {
30 + JavaScriptObject zAncestorHandle = LLgetAncestor( zCurrentAncestors );
31 + for ( int i = 0; true; i++ ) {
32 + LOGGER.debug.log( "getAncestorIndexedWinHandle( ", zCurrentAncestors, ", ", i, " )" );
33 + JavaScriptObject zHandle = getAncestorIndexedWinHandle( zAncestorHandle, i );
34 + if ( zHandle == null ) {
35 + break;
36 + }
37 + registerAncestor( zHandle );
38 + }
39 + }
40 + return !sAncestorWinHandles.isEmpty();
41 + }
42 +
43 + private static JavaScriptObject LLgetAncestor( int pIndex ) {
44 + if ( ((0 <= pIndex) && (pIndex < sAncestorWinHandles.size())) ) {
45 + JavaScriptObject zAncestorWinHandle = sAncestorWinHandles.get( pIndex );
46 + if ( zAncestorWinHandle != null ) {
47 + LOGGER.debug.log( "getAncestor( ", pIndex, " ): Returned!" );
48 + return zAncestorWinHandle;
49 + }
50 + }
51 + LOGGER.debug.log( "getAncestor( ", pIndex, " ): null" );
52 + return null;
53 + }
54 +
55 + private static void notifyAncestryOfNewDecendent( String pWinName, JavaScriptObject pWinHandle ) {
56 + for ( int i = 0; i < sAncestorWinHandles.size(); i++ ) {
57 + JavaScriptObject zAncestorWinHandle = sAncestorWinHandles.get( i );
58 + String zError = notifyNewDecendent( zAncestorWinHandle, pWinName, pWinHandle );
59 + if ( zError.length() == 0 ) {
60 + return; // Success!
61 + }
62 + LOGGER.debug.log( "Ancestor( ", i, " ): ", zError );
63 + }
64 + }
65 +
66 + ///////////////////////////////////////////////////////////////////////////////////////////////////////////
67 +
68 + private static Map<String, String> sFutureChildren = new HashMap<String, String>();
69 +
70 + private static void registerFutureChild( String pWinName, String pUrl ) {
71 + sFutureChildren.put( pWinName, pUrl );
72 + }
73 +
74 + public static void openChildWindow( String pWinName, String pUrl ) {
75 + registerFutureChild( pWinName, pUrl );
76 + JavaScriptObject zNewWinHandle = openNewWindow( "ServerApp?NewWindowPage", //
77 + pWinName, //
78 + UtilsGwt.CHROMELESS_OVERFLOW );
79 + report( "openNewWindow", pWinName, zNewWinHandle );
80 + }
81 +
82 + private static void report( String pMethod, String pWinName, JavaScriptObject pWinHandle ) {
83 + if ( LOGGER.debug.isEnabled() ) {
84 + StringBuilder sb = new StringBuilder().append( pMethod ).append( "( '" ).append( pWinName ).append( "' ): " );
85 + if ( pWinHandle == null ) {
86 + sb.append( "null" );
87 + } else {
88 + sb.append( "State: " ).append( NativeExtendedFamilyManagerSupport.getWindowState( pWinHandle ) );
89 + // sb.append( " X: " ).append( getWindowPosX( pWinHandle ) );
90 + // sb.append( " Y: " ).append( getWindowPosY( pWinHandle ) );
91 + }
92 + LOGGER.debug.log( sb.toString() );
93 + }
94 + }
95 +
96 + // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv called from NativeExtendedFamilyManagerSupport vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
97 +
98 + public static JavaScriptObject getAncestor( Integer pIndex ) {
99 + return LLgetAncestor( (pIndex != null) ? pIndex : -1 );
100 + }
101 +
102 + protected static void registerAncestor( JavaScriptObject pWinHandle ) {
103 + sAncestorWinHandles.add( pWinHandle );
104 + LOGGER.debug.log( "registerAncestor: ", sAncestorWinHandles.size() );
105 + }
106 +
107 + protected static void registerNewChildWindow( String pWinName, JavaScriptObject pWinHandle ) {
108 + report( "regNewChild", pWinName, pWinHandle );
109 + }
110 +
111 + protected static String ackNewChildWindow( String pWinName, JavaScriptObject pWinHandle ) {
112 + report( "ackNewChild", pWinName, pWinHandle );
113 + notifyAncestryOfNewDecendent( pWinName, pWinHandle );
114 + String zUrl = sFutureChildren.remove( pWinName );
115 + return (zUrl != null) ? zUrl : "ServerApp?RealPage";
116 + }
117 +
118 + protected static void newDecendentWindow( String pWinName, JavaScriptObject pWinHandle ) {
119 + report( "ackNewDecendent", pWinName, pWinHandle );
120 + notifyAncestryOfNewDecendent( pWinName, pWinHandle );
121 + }
122 + }