|
@@ -10,8 +10,7 @@ |
10 |
10 |
|
import com.google.gwt.event.dom.client.*; |
11 |
11 |
|
import com.google.gwt.user.client.ui.*; |
12 |
12 |
|
|
13 |
|
- |
public class RestrictedResourceSwitcher implements AlternateOptionsView |
14 |
|
- |
{ |
|
13 |
+ |
public class RestrictedResourceSwitcher implements AlternateOptionsView { |
15 |
14 |
|
private final OurImage mPickerButton = new OurImage( "common/images/misc/sites_button.gif" ); |
16 |
15 |
|
private final AlternateOptionPickerWidgetPanel mPickerWidgetPanel; |
17 |
16 |
|
private final RestrictedResourceSwitcherCallBack mCallBack; |
|
@@ -23,28 +22,24 @@ |
23 |
22 |
|
*/ |
24 |
23 |
|
private AlternateRestrictedResourceOption[] mAlternateOptions = new AlternateRestrictedResourceOption[0]; |
25 |
24 |
|
|
26 |
|
- |
public RestrictedResourceSwitcher( AlternateOptionPickerWidgetPanel pPickerWidgetPanel, RestrictedResourceSwitcherCallBack pCallBack ) |
27 |
|
- |
{ |
|
25 |
+ |
public RestrictedResourceSwitcher( AlternateOptionPickerWidgetPanel pPickerWidgetPanel, RestrictedResourceSwitcherCallBack pCallBack ) { |
28 |
26 |
|
mPickerWidgetPanel = Objects.assertNotNull( "PickerWidgetPanel", pPickerWidgetPanel ); |
29 |
27 |
|
mCallBack = Objects.assertNotNull( "CallBack", pCallBack ); |
30 |
28 |
|
|
31 |
29 |
|
mPickerButton.setWidth( "13" ); |
32 |
30 |
|
mPickerButton.setHeight( "14" ); |
33 |
|
- |
mPickerButton.addClickHandler( new ClickHandler() |
34 |
|
- |
{ |
|
31 |
+ |
mPickerButton.addClickHandler( new ClickHandler() { |
35 |
32 |
|
@Override |
36 |
|
- |
public void onClick( ClickEvent pEvent ) |
37 |
|
- |
{ |
38 |
|
- |
if ( mAlternateOptions == null ) |
39 |
|
- |
{ |
40 |
|
- |
new DialogViewDialog( ClientContext.get().get( RestrictedResourcePickerDialogViewFactory.class ).createDialog( Dialog.Opaqueness.Semi, mCallBack ) ).show(); |
|
33 |
+ |
public void onClick( ClickEvent pEvent ) { |
|
34 |
+ |
if ( mAlternateOptions == null ) { |
|
35 |
+ |
new DialogViewDialog( |
|
36 |
+ |
ClientContext.get().get( RestrictedResourcePickerDialogViewFactory.class ).createDialog( Dialog.Opaqueness.Semi, mCallBack ) ).show(); |
41 |
37 |
|
return; |
42 |
38 |
|
} |
43 |
39 |
|
|
44 |
40 |
|
// list |
45 |
41 |
|
String[] labels = new String[mAlternateOptions.length]; |
46 |
|
- |
for ( int i = 0; i < mAlternateOptions.length; i++ ) |
47 |
|
- |
{ |
|
42 |
+ |
for ( int i = 0; i < mAlternateOptions.length; i++ ) { |
48 |
43 |
|
labels[i] = mAlternateOptions[i].getName(); |
49 |
44 |
|
} |
50 |
45 |
|
ListTable list = new ListTable(); |
|
@@ -55,21 +50,17 @@ |
55 |
50 |
|
zPopup.addStyleName( "RestrictedResourcesPopupPanel" ); |
56 |
51 |
|
zPopup.setWidget( list ); |
57 |
52 |
|
|
58 |
|
- |
list.setClickCommand( new ObjectCommand<Integer>() |
59 |
|
- |
{ |
|
53 |
+ |
list.setClickCommand( new ObjectCommand<Integer>() { |
60 |
54 |
|
@Override |
61 |
|
- |
public void execute( Integer pIndex ) |
62 |
|
- |
{ |
|
55 |
+ |
public void execute( Integer pIndex ) { |
63 |
56 |
|
mCallBack.switchToRestrictedResource( mAlternateOptions[pIndex] ); |
64 |
57 |
|
zPopup.hide( false ); |
65 |
58 |
|
} |
66 |
59 |
|
} ); |
67 |
60 |
|
|
68 |
|
- |
zPopup.setPopupPositionAndShow( new PopupPanel.PositionCallback() |
69 |
|
- |
{ |
|
61 |
+ |
zPopup.setPopupPositionAndShow( new PopupPanel.PositionCallback() { |
70 |
62 |
|
@Override |
71 |
|
- |
public void setPosition( int offsetWidth, int offsetHeight ) |
72 |
|
- |
{ |
|
63 |
+ |
public void setPosition( int offsetWidth, int offsetHeight ) { |
73 |
64 |
|
int left = mPickerButton.getAbsoluteLeft() - 10; |
74 |
65 |
|
int top = mPickerButton.getAbsoluteTop() - offsetHeight; |
75 |
66 |
|
zPopup.setPopupPosition( left, top ); |
|
@@ -80,8 +71,7 @@ |
80 |
71 |
|
} |
81 |
72 |
|
|
82 |
73 |
|
@Override |
83 |
|
- |
public void setAlternateOptions( AlternateRestrictedResourceOption[] pAlternateOptions ) |
84 |
|
- |
{ |
|
74 |
+ |
public void setAlternateOptions( AlternateRestrictedResourceOption[] pAlternateOptions ) { |
85 |
75 |
|
mAlternateOptions = pAlternateOptions; |
86 |
76 |
|
boolean buttonEnabled = (mAlternateOptions == null) || (mAlternateOptions.length > 0); |
87 |
77 |
|
mPickerWidgetPanel.setPicker( buttonEnabled ? mPickerButton : null ); |