Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/client/taskbar/FavoritesContextMenu.java

Diff revisions: vs.
  @@ -1,208 +1,208 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client.taskbar;
3 -
4 - import org.litesoft.GWT.client.*;
5 - import org.litesoft.GWT.client.iconservice.*;
6 - import org.litesoft.GWT.client.widgets.*;
7 - import org.litesoft.GWT.client.widgets.nonpublic.*;
8 -
9 - import com.google.gwt.user.client.*;
10 - import com.google.gwt.user.client.ui.*;
11 -
12 - public class FavoritesContextMenu extends PopupPanel {
13 - private boolean isHorizontal;
14 - Grid mGrid;
15 - private static final int ADDITIONAL_OFFSET = 22; // 16
16 - private static final int PADDING = 5;
17 -
18 - public FavoritesContextMenu( boolean autoHide, final TaskbarHelper pHelper,
19 - final TaskbarItem pTaskbarItem ) {
20 - super( autoHide );
21 -
22 - final boolean isFirstItem = pHelper.isFirstFavoriteItem( pTaskbarItem );
23 - final boolean isLastItem = pHelper.isLastFavoriteItem( pTaskbarItem );
24 -
25 - isHorizontal = pHelper.isPositionHorizontal();
26 -
27 - if ( isHorizontal ) {
28 - mGrid = new Grid( 1, 3 );
29 -
30 - if ( isFirstItem ) {
31 - mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_left-Disabled.gif" ) ) );
32 - } else {
33 - mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_left.gif" ) ) );
34 - }
35 -
36 - if ( isLastItem ) {
37 - mGrid.setWidget( 0, 2, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_right-Disabled.gif" ) ) );
38 - } else {
39 - mGrid.setWidget( 0, 2, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_right.gif" ) ) );
40 - }
41 -
42 - mGrid.setWidget( 0, 1, new OneCellTable( new Image( "images/remove_red.gif" ) ) );
43 -
44 - mGrid.addTableListener( new TableListener() {
45 - public void onCellClicked( SourcesTableEvents sender, int row, int cell ) {
46 - FavoritesManager favoritesManager = FavoritesManager.INSTANCE;
47 - switch ( cell ) {
48 - case 0:
49 - if ( !isFirstItem ) {
50 - favoritesManager.moveFavoriteUp( pTaskbarItem );
51 - }
52 - break;
53 - case 1:
54 - favoritesManager.removeFavorite( pTaskbarItem );
55 - break;
56 - case 2:
57 - if ( !isLastItem ) {
58 - favoritesManager.moveFavoriteDown( pTaskbarItem );
59 - }
60 - break;
61 - default:
62 - break;
63 - }
64 - hide();
65 - pHelper.hidePopup();
66 - }
67 - } );
68 - } else {
69 - mGrid = new Grid( 3, 1 );
70 -
71 - if ( isFirstItem ) {
72 - mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_up-Disabled.gif" ) ) );
73 - } else {
74 - mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_up.gif" ) ) );
75 - }
76 -
77 - if ( isLastItem ) {
78 - mGrid.setWidget( 2, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_down-Disabled.gif" ) ) );
79 - } else {
80 - mGrid.setWidget( 2, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_down.gif" ) ) );
81 - }
82 -
83 - mGrid.setWidget( 1, 0, new OneCellTable( new Image( "images/remove_red.gif" ) ) );
84 -
85 - mGrid.addTableListener( new TableListener() {
86 - public void onCellClicked( SourcesTableEvents sender, int row, int cell ) {
87 - FavoritesManager favoritesManager = FavoritesManager.INSTANCE;
88 - switch ( row ) {
89 - case 0:
90 - if ( !isFirstItem ) {
91 - favoritesManager.moveFavoriteUp( pTaskbarItem );
92 - }
93 - break;
94 - case 1:
95 - favoritesManager.removeFavorite( pTaskbarItem );
96 - break;
97 - case 2:
98 - if ( !isLastItem ) {
99 - favoritesManager.moveFavoriteDown( pTaskbarItem );
100 - }
101 - break;
102 - default:
103 - break;
104 - }
105 - hide();
106 - pHelper.hidePopup();
107 - }
108 - } );
109 - }
110 - add( mGrid );
111 - }
112 -
113 - public void showContextMenu( final int pSenderAbsoluteLeft, final int pSenderAbsoluteTop ) {
114 - setPopupPositionAndShow( new PopupPanel.PositionCallback() {
115 - public void setPosition( int offsetWidth, int offsetHeight ) {
116 - int popupPositionX = 0;
117 - int popupPositionY = 0;
118 -
119 - int clientWidth = Window.getClientWidth();
120 - int clientHeight = Window.getClientHeight();
121 -
122 - if ( isHorizontal ) {
123 - if ( (pSenderAbsoluteLeft + offsetWidth) > clientWidth ) {
124 - popupPositionX = pSenderAbsoluteLeft - offsetWidth;
125 - } else {
126 - popupPositionX = pSenderAbsoluteLeft;
127 - }
128 -
129 - if ( (pSenderAbsoluteTop + offsetHeight + PADDING) > clientHeight ) {
130 - popupPositionY = pSenderAbsoluteTop - offsetHeight;
131 - } else {
132 - popupPositionY = pSenderAbsoluteTop + ADDITIONAL_OFFSET;
133 - }
134 - } else {
135 - if ( (pSenderAbsoluteLeft + offsetWidth + PADDING) > clientWidth ) {
136 - popupPositionX = pSenderAbsoluteLeft - offsetWidth;
137 - } else {
138 - popupPositionX = pSenderAbsoluteLeft + ADDITIONAL_OFFSET;
139 - }
140 -
141 - if ( (pSenderAbsoluteTop + offsetHeight) > clientHeight ) {
142 - popupPositionY = pSenderAbsoluteTop - offsetHeight;
143 - } else {
144 - popupPositionY = pSenderAbsoluteTop;
145 - }
146 - }
147 -
148 - setPopupPosition( popupPositionX, popupPositionY );
149 - }
150 - } );
151 - }
152 -
153 - private class OneCellTable extends TightGrid {
154 - public OneCellTable( Image pImage ) {
155 - super( 1, 1 );
156 - setWidget( 0, 0, pImage );
157 - DOM.setElementAttribute( getElement(), "width", "22" );
158 - DOM.setElementAttribute( getElement(), "height", "22" );
159 - addStyleName( "OneCellTable" );
160 -
161 - setOnBrowserEventListener( Event.MOUSEEVENTS, new OnBrowserEventListener() {
162 - public boolean onBrowserEvent( Event event ) {
163 - switch ( DOM.eventGetType( event ) ) {
164 - case Event.ONMOUSEUP:
165 - UtilsGwt.eventPreventDefaultAndCancelBubble( event );
166 -
167 - cleanStyles();
168 - addStyleName( "OneCellTable-MouseUp" );
169 - break;
170 -
171 - case Event.ONMOUSEOVER:
172 - UtilsGwt.eventPreventDefaultAndCancelBubble( event );
173 -
174 - cleanStyles();
175 - addStyleName( "OneCellTable-MouseOver" );
176 - break;
177 -
178 - case Event.ONMOUSEOUT:
179 - UtilsGwt.eventPreventDefaultAndCancelBubble( event );
180 -
181 - cleanStyles();
182 - addStyleName( "OneCellTable-MouseOut" );
183 - break;
184 -
185 - case Event.ONMOUSEDOWN:
186 - UtilsGwt.eventPreventDefaultAndCancelBubble( event );
187 -
188 - cleanStyles();
189 - addStyleName( "OneCellTable-MouseDown" );
190 - break;
191 -
192 - case Event.ONMOUSEMOVE:
193 - default:
194 - break;
195 - }
196 - return false;
197 - }
198 - } );
199 - }
200 -
201 - private void cleanStyles() {
202 - removeStyleName( "OneCellTable-MouseUp" );
203 - removeStyleName( "OneCellTable-MouseOver" );
204 - removeStyleName( "OneCellTable-MouseOut" );
205 - removeStyleName( "OneCellTable-MouseDown" );
206 - }
207 - }
208 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client.taskbar;
3 +
4 + import org.litesoft.GWT.client.*;
5 + import org.litesoft.GWT.client.iconservice.*;
6 + import org.litesoft.GWT.client.widgets.*;
7 + import org.litesoft.GWT.client.widgets.nonpublic.*;
8 +
9 + import com.google.gwt.user.client.*;
10 + import com.google.gwt.user.client.ui.*;
11 +
12 + public class FavoritesContextMenu extends PopupPanel {
13 + private boolean isHorizontal;
14 + Grid mGrid;
15 + private static final int ADDITIONAL_OFFSET = 22; // 16
16 + private static final int PADDING = 5;
17 +
18 + public FavoritesContextMenu( boolean autoHide, final TaskbarHelper pHelper,
19 + final TaskbarItem pTaskbarItem ) {
20 + super( autoHide );
21 +
22 + final boolean isFirstItem = pHelper.isFirstFavoriteItem( pTaskbarItem );
23 + final boolean isLastItem = pHelper.isLastFavoriteItem( pTaskbarItem );
24 +
25 + isHorizontal = pHelper.isPositionHorizontal();
26 +
27 + if ( isHorizontal ) {
28 + mGrid = new Grid( 1, 3 );
29 +
30 + if ( isFirstItem ) {
31 + mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_left-Disabled.gif" ) ) );
32 + } else {
33 + mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_left.gif" ) ) );
34 + }
35 +
36 + if ( isLastItem ) {
37 + mGrid.setWidget( 0, 2, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_right-Disabled.gif" ) ) );
38 + } else {
39 + mGrid.setWidget( 0, 2, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_right.gif" ) ) );
40 + }
41 +
42 + mGrid.setWidget( 0, 1, new OneCellTable( new Image( "images/remove_red.gif" ) ) );
43 +
44 + mGrid.addTableListener( new TableListener() {
45 + public void onCellClicked( SourcesTableEvents sender, int row, int cell ) {
46 + FavoritesManager favoritesManager = FavoritesManager.INSTANCE;
47 + switch ( cell ) {
48 + case 0:
49 + if ( !isFirstItem ) {
50 + favoritesManager.moveFavoriteUp( pTaskbarItem );
51 + }
52 + break;
53 + case 1:
54 + favoritesManager.removeFavorite( pTaskbarItem );
55 + break;
56 + case 2:
57 + if ( !isLastItem ) {
58 + favoritesManager.moveFavoriteDown( pTaskbarItem );
59 + }
60 + break;
61 + default:
62 + break;
63 + }
64 + hide();
65 + pHelper.hidePopup();
66 + }
67 + } );
68 + } else {
69 + mGrid = new Grid( 3, 1 );
70 +
71 + if ( isFirstItem ) {
72 + mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_up-Disabled.gif" ) ) );
73 + } else {
74 + mGrid.setWidget( 0, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_up.gif" ) ) );
75 + }
76 +
77 + if ( isLastItem ) {
78 + mGrid.setWidget( 2, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_down-Disabled.gif" ) ) );
79 + } else {
80 + mGrid.setWidget( 2, 0, new OneCellTable( new Image( "common/images/windowbar/favcontext/arrow_down.gif" ) ) );
81 + }
82 +
83 + mGrid.setWidget( 1, 0, new OneCellTable( new Image( "images/remove_red.gif" ) ) );
84 +
85 + mGrid.addTableListener( new TableListener() {
86 + public void onCellClicked( SourcesTableEvents sender, int row, int cell ) {
87 + FavoritesManager favoritesManager = FavoritesManager.INSTANCE;
88 + switch ( row ) {
89 + case 0:
90 + if ( !isFirstItem ) {
91 + favoritesManager.moveFavoriteUp( pTaskbarItem );
92 + }
93 + break;
94 + case 1:
95 + favoritesManager.removeFavorite( pTaskbarItem );
96 + break;
97 + case 2:
98 + if ( !isLastItem ) {
99 + favoritesManager.moveFavoriteDown( pTaskbarItem );
100 + }
101 + break;
102 + default:
103 + break;
104 + }
105 + hide();
106 + pHelper.hidePopup();
107 + }
108 + } );
109 + }
110 + add( mGrid );
111 + }
112 +
113 + public void showContextMenu( final int pSenderAbsoluteLeft, final int pSenderAbsoluteTop ) {
114 + setPopupPositionAndShow( new PopupPanel.PositionCallback() {
115 + public void setPosition( int offsetWidth, int offsetHeight ) {
116 + int popupPositionX = 0;
117 + int popupPositionY = 0;
118 +
119 + int clientWidth = Window.getClientWidth();
120 + int clientHeight = Window.getClientHeight();
121 +
122 + if ( isHorizontal ) {
123 + if ( (pSenderAbsoluteLeft + offsetWidth) > clientWidth ) {
124 + popupPositionX = pSenderAbsoluteLeft - offsetWidth;
125 + } else {
126 + popupPositionX = pSenderAbsoluteLeft;
127 + }
128 +
129 + if ( (pSenderAbsoluteTop + offsetHeight + PADDING) > clientHeight ) {
130 + popupPositionY = pSenderAbsoluteTop - offsetHeight;
131 + } else {
132 + popupPositionY = pSenderAbsoluteTop + ADDITIONAL_OFFSET;
133 + }
134 + } else {
135 + if ( (pSenderAbsoluteLeft + offsetWidth + PADDING) > clientWidth ) {
136 + popupPositionX = pSenderAbsoluteLeft - offsetWidth;
137 + } else {
138 + popupPositionX = pSenderAbsoluteLeft + ADDITIONAL_OFFSET;
139 + }
140 +
141 + if ( (pSenderAbsoluteTop + offsetHeight) > clientHeight ) {
142 + popupPositionY = pSenderAbsoluteTop - offsetHeight;
143 + } else {
144 + popupPositionY = pSenderAbsoluteTop;
145 + }
146 + }
147 +
148 + setPopupPosition( popupPositionX, popupPositionY );
149 + }
150 + } );
151 + }
152 +
153 + private class OneCellTable extends TightGrid {
154 + public OneCellTable( Image pImage ) {
155 + super( 1, 1 );
156 + setWidget( 0, 0, pImage );
157 + DOM.setElementAttribute( getElement(), "width", "22" );
158 + DOM.setElementAttribute( getElement(), "height", "22" );
159 + addStyleName( "OneCellTable" );
160 +
161 + setOnBrowserEventListener( Event.MOUSEEVENTS, new OnBrowserEventListener() {
162 + public boolean onBrowserEvent( Event event ) {
163 + switch ( DOM.eventGetType( event ) ) {
164 + case Event.ONMOUSEUP:
165 + UtilsGwt.eventPreventDefaultAndCancelBubble( event );
166 +
167 + cleanStyles();
168 + addStyleName( "OneCellTable-MouseUp" );
169 + break;
170 +
171 + case Event.ONMOUSEOVER:
172 + UtilsGwt.eventPreventDefaultAndCancelBubble( event );
173 +
174 + cleanStyles();
175 + addStyleName( "OneCellTable-MouseOver" );
176 + break;
177 +
178 + case Event.ONMOUSEOUT:
179 + UtilsGwt.eventPreventDefaultAndCancelBubble( event );
180 +
181 + cleanStyles();
182 + addStyleName( "OneCellTable-MouseOut" );
183 + break;
184 +
185 + case Event.ONMOUSEDOWN:
186 + UtilsGwt.eventPreventDefaultAndCancelBubble( event );
187 +
188 + cleanStyles();
189 + addStyleName( "OneCellTable-MouseDown" );
190 + break;
191 +
192 + case Event.ONMOUSEMOVE:
193 + default:
194 + break;
195 + }
196 + return false;
197 + }
198 + } );
199 + }
200 +
201 + private void cleanStyles() {
202 + removeStyleName( "OneCellTable-MouseUp" );
203 + removeStyleName( "OneCellTable-MouseOver" );
204 + removeStyleName( "OneCellTable-MouseOut" );
205 + removeStyleName( "OneCellTable-MouseDown" );
206 + }
207 + }
208 + }