Subversion Repository Public Repository

litesoft

Diff Revisions 948 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/view/RestrictedResourceSwitcher.java

Diff revisions: vs.
  @@ -1,79 +1,79 @@
1 - package org.litesoft.GWT.client.view;
2 -
3 - import org.litesoft.GWT.client.*;
4 - import org.litesoft.GWT.client.widgets.*;
5 - import org.litesoft.bo.views.*;
6 - import org.litesoft.commonfoundation.typeutils.*;
7 - import org.litesoft.core.*;
8 - import org.litesoft.core.util.*;
9 -
10 - import com.google.gwt.event.dom.client.*;
11 - import com.google.gwt.user.client.ui.*;
12 -
13 - public class RestrictedResourceSwitcher implements AlternateOptionsView {
14 - private final OurImage mPickerButton = new OurImage( "common/images/misc/sites_button.gif" );
15 - private final AlternateOptionPickerWidgetPanel mPickerWidgetPanel;
16 - private final RestrictedResourceSwitcherCallBack mCallBack;
17 -
18 - /*
19 - * length = 0 means no alternative sites
20 - * length > 0 means alternative sites to display
21 - * null means dialog will be shown (due to too many to list)
22 - */
23 - private AlternateRestrictedResourceOption[] mAlternateOptions = new AlternateRestrictedResourceOption[0];
24 -
25 - public RestrictedResourceSwitcher( AlternateOptionPickerWidgetPanel pPickerWidgetPanel, RestrictedResourceSwitcherCallBack pCallBack ) {
26 - mPickerWidgetPanel = Objects.assertNotNull( "PickerWidgetPanel", pPickerWidgetPanel );
27 - mCallBack = Objects.assertNotNull( "CallBack", pCallBack );
28 -
29 - mPickerButton.setWidth( "13" );
30 - mPickerButton.setHeight( "14" );
31 - mPickerButton.addClickHandler( new ClickHandler() {
32 - @Override
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();
37 - return;
38 - }
39 -
40 - // list
41 - String[] labels = new String[mAlternateOptions.length];
42 - for ( int i = 0; i < mAlternateOptions.length; i++ ) {
43 - labels[i] = mAlternateOptions[i].getName();
44 - }
45 - ListTable list = new ListTable();
46 - list.setData( labels );
47 -
48 - // popup
49 - final PopupPanel zPopup = new PopupPanel( true, false );
50 - zPopup.addStyleName( "RestrictedResourcesPopupPanel" );
51 - zPopup.setWidget( list );
52 -
53 - list.setClickCommand( new ObjectCommand<Integer>() {
54 - @Override
55 - public void execute( Integer pIndex ) {
56 - mCallBack.switchToRestrictedResource( mAlternateOptions[pIndex] );
57 - zPopup.hide( false );
58 - }
59 - } );
60 -
61 - zPopup.setPopupPositionAndShow( new PopupPanel.PositionCallback() {
62 - @Override
63 - public void setPosition( int offsetWidth, int offsetHeight ) {
64 - int left = mPickerButton.getAbsoluteLeft() - 10;
65 - int top = mPickerButton.getAbsoluteTop() - offsetHeight;
66 - zPopup.setPopupPosition( left, top );
67 - }
68 - } );
69 - }
70 - } );
71 - }
72 -
73 - @Override
74 - public void setAlternateOptions( AlternateRestrictedResourceOption[] pAlternateOptions ) {
75 - mAlternateOptions = pAlternateOptions;
76 - boolean buttonEnabled = (mAlternateOptions == null) || (mAlternateOptions.length > 0);
77 - mPickerWidgetPanel.setPicker( buttonEnabled ? mPickerButton : null );
78 - }
79 - }
1 + package org.litesoft.GWT.client.view;
2 +
3 + import org.litesoft.GWT.client.*;
4 + import org.litesoft.GWT.client.widgets.*;
5 + import org.litesoft.bo.views.*;
6 + import org.litesoft.commonfoundation.base.*;
7 + import org.litesoft.core.*;
8 + import org.litesoft.core.util.*;
9 +
10 + import com.google.gwt.event.dom.client.*;
11 + import com.google.gwt.user.client.ui.*;
12 +
13 + public class RestrictedResourceSwitcher implements AlternateOptionsView {
14 + private final OurImage mPickerButton = new OurImage( "common/images/misc/sites_button.gif" );
15 + private final AlternateOptionPickerWidgetPanel mPickerWidgetPanel;
16 + private final RestrictedResourceSwitcherCallBack mCallBack;
17 +
18 + /*
19 + * length = 0 means no alternative sites
20 + * length > 0 means alternative sites to display
21 + * null means dialog will be shown (due to too many to list)
22 + */
23 + private AlternateRestrictedResourceOption[] mAlternateOptions = new AlternateRestrictedResourceOption[0];
24 +
25 + public RestrictedResourceSwitcher( AlternateOptionPickerWidgetPanel pPickerWidgetPanel, RestrictedResourceSwitcherCallBack pCallBack ) {
26 + mPickerWidgetPanel = Confirm.isNotNull( "PickerWidgetPanel", pPickerWidgetPanel );
27 + mCallBack = Confirm.isNotNull( "CallBack", pCallBack );
28 +
29 + mPickerButton.setWidth( "13" );
30 + mPickerButton.setHeight( "14" );
31 + mPickerButton.addClickHandler( new ClickHandler() {
32 + @Override
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();
37 + return;
38 + }
39 +
40 + // list
41 + String[] labels = new String[mAlternateOptions.length];
42 + for ( int i = 0; i < mAlternateOptions.length; i++ ) {
43 + labels[i] = mAlternateOptions[i].getName();
44 + }
45 + ListTable list = new ListTable();
46 + list.setData( labels );
47 +
48 + // popup
49 + final PopupPanel zPopup = new PopupPanel( true, false );
50 + zPopup.addStyleName( "RestrictedResourcesPopupPanel" );
51 + zPopup.setWidget( list );
52 +
53 + list.setClickCommand( new ObjectCommand<Integer>() {
54 + @Override
55 + public void execute( Integer pIndex ) {
56 + mCallBack.switchToRestrictedResource( mAlternateOptions[pIndex] );
57 + zPopup.hide( false );
58 + }
59 + } );
60 +
61 + zPopup.setPopupPositionAndShow( new PopupPanel.PositionCallback() {
62 + @Override
63 + public void setPosition( int offsetWidth, int offsetHeight ) {
64 + int left = mPickerButton.getAbsoluteLeft() - 10;
65 + int top = mPickerButton.getAbsoluteTop() - offsetHeight;
66 + zPopup.setPopupPosition( left, top );
67 + }
68 + } );
69 + }
70 + } );
71 + }
72 +
73 + @Override
74 + public void setAlternateOptions( AlternateRestrictedResourceOption[] pAlternateOptions ) {
75 + mAlternateOptions = pAlternateOptions;
76 + boolean buttonEnabled = (mAlternateOptions == null) || (mAlternateOptions.length > 0);
77 + mPickerWidgetPanel.setPicker( buttonEnabled ? mPickerButton : null );
78 + }
79 + }