1 11 package org.eclipse.debug.internal.ui.views.memory; 12 13 import java.util.ArrayList ; 14 import java.util.Enumeration ; 15 import java.util.Hashtable ; 16 import java.util.StringTokenizer ; 17 18 import org.eclipse.core.commands.AbstractHandler; 19 import org.eclipse.core.commands.ExecutionEvent; 20 import org.eclipse.core.commands.ExecutionException; 21 import org.eclipse.core.runtime.IAdaptable; 22 import org.eclipse.core.runtime.Preferences; 23 import org.eclipse.debug.internal.ui.DebugUIMessages; 24 import org.eclipse.debug.internal.ui.DebugUIPlugin; 25 import org.eclipse.debug.internal.ui.views.variables.VariablesViewMessages; 26 import org.eclipse.debug.ui.DebugUITools; 27 import org.eclipse.debug.ui.IDebugUIConstants; 28 import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; 29 import org.eclipse.debug.ui.memory.IMemoryRenderingSite; 30 import org.eclipse.debug.ui.memory.IMemoryRenderingSynchronizationService; 31 import org.eclipse.jface.action.IAction; 32 import org.eclipse.jface.action.IMenuManager; 33 import org.eclipse.jface.action.MenuManager; 34 import org.eclipse.jface.action.Separator; 35 import org.eclipse.jface.action.ToolBarManager; 36 import org.eclipse.jface.viewers.ISelection; 37 import org.eclipse.jface.viewers.ISelectionChangedListener; 38 import org.eclipse.jface.viewers.ISelectionProvider; 39 import org.eclipse.jface.viewers.IStructuredSelection; 40 import org.eclipse.jface.viewers.SelectionChangedEvent; 41 import org.eclipse.jface.viewers.StructuredSelection; 42 import org.eclipse.swt.SWT; 43 import org.eclipse.swt.custom.SashForm; 44 import org.eclipse.swt.custom.ViewForm; 45 import org.eclipse.swt.events.FocusAdapter; 46 import org.eclipse.swt.events.FocusEvent; 47 import org.eclipse.swt.widgets.Composite; 48 import org.eclipse.swt.widgets.Control; 49 import org.eclipse.swt.widgets.Event; 50 import org.eclipse.swt.widgets.Label; 51 import org.eclipse.swt.widgets.Listener; 52 import org.eclipse.swt.widgets.ToolBar; 53 import org.eclipse.ui.IActionBars; 54 import org.eclipse.ui.IPartListener2; 55 import org.eclipse.ui.IViewReference; 56 import org.eclipse.ui.IViewSite; 57 import org.eclipse.ui.IWorkbenchPart; 58 import org.eclipse.ui.IWorkbenchPartReference; 59 import org.eclipse.ui.PartInitException; 60 import org.eclipse.ui.PlatformUI; 61 import org.eclipse.ui.commands.ICommandService; 62 import org.eclipse.ui.contexts.IContextService; 63 import org.eclipse.ui.handlers.IHandlerService; 64 import org.eclipse.ui.part.ViewPart; 65 66 70 public class MemoryView extends ViewPart implements IMemoryRenderingSite { 71 72 protected MemoryViewSelectionProvider fSelectionProvider; 73 private MemoryViewPartListener fPartListener; 74 75 private SashForm fSashForm; 76 private Hashtable fViewPanes = new Hashtable (); 77 private Hashtable fViewPaneControls = new Hashtable (); 78 private ArrayList fVisibleViewPanes = new ArrayList (); 79 private boolean fVisible; 80 81 private ArrayList fWeights = new ArrayList (); 82 83 private static final String VISIBILITY_PREF = IDebugUIConstants.ID_MEMORY_VIEW+".viewPanesVisibility"; private static final String ID_MEMORY_VIEW_CONTEXT = "org.eclipse.debug.ui.memoryview"; private static final String ID_ADD_MEMORY_BLOCK_COMMAND = "org.eclipse.debug.ui.commands.addMemoryMonitor"; private static final String ID_TOGGLE_MEMORY_MONITORS_PANE_COMMAND = "org.eclipse.debug.ui.commands.toggleMemoryMonitorsPane"; private static final String ID_NEXT_MEMORY_BLOCK_COMMAND = "org.eclipse.debug.ui.commands.nextMemoryBlock"; 89 public static final String VIEW_PANE_ORIENTATION_PREF = IDebugUIConstants.ID_MEMORY_VIEW+".orientation"; public static final int HORIZONTAL_VIEW_ORIENTATION = 0; 91 public static final int VERTICAL_VIEW_ORIENTATION =1; 92 93 private String [] defaultVisiblePaneIds ={MemoryBlocksTreeViewPane.PANE_ID, IDebugUIConstants.ID_RENDERING_VIEW_PANE_1}; 94 95 private MemoryBlocksTreeViewPane fMemBlkViewer; 96 97 private MemoryViewSynchronizationService fSyncService; 98 99 private boolean fPinMBDisplay = false; private static int fViewCnt = 0; 101 102 private AbstractHandler fAddHandler; 103 private AbstractHandler fToggleMonitorsHandler; 104 private AbstractHandler fNextMemoryBlockHandler; 105 106 private ViewPaneOrientationAction[] fOrientationActions; 107 private int fViewOrientation = HORIZONTAL_VIEW_ORIENTATION; 108 109 private String fActivePaneId; 110 111 class MemoryViewSelectionProvider implements ISelectionProvider, ISelectionChangedListener 112 { 113 ArrayList fListeners = new ArrayList (); 114 115 IStructuredSelection fSelections = new StructuredSelection(); 116 117 120 public void addSelectionChangedListener(ISelectionChangedListener listener) 121 { 122 if (!fListeners.contains(listener)) 123 fListeners.add(listener); 124 125 } 126 127 130 public ISelection getSelection() 131 { 132 return fSelections; 133 } 134 135 138 public void removeSelectionChangedListener(ISelectionChangedListener listener) 139 { 140 if (fListeners.contains(listener)) 141 fListeners.remove(listener); 142 143 } 144 145 148 public void setSelection(ISelection selection) 149 { 150 if (selection instanceof IStructuredSelection) 151 { 152 boolean fireChanged = false; 153 154 if (fSelections.getFirstElement() != ((IStructuredSelection)selection).getFirstElement()) 156 fireChanged = true; 157 158 fSelections = (IStructuredSelection)selection; 159 160 if (fireChanged) 161 fireChanged(); 162 } 163 } 164 165 public void fireChanged() 166 { 167 SelectionChangedEvent evt = new SelectionChangedEvent(this, getSelection()); 168 for (int i=0; i<fListeners.size(); i++) 169 { 170 ((ISelectionChangedListener)fListeners.get(i)).selectionChanged(evt); 171 } 172 } 173 174 177 public void selectionChanged(SelectionChangedEvent event) { 178 ISelection viewPaneSelection = event.getSelection(); 179 180 if (viewPaneSelection instanceof IStructuredSelection) 181 { 182 Object selected = ((IStructuredSelection)viewPaneSelection).getFirstElement(); 183 184 if (selected != null) 185 { 186 StructuredSelection strucSelection = new StructuredSelection(new Object []{selected}); 187 setSelection(strucSelection); 188 } 189 else 190 { 191 setSelection(viewPaneSelection); 192 } 193 } 194 } 195 } 196 197 class MemoryViewPartListener implements IPartListener2 198 { 199 IMemoryRenderingSite fView = null; 200 201 public MemoryViewPartListener(IMemoryRenderingSite view) 202 { 203 fView = view; 204 } 205 206 209 public void partActivated(IWorkbenchPartReference ref) { 210 } 211 212 215 public void partBroughtToTop(IWorkbenchPartReference ref) { 216 } 217 218 221 public void partClosed(IWorkbenchPartReference ref) { 222 } 223 224 227 public void partDeactivated(IWorkbenchPartReference ref) { 228 } 229 230 233 public void partHidden(IWorkbenchPartReference ref) { 234 235 IWorkbenchPart part = ref.getPart(false); 236 237 if (part == fView) 238 { 239 setVisible(false); 240 } 241 } 242 243 246 public void partVisible(IWorkbenchPartReference ref) { 247 IWorkbenchPart part = ref.getPart(false); 248 249 if (part == fView) 250 { 251 setVisible(true); 252 restoreView(); 253 } 254 255 } 256 257 260 public void partInputChanged(IWorkbenchPartReference ref) { 261 } 262 263 public void partOpened(IWorkbenchPartReference ref) 264 { 265 } 266 } 267 268 public void init(IViewSite site) throws PartInitException { 269 super.init(site); 270 271 fViewCnt ++; 272 String secondaryId = site.getSecondaryId(); 273 if (secondaryId != null) 274 MemoryViewIdRegistry.registerView(secondaryId); 275 276 if (fViewCnt == 1) 281 { 282 if (DebugUIPlugin.getActiveWorkbenchWindow() != null && 284 DebugUIPlugin.getActiveWorkbenchWindow().getActivePage() != null) 285 { 286 IViewReference references[] = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences(); 287 for (int i=0; i<references.length; i++) 288 { 289 if (references[i].getSecondaryId() != null) 290 { 291 MemoryViewIdRegistry.registerView(references[i].getSecondaryId()); 292 } 293 } 294 } 295 } 296 297 fSyncService = new MemoryViewSynchronizationService(); 298 } 299 300 303 public void createPartControl(Composite parent) { 304 fSashForm = new SashForm(parent, SWT.HORIZONTAL); 305 306 fSelectionProvider = new MemoryViewSelectionProvider(); 307 308 getSite().setSelectionProvider(fSelectionProvider); 310 311 createMemoryBlocksTreeViewPane(fSashForm); 312 createRenderingViewPane(IDebugUIConstants.ID_RENDERING_VIEW_PANE_1); 313 createRenderingViewPane(IDebugUIConstants.ID_RENDERING_VIEW_PANE_2); 314 315 setVisible(true); 316 317 Integer [] weights = (Integer [])fWeights.toArray(new Integer [fWeights.size()]); 319 int[] intWeights = new int[weights.length]; 320 for (int i=0; i<weights.length; i++) 321 { 322 intWeights[i] = weights[i].intValue(); 323 } 324 fSashForm.setWeights(intWeights); 325 loadViewPanesVisibility(); 326 327 createOrientationActions(); 328 loadOrientation(); 329 330 fPartListener = new MemoryViewPartListener(this); 331 getSite().getPage().addPartListener(fPartListener); 332 activateHandlers(); 333 restoreView(); 335 } 336 337 338 public void activateHandlers() { 339 ICommandService commandSupport = (ICommandService)getSite().getService(ICommandService.class); 340 IHandlerService handlerService = (IHandlerService)getSite().getService(IHandlerService.class); 341 IContextService contextSupport = (IContextService)getSite().getService(IContextService.class); 342 343 if (commandSupport != null && handlerService != null && contextSupport != null) 344 { 345 contextSupport.activateContext(ID_MEMORY_VIEW_CONTEXT); 346 347 fAddHandler = new AbstractHandler() { 348 public Object execute(ExecutionEvent event) throws ExecutionException { 349 IAdaptable context = DebugUITools.getDebugContext(); 350 if (context != null && MemoryViewUtil.isValidSelection(new StructuredSelection(context))) 351 { 352 RetargetAddMemoryBlockAction action = new RetargetAddMemoryBlockAction(MemoryView.this); 353 action.run(); 354 action.dispose(); 355 } 356 return null; 357 }}; 358 handlerService.activateHandler(ID_ADD_MEMORY_BLOCK_COMMAND, fAddHandler); 359 360 fToggleMonitorsHandler = new AbstractHandler() { 361 public Object execute(ExecutionEvent event) throws ExecutionException { 362 ToggleMemoryMonitorsAction action = new ToggleMemoryMonitorsAction(); 363 action.init(MemoryView.this); 364 action.run(); 365 action.dispose(); 366 return null; 367 } 368 }; 369 370 handlerService.activateHandler(ID_TOGGLE_MEMORY_MONITORS_PANE_COMMAND, fToggleMonitorsHandler); 371 372 fNextMemoryBlockHandler = new AbstractHandler() { 373 374 public Object execute(ExecutionEvent event) 375 throws ExecutionException { 376 SwitchMemoryBlockAction action = new SwitchMemoryBlockAction(); 377 action.init(MemoryView.this); 378 action.run(); 379 action.dispose(); 380 return null; 381 } 382 }; 383 handlerService.activateHandler(ID_NEXT_MEMORY_BLOCK_COMMAND, fNextMemoryBlockHandler); 384 } 385 } 386 387 390 private void createMemoryBlocksTreeViewPane(Composite parent) { 391 392 fMemBlkViewer = new MemoryBlocksTreeViewPane(this); 393 fViewPanes.put(MemoryBlocksTreeViewPane.PANE_ID, fMemBlkViewer); 394 ViewForm viewerViewForm = new ViewForm(parent, SWT.NONE); 395 PlatformUI.getWorkbench().getHelpSystem().setHelp(viewerViewForm, IDebugUIConstants.PLUGIN_ID + ".MemoryView_context"); fViewPaneControls.put(MemoryBlocksTreeViewPane.PANE_ID, viewerViewForm); 397 fWeights.add(new Integer (15)); 398 399 fMemBlkViewer.addSelectionListener(fSelectionProvider); 400 401 Control viewerControl = fMemBlkViewer.createViewPane(viewerViewForm, MemoryBlocksTreeViewPane.PANE_ID, DebugUIMessages.MemoryView_Memory_monitors); 402 viewerViewForm.setContent(viewerControl); 403 404 ISelection selection = fMemBlkViewer.getSelectionProvider().getSelection(); 405 if (selection != null) 406 fSelectionProvider.setSelection(selection); 407 408 ToolBarManager viewerToolBarMgr = new ToolBarManager(SWT.FLAT); 409 IAction[] actions = fMemBlkViewer.getActions(); 410 for (int i=0; i<actions.length; i++) 411 { 412 viewerToolBarMgr.add(actions[i]); 413 } 414 ToolBar viewerToolbar = viewerToolBarMgr.createControl(viewerViewForm); 415 viewerViewForm.setTopRight(viewerToolbar); 416 417 Label viewerLabel = new Label(viewerViewForm, SWT.WRAP); 418 viewerLabel.setText(DebugUIMessages.MemoryView_Memory_monitors); 419 viewerViewForm.setTopLeft(viewerLabel); 420 421 fMemBlkViewer.getControl().addFocusListener(new FocusAdapter() { 422 public void focusGained(FocusEvent e) { 423 fActivePaneId = fMemBlkViewer.getId(); 424 }}); 425 } 426 427 431 private Listener createDeactivateListener(final IMemoryViewPane viewPane) { 432 Listener deactivateListener = new Listener() { 433 private String id=viewPane.getId(); 434 public void handleEvent(Event event) { 435 if (fActivePaneId.equals(id)) 436 viewPane.removeSelctionListener(fSelectionProvider); 437 }}; 438 return deactivateListener; 439 } 440 441 444 private Listener createActivateListener(final IMemoryViewPane viewPane) { 445 Listener activateListener = new Listener() { 446 private String id=viewPane.getId(); 447 public void handleEvent(Event event) { 448 fActivePaneId = id; 449 viewPane.addSelectionListener(fSelectionProvider); 450 fSelectionProvider.setSelection(viewPane.getSelectionProvider().getSelection()); 451 }}; 452 return activateListener; 453 } 454 455 458 public void createRenderingViewPane(final String paneId) { 459 final RenderingViewPane renderingPane = new RenderingViewPane(this); 460 fViewPanes.put(paneId, renderingPane); 461 ViewForm renderingViewForm = new ViewForm(fSashForm, SWT.NONE); 462 fViewPaneControls.put(paneId, renderingViewForm); 463 fWeights.add(new Integer (40)); 464 465 Control renderingControl = renderingPane.createViewPane(renderingViewForm, paneId, DebugUIMessages.MemoryView_Memory_renderings); 466 PlatformUI.getWorkbench().getHelpSystem().setHelp(renderingControl, IDebugUIConstants.PLUGIN_ID + ".MemoryView_context"); renderingViewForm.setContent(renderingControl); 468 469 ToolBarManager renderingViewMgr = new ToolBarManager(SWT.FLAT); 470 IAction[] renderingActions = renderingPane.getActions(); 471 for (int i=0; i<renderingActions.length; i++) 472 { 473 renderingViewMgr.add(renderingActions[i]); 474 } 475 476 ToolBar renderingToolbar = renderingViewMgr.createControl(renderingViewForm); 477 renderingViewForm.setTopRight(renderingToolbar); 478 479 Label renderingLabel = new Label(renderingViewForm, SWT.NONE); 480 renderingLabel.setText(renderingPane.getLabel()); 481 renderingViewForm.setTopLeft(renderingLabel); 482 483 Listener renderingActivateListener = createActivateListener(renderingPane); 484 renderingControl.addListener(SWT.Activate, renderingActivateListener); 485 486 Listener renderingDeactivateListener = createDeactivateListener(renderingPane); 487 renderingControl.addListener(SWT.Deactivate, renderingDeactivateListener); 488 489 } 490 493 public void setFocus() { 494 if (fActivePaneId == null) 495 fActivePaneId = fMemBlkViewer.getId(); 496 497 IMemoryViewPane pane = getViewPane(fActivePaneId); 498 pane.getControl().setFocus(); 499 } 500 501 public void dispose() { 502 getSite().getPage().removePartListener(fPartListener); 503 504 Enumeration enumeration = fViewPanes.elements(); 505 while (enumeration.hasMoreElements()) 506 { 507 Object element = enumeration.nextElement(); 508 if (element instanceof IMemoryViewPane) 509 { 510 ((IMemoryViewPane)element).dispose(); 511 } 512 } 513 514 fViewPaneControls.clear(); 515 516 IViewSite viewSite = getViewSite(); 517 String secondaryId = viewSite.getSecondaryId(); 518 if (secondaryId != null) 519 MemoryViewIdRegistry.deregisterView(secondaryId); 520 521 fSyncService.shutdown(); 522 523 if (fAddHandler != null) 524 fAddHandler.dispose(); 525 526 if (fToggleMonitorsHandler != null) 527 fToggleMonitorsHandler.dispose(); 528 529 if (fNextMemoryBlockHandler != null) 530 fNextMemoryBlockHandler.dispose(); 531 532 super.dispose(); 533 } 534 535 private void setVisible(boolean visible) 536 { 537 IMemoryViewPane[] viewPanes = getViewPanes(); 538 539 for (int i=0; i<viewPanes.length; i++) 540 { 541 if (fVisible) 545 viewPanes[i].setVisible(visible && viewPanes[i].isVisible()); 546 else 547 { 548 if (isViewPaneVisible(viewPanes[i].getId())) 549 viewPanes[i].setVisible(visible); 550 } 551 } 552 553 fVisible = visible; 554 } 555 556 559 public IMemoryViewPane getViewPane(String paneId) { 560 return (IMemoryViewPane)fViewPanes.get(paneId); 561 } 562 563 566 public IMemoryViewPane[] getViewPanes() { 567 IMemoryViewPane[] viewPanes = new IMemoryViewPane[fViewPanes.size()]; 568 569 Enumeration enumeration = fViewPanes.elements(); 570 int i=0; 571 while (enumeration.hasMoreElements()) 572 { 573 viewPanes[i] = (IMemoryViewPane)enumeration.nextElement(); 574 i++; 575 } 576 577 return viewPanes; 578 } 579 580 584 private void restoreView() { 585 IMemoryViewPane[] viewPanes = getViewPanes(); 586 for (int i=0; i<viewPanes.length; i++) 587 { 588 viewPanes[i].restoreViewPane(); 589 } 590 } 591 594 public void showViewPane(boolean show, String paneId) { 595 596 Control viewPaneControl = (Control)fViewPaneControls.get(paneId); 597 598 if (viewPaneControl != null) 599 { 600 Control children[] = fSashForm.getChildren(); 601 602 for (int i=0; i<children.length; i++) 603 { 604 if (children[i] == viewPaneControl) 605 { 606 children[i].setVisible(show); 607 IMemoryViewPane viewPane = (IMemoryViewPane)fViewPanes.get(paneId); 608 if (viewPane != null) 609 viewPane.setVisible(show); 610 } 611 } 612 fSashForm.layout(); 613 } 614 615 storeViewPaneVisibility(); 616 } 617 620 public boolean isViewPaneVisible(String paneId) { 621 return fVisibleViewPanes.contains(paneId); 622 } 623 624 private void storeViewPaneVisibility() 625 { 626 fVisibleViewPanes.clear(); 627 Preferences prefs = DebugUIPlugin.getDefault().getPluginPreferences(); 628 StringBuffer visibleViewPanes= new StringBuffer (); 629 630 Enumeration enumeration = fViewPaneControls.keys(); 631 632 while (enumeration.hasMoreElements()) 633 { 634 String paneId = (String )enumeration.nextElement(); 635 636 Control control = (Control)fViewPaneControls.get(paneId); 637 if (control.isVisible()) 638 { 639 visibleViewPanes.append(paneId); 640 visibleViewPanes.append(","); fVisibleViewPanes.add(paneId); 642 } 643 } 644 645 prefs.setValue(getVisibilityPrefId(), visibleViewPanes.toString()); 646 } 647 648 private void loadViewPanesVisibility() 649 { 650 Preferences prefs = DebugUIPlugin.getDefault().getPluginPreferences(); 651 String visiblePanes = prefs.getString(getVisibilityPrefId()); 652 653 if (visiblePanes != null && visiblePanes.length() > 0) 654 { 655 StringTokenizer tokenizer = new StringTokenizer (visiblePanes, ","); while (tokenizer.hasMoreTokens()) 657 { 658 String paneId = tokenizer.nextToken(); 659 fVisibleViewPanes.add(paneId); 660 } 661 } 662 else 663 { 664 for (int i=0 ;i<defaultVisiblePaneIds.length; i++) 665 { 666 fVisibleViewPanes.add(defaultVisiblePaneIds[i]); 667 } 668 } 669 670 Enumeration enumeration = fViewPaneControls.keys(); 671 while (enumeration.hasMoreElements()) 672 { 673 String paneId = (String )enumeration.nextElement(); 674 boolean visible = false; 675 if(fVisibleViewPanes.contains(paneId)) 676 visible = true; 677 678 Control control = (Control)fViewPaneControls.get(paneId); 679 control.setVisible(visible); 680 681 IMemoryViewPane viewPane = (IMemoryViewPane)fViewPanes.get(paneId); 682 viewPane.setVisible(visible); 683 } 684 685 fSashForm.layout(); 686 } 687 688 private void loadOrientation() 689 { 690 Preferences prefs = DebugUIPlugin.getDefault().getPluginPreferences(); 691 fViewOrientation = prefs.getInt(getOrientationPrefId()); 692 693 for (int i=0; i<fOrientationActions.length; i++) 694 { 695 if (fOrientationActions[i].getOrientation() == fViewOrientation) 696 { 697 fOrientationActions[i].run(); 698 } 699 } 700 updateOrientationActions(); 701 } 702 703 private void saveOrientation() 704 { 705 Preferences prefs = DebugUIPlugin.getDefault().getPluginPreferences(); 706 prefs.setValue(getOrientationPrefId(), fViewOrientation); 707 } 708 709 private void updateOrientationActions() 710 { 711 for (int i=0; i<fOrientationActions.length; i++) 712 { 713 if (fOrientationActions[i].getOrientation() == fViewOrientation) 714 { 715 fOrientationActions[i].setChecked(true); 716 } 717 else 718 { 719 fOrientationActions[i].setChecked(false); 720 } 721 722 } 723 } 724 725 728 public IMemoryRenderingSynchronizationService getSynchronizationService() { 729 return fSyncService; 730 } 731 732 735 public IMemoryRenderingContainer[] getMemoryRenderingContainers() { 736 Enumeration enumeration = fViewPanes.elements(); 737 ArrayList containers = new ArrayList (); 738 while (enumeration.hasMoreElements()){ 739 Object obj = enumeration.nextElement(); 740 if (obj instanceof IMemoryRenderingContainer) 741 containers.add(obj); 742 } 743 744 return (IMemoryRenderingContainer[])containers.toArray(new IMemoryRenderingContainer[containers.size()]); 745 } 746 747 750 public IMemoryRenderingContainer getContainer(String id) { 751 Object viewPane = fViewPanes.get(id); 752 753 if (viewPane instanceof IMemoryRenderingContainer) 754 return (IMemoryRenderingContainer)viewPane; 755 756 return null; 757 } 758 759 public boolean isPinMBDisplay() { 760 return fPinMBDisplay; 761 } 762 763 764 public void setPinMBDisplay(boolean pinMBDisplay) { 765 fPinMBDisplay = pinMBDisplay; 766 } 767 768 private String getVisibilityPrefId() 769 { 770 IViewSite vs = getViewSite(); 771 String viewId = vs.getSecondaryId(); 772 773 if (viewId != null) 774 return VISIBILITY_PREF + "." + viewId; 776 return VISIBILITY_PREF; 777 } 778 779 private String getOrientationPrefId() 780 { 781 IViewSite vs = getViewSite(); 782 String viewId = vs.getSecondaryId(); 783 784 if (viewId != null) 785 return VIEW_PANE_ORIENTATION_PREF + "." + viewId; 787 return VIEW_PANE_ORIENTATION_PREF; 788 } 789 790 private void createOrientationActions() 791 { 792 IActionBars actionBars = getViewSite().getActionBars(); 793 IMenuManager viewMenu = actionBars.getMenuManager(); 794 795 fOrientationActions = new ViewPaneOrientationAction[2]; 796 fOrientationActions[0] = new ViewPaneOrientationAction(this, HORIZONTAL_VIEW_ORIENTATION); 797 fOrientationActions[1] = new ViewPaneOrientationAction(this, VERTICAL_VIEW_ORIENTATION); 798 799 viewMenu.add(new Separator()); 800 MenuManager layoutSubMenu = new MenuManager(VariablesViewMessages.VariablesView_40); 801 layoutSubMenu.add(fOrientationActions[0]); 802 layoutSubMenu.add(fOrientationActions[1]); 803 viewMenu.add(layoutSubMenu); 804 viewMenu.add(new Separator()); 805 } 806 807 public void setViewPanesOrientation(int orientation) 808 { 809 fViewOrientation = orientation; 810 if (fViewOrientation == VERTICAL_VIEW_ORIENTATION) 811 fSashForm.setOrientation(SWT.VERTICAL); 812 else 813 fSashForm.setOrientation(SWT.HORIZONTAL); 814 815 saveOrientation(); 816 updateOrientationActions(); 817 } 818 819 public int getViewPanesOrientation() 820 { 821 return fViewOrientation; 822 } 823 } 824 | Popular Tags |