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