1 /******************************************************************************* 2 * Copyright (c) 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.core.commands.operations; 12 13 /** 14 * <p> 15 * A simple, lightweight undo context that can be used to tag any operation. It 16 * does not provided a specialized label. This class may be instantiated by 17 * clients. This class may also be subclassed. 18 * </p> 19 * 20 * @since 3.1 21 */ 22 public class UndoContext implements IUndoContext { 23 24 /** 25 * <p> 26 * Get the label that describes the undo context. The default implementation 27 * returns the empty String. Subclasses may override. 28 * </p> 29 * 30 * @return the label for the context. 31 */ 32 public String getLabel() { 33 return ""; //$NON-NLS-1$ 34 } 35 36 /** 37 * <p> 38 * Return whether the specified context is considered a match for the 39 * receiving context. When a context matches another context, operations 40 * that have the context are considered to also have the matching context. 41 * The default implementation checks whether the supplied context is 42 * identical to this context. Subclasses may override. 43 * </p> 44 * 45 * @param context 46 * the context to be checked against the receiving context. 47 * 48 * @return <code>true</code> if the receiving context can be considered a 49 * match for the specified context, and <code>false</code> if it 50 * cannot. 51 */ 52 public boolean matches(IUndoContext context) { 53 return context == this; 54 } 55 } 56