Project

General

Profile

1811q_20150910_1.txt

Sergey Ivanovskiy, 09/10/2015 12:59 PM

Download (12.8 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java'
2
--- src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java	2015-09-09 21:55:03 +0000
3
+++ src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java	2015-09-10 15:14:23 +0000
4
@@ -590,7 +590,9 @@
5
    extends Label<GuiOutputManager>
6
    {
7
 
8
+      /** The cached window title */
9
       private String title;
10
+      /** True value indicates that the title is changed and the graphics device must be notified.*/
11
       private boolean titleIsChanged;
12
       /**
13
        * Basic c'tor.
14
@@ -638,6 +640,7 @@
15
          
16
          if (titleIsChanged || !title.equals(getTitle()))
17
          {
18
+            // notify client about new title
19
             gd.setTitle(title);
20
             titleIsChanged = false;
21
          }
22

    
23
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
24
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-09-09 21:55:03 +0000
25
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-09-10 16:31:01 +0000
26
@@ -1407,7 +1407,10 @@
27
       }
28
       
29
       var win = getWindow(wid);
30
-      
31
+
32
+      //remove its task icon
33
+      taskBar.removeTaskIcon(wid);
34
+
35
       win.cleanup();
36
       
37
       for (var image in images)
38
@@ -1447,6 +1450,8 @@
39
       var win = getWindow(wid);
40
       
41
       win.setVisible(visible);
42
+      // view/hide task icon usecases 
43
+      taskBar.setTaskIconVisible(wid, visible);
44
    };
45
    
46
    /**
47
@@ -1597,8 +1602,8 @@
48
       
49
       desktop = new VirtualDesktop(
50
             sendWindowStateActive,
51
-            [194, 194, 194],
52
-            [128, 128, 128],
53
+            [174, 174, 174],
54
+            [144, 144, 144],
55
             p2j.fonts,
56
             p2j.logger);
57
       taskBar = desktop.getTaskBar();
58

    
59
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js'
60
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js	2015-09-09 21:55:03 +0000
61
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js	2015-09-10 16:49:12 +0000
62
@@ -201,55 +201,36 @@
63
     */
64
    function TaskBar(peer, bg, fg, fontsManager, logger)
65
    {
66
+      /** The dragged task bar panel opacity */
67
       var DRAGGED_OPACITY = 0.3;
68
-      /**
69
-       * Top padding from the task bar border
70
-       */
71
+      /** Top padding from the task bar border */
72
       var TOP_PADDING    = 2;
73
-      /**
74
-       * Bottom padding from the task bar border
75
-       */
76
+      /** Bottom padding from the task bar border */
77
       var BOTTOM_PADDING = 2;
78
-      /**
79
-       * Left padding from the task bar border
80
-       */
81
+      /** Left padding from the task bar border */
82
       var LEFT_PADDING  = 2;
83
-      /**
84
-       * Right padding from the task bar border
85
-       */
86
+      /** Right padding from the task bar border */
87
       var RIGHT_PADDING = 2;
88
-      /**
89
-       * Margin around the icon
90
-       */
91
+      /** Margin around the icon */
92
       var ICON_MARGIN  = 1;
93
-      /**
94
-       * Margin around the text
95
-       */
96
+      /** Margin around the text */
97
       var TEXT_MARGIN  = 4;
98
-      /**
99
-       * The task bar title.
100
-       */
101
+      /** The task bar title. */
102
       var TASK_BAR_TITLE = "Task Bar";
103
-      /**
104
-       * The default task icon widget dimension: 40 x32
105
-       */
106
+      /** The default task icon widget dimension: 40 x32 */
107
       var TASK_ICON_WIDTH  = 40; 
108
       var TASK_ICON_HEIGHT = 32;
109
-      /**
110
-       * The space between task icons.
111
-       */
112
+      /** The space between task icons. */
113
       var SHIFT = 2;
114
       
115
       /**
116
-       * The task bar font id uses negative number in order
117
-       * to be different from fonts created for p2j windows
118
+       * The task bar font id uses negative number in order to be different from fonts
119
+       * created for p2j windows.
120
        */
121
       var TASK_BAR_FONT_ID = -1;
122
 
123
       var LIGHTEN_COLOR_INTENSE = 10;
124
-      /**
125
-       * The task bar dragged panel
126
-       */
127
+      /** The task bar dragged panel */
128
       var dragged;
129
       
130
       var canvas = document.createElement('canvas');
131
@@ -262,8 +243,10 @@
132
       var ctx = canvas.getContext('2d', {alpha : true});
133
       var strokesManager = new LineStrokes();
134
       var canvasRenderer = new CanvasRenderer(canvas, ctx, strokesManager, fontsManager, logger);
135
-      
136
+      /** visible task icons */
137
       var taskIcons = [];
138
+      /** hidden task icons */
139
+      var hiddenTaskIcons = [];
140
 
141
       var viewLogButton = createViewLogButton(logger);
142
       
143
@@ -282,9 +265,7 @@
144
          setDefaultTooltip();
145
       }
146
       
147
-      /**
148
-       * The default task bar tooltip.
149
-       */
150
+      /** The default task bar tooltip. */
151
       function setDefaultTooltip()
152
       {
153
          peer.title = TASK_BAR_TITLE;
154
@@ -383,10 +364,11 @@
155
          
156
          var unified = calculateTaskIconWidth(width, height, SHIFT, horizontalLayout);
157
          setUnifiedDimension(unified, TASK_ICON_HEIGHT, horizontalLayout);
158
-         
159
+        
160
+         //find first visible
161
          var x;
162
          var y;
163
-         
164
+        
165
          if (horizontalLayout)
166
          {
167
             x = LEFT_PADDING;
168
@@ -567,10 +549,10 @@
169
          sysButtons.forEach(setDimension);
170
       };
171
 
172
-      /**
173
-       * Draws the task bar on the canvas.
174
-       */
175
-      this.draw = function()
176
+      this.draw = draw;
177
+
178
+      /** Draws the task bar on the canvas. */
179
+      function draw()
180
       {
181
          doLayout(peer.offsetWidth, peer.offsetHeight);
182
       }
183
@@ -588,14 +570,92 @@
184
        */
185
       function addTaskIcon(windowId)
186
       {
187
-         var taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground,
188
-               "", null, 0, 0);
189
-         taskIcons.push(taskIcon);
190
-         // By default the task is active. Only one task can be active.
191
-         deactivateHead();
192
-         return taskIcon;
193
-      };
194
-
195
+         var taskIcon = findTaskIcon(windowId);
196
+         if (taskIcon === null)
197
+         {
198
+            taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground,
199
+                  "", null, 0, 0);
200
+            taskIcons.push(taskIcon);
201
+            // By default the task is active. Only one task can be active.
202
+            deactivateHead();
203
+         }
204
+         return taskIcon;
205
+      };
206
+
207
+      this.removeTaskIcon = removeTaskIcon;
208
+
209
+      /**
210
+       * Removes the task icon corresponding to the given window.
211
+       * 
212
+       * @param    {Number} windowId
213
+       *           The id of the window.
214
+       * 
215
+       * @return   {TaskIcon}
216
+       *           The removed window task icon.
217
+       */
218
+      function removeTaskIcon(windowId)
219
+      {
220
+         var taskIcon = findWidget(windowId, taskIcons);
221
+         if (taskIcon)
222
+         {
223
+            var index = taskIcon.index;
224
+            //shrunk the task icons by removing it
225
+            taskIcons.splice(index, 1);
226
+            return taskIcon;
227
+         }
228
+         taskIcon = findWidget(windowId, hiddenTaskIcons);
229
+         if (taskIcon)
230
+         {
231
+            var index = taskIcon.index;
232
+            //shrunk the task icons by removing it
233
+            hiddenTaskIcons.splice(index, 1);
234
+            return taskIcon;
235
+         }
236
+         return taskIcon;
237
+      };
238
+
239
+      this.setTaskIconVisible = setTaskIconVisible;
240
+
241
+      /**
242
+       * View/hides the task icon for the given window.
243
+       * 
244
+       * @param    {Number} windowId
245
+       *           The id of the window.
246
+       * @param    {Boolean} visible
247
+       *           The true value indicates that the target task icon becomes
248
+       *           displayed on the task bar.
249
+       * 
250
+       * @return   {TaskIcon}
251
+       *           The visible/hidden window task icon.
252
+       */
253
+      function setTaskIconVisible(windowId, visible)
254
+      {
255
+         var taskIcon;
256
+         var widgetsToAdd;
257
+         var widgetsToRemove;
258
+         if (visible)
259
+         {
260
+            widgetsToRemove = hiddenTaskIcons;
261
+            widgetsToAdd    = taskIcons;
262
+         }
263
+         else
264
+         {
265
+            widgetsToRemove = taskIcons;
266
+            widgetsToAdd    = hiddenTaskIcons;
267
+         }
268
+         taskIcon = findWidget(windowId, widgetsToRemove);
269
+         if (taskIcon)
270
+         {
271
+            var index = taskIcon.index;
272
+            //shrunk the task icons by removing it
273
+            widgetsToRemove.splice(index, 1);
274
+            widgetsToAdd.push(taskIcon);
275
+            //if the task icon becomes visible it should be active
276
+            taskIcon.setActive(visible);
277
+         }
278
+         return taskIcon;
279
+      };
280
+      
281
       /**
282
        * Deactivate the head tasks.
283
        */
284
@@ -628,9 +688,12 @@
285
       function setIconForTask(windowId, iconData, iconWidth, iconHeight)
286
       {
287
          var taskIcon = findTaskIcon(windowId);
288
-         taskIcon.iconData = iconData;
289
-         taskIcon.iconWidth = iconWidth;
290
-         taskIcon.iconHeight = iconHeight;
291
+         if (taskIcon)
292
+         {
293
+            taskIcon.iconData = iconData;
294
+            taskIcon.iconWidth = iconWidth;
295
+            taskIcon.iconHeight = iconHeight;
296
+         }
297
          return taskIcon;
298
       };
299
       
300
@@ -650,7 +713,10 @@
301
       function setTitleForTask(windowId, title)
302
       {
303
          var taskIcon = findTaskIcon(windowId);
304
-         taskIcon.title = title;
305
+         if (taskIcon)
306
+         {
307
+            taskIcon.title = title;
308
+         }
309
          return taskIcon;
310
       };
311
 
312
@@ -700,17 +766,39 @@
313
        */
314
       function findTaskIcon(windowId)
315
       {
316
-         for (var i = 0; i < taskIcons.length; i++)
317
-         {
318
-            var taskIcon = taskIcons[i];
319
+         var taskIcon = findWidget(windowId, taskIcons);
320
+         if (taskIcon)
321
+         {
322
+            return taskIcon;
323
+         }
324
+         //try hidden task icons
325
+         return findWidget(windowId, hiddenTaskIcons);
326
+      };
327
+      
328
+      /**
329
+       * Find the window task that represents the target window from the given searchable set.
330
+       * 
331
+       * @param    {Number} windowId
332
+       *           The target window id.
333
+       * @param    {Array} widgets
334
+       *           The searchable array of TaskIcon.
335
+       * 
336
+       * @return   {TaskIcon}
337
+       *           The task that represents the target window.
338
+       */
339
+      function findWidget(windowId, widgets)
340
+      {
341
+         for (var i = 0; i < widgets.length; i++)
342
+         {
343
+            var taskIcon = widgets[i];
344
             if (taskIcon.id === windowId)
345
             {
346
+               taskIcon.index = i;
347
                return taskIcon;
348
             }
349
          }
350
          return null;
351
       };
352
-      
353
       /**
354
        * Collapses the given window. Sets the corresponding task icon to be inactive.
355
        * 
356
@@ -724,7 +812,6 @@
357
          {
358
             return;
359
          }
360
-         logger.log("TaskBar.iconify(" + windowId + ")");
361
          taskIcon.setActive(false);
362
          taskIcon.draw();
363
       };
364
@@ -742,7 +829,6 @@
365
          {
366
             return;
367
          }
368
-         logger.log("TaskBar.deiconify(" + windowId + ")");
369
          taskIcon.setActive(true);
370
          taskIcon.draw();
371
       };
372
@@ -834,7 +920,7 @@
373
                parent.addChild(dragged);
374
                parent.style.zIndex = MAX_Z_INDEX;
375
             }
376
-            doLayout(peer.offsetWidth, peer.offsetHeight);
377
+            draw();
378
          }
379
          event.preventDefault();
380
       }, false);
381
@@ -924,7 +1010,7 @@
382
                   function()
383
                   {
384
                      resizeTimeout = null;
385
-                     doLayout(peer.offsetWidth, peer.offsetHeight);
386
+                     draw();
387
                   }, 100);
388
          }
389
       };
390
@@ -984,6 +1070,9 @@
391
          var active = true;
392
          this.x = 0;
393
          this.y = 0;
394
+         /**The internal index, if the task icon is on the task bar, it is set
395
+          * to the task icon postion. It holds only a temporary state.*/
396
+         this.index = -1;
397
          /**
398
           * Defines the widget's title layout, 
399
           */
400
@@ -1002,9 +1091,7 @@
401
 
402
          this.setActive = setActive;
403
 
404
-         /**
405
-          * Sets an active state.
406
-          */
407
+         /** Sets an active state. */
408
          function setActive(value)
409
          {
410
             active = value;
411
@@ -1012,9 +1099,7 @@
412
 
413
          this.isActive  = isActive;
414
 
415
-         /**
416
-          * Is active?
417
-          */
418
+         /** Is active? */
419
          function isActive()
420
          {
421
             return active;
422
@@ -1028,7 +1113,7 @@
423
          function draw()
424
          {
425
             var c;
426
-            if (active)
427
+            if (!active)
428
             {
429
                c = canvasRenderer.lightenColor(that.color);
430
             }
431
@@ -1102,7 +1187,7 @@
432
                   xTextPos = 0;
433
                   yTextPos = 0;
434
                }
435
-               if (active)
436
+               if (!active)
437
                {
438
                   var textRgb = canvasRenderer.parseColor(ctx.fillStyle);
439
                   var selectedTextRgb = canvasRenderer.lightenColor(textRgb).map(
440