1 /******************************************************************************* 2 * Copyright (c) 2006, 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.SWT; 18 import org.eclipse.swt.widgets.Composite; 19 import org.eclipse.swt.widgets.CoolBar; 20 import org.eclipse.swt.widgets.Menu; 21 import org.eclipse.swt.widgets.ToolBar; 22 23 /** 24 * This extension to the {@link IWidget} interface allows clients adding 25 * elements to the trim to receive notifications if the User moves the widget to 26 * another trim area. 27 * <p> 28 * This class is intended to be the base for any trim contributions. 29 * </p> 30 * @since 3.2 31 * 32 */ 33 public abstract class AbstractTrimWidget implements IWidget { 34 /** 35 * This method is called to initially construct the widget and is also called 36 * whenever the widget's composite has been moved to a trim area on a different 37 * side of the workbench. It is the client's responsibility to control the 38 * life-cycle of the Control it manages. 39 * <p> 40 * For example: If the implementation is constructing a {@link ToolBar} and the 41 * orientation were to change from horizontal to vertical it would have to 42 * <code>dispose</code> its old ToolBar and create a new one with the correct 43 * orientation. 44 * </p> 45 * <p> 46 * The sides can be one of: 47 * </p> 48 * <ul> 49 * <li>{@link SWT#TOP}</li> 50 * <li>{@link SWT#BOTTOM}</li> 51 * <li>{@link SWT#LEFT}</li> 52 * <li>{@link SWT#RIGHT}</li> 53 * </ul> 54 * 55 * @param parent The parent to (re)create the widget under 56 * 57 * @param oldSide The previous side ({@link SWT#DEFAULT} on the initial fill) 58 * @param newSide The current side 59 */ fill(Composite parent, int oldSide, int newSide)60 public abstract void fill(Composite parent, int oldSide, int newSide); 61 62 @Override dispose()63 public abstract void dispose(); 64 65 @Override fill(Composite parent)66 public void fill(Composite parent) { 67 } 68 69 @Override fill(Menu parent, int index)70 public void fill(Menu parent, int index) { 71 } 72 73 @Override fill(ToolBar parent, int index)74 public void fill(ToolBar parent, int index) { 75 } 76 77 @Override fill(CoolBar parent, int index)78 public void fill(CoolBar parent, int index) { 79 } 80 } 81