|
@@ -6,6 +6,7 @@ |
6 |
6 |
|
import com.google.gwt.user.client.ui.*; |
7 |
7 |
|
import org.litesoft.GWT.client.*; |
8 |
8 |
|
import org.litesoft.GWT.client.widgets.*; |
|
9 |
+ |
import org.litesoft.GWT.client.widgets.Button; |
9 |
10 |
|
import org.litesoft.bo.*; |
10 |
11 |
|
import org.litesoft.bo.views.*; |
11 |
12 |
|
import org.litesoft.core.util.*; |
|
@@ -30,8 +31,8 @@ |
30 |
31 |
|
private boolean mUnique, mSearching = false; |
31 |
32 |
|
private TableDataReloadable mReloadable = null; |
32 |
33 |
|
private MessageLabel mMessage = new MessageLabel(); |
33 |
|
- |
private NewButton mNewButton; |
34 |
|
- |
private SelectButton mSelectButton; |
|
34 |
+ |
private Button mNewButton, mSelectButton; |
|
35 |
+ |
private ButtonHelper mNewButtonHelper, mSelectButtonHelper; |
35 |
36 |
|
private boolean mShowing = false; |
36 |
37 |
|
private boolean mRealtimeUpdatingSuppressed = false; |
37 |
38 |
|
private boolean mUpdateRequested = false; |
|
@@ -45,22 +46,34 @@ |
45 |
46 |
|
mDefaultNoRowTableClickCommand = pDefaultNoRowTableClickCommand; |
46 |
47 |
|
mUnique = pUnique; |
47 |
48 |
|
|
48 |
|
- |
(mNewButton = new NewButton( pNewAllowed, new ClickHandler() |
|
49 |
+ |
mNewButtonHelper = new ButtonHelper(pNewAllowed, mNewButton = DefButtonNamed.newReg().enabledToolTip( "Create New Record" ).add( new ClickHandler() |
49 |
50 |
|
{ |
50 |
51 |
|
@Override |
51 |
52 |
|
public void onClick( ClickEvent event ) |
52 |
53 |
|
{ |
53 |
54 |
|
requestNew(); |
54 |
55 |
|
} |
55 |
|
- |
} )).setTitle( "Create New Record" ); |
56 |
|
- |
(mSelectButton = new SelectButton( new ClickHandler() |
|
56 |
+ |
} ).create() ); |
|
57 |
+ |
updateNewButton(); |
|
58 |
+ |
mSelectButtonHelper = new ButtonHelper( true, mSelectButton = DefButtonNamed.select().enabledToolTip( "Single Row Select" ).add( new ClickHandler() |
57 |
59 |
|
{ |
58 |
60 |
|
@Override |
59 |
61 |
|
public void onClick( ClickEvent event ) |
60 |
62 |
|
{ |
61 |
63 |
|
requestSingle(); |
62 |
64 |
|
} |
63 |
|
- |
} )).setTitle( "Single Row Select" ); |
|
65 |
+ |
} ).create() ); |
|
66 |
+ |
updateSelectButton(); |
|
67 |
+ |
} |
|
68 |
+ |
|
|
69 |
+ |
private void updateNewButton() |
|
70 |
+ |
{ |
|
71 |
+ |
mNewButtonHelper.update( !mUnique || mList.isEmpty() ); |
|
72 |
+ |
} |
|
73 |
+ |
|
|
74 |
+ |
private void updateSelectButton() |
|
75 |
+ |
{ |
|
76 |
+ |
mSelectButtonHelper.update( mList.size() == 1 ); |
64 |
77 |
|
} |
65 |
78 |
|
|
66 |
79 |
|
public Widget addReloadable( TableDataReloadable pReloadable ) |
|
@@ -86,8 +99,8 @@ |
86 |
99 |
|
if ( mSearching != pSearching ) |
87 |
100 |
|
{ |
88 |
101 |
|
mSearching = pSearching; |
89 |
|
- |
mNewButton.update(); |
90 |
|
- |
mSelectButton.update(); |
|
102 |
+ |
updateNewButton(); |
|
103 |
+ |
updateSelectButton(); |
91 |
104 |
|
} |
92 |
105 |
|
} |
93 |
106 |
|
|
|
@@ -227,8 +240,8 @@ |
227 |
240 |
|
{ |
228 |
241 |
|
mList = pList; |
229 |
242 |
|
updateRowCount(); |
230 |
|
- |
mNewButton.update(); |
231 |
|
- |
mSelectButton.update(); |
|
243 |
+ |
updateNewButton(); |
|
244 |
+ |
updateSelectButton(); |
232 |
245 |
|
super.requestRows( pRequest, pCallback ); |
233 |
246 |
|
} |
234 |
247 |
|
|
|
@@ -402,20 +415,28 @@ |
402 |
415 |
|
{ |
403 |
416 |
|
private boolean mVisible = true; |
404 |
417 |
|
private boolean mEnabled = true; |
|
418 |
+ |
private boolean mAllowed; |
|
419 |
+ |
private Button mButton; |
|
420 |
+ |
|
|
421 |
+ |
public ButtonHelper( boolean pAllowed, Button pButton ) |
|
422 |
+ |
{ |
|
423 |
+ |
mAllowed = pAllowed; |
|
424 |
+ |
mButton = pButton; |
|
425 |
+ |
} |
405 |
426 |
|
|
406 |
|
- |
public void update( ButtonBase pButton, boolean pPossiblyVisible, boolean pPossiblyEnable ) |
|
427 |
+ |
public void update( boolean pPossiblyEnable ) |
407 |
428 |
|
{ |
408 |
|
- |
if ( !pPossiblyVisible ) |
|
429 |
+ |
if ( !mAllowed ) |
409 |
430 |
|
{ |
410 |
431 |
|
if ( mVisible ) |
411 |
432 |
|
{ |
412 |
|
- |
UtilsGwt.setHidden( pButton, !(mVisible = false) ); |
|
433 |
+ |
UtilsGwt.setHidden( mButton, !(mVisible = false) ); |
413 |
434 |
|
} |
414 |
435 |
|
return; |
415 |
436 |
|
} |
416 |
437 |
|
if ( mSearching != mVisible ) |
417 |
438 |
|
{ |
418 |
|
- |
UtilsGwt.setHidden( pButton, !(mVisible = mSearching) ); |
|
439 |
+ |
UtilsGwt.setHidden( mButton, !(mVisible = mSearching) ); |
419 |
440 |
|
if ( !mVisible ) |
420 |
441 |
|
{ |
421 |
442 |
|
return; |
|
@@ -424,43 +445,8 @@ |
424 |
445 |
|
boolean zEnabled = pPossiblyEnable && !mFilterManager.isEmpty(); |
425 |
446 |
|
if ( mEnabled != zEnabled ) |
426 |
447 |
|
{ |
427 |
|
- |
pButton.setEnabled( mEnabled = zEnabled ); |
|
448 |
+ |
mButton.setEnabled( mEnabled = zEnabled ); |
428 |
449 |
|
} |
429 |
450 |
|
} |
430 |
451 |
|
} |
431 |
|
- |
|
432 |
|
- |
private class NewButton extends RegButton |
433 |
|
- |
{ |
434 |
|
- |
private boolean mAllowed; |
435 |
|
- |
|
436 |
|
- |
private NewButton( boolean pAllowed, ClickHandler pHandler ) |
437 |
|
- |
{ |
438 |
|
- |
super( "New", pHandler ); |
439 |
|
- |
mAllowed = pAllowed; |
440 |
|
- |
update(); |
441 |
|
- |
} |
442 |
|
- |
|
443 |
|
- |
private ButtonHelper mHelper = new ButtonHelper(); |
444 |
|
- |
|
445 |
|
- |
public void update() |
446 |
|
- |
{ |
447 |
|
- |
mHelper.update( this, mAllowed, !mUnique || mList.isEmpty() ); |
448 |
|
- |
} |
449 |
|
- |
} |
450 |
|
- |
|
451 |
|
- |
private class SelectButton extends GreenButton |
452 |
|
- |
{ |
453 |
|
- |
private SelectButton( ClickHandler pHandler ) |
454 |
|
- |
{ |
455 |
|
- |
super( "Select", pHandler ); |
456 |
|
- |
update(); |
457 |
|
- |
} |
458 |
|
- |
|
459 |
|
- |
private ButtonHelper mHelper = new ButtonHelper(); |
460 |
|
- |
|
461 |
|
- |
public void update() |
462 |
|
- |
{ |
463 |
|
- |
mHelper.update( this, true, mList.size() == 1 ); |
464 |
|
- |
} |
465 |
|
- |
} |
466 |
452 |
|
} |