|
@@ -1,8 +1,6 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.GWT.client.nonpublic; |
3 |
3 |
|
|
4 |
|
- |
import java.util.*; |
5 |
|
- |
|
6 |
4 |
|
import org.litesoft.GWT.client.*; |
7 |
5 |
|
|
8 |
6 |
|
import com.google.gwt.core.client.*; |
|
@@ -10,42 +8,35 @@ |
10 |
8 |
|
import com.google.gwt.user.client.*; |
11 |
9 |
|
import com.google.gwt.user.client.ui.*; |
12 |
10 |
|
|
13 |
|
- |
public class AbstractPopupManager implements CloseHandler<PopupPanel> |
14 |
|
- |
{ |
15 |
|
- |
protected static void show( AbstractEntry pEntry ) |
16 |
|
- |
{ |
|
11 |
+ |
import java.util.*; |
|
12 |
+ |
|
|
13 |
+ |
public class AbstractPopupManager implements CloseHandler<PopupPanel> { |
|
14 |
+ |
protected static void show( AbstractEntry pEntry ) { |
17 |
15 |
|
INSTANCE.addAndShow( pEntry ); |
18 |
16 |
|
} |
19 |
17 |
|
|
20 |
18 |
|
private static final AbstractPopupManager INSTANCE = new AbstractPopupManager(); |
21 |
19 |
|
|
22 |
|
- |
private void addAndShow( AbstractEntry pEntry ) |
23 |
|
- |
{ |
24 |
|
- |
if ( add( pEntry ) && !showing() ) |
25 |
|
- |
{ |
|
20 |
+ |
private void addAndShow( AbstractEntry pEntry ) { |
|
21 |
+ |
if ( add( pEntry ) && !showing() ) { |
26 |
22 |
|
pEntry = getEntry(); |
27 |
|
- |
if ( pEntry != null ) |
28 |
|
- |
{ |
|
23 |
+ |
if ( pEntry != null ) { |
29 |
24 |
|
pEntry.show( this ); |
30 |
25 |
|
} |
31 |
26 |
|
} |
32 |
27 |
|
} |
33 |
28 |
|
|
34 |
29 |
|
@Override |
35 |
|
- |
public void onClose( CloseEvent<PopupPanel> event ) |
36 |
|
- |
{ |
|
30 |
+ |
public void onClose( CloseEvent<PopupPanel> event ) { |
37 |
31 |
|
AbstractEntry zEntry = nextEntry(); |
38 |
|
- |
if ( zEntry != null ) |
39 |
|
- |
{ |
|
32 |
+ |
if ( zEntry != null ) { |
40 |
33 |
|
zEntry.show( this ); |
41 |
34 |
|
} |
42 |
35 |
|
} |
43 |
36 |
|
|
44 |
|
- |
private synchronized boolean add( AbstractEntry pEntry ) |
45 |
|
- |
{ |
|
37 |
+ |
private synchronized boolean add( AbstractEntry pEntry ) { |
46 |
38 |
|
String zFrom = pEntry.getFrom(); |
47 |
|
- |
if ( mFromsInQueue.contains( zFrom ) ) |
48 |
|
- |
{ |
|
39 |
+ |
if ( mFromsInQueue.contains( zFrom ) ) { |
49 |
40 |
|
return false; |
50 |
41 |
|
} |
51 |
42 |
|
mFromsInQueue.add( zFrom ); |
|
@@ -60,8 +51,7 @@ |
60 |
51 |
|
/** |
61 |
52 |
|
* Will "manage" the mShowing flag |
62 |
53 |
|
*/ |
63 |
|
- |
private synchronized boolean showing() |
64 |
|
- |
{ |
|
54 |
+ |
private synchronized boolean showing() { |
65 |
55 |
|
boolean rv = mShowing; |
66 |
56 |
|
mShowing = true; |
67 |
57 |
|
return rv; |
|
@@ -70,54 +60,44 @@ |
70 |
60 |
|
/** |
71 |
61 |
|
* Will "manage" the mShowing flag in conjunction w/ the mFromQueue |
72 |
62 |
|
*/ |
73 |
|
- |
private synchronized AbstractEntry getEntry() |
74 |
|
- |
{ |
75 |
|
- |
if ( !mFromQueue.isEmpty() ) |
76 |
|
- |
{ |
|
63 |
+ |
private synchronized AbstractEntry getEntry() { |
|
64 |
+ |
if ( !mFromQueue.isEmpty() ) { |
77 |
65 |
|
return mFromQueue.get( 0 ); |
78 |
66 |
|
} |
79 |
67 |
|
mShowing = false; |
80 |
68 |
|
return null; |
81 |
69 |
|
} |
82 |
70 |
|
|
83 |
|
- |
private synchronized AbstractEntry nextEntry() |
84 |
|
- |
{ |
85 |
|
- |
if ( !mFromQueue.isEmpty() ) |
86 |
|
- |
{ |
|
71 |
+ |
private synchronized AbstractEntry nextEntry() { |
|
72 |
+ |
if ( !mFromQueue.isEmpty() ) { |
87 |
73 |
|
AbstractEntry entry = mFromQueue.remove( 0 ); |
88 |
74 |
|
mFromsInQueue.remove( entry.getFrom() ); |
89 |
75 |
|
} |
90 |
76 |
|
return getEntry(); |
91 |
77 |
|
} |
92 |
78 |
|
|
93 |
|
- |
protected abstract static class AbstractEntry |
94 |
|
- |
{ |
|
79 |
+ |
protected abstract static class AbstractEntry { |
95 |
80 |
|
private String mFrom; |
96 |
81 |
|
protected String mTitle, mBody; |
97 |
82 |
|
protected DialogCloseCallBack mCloseCallBack; |
98 |
83 |
|
|
99 |
|
- |
public AbstractEntry( String pFrom, String pTitle, String pBody, DialogCloseCallBack pCloseCallBack ) |
100 |
|
- |
{ |
|
84 |
+ |
public AbstractEntry( String pFrom, String pTitle, String pBody, DialogCloseCallBack pCloseCallBack ) { |
101 |
85 |
|
mFrom = pFrom; |
102 |
86 |
|
mTitle = pTitle; |
103 |
87 |
|
mBody = pBody; |
104 |
88 |
|
mCloseCallBack = pCloseCallBack; |
105 |
89 |
|
} |
106 |
90 |
|
|
107 |
|
- |
public String getFrom() |
108 |
|
- |
{ |
|
91 |
+ |
public String getFrom() { |
109 |
92 |
|
return mFrom; |
110 |
93 |
|
} |
111 |
94 |
|
|
112 |
|
- |
public void show( CloseHandler<PopupPanel> pCloseHandler ) |
113 |
|
- |
{ |
|
95 |
+ |
public void show( CloseHandler<PopupPanel> pCloseHandler ) { |
114 |
96 |
|
final AbstractMessageDialog zDialog = create(); |
115 |
97 |
|
zDialog.addCloseHandler( pCloseHandler ); |
116 |
|
- |
Scheduler.get().scheduleDeferred( new Command() |
117 |
|
- |
{ |
|
98 |
+ |
Scheduler.get().scheduleDeferred( new Command() { |
118 |
99 |
|
@Override |
119 |
|
- |
public void execute() |
120 |
|
- |
{ |
|
100 |
+ |
public void execute() { |
121 |
101 |
|
zDialog.show(); |
122 |
102 |
|
} |
123 |
103 |
|
} ); |
|
@@ -126,8 +106,7 @@ |
126 |
106 |
|
abstract protected AbstractMessageDialog create(); |
127 |
107 |
|
} |
128 |
108 |
|
|
129 |
|
- |
public static void prefetchImages() |
130 |
|
- |
{ |
|
109 |
+ |
public static void prefetchImages() { |
131 |
110 |
|
Image.prefetch( "common/images/misc/InfoIcon.gif" ); |
132 |
111 |
|
Image.prefetch( "common/images/misc/ConfirmIcon.gif" ); |
133 |
112 |
|
Image.prefetch( "common/images/misc/AlertError.gif" ); |