~smaioli/azureus/ubuntu-experimental

« back to all changes in this revision

Viewing changes to org/gudy/azureus2/ui/swt/Tab.java

MergedĀ VuzeĀ 4.2.0.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
import com.aelitis.azureus.ui.swt.utils.ColorCache;
53
53
 
54
54
import org.gudy.azureus2.plugins.PluginView;
 
55
import org.gudy.azureus2.plugins.ui.UIPluginView;
55
56
 
56
57
/**
57
58
 * @author Olivier
186
187
                                        eventCloseAllowed = true;
187
188
                                        if (selectedItem != null) {
188
189
                                                ((CTabFolder) folder).setSelection((CTabItem) selectedItem);
 
190
                                                ensureVisibilities();
189
191
                                        }
190
192
                                }
191
193
                        });
234
236
                                        return;
235
237
                                }
236
238
 
237
 
                                if (useCustomTab) {
238
 
                                        CTabItem item = (CTabItem) event.item;
239
 
                                        if (item != null && !item.isDisposed() && !folder.isDisposed()) {
240
 
                                                try {
241
 
                                                        ((CTabFolder) folder).setSelection(item);
242
 
                                                        Control control = item.getControl();
243
 
                                                        if (control != null) {
244
 
                                                                control.setVisible(true);
245
 
                                                                control.setFocus();
246
 
                                                        }
247
 
                                                } catch (Throwable e) {
248
 
                                                        Debug.printStackTrace(e);
249
 
                                                        //Do nothing
250
 
                                                }
251
 
                                        }
 
239
                                if (useCustomTab && !folder.isDisposed()) {
 
240
                                        ensureVisibilities();
252
241
                                }
253
242
 
254
243
                                mainwindow.getUIFunctions().refreshIconBar();
316
305
 
317
306
  
318
307
 
319
 
        public Item createTabItem(IView _view, boolean bFocus) {
 
308
        /**
 
309
         * 
 
310
         *
 
311
         * @since 4.0.0.5
 
312
         */
 
313
        protected void ensureVisibilities() {
 
314
                if (!(folder instanceof CTabFolder)) {
 
315
                        return;
 
316
                }
 
317
                CTabItem[] items = ((CTabFolder) folder).getItems();
 
318
                CTabItem item = ((CTabFolder) folder).getSelection();
 
319
                for (int i = 0; i < items.length; i++) {
 
320
                        CTabItem tabItem = items[i];
 
321
                        if (tabItem == null || tabItem.isDisposed()) {
 
322
                                continue;
 
323
                        }
 
324
                        if (tabItem == item) {
 
325
                                try {
 
326
                                        ((CTabFolder) folder).setSelection(tabItem);
 
327
                                        Control control = getView(tabItem).getComposite();
 
328
                                        if (control != null) {
 
329
                                                control.setVisible(true);
 
330
                                                control.setFocus();
 
331
                                        }
 
332
                                        
 
333
                                } catch (Throwable e) {
 
334
                                        Debug.printStackTrace(e);
 
335
                                        //Do nothing
 
336
                                }
 
337
                        } else {
 
338
                                try {
 
339
                                        Control control = getView(tabItem).getComposite();
 
340
                                        if (control != null) {
 
341
                                                control.setVisible(false);
 
342
                                        }
 
343
                                } catch (Throwable e) {
 
344
                                        Debug.printStackTrace(e);
 
345
                                        //Do nothing
 
346
                                }
 
347
                        }
 
348
                }
 
349
        }
 
350
 
 
351
        public Item createTabItem(final IView _view, boolean bFocus) {
320
352
                if (folder.isDisposed()) {
321
353
                        return null;
322
354
                }
368
400
                                                                return;
369
401
                                                        }
370
402
                                                        alreadyHere = true;
371
 
                                                        Utils.disposeComposite(tabArea);
 
403
                                                        Item tab = getTab(_view);
 
404
                                                        if (tab != null) {
 
405
                                                                closed(tab);
 
406
                                                        }
372
407
                                                }
373
408
                                        });
374
409
                                }
378
413
                                ((CTabItem) tabItem).setControl(tabArea);
379
414
                                // Disabled for SWT 3.2RC5.. CTabItem tooltip doesn't always disappear
380
415
                                //                              ((CTabItem) tabItem).setToolTipText(view.getFullTitle());
381
 
                                if (bFocus)
 
416
                                if (bFocus) {
382
417
                                        ((CTabFolder) folder).setSelection((CTabItem) tabItem);
 
418
                                        ensureVisibilities();
 
419
                                }
383
420
                        } else {
384
421
                                ((TabItem) tabItem).setControl(tabArea);
385
422
                                ((TabItem) tabItem).setToolTipText(_view.getFullTitle());
386
423
                                TabItem items[] = {
387
424
                                        (TabItem) tabItem
388
425
                                };
389
 
                                if (bFocus)
 
426
                                if (bFocus) {
390
427
                                        ((TabFolder) folder).setSelection(items);
 
428
                                }
391
429
                        }
392
430
                } catch (Exception e) {
393
431
                        tabs.remove(tabItem);
584
622
              {
585
623
                  hasDetails = true;
586
624
                  break;
 
625
              }else if ( view instanceof UIPluginView && ((UIPluginView)view).getViewID().equals( "DMView" )){
 
626
                  hasDetails = true;
 
627
                  break;
587
628
              }
588
629
          }
589
630
      }
614
655
        IView view = (IView) tabs.get(tab_items[i]);
615
656
        if (view instanceof ManagerView) {
616
657
          closed(tab_items[i]);
 
658
        }else if ( view instanceof UIPluginView && ((UIPluginView)view).getViewID().equals( "DMView" )){
 
659
          closed(tab_items[i]);
617
660
        }
618
661
      }
619
662
  }
660
703
      else if(index < 0)
661
704
        index = tabFolder.getItemCount() - 1;
662
705
      tabFolder.setSelection(index);
 
706
                        ensureVisibilities();
663
707
    }
664
708
  }
665
709
 
761
805
                if (folder != null && !folder.isDisposed()) {
762
806
                        if (useCustomTab) {
763
807
                                ((CTabFolder) folder).setSelection((CTabItem) item);
 
808
                                ensureVisibilities();
764
809
                        } else {
765
810
                                TabItem items[] = {
766
811
                                        (TabItem) item