Subversion Repository Public Repository

litesoft

Diff Revisions 948 vs 950 for /trunk/Java/DATT/src/org/litesoft/datt/client/RestrictedResourceSwitcher.java

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