1 /******************************************************************************* 2 * Copyright (c) 2005, 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 15 package org.eclipse.jface.menus; 16 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.CoolBar; 19 import org.eclipse.swt.widgets.Menu; 20 import org.eclipse.swt.widgets.ToolBar; 21 22 /** 23 * <p> 24 * Provides a hook by which third-party code can contribute SWT widgets to a 25 * menu, tool bar or status line. This can be used, for example, to add a combo 26 * box to the status line, or a "Location" bar to the tool bar. 27 * </p> 28 * <p> 29 * It is possible for fill and dispose to be called multiple times for a single 30 * instance of <code>IWidget</code>. 31 * </p> 32 * <p> 33 * Clients may implement, but must not extend. 34 * </p> 35 * 36 * @since 3.2 37 */ 38 public interface IWidget { 39 40 /** 41 * Disposes of the underlying widgets. This can be called when the widget is 42 * becoming hidden. 43 */ dispose()44 public void dispose(); 45 46 /** 47 * Fills the given composite control with controls representing this widget. 48 * 49 * @param parent 50 * the parent control 51 */ fill(Composite parent)52 public void fill(Composite parent); 53 54 /** 55 * Fills the given menu with controls representing this widget. 56 * 57 * @param parent 58 * the parent menu 59 * @param index 60 * the index where the controls are inserted, or <code>-1</code> 61 * to insert at the end 62 */ fill(Menu parent, int index)63 public void fill(Menu parent, int index); 64 65 /** 66 * Fills the given tool bar with controls representing this contribution 67 * item. 68 * 69 * @param parent 70 * the parent tool bar 71 * @param index 72 * the index where the controls are inserted, or <code>-1</code> 73 * to insert at the end 74 */ fill(ToolBar parent, int index)75 public void fill(ToolBar parent, int index); 76 77 /** 78 * Fills the given cool bar with controls representing this contribution 79 * item. 80 * 81 * @param parent 82 * the parent cool bar 83 * @param index 84 * the index where the controls are inserted, or <code>-1</code> 85 * to insert at the end 86 */ fill(CoolBar parent, int index)87 public void fill(CoolBar parent, int index); 88 } 89