sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/pi/editors/PIPageEditorContributor.java
changeset 2 b9ab3b238396
child 12 ae255c9aa552
equal deleted inserted replaced
1:1050670c6980 2:b9ab3b238396
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 package com.nokia.carbide.cpp.pi.editors;
       
    20 
       
    21 import org.eclipse.jface.action.IMenuManager;
       
    22 import org.eclipse.jface.action.IToolBarManager;
       
    23 import org.eclipse.jface.action.MenuManager;
       
    24 import org.eclipse.jface.action.Separator;
       
    25 import org.eclipse.ui.IActionBars;
       
    26 import org.eclipse.ui.IEditorPart;
       
    27 import org.eclipse.ui.IWorkbenchActionConstants;
       
    28 import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
       
    29 
       
    30 /**
       
    31  * Manages the installation/deinstallation of global actions for multi-page editors.
       
    32  * Responsible for the redirection of global actions to the active editor.
       
    33  * Multi-page contributor replaces the contributors for the individual editors in the multi-page editor.
       
    34  */
       
    35 public class PIPageEditorContributor extends MultiPageEditorActionBarContributor {
       
    36 	
       
    37 	private MenuManager piManager;
       
    38 
       
    39 	/**
       
    40 	 * Creates a multi-page contributor.
       
    41 	 */
       
    42 	public PIPageEditorContributor() {
       
    43 		super();
       
    44 		PIPageEditor.createActions();
       
    45 	}
       
    46 
       
    47 	public void setActivePage(IEditorPart part) {
       
    48 	}
       
    49 
       
    50 	public void contributeToMenu(IMenuManager manager) {
       
    51 		// record the ActionBars object
       
    52 		PIPageEditor.setMenuManager(manager);
       
    53 
       
    54 		// record the ActionBars object
       
    55 		if (getActionBars() != null)
       
    56 			PIPageEditor.setActionBars(getActionBars());
       
    57 
       
    58 		// create a top-level menu manager for PIPageEditor
       
    59 		if (piManager != null) {
       
    60 			piManager.dispose();
       
    61 		}
       
    62 		piManager = new MenuManager(Messages.getString("PIPageEditorContributor.PerformanceInvestigator"), PIPageEditor.menuID); //$NON-NLS-1$
       
    63 		manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, piManager);
       
    64 		PIPageEditor.setPIMenuManager(piManager);
       
    65 	}
       
    66 	
       
    67 	public void contributeToToolBar(IToolBarManager manager) {
       
    68 		// add the created actions to the tool bar
       
    69 		manager.add(new Separator("piEditorGroup1")); //$NON-NLS-1$
       
    70 		manager.add(PIPageEditor.getSelectTimeAction());
       
    71 		manager.add(new Separator("piEditorGroup2")); //$NON-NLS-1$
       
    72 		manager.add(PIPageEditor.getZoomInAction());
       
    73 		manager.add(PIPageEditor.getZoomOutAction());
       
    74 		manager.add(PIPageEditor.getZoomToSelectionAction());
       
    75 		manager.add(PIPageEditor.getZoomToTraceAction());
       
    76 	}
       
    77 	
       
    78 	public void init(IActionBars bars) {
       
    79 		super.init(bars);
       
    80 	}
       
    81 }