1 /******************************************************************************* 2 * Copyright (c) 2000, 2015 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.ui; 15 16 import org.eclipse.jface.dialogs.IPageChangeProvider; 17 import org.eclipse.jface.dialogs.IPageChangedListener; 18 import org.eclipse.jface.dialogs.PageChangedEvent; 19 20 /** 21 * Interface for listening to part lifecycle events. 22 * <p> 23 * This is a replacement for <code>IPartListener</code>. 24 * <p> 25 * As of 3.5, if the implementation of this listener also implements 26 * {@link IPageChangedListener} then it will also be notified about 27 * {@link PageChangedEvent}s from parts that implement 28 * {@link IPageChangeProvider}. 29 * </p> 30 * <p> 31 * This interface may be implemented by clients. 32 * </p> 33 * 34 * @see IPartService#addPartListener(IPartListener2) 35 */ 36 public interface IPartListener2 { 37 38 /** 39 * Notifies this listener that the given part has been activated. 40 * 41 * @param partRef the part that was activated 42 * @see IWorkbenchPage#activate 43 */ partActivated(IWorkbenchPartReference partRef)44 default void partActivated(IWorkbenchPartReference partRef) { 45 } 46 47 /** 48 * Notifies this listener that the given part has been brought to the top. 49 * <p> 50 * These events occur when an editor is brought to the top in the editor area, 51 * or when a view is brought to the top in a page book with multiple views. They 52 * are normally only sent when a part is brought to the top programmatically 53 * (via <code>IPerspective.bringToTop</code>). When a part is activated by the 54 * user clicking on it, only <code>partActivated</code> is sent. 55 * </p> 56 * 57 * @param partRef the part that was surfaced 58 * @see IWorkbenchPage#bringToTop 59 */ partBroughtToTop(IWorkbenchPartReference partRef)60 default void partBroughtToTop(IWorkbenchPartReference partRef) { 61 } 62 63 /** 64 * Notifies this listener that the given part has been closed. 65 * <p> 66 * Note that if other perspectives in the same page share the view, this 67 * notification is not sent. It is only sent when the view is being removed from 68 * the page entirely (it is being disposed). 69 * </p> 70 * 71 * @param partRef the part that was closed 72 * @see IWorkbenchPage#hideView 73 */ partClosed(IWorkbenchPartReference partRef)74 default void partClosed(IWorkbenchPartReference partRef) { 75 } 76 77 /** 78 * Notifies this listener that the given part has been deactivated. 79 * 80 * @param partRef the part that was deactivated 81 * @see IWorkbenchPage#activate 82 */ partDeactivated(IWorkbenchPartReference partRef)83 default void partDeactivated(IWorkbenchPartReference partRef) { 84 } 85 86 /** 87 * Notifies this listener that the given part has been opened. 88 * <p> 89 * Note that if other perspectives in the same page share the view, this 90 * notification is not sent. It is only sent when the view is being newly opened 91 * in the page (it is being created). 92 * </p> 93 * 94 * @param partRef the part that was opened 95 * @see IWorkbenchPage#showView 96 */ partOpened(IWorkbenchPartReference partRef)97 default void partOpened(IWorkbenchPartReference partRef) { 98 } 99 100 /** 101 * Notifies this listener that the given part is hidden or obscured by another 102 * part. 103 * 104 * @param partRef the part that is hidden or obscured by another part 105 */ partHidden(IWorkbenchPartReference partRef)106 default void partHidden(IWorkbenchPartReference partRef) { 107 } 108 109 /** 110 * Notifies this listener that the given part is visible. 111 * 112 * @param partRef the part that is visible 113 */ partVisible(IWorkbenchPartReference partRef)114 default void partVisible(IWorkbenchPartReference partRef) { 115 } 116 117 /** 118 * Notifies this listener that the given part's input was changed. 119 * 120 * @param partRef the part whose input was changed 121 */ partInputChanged(IWorkbenchPartReference partRef)122 default void partInputChanged(IWorkbenchPartReference partRef) { 123 } 124 } 125