1 11 12 package org.eclipse.ui.internal; 13 14 import java.util.ArrayList ; 15 import java.util.HashMap ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 import java.util.Map ; 19 20 import org.eclipse.core.runtime.MultiStatus; 21 import org.eclipse.jface.util.Geometry; 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.graphics.Point; 24 import org.eclipse.swt.graphics.Rectangle; 25 import org.eclipse.ui.IMemento; 26 import org.eclipse.ui.IPerspectiveDescriptor; 27 import org.eclipse.ui.IPerspectiveListener2; 28 import org.eclipse.ui.IViewReference; 29 import org.eclipse.ui.IWorkbenchPage; 30 import org.eclipse.ui.IWorkbenchPart; 31 import org.eclipse.ui.IWorkbenchPartReference; 32 import org.eclipse.ui.internal.StartupThreading.StartupRunnable; 33 import org.eclipse.ui.internal.layout.IWindowTrim; 34 import org.eclipse.ui.internal.layout.LayoutUtil; 35 import org.eclipse.ui.internal.layout.TrimLayout; 36 import org.eclipse.ui.internal.presentations.PresentablePart; 37 import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation; 38 import org.eclipse.ui.internal.tweaklets.Animations; 39 import org.eclipse.ui.internal.tweaklets.Tweaklets; 40 import org.eclipse.ui.internal.util.Util; 41 import org.eclipse.ui.presentations.IPresentablePart; 42 import org.eclipse.ui.presentations.IStackPresentationSite; 43 44 53 public class FastViewManager { 54 private Perspective perspective; 55 private WorkbenchPage page; 56 private WorkbenchWindow wbw; 57 private TrimLayout tbm; 58 59 69 private Map idToFastViewsMap = new HashMap (); 70 71 74 private boolean deferringUpdates = false; 75 76 80 private AnimationEngine batchAnimation = null; 81 82 85 private AnimationEngine oneShotAnimation = null; 86 88 private IPerspectiveListener2 perspListener = new IPerspectiveListener2() { 89 public void perspectiveActivated(IWorkbenchPage page, 90 IPerspectiveDescriptor perspective) { 91 if (FastViewManager.this.perspective.getDesc() == perspective) 93 handlePerspectiveActivation(page, perspective); 94 } 95 96 public void perspectiveChanged(IWorkbenchPage changedPage, 97 IPerspectiveDescriptor perspective, 98 IWorkbenchPartReference partRef, String changeId) { 99 if (FastViewManager.this.perspective.getDesc() == perspective) 101 handlePerspectiveChange(changedPage, perspective, partRef, 102 changeId); 103 } 104 105 public void perspectiveChanged(IWorkbenchPage changedPage, 106 IPerspectiveDescriptor perspective, String changeId) { 107 if (FastViewManager.this.perspective.getDesc() == perspective) 109 handlePerspectiveChange(changedPage, perspective, changeId); 110 } 111 }; 112 113 119 public FastViewManager(Perspective perspective, WorkbenchPage page) { 120 this.perspective = perspective; 121 this.page = page; 122 123 wbw = (WorkbenchWindow) page.getWorkbenchWindow(); 125 tbm = (TrimLayout) wbw.getTrimManager(); 126 } 127 128 protected void handlePerspectiveActivation(IWorkbenchPage activatingPage, 129 IPerspectiveDescriptor activatingPerspective) { 130 if (activatingPage == page 133 && perspective.getDesc() == activatingPerspective) 134 updateTrim(FastViewBar.FASTVIEWBAR_ID); 135 } 136 137 protected void handlePerspectiveChange(IWorkbenchPage changedPage, 138 IPerspectiveDescriptor changedPerspective, 139 IWorkbenchPartReference partRef, String changeId) { 140 if (changedPage != page && perspective.getDesc() != changedPerspective) 142 return; 143 144 if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_HIDE)) { 145 if (partRef instanceof IViewReference) { 146 ViewReference ref = (ViewReference) partRef; 147 if (ref.getPane().getContainer() instanceof ViewStack) { 148 int viewCount = 0; 149 LayoutPart[] children = ref.getPane().getContainer().getChildren(); 150 for (int i = 0; i < children.length; i++) { 151 if (children[i] instanceof ViewPane && children[i] != ref.getPane()) 152 viewCount++; 153 } 154 155 if (viewCount == 0) 156 ref.getPane().getStack().setState(IStackPresentationSite.STATE_RESTORED); 157 } 158 } 159 removeViewReference((IViewReference) partRef, false, true); 163 } 164 165 if (changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_REMOVE)) { 166 removeViewReference((IViewReference) partRef, false, true); 170 } 171 } 172 173 protected void handlePerspectiveChange(IWorkbenchPage changedPage, 174 IPerspectiveDescriptor changedPerspective, String changeId) { 175 } 176 177 181 public List getFastViews(String forId) { 182 List fvs = new ArrayList (); 183 184 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 185 while (mapIter.hasNext()) { 186 String id = (String ) mapIter.next(); 187 if (forId == null || forId.equals(id)) { 188 List fvList = (List ) idToFastViewsMap.get(id); 189 for (Iterator fvIter = fvList.iterator(); fvIter.hasNext();) { 190 fvs.add(fvIter.next()); 191 } 192 } 193 } 194 195 return fvs; 196 } 197 198 223 public void addViewReference(String id, int index, IViewReference ref, 224 boolean update) { 225 if (id == null || ref == null) 226 return; 227 228 List fvList = (List ) idToFastViewsMap.get(id); 229 if (fvList == null) { 230 fvList = new ArrayList (); 232 idToFastViewsMap.put(id, fvList); 233 } 234 235 if (index < 0 || index > fvList.size()) 237 index = fvList.size(); 238 239 String curLocation = getIdForRef(ref); 241 if (curLocation != null) { 242 if (id.equals(curLocation)) { 244 int curIndex = fvList.indexOf(ref); 245 if (index == curIndex) 246 return; 248 if (index > curIndex) 252 index--; 253 } 254 255 removeViewReference(ref, false, true); 257 } else { 258 makeFast(ref, true, false); 260 } 261 262 fvList.add(index, ref); 263 264 if (update) 267 updateTrim(id); 268 } 269 270 278 private ViewStackTrimToolBar getTrimForViewStack(String id, 279 int suggestedSide, int paneOrientation) { 280 ViewStackTrimToolBar trim = (ViewStackTrimToolBar) tbm.getTrim(id); 282 if (trim == null) { 283 int cachedSide = tbm.getPreferredArea(id); 284 if (cachedSide != -1) 285 suggestedSide = cachedSide; 286 287 IWindowTrim beforeMe = tbm.getPreferredLocation(id); 288 289 trim = new ViewStackTrimToolBar(id, suggestedSide, 290 paneOrientation, wbw); 291 tbm.addTrim(suggestedSide, trim, beforeMe); 292 updateTrim(trim.getId()); 293 } 294 295 return trim; 296 } 297 298 308 private void updateTrim(String id) { 309 IWindowTrim trim = tbm.getTrim(id); 311 312 if (trim == null) 314 return; 315 316 List fvs = (List ) idToFastViewsMap.get(id); 318 if (fvs != null && fvs.size() == 0 319 && !FastViewBar.FASTVIEWBAR_ID.equals(id)) { 320 if (trim.getControl().getVisible()) { 321 tbm.setTrimVisible(trim, false); 322 tbm.forceLayout(); 323 } 324 return; 325 } 326 327 if (!trim.getControl().getVisible()) { 329 tbm.setTrimVisible(trim, true); 330 } 331 332 if (trim instanceof FastViewBar) { 333 FastViewBar fvb = (FastViewBar) trim; 334 fvb.update(true); 335 } else if (trim instanceof ViewStackTrimToolBar) { 336 ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim; 337 vstb.update(true); 338 vstb.getControl().pack(); 339 LayoutUtil.resize(trim.getControl()); 340 } 341 342 tbm.forceLayout(); 343 } 344 345 351 public void removeViewReference(IViewReference ref, boolean makeUnfast, boolean update) { 352 String id = getIdForRef(ref); 353 354 if (id != null) { 355 List fvList = (List ) idToFastViewsMap.get(id); 357 fvList.remove(ref); 358 359 if (makeUnfast) 360 makeFast(ref, false, false); 361 362 if (update) 363 updateTrim(id); 364 } 365 } 366 367 373 private void makeFast(IViewReference ref, boolean makeFast, boolean activate) { 374 if (ref == null || page == null) 375 return; 376 377 if (makeFast) { 378 page.makeFastView(ref); 379 } else { 380 page.removeFastView(ref); 381 382 if (activate) { 383 IWorkbenchPart toActivate = ref.getPart(true); 384 if (toActivate != null) { 385 page.activate(toActivate); 386 } 387 } 388 } 389 } 390 391 396 boolean isFastView(IViewReference ref) { 397 return getIdForRef(ref) != null; 398 } 399 400 406 public String getIdForRef(IViewReference ref) { 407 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 408 while (mapIter.hasNext()) { 409 String id = (String ) mapIter.next(); 410 List fvList = (List ) idToFastViewsMap.get(id); 411 if (fvList.contains(ref)) 412 return id; 413 } 414 415 return null; 416 } 417 418 422 public int getViewSide(IViewReference ref) { 423 IWindowTrim trim = getTrimForRef(ref); 424 if (trim == null) 425 return SWT.BOTTOM; 426 427 int curSide = SWT.BOTTOM; 428 int paneOrientation = SWT.BOTTOM; 429 430 if (trim instanceof ViewStackTrimToolBar) { 431 curSide = ((ViewStackTrimToolBar) trim).getCurrentSide(); 432 paneOrientation = ((ViewStackTrimToolBar) trim) 433 .getPaneOrientation(); 434 } else if (trim instanceof FastViewBar) { 435 curSide = ((FastViewBar) trim).getSide(); 436 paneOrientation = ((FastViewBar) trim).getOrientation(ref); 437 } 438 439 Point trimCenter = Geometry.centerPoint(trim.getControl().getBounds()); 441 Point shellCenter = Geometry.centerPoint(trim.getControl().getShell() 442 .getClientArea()); 443 444 if (paneOrientation == SWT.HORIZONTAL) { 446 if (curSide == SWT.TOP || curSide == SWT.BOTTOM) 447 return curSide; 448 449 return (trimCenter.y < shellCenter.y) ? SWT.TOP : SWT.BOTTOM; 451 } 452 453 if (paneOrientation == SWT.VERTICAL) { 454 if (curSide == SWT.LEFT || curSide == SWT.RIGHT) 455 return curSide; 456 457 return (trimCenter.x < shellCenter.x) ? SWT.LEFT : SWT.RIGHT; 459 } 460 461 return SWT.BOTTOM; 462 } 463 464 471 private IWindowTrim getTrimForRef(IViewReference ref) { 472 String id = getIdForRef(ref); 473 if (id == null) 474 return null; 476 return tbm.getTrim(id); 477 } 478 479 483 private List getTrueViewOrder(ViewStack stack) { 484 List orderedViews = new ArrayList (); 485 IPresentablePart[] parts = null; 486 if (stack.getPresentation() instanceof TabbedStackPresentation) { 487 TabbedStackPresentation tsp = (TabbedStackPresentation) stack 488 .getPresentation(); 489 parts = tsp.getPartList(); 491 } 492 493 if (parts == null || parts.length == 0){ 496 List partList = stack.getPresentableParts(); 501 parts = (IPresentablePart[]) partList.toArray(new IPresentablePart[partList.size()]); 502 } 503 504 for (int i = 0; i < parts.length; i++) { 506 if (parts[i] instanceof PresentablePart) { 507 PresentablePart part = (PresentablePart) parts[i]; 508 IWorkbenchPartReference ref = part.getPane() 509 .getPartReference(); 510 if (ref instanceof IViewReference) 511 orderedViews.add(ref); 512 } 513 } 514 515 return orderedViews; 516 } 517 518 public void moveToTrim(ViewStack vs, boolean restoreOnUnzoom) { 519 if (vs.getBounds().width == 0) 521 return; 523 Rectangle stackBounds = perspective.getPresentation().getCachedBoundsFor(vs.getID()); 526 527 if (stackBounds == null) 529 stackBounds = vs.getBounds(); 530 531 int paneOrientation = (stackBounds.width > stackBounds.height) ? SWT.HORIZONTAL 532 : SWT.VERTICAL; 533 534 String selId = ""; PartPane selectedTab = vs.getSelection(); 537 if (selectedTab != null) 538 selId = selectedTab.getCompoundId(); 539 540 vs.deferUpdates(true); 541 542 RectangleAnimationFeedbackBase animation = (RectangleAnimationFeedbackBase) getDeferrableAnimation().getFeedback(); 544 animation.addStartRect(vs.getControl()); 545 546 List toMove = getTrueViewOrder(vs); 549 for (Iterator viewIter = toMove.iterator(); viewIter.hasNext();) { 550 IViewReference ref = (IViewReference) viewIter.next(); 551 addViewReference(vs.getID(), -1, ref, false); 552 } 553 554 vs.deferUpdates(false); 555 556 ViewStackTrimToolBar vstb = getTrimForViewStack(vs.getID(), perspective 558 .calcStackSide(stackBounds), paneOrientation); 559 vstb.setRestoreOnUnzoom(restoreOnUnzoom); 560 vstb.setSelectedTabId(selId); 561 updateTrim(vstb.getId()); 562 563 if (vstb != null) { 565 animation.addEndRect(vstb.getControl()); 566 scheduleDeferrableAnimation(); 567 } 568 } 569 570 577 public void restoreToPresentation(String id) { 578 ViewStackTrimToolBar vstb = getViewStackTrimToolbar(id); 579 580 if (vstb == null) 583 return; 584 585 page.hideFastView(); 587 588 String selectedTabId = vstb.getSelectedTabId(); 591 String [] idParts = Util.split(selectedTabId, ':'); 592 if (idParts[0].length() == selectedTabId.length()) 593 idParts[1] = null; 594 595 List fvs = getFastViews(id); 596 for (Iterator fvIter = fvs.iterator(); fvIter.hasNext();) { 597 IViewReference ref = (IViewReference) fvIter.next(); 598 removeViewReference(ref, true, !fvIter.hasNext()); 599 } 600 601 LayoutPart stack = perspective.getPresentation().findPart(id, null); 603 if (stack instanceof PartStack) { 604 LayoutPart selTab = perspective.getPresentation().findPart(idParts[0], idParts[1]); 605 if (selTab instanceof PartPane && selTab instanceof ViewPane) { 606 ((PartStack)stack).setSelection(selTab); 607 608 if (!deferringUpdates) 610 ((ViewPane)selTab).requestActivation(); 611 } 612 } 613 614 updateTrim(id); 616 } 617 618 621 public void restoreZoomedViewStacks() { 622 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 623 while (mapIter.hasNext()) { 624 String id = (String ) mapIter.next(); 625 IWindowTrim trim = tbm.getTrim(id); 626 if (trim != null && trim instanceof ViewStackTrimToolBar) { 627 ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim; 628 if (vstb.restoreOnUnzoom()) 629 restoreToPresentation(vstb.getId()); 630 } 631 } 632 } 633 634 640 public void setFastViewIconSelection(IViewReference ref, boolean selected) { 641 String id = getIdForRef(ref); 642 IWindowTrim trim = tbm.getTrim(id); 643 if (trim instanceof ViewStackTrimToolBar) { 644 ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim; 645 vstb.setIconSelection(ref, selected); 646 } else if (trim instanceof FastViewBar) { 647 FastViewBar fvb = (FastViewBar) trim; 648 if (selected) { 649 fvb.setSelection(ref); 650 } else { 651 if (ref == fvb.getSelection()) { 652 fvb.setSelection(null); 653 } 654 } 655 } 656 657 } 658 659 662 public void activate() { 663 wbw.addPerspectiveListener(perspListener); 664 setTrimStackVisibility(true); 665 } 666 667 670 public void deActivate() { 671 wbw.removePerspectiveListener(perspListener); 672 setTrimStackVisibility(false); 673 } 674 675 680 public boolean restoreAllTrimStacks() { 681 boolean stacksWereRestored = false; 682 683 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 684 while (mapIter.hasNext()) { 685 String id = (String ) mapIter.next(); 686 687 if (id.equals(FastViewBar.FASTVIEWBAR_ID)) 689 continue; 690 691 List fvs = getFastViews(id); 693 for (Iterator fvIter = fvs.iterator(); fvIter.hasNext();) { 694 IViewReference ref = (IViewReference) fvIter.next(); 695 removeViewReference(ref, true, !fvIter.hasNext()); 696 } 697 698 IWindowTrim trim = tbm.getTrim(id); 700 if (trim != null && trim instanceof ViewStackTrimToolBar) { 701 tbm.removeTrim(trim); 702 trim.getControl().dispose(); 703 704 stacksWereRestored = true; 705 } 706 } 707 708 tbm.forceLayout(); 709 710 return stacksWereRestored; 711 } 712 713 716 private void setTrimStackVisibility(boolean visible) { 717 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 718 while (mapIter.hasNext()) { 719 String id = (String ) mapIter.next(); 720 List fvs = getFastViews(id); 721 722 if (visible && fvs.size() == 0) 724 continue; 725 726 IWindowTrim trim = tbm.getTrim(id); 727 if (trim != null && trim instanceof ViewStackTrimToolBar) { 728 ((ViewStackTrimToolBar)trim).update(true); 729 tbm.setTrimVisible(trim, visible); 730 } 731 } 732 } 733 734 public void saveState(IMemento memento) { 735 FastViewBar fvb = wbw.getFastViewBar(); 737 if (fvb != null) { 738 List fvRefs = getFastViews(FastViewBar.FASTVIEWBAR_ID); 739 if (fvRefs.size() > 0) { 740 IMemento childMem = memento 741 .createChild(IWorkbenchConstants.TAG_FAST_VIEWS); 742 Iterator itr = fvRefs.iterator(); 743 while (itr.hasNext()) { 744 IViewReference ref = (IViewReference) itr.next(); 745 IMemento viewMemento = childMem 746 .createChild(IWorkbenchConstants.TAG_VIEW); 747 String id = ViewFactory.getKey(ref); 748 viewMemento.putString(IWorkbenchConstants.TAG_ID, id); 749 float ratio = perspective.getFastViewWidthRatio(ref); 750 viewMemento.putFloat(IWorkbenchConstants.TAG_RATIO, ratio); 751 } 752 } 753 } 754 755 IMemento barsMemento = memento 757 .createChild(IWorkbenchConstants.TAG_FAST_VIEW_BARS); 758 759 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 760 while (mapIter.hasNext()) { 761 String id = (String ) mapIter.next(); 762 763 if (FastViewBar.FASTVIEWBAR_ID.equals(id)) 765 continue; 766 767 List fvs = getFastViews(id); 768 if (fvs.size() > 0) { 769 IMemento barMemento = barsMemento 770 .createChild(IWorkbenchConstants.TAG_FAST_VIEW_BAR); 771 barMemento.putString(IWorkbenchConstants.TAG_ID, id); 772 773 ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) tbm 775 .getTrim(id); 776 if (vstb != null) { 777 barMemento.putInteger( 778 IWorkbenchConstants.TAG_FAST_VIEW_SIDE, 779 vstb.getCurrentSide()); 780 781 barMemento.putInteger( 782 IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION, 783 vstb.getPaneOrientation()); 784 785 int boolVal = vstb.restoreOnUnzoom() ? 1 : 0; 786 barMemento.putInteger(IWorkbenchConstants.TAG_FAST_VIEW_STYLE, boolVal); 787 788 barMemento.putString(IWorkbenchConstants.TAG_FAST_VIEW_SEL_ID, vstb.getSelectedTabId()); 789 } 790 791 IMemento viewsMem = barMemento 792 .createChild(IWorkbenchConstants.TAG_FAST_VIEWS); 793 Iterator itr = fvs.iterator(); 794 while (itr.hasNext()) { 795 IMemento refMem = viewsMem 796 .createChild(IWorkbenchConstants.TAG_VIEW); 797 IViewReference ref = (IViewReference) itr.next(); 798 799 String viewId = ViewFactory.getKey(ref); 801 refMem.putString(IWorkbenchConstants.TAG_ID, viewId); 802 803 float ratio = perspective.getFastViewWidthRatio(ref); 805 refMem.putFloat(IWorkbenchConstants.TAG_RATIO, ratio); 806 } 807 } 808 } 809 } 810 811 public void restoreState(IMemento memento, MultiStatus result) { 812 IMemento fastViewsMem = memento 814 .getChild(IWorkbenchConstants.TAG_FAST_VIEWS); 815 816 List refsList = new ArrayList (); 818 idToFastViewsMap.put(FastViewBar.FASTVIEWBAR_ID, refsList); 819 820 if (fastViewsMem != null) { 821 IMemento[] views = fastViewsMem 822 .getChildren(IWorkbenchConstants.TAG_VIEW); 823 for (int x = 0; x < views.length; x++) { 824 IMemento childMem = views[x]; 826 IViewReference ref = perspective.restoreFastView(childMem, 827 result); 828 if (ref != null) 829 refsList.add(ref); 830 } 831 } 832 833 IMemento barsMem = memento 835 .getChild(IWorkbenchConstants.TAG_FAST_VIEW_BARS); 836 837 if (barsMem == null) 839 return; 840 841 IMemento[] bars = barsMem 842 .getChildren(IWorkbenchConstants.TAG_FAST_VIEW_BAR); 843 for (int i = 0; i < bars.length; i++) { 844 final String id = bars[i].getString(IWorkbenchConstants.TAG_ID); 845 fastViewsMem = bars[i].getChild(IWorkbenchConstants.TAG_FAST_VIEWS); 846 847 refsList = new ArrayList (); 849 idToFastViewsMap.put(id, refsList); 850 851 if (fastViewsMem != null) { 852 IMemento[] views = fastViewsMem 853 .getChildren(IWorkbenchConstants.TAG_VIEW); 854 result.merge(perspective.createReferences(views)); 855 856 if (views.length > 0) { 859 final int side = bars[i].getInteger( 860 IWorkbenchConstants.TAG_FAST_VIEW_SIDE) 861 .intValue(); 862 final int orientation = bars[i].getInteger( 863 IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION) 864 .intValue(); 865 int boolVal = bars[i].getInteger( 866 IWorkbenchConstants.TAG_FAST_VIEW_STYLE).intValue(); 867 final boolean restoreOnUnzoom = (boolVal > 0); 868 869 final String selId = bars[i].getString(IWorkbenchConstants.TAG_FAST_VIEW_SEL_ID); 870 871 StartupThreading.runWithoutExceptions(new StartupRunnable() { 873 public void runWithException() throws Throwable { 874 ViewStackTrimToolBar vstb = getTrimForViewStack(id, side, orientation); 875 vstb.setRestoreOnUnzoom(restoreOnUnzoom); 876 if (selId != null) 877 vstb.setSelectedTabId(selId); 878 } 879 }); 880 } 881 882 for (int x = 0; x < views.length; x++) { 883 IMemento childMem = views[x]; 885 IViewReference ref = perspective.restoreFastView(childMem, 886 result); 887 if (ref != null) 888 refsList.add(ref); 889 } 890 } 891 } 892 } 893 894 901 public ViewStackTrimToolBar getViewStackTrimToolbar(String id) { 902 return (ViewStackTrimToolBar) tbm.getTrim(id); 903 } 904 905 public void printFVModel() { 906 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 907 while (mapIter.hasNext()) { 908 String id = (String ) mapIter.next(); 909 List fvList = (List ) idToFastViewsMap.get(id); 910 System.out.println("FastView: " + id + " count = " + fvList.size()); for (Iterator fvIter = fvList.iterator(); fvIter.hasNext();) { 912 IViewReference ref = (IViewReference) fvIter.next(); 913 System.out.println(" Ref: " + ref.getId()); } 915 } 916 } 917 918 926 public void deferUpdates(boolean defer) { 927 if (defer && !deferringUpdates) { 928 deferringUpdates = defer; 929 930 deferAnimations(true); 931 932 return; 933 } 934 935 deferringUpdates = false; 937 deferAnimations(false); 938 } 939 940 949 private void deferAnimations(boolean defer) { 950 if (defer) { 951 RectangleAnimationFeedbackBase feedback = ((Animations) Tweaklets 952 .get(Animations.KEY)).createFeedback(wbw.getShell()); 953 batchAnimation = new AnimationEngine(feedback, 400); 954 return; 955 } 956 957 if (batchAnimation != null) 958 batchAnimation.schedule(); 959 batchAnimation = null; 960 } 961 962 966 private AnimationEngine getDeferrableAnimation() { 967 if (deferringUpdates) 968 return batchAnimation; 969 970 RectangleAnimationFeedbackBase feedback = ((Animations) Tweaklets 972 .get(Animations.KEY)).createFeedback(wbw.getShell()); 973 oneShotAnimation = new AnimationEngine(feedback, 400); 974 return oneShotAnimation; 975 } 976 977 private void scheduleDeferrableAnimation() { 978 if (deferringUpdates) 979 return; 980 981 if (oneShotAnimation != null) 984 oneShotAnimation.schedule(); 985 oneShotAnimation = null; 986 } 987 988 996 public ViewStackTrimToolBar getBottomRightTrimStack() { 997 ViewStackTrimToolBar blTrimStack = null; 998 Point blPt = new Point(0,0); 999 1000 Iterator mapIter = idToFastViewsMap.keySet().iterator(); 1001 while (mapIter.hasNext()) { 1002 String id = (String ) mapIter.next(); 1003 1004 if (id.equals(FastViewBar.FASTVIEWBAR_ID)) 1006 continue; 1007 1008 if (getFastViews(id).size() > 0) { 1009 ViewStackTrimToolBar vstt = getViewStackTrimToolbar(id); 1011 Point loc = vstt.getControl().getLocation(); 1012 if (loc.y > blPt.y || (loc.y == blPt.y && loc.x > blPt.x)) { 1013 blPt = loc; 1014 blTrimStack = vstt; 1015 } 1016 } 1017 } 1018 1019 return blTrimStack; 1020 } 1021} 1022 | Popular Tags |