litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
package org.litesoft.initfrom.client;
import org.litesoft.GWT.client.*;
import org.litesoft.GWT.client.view.*;
import org.litesoft.GWT.client.widgets.*;
import org.litesoft.bo.views.*;
import org.litesoft.core.util.*;
import org.litesoft.initfrom.client.ui.views.*;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.*;
public class RestrictedResourceSwitcher implements AlternateOptionsView
{
private final OurImage mPickerButton = new OurImage( "common/images/misc/sites_button.gif" );
private final AlternateOptionPickerWidgetPanel mPickerWidgetPanel;
private final CallBack mCallBack;
/*
* length = 0 means no alternative sites
* length > 0 means alternative sites to display
* null means dialog will be shown (due to too many to list)
*/
private AlternateRestrictedResourceOption[] mAlternateOptions = new AlternateRestrictedResourceOption[0];
public RestrictedResourceSwitcher( AlternateOptionPickerWidgetPanel pPickerWidgetPanel, CallBack pCallBack )
{
mPickerWidgetPanel = UtilsCommon.assertNotNull( "PickerWidgetPanel", pPickerWidgetPanel );
mCallBack = UtilsCommon.assertNotNull( "CallBack", pCallBack );
mPickerButton.setWidth( "13" );
mPickerButton.setHeight( "14" );
mPickerButton.addClickHandler( new ClickHandler()
{
@Override
public void onClick( ClickEvent pEvent )
{
if ( mAlternateOptions == null )
{
new DialogViewDialog( new RestrictedResourcePickerDialog( Dialog.Opaqueness.Semi, mCallBack ) ).show();
return;
}
// list
String[] labels = new String[mAlternateOptions.length];
for ( int i = 0; i < mAlternateOptions.length; i++ )
{
labels[i] = mAlternateOptions[i].getName();
}
ListTable list = new ListTable();
list.setData( labels );
// popup
final PopupPanel zPopup = new PopupPanel( true, false );
zPopup.addStyleName( "RestrictedResourcesPopupPanel" );
zPopup.setWidget( list );
list.setClickCommand( new ObjectCommand<Integer>()
{
@Override
public void execute( Integer pIndex )
{
mCallBack.switchToRestrictedResource( mAlternateOptions[pIndex] );
zPopup.hide( false );
}
} );
zPopup.setPopupPositionAndShow( new PopupPanel.PositionCallback()
{
@Override
public void setPosition( int offsetWidth, int offsetHeight )
{
int left = mPickerButton.getAbsoluteLeft() - 10;
int top = mPickerButton.getAbsoluteTop() - offsetHeight;
zPopup.setPopupPosition( left, top );
}
} );
}
} );
}
@Override
public void setAlternateOptions( AlternateRestrictedResourceOption[] pAlternateOptions )
{
mAlternateOptions = pAlternateOptions;
boolean buttonEnabled = (mAlternateOptions == null) || (mAlternateOptions.length > 0);
mPickerWidgetPanel.setPicker( buttonEnabled ? mPickerButton : null );
}
public static interface CallBack
{
void switchToRestrictedResource( AlternateRestrictedResourceOption pAlternateOption );
}
}
|
Revision |
Author |
Commited |
Message |
459
|
GeorgeS
|
Sun 21 Aug, 2011 00:42:41 +0000 |
|