Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/client/taskbar/TaskbarHelper.java

Diff revisions: vs.
  @@ -1,19 +1,18 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.GWT.client.taskbar;
3 3
4 - import java.util.*;
5 -
6 4 import org.litesoft.GWT.client.*;
7 5 import org.litesoft.GWT.client.iconservice.*;
8 6 import org.litesoft.GWT.client.nonpublic.*;
9 7 import org.litesoft.GWT.client.widgets.*;
10 8 import org.litesoft.GWT.client.widgets.nonpublic.*;
11 9
12 - import com.google.gwt.user.client.ui.*;
13 10 import com.google.gwt.user.client.*;
11 + import com.google.gwt.user.client.ui.*;
12 +
13 + import java.util.*;
14 14
15 - public class TaskbarHelper implements FloatableContainerListener
16 - {
15 + public class TaskbarHelper implements FloatableContainerListener {
17 16 private NEWSposition mPosition;
18 17 private List mFavorites = new ArrayList();
19 18 private List mTasks = new ArrayList();
  @@ -30,28 +29,22 @@
30 29 private TaskbarDockingPanel mTaskbarDockingPanel;
31 30 private HashMap mFloaterToTaskbarItemMap = new HashMap();
32 31
33 - public TaskbarHelper( FloaterFactoryFactory pFloaterFactoryFactory )
34 - {
32 + public TaskbarHelper( FloaterFactoryFactory pFloaterFactoryFactory ) {
35 33 mFloaterFactoryFactory = pFloaterFactoryFactory;
36 34
37 35 mPopup = new PopupPanel( true );
38 36 mPopupImage = new PopupImage();
39 37
40 - mPopupImage.addClickListener( new ClickListener()
41 - {
42 - public void onClick( Widget sender )
43 - {
38 + mPopupImage.addClickListener( new ClickListener() {
39 + public void onClick( Widget sender ) {
44 40 mPopupImage.click( sender );
45 41 }
46 42 } );
47 43
48 - mPopupImage.addMouseListener( new MouseListenerAdapter()
49 - {
50 - public void onMouseLeave( Widget sender )
51 - {
44 + mPopupImage.addMouseListener( new MouseListenerAdapter() {
45 + public void onMouseLeave( Widget sender ) {
52 46 // Element toElement = DOM.eventGetToElement( DOM.eventGetCurrentEvent() );
53 - if ( !mContextMenuIsShown )
54 - {
47 + if ( !mContextMenuIsShown ) {
55 48 hidePopup();
56 49 showTaskbarImage( getLastItem() );
57 50 }
  @@ -61,38 +54,31 @@
61 54 mPopup.setPixelSize( POPUP_WIDTH, POPUP_HEIGHT );
62 55 }
63 56
64 - public TaskbarHelper getTaskbarHelper()
65 - {
57 + public TaskbarHelper getTaskbarHelper() {
66 58 return this;
67 59 }
68 60
69 - public void setPosition( NEWSposition pPosition )
70 - {
61 + public void setPosition( NEWSposition pPosition ) {
71 62 mPosition = pPosition;
72 63 }
73 64
74 - public void setTaskbarDockingPanel( TaskbarDockingPanel pTaskbarDockingPanel )
75 - {
65 + public void setTaskbarDockingPanel( TaskbarDockingPanel pTaskbarDockingPanel ) {
76 66 mTaskbarDockingPanel = pTaskbarDockingPanel;
77 67 }
78 68
79 - public TaskbarDockingPanel getTaskbarDockingPanel()
80 - {
69 + public TaskbarDockingPanel getTaskbarDockingPanel() {
81 70 return mTaskbarDockingPanel;
82 71 }
83 72
84 - public boolean isFirstFavoriteItem( TaskbarItem pTaskbarItem )
85 - {
73 + public boolean isFirstFavoriteItem( TaskbarItem pTaskbarItem ) {
86 74 return mFavorites.indexOf( pTaskbarItem ) == 0;
87 75 }
88 76
89 - public boolean isLastFavoriteItem( TaskbarItem pTaskbarItem )
90 - {
77 + public boolean isLastFavoriteItem( TaskbarItem pTaskbarItem ) {
91 78 return mFavorites.indexOf( pTaskbarItem ) == (mFavorites.size() - 1);
92 79 }
93 80
94 - public void addToTasks( SizeableFloater pFloater, TaskbarEntry pTaskbarEntry )
95 - {
81 + public void addToTasks( SizeableFloater pFloater, TaskbarEntry pTaskbarEntry ) {
96 82 TaskbarItem taskbarItem = new TaskbarFloaterItem( this, (TaskbarFloaterEntry) pTaskbarEntry );
97 83
98 84 mFloaterToTaskbarItemMap.put( pFloater, taskbarItem );
  @@ -102,12 +88,10 @@
102 88 mItemsPanel.relayout();
103 89 }
104 90
105 - public void removeFromTasks( SizeableFloater pFloater )
106 - {
91 + public void removeFromTasks( SizeableFloater pFloater ) {
107 92
108 93 TaskbarItem taskbarItem = (TaskbarItem) mFloaterToTaskbarItemMap.get( pFloater );
109 - if ( taskbarItem != null )
110 - {
94 + if ( taskbarItem != null ) {
111 95 mTasks.remove( taskbarItem );
112 96 mItemsPanel.remove( taskbarItem.getTaskbarWidget() );
113 97 mItemsPanel.relayout();
  @@ -115,32 +99,26 @@
115 99 mFloaterToTaskbarItemMap.remove( pFloater );
116 100 }
117 101
118 - public TaskbarItem[] getFavorites()
119 - {
102 + public TaskbarItem[] getFavorites() {
120 103 return toArray( mFavorites );
121 104 }
122 105
123 - public TaskbarItem[] getTasks()
124 - {
106 + public TaskbarItem[] getTasks() {
125 107 return toArray( mTasks );
126 108 }
127 109
128 - private TaskbarItem[] toArray( List pList )
129 - {
110 + private TaskbarItem[] toArray( List pList ) {
130 111 TaskbarItem[] rv = new TaskbarItem[pList.size()];
131 - for ( int i = 0; i < pList.size(); i++ )
132 - {
112 + for ( int i = 0; i < pList.size(); i++ ) {
133 113 rv[i] = (TaskbarItem) pList.get( i );
134 114 }
135 115 return rv;
136 116 }
137 117
138 - public void addTo( AbstractSizeableOneDimensionalPanel pPanel, String pSeparatorURL )
139 - {
118 + public void addTo( AbstractSizeableOneDimensionalPanel pPanel, String pSeparatorURL ) {
140 119 mItemsPanel = pPanel;
141 120 TaskbarItem[] items = getFavorites();
142 - for ( int i = 0; i < items.length; i++ )
143 - {
121 + for ( int i = 0; i < items.length; i++ ) {
144 122 pPanel.add( items[i].getTaskbarWidget() );
145 123 }
146 124
  @@ -148,41 +126,33 @@
148 126 pPanel.add( mSeparator );
149 127
150 128 items = getTasks();
151 - for ( int i = 0; i < items.length; i++ )
152 - {
129 + for ( int i = 0; i < items.length; i++ ) {
153 130 pPanel.add( items[i].getTaskbarWidget() );
154 131 }
155 132 }
156 133
157 - public void bringToFront( TaskbarItem pItem )
158 - {
134 + public void bringToFront( TaskbarItem pItem ) {
159 135 pItem.bringToFront();
160 136 }
161 137
162 - public void manageFloater( TaskbarItem pItem )
163 - {
138 + public void manageFloater( TaskbarItem pItem ) {
164 139 pItem.manageFloater();
165 140 }
166 141
167 - public void updateFavoritesDisplay( List pFavorites )
168 - {
142 + public void updateFavoritesDisplay( List pFavorites ) {
169 143 mFavorites.clear();
170 144
171 - for ( int j = 0; j < (pFavorites.size()); j++ )
172 - {
145 + for ( int j = 0; j < (pFavorites.size()); j++ ) {
173 146 mFavorites.add( new TaskbarFavoriteItem( this, (TaskbarFavoriteEntry) pFavorites.get( j ) ) );
174 147 }
175 148
176 - if ( mItemsPanel != null )
177 - {
149 + if ( mItemsPanel != null ) {
178 150 int separatorIndex = mItemsPanel.getWidgetIndex( mSeparator );
179 - for ( int i = separatorIndex - 1; i >= 0; i-- )
180 - {
151 + for ( int i = separatorIndex - 1; i >= 0; i-- ) {
181 152 mItemsPanel.remove( i );
182 153 }
183 154
184 - for ( int j = 0; j < (mFavorites.size()); j++ )
185 - {
155 + for ( int j = 0; j < (mFavorites.size()); j++ ) {
186 156 TaskbarItem item = (TaskbarItem) mFavorites.get( j );
187 157 mItemsPanel.insert( item.getTaskbarWidget(), mItemsPanel.getWidgetIndex( mSeparator ) );
188 158 }
  @@ -190,20 +160,17 @@
190 160 }
191 161 }
192 162
193 - public boolean isPositionHorizontal()
194 - {
163 + public boolean isPositionHorizontal() {
195 164 return mPosition.isNorthOrSouth();
196 165 }
197 166
198 167 private TaskbarItem mLastItem = null;
199 168
200 - public TaskbarItem getLastItem()
201 - {
169 + public TaskbarItem getLastItem() {
202 170 return mLastItem;
203 171 }
204 172
205 - public void showPopup( TaskbarItem pItem )
206 - {
173 + public void showPopup( TaskbarItem pItem ) {
207 174 showTaskbarImage( getLastItem() );
208 175 mLastItem = pItem;
209 176 mPopup.hide();
  @@ -216,29 +183,20 @@
216 183 int zWidthDiff = POPUP_WIDTH - widget.getOffsetWidth();
217 184 int zHeightDiff = POPUP_HEIGHT - widget.getOffsetHeight();
218 185
219 - if ( isPositionHorizontal() )
220 - {
186 + if ( isPositionHorizontal() ) {
221 187 newLeft = widget.getAbsoluteLeft() - (zWidthDiff / 2);
222 188
223 - if ( (widget.getAbsoluteTop() + POPUP_HEIGHT) > (Window.getClientHeight() - 9) )
224 - {
189 + if ( (widget.getAbsoluteTop() + POPUP_HEIGHT) > (Window.getClientHeight() - 9) ) {
225 190 newTop = widget.getAbsoluteTop() - (POPUP_HEIGHT - widget.getOffsetHeight());
226 - }
227 - else
228 - {
191 + } else {
229 192 newTop = widget.getAbsoluteTop();
230 193 }
231 - }
232 - else
233 - {
194 + } else {
234 195 newTop = widget.getAbsoluteTop() - (zHeightDiff / 2);
235 196
236 - if ( (widget.getAbsoluteLeft() + POPUP_WIDTH) > (Window.getClientWidth() - 9) )
237 - {
197 + if ( (widget.getAbsoluteLeft() + POPUP_WIDTH) > (Window.getClientWidth() - 9) ) {
238 198 newLeft = widget.getAbsoluteLeft() - (POPUP_WIDTH - widget.getOffsetWidth());
239 - }
240 - else
241 - {
199 + } else {
242 200 newLeft = widget.getAbsoluteLeft();
243 201 }
244 202 }
  @@ -248,131 +206,100 @@
248 206 hideTaskbarImage( pItem );
249 207 }
250 208
251 - private void hideTaskbarImage( TaskbarItem pItem )
252 - {
209 + private void hideTaskbarImage( TaskbarItem pItem ) {
253 210 DOM.setStyleAttribute( pItem.getTaskbarWidget().getElement(), "visibility", "hidden" );
254 211 }
255 212
256 - private void showTaskbarImage()
257 - {
258 - if ( mItem != null )
259 - {
213 + private void showTaskbarImage() {
214 + if ( mItem != null ) {
260 215 DOM.setStyleAttribute( mItem.getTaskbarWidget().getElement(), "visibility", "visible" );
261 216 }
262 217 }
263 218
264 - private void showTaskbarImage( TaskbarItem pItem )
265 - {
266 - if ( pItem != null )
267 - {
219 + private void showTaskbarImage( TaskbarItem pItem ) {
220 + if ( pItem != null ) {
268 221 DOM.setStyleAttribute( pItem.getTaskbarWidget().getElement(), "visibility", "visible" );
269 222 }
270 223 }
271 224
272 - public void hidePopup()
273 - {
225 + public void hidePopup() {
274 226 mPopup.hide();
275 227 teardownForPopup();
276 228 }
277 229
278 - public void setupForPopup( boolean pFavorite, TaskbarItem pTaskbarItem )
279 - {
230 + public void setupForPopup( boolean pFavorite, TaskbarItem pTaskbarItem ) {
280 231 mIsFavorite = pFavorite;
281 232 mItem = pTaskbarItem;
282 233 }
283 234
284 - private void teardownForPopup()
285 - {
235 + private void teardownForPopup() {
286 236 mIsFavorite = false;
287 237 mItem = null;
288 238 mPopupImage.setUrl( "common/images/misc/TransparentSpacer.gif" );
289 239 }
290 240
291 - public void floaterAdded( SizeableFloater pFloater )
292 - {
293 - if ( pFloater instanceof ITaskbarFloaterManageable )
294 - {
241 + public void floaterAdded( SizeableFloater pFloater ) {
242 + if ( pFloater instanceof ITaskbarFloaterManageable ) {
295 243 addToTasks( pFloater, new TaskbarFloaterEntry( (ITaskbarFloaterManageable) pFloater ) );
296 244 }
297 245 }
298 246
299 - public void floaterRemoved( SizeableFloater pFloater )
300 - {
247 + public void floaterRemoved( SizeableFloater pFloater ) {
301 248 removeFromTasks( pFloater );
302 249 }
303 250
304 - public void setActive( SizeableFloater pFloater )
305 - {
251 + public void setActive( SizeableFloater pFloater ) {
306 252 BackgroundCellForTaskbarItem widgetForFloater =
307 253 (BackgroundCellForTaskbarItem) getTaskbarWidgetForFloater( pFloater );
308 - if ( widgetForFloater != null )
309 - {
254 + if ( widgetForFloater != null ) {
310 255 widgetForFloater.setActiveStyle();
311 256 }
312 257 }
313 258
314 - public void clearActive( SizeableFloater pFloater )
315 - {
259 + public void clearActive( SizeableFloater pFloater ) {
316 260 BackgroundCellForTaskbarItem widgetForFloater =
317 261 (BackgroundCellForTaskbarItem) getTaskbarWidgetForFloater( pFloater );
318 - if ( widgetForFloater != null )
319 - {
262 + if ( widgetForFloater != null ) {
320 263 widgetForFloater.setRegularStyle();
321 264 }
322 265 }
323 266
324 - private Widget getTaskbarWidgetForFloater( SizeableFloater pFloater )
325 - {
267 + private Widget getTaskbarWidgetForFloater( SizeableFloater pFloater ) {
326 268 TaskbarItem zTaskbarItem = (TaskbarItem) mFloaterToTaskbarItemMap.get( pFloater );
327 - if ( zTaskbarItem != null )
328 - {
269 + if ( zTaskbarItem != null ) {
329 270 return zTaskbarItem.getTaskbarWidget();
330 - }
331 - else
332 - {
271 + } else {
333 272 return null;
334 273 }
335 274 }
336 275
337 - public void click( Widget sender )
338 - {
276 + public void click( Widget sender ) {
339 277 mPopupImage.click( sender );
340 278 }
341 279
342 - private class PopupImage extends OurImage
343 - {
344 - public void click( Widget sender )
345 - {
346 - if ( mIsFavorite )
347 - {
280 + private class PopupImage extends OurImage {
281 + public void click( Widget sender ) {
282 + if ( mIsFavorite ) {
348 283 clickFavorite( sender );
349 - }
350 - else
351 - {
284 + } else {
352 285 clickItem();
353 286 }
354 287 }
355 288
356 - private void clickItem()
357 - {
289 + private void clickItem() {
358 290 IFloaterPanelMoveAndSize zFloaterPanel = mItem.getFloaterPanel();
359 - if ( UtilsGwt.wasAltKeyDownOnCurrentEvent() )
360 - {
291 + if ( UtilsGwt.wasAltKeyDownOnCurrentEvent() ) {
361 292 mItem.bringToFront();
362 293 mItem.manageFloater();
363 294 showTaskbarImage();
364 295 hidePopup();
365 - }
366 - else if ( zFloaterPanel.isChromed() )
367 - {
296 + } else if ( zFloaterPanel.isChromed() ) {
368 297 mItem.bringToFront();
369 298 }
370 299 }
371 300
372 - private void clickFavorite( Widget sender )
373 - {
374 - if ( !UtilsGwt.wasAltKeyDownOnCurrentEvent() )
375 - {
301 + private void clickFavorite( Widget sender ) {
302 + if ( !UtilsGwt.wasAltKeyDownOnCurrentEvent() ) {
376 303 mFloaterFactoryFactory.launchFloater( ((TaskbarFavoriteItem) mItem).getFloaterFactoryRef() );
377 304 return;
378 305 }
  @@ -380,10 +307,8 @@
380 307 zContextMenu.addStyleName( "FavoritesPopupMenu" );
381 308 zContextMenu.showContextMenu( sender.getAbsoluteLeft(), sender.getAbsoluteTop() );
382 309 mContextMenuIsShown = true;
383 - zContextMenu.addPopupListener( new PopupListener()
384 - {
385 - public void onPopupClosed( PopupPanel sender, boolean autoClosed )
386 - {
310 + zContextMenu.addPopupListener( new PopupListener() {
311 + public void onPopupClosed( PopupPanel sender, boolean autoClosed ) {
387 312 mContextMenuIsShown = false;
388 313 showTaskbarImage();
389 314 hidePopup();