/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.compare; import java.util.ResourceBundle; import org.eclipse.jface.action.Action; import org.eclipse.compare.internal.CompareNavigator; import org.eclipse.compare.internal.CompareUIPlugin; import org.eclipse.compare.internal.Utilities; /** * A NavigationAction is used to navigate through the individual * differences of a CompareEditorInput. *

* Clients may instantiate this class; it is not intended to be subclassed. *

* @since 2.0 */ public class NavigationAction extends Action { private boolean fNext; private CompareEditorInput fCompareEditorInput; /** * Creates a NavigationAction. * * @param next if true action goes to the next difference; otherwise to the previous difference. */ public NavigationAction(boolean next) { this(CompareUIPlugin.getResourceBundle(), next); } /** * Creates a NavigationAction that initializes its attributes * from the given ResourceBundle. * * @param bundle is used to initialize the action * @param next if true action goes to the next difference; otherwise to the previous difference. */ public NavigationAction(ResourceBundle bundle, boolean next) { Utilities.initAction(this, bundle, next ? "action.Next." : "action.Previous."); //$NON-NLS-2$ //$NON-NLS-1$ fNext= next; } public void run() { if (fCompareEditorInput != null) { Object adapter= fCompareEditorInput.getAdapter(CompareNavigator.class); if (adapter instanceof CompareNavigator) ((CompareNavigator)adapter).selectChange(fNext); } } /** * Sets the CompareEditorInput on which this action operates. * * @param input the CompareEditorInput on which this action operates; if null action does nothing */ public void setCompareEditorInput(CompareEditorInput input) { fCompareEditorInput= input; } }