KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > actions > NavigateAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.team.internal.ui.synchronize.actions;
12
13 import org.eclipse.compare.ICompareNavigator;
14 import org.eclipse.jface.action.Action;
15 import org.eclipse.team.internal.ui.Utils;
16 import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
17 import org.eclipse.team.ui.synchronize.*;
18 import org.eclipse.ui.IActionBars;
19 import org.eclipse.ui.actions.ActionFactory;
20
21 /**
22  * Action to navigate the changes shown in the Synchronize View. This
23  * will coordinate change browsing between the view and the compare
24  * editors.
25  *
26  * @since 3.0
27  */

28 public class NavigateAction extends Action {
29     private final boolean next;
30     private ISynchronizePageConfiguration configuration;
31     
32     public NavigateAction(ISynchronizePageConfiguration configuration, boolean next) {
33         this.configuration = configuration;
34         this.next = next;
35         IActionBars bars = configuration.getSite().getActionBars();
36         if (next) {
37             Utils.initAction(this, "action.navigateNext."); //$NON-NLS-1$
38
if (bars != null)
39                 bars.setGlobalActionHandler(ActionFactory.NEXT.getId(), this);
40         } else {
41             Utils.initAction(this, "action.navigatePrevious."); //$NON-NLS-1$
42
if (bars != null)
43                 bars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), this);
44         }
45     }
46     
47     /**
48      * Two types of navigation is supported: navigation that is specific to coordinating between a view
49      * and a compare editor and navigation simply using the configured navigator.
50      */

51     public void run() {
52         ICompareNavigator nav = (ICompareNavigator)configuration.getProperty(SynchronizePageConfiguration.P_NAVIGATOR);
53         nav.selectChange(next);
54     }
55 }
56
Popular Tags