KickJava   Java API By Example, From Geeks To Geeks.

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


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.jface.action.Action;
14 import org.eclipse.jface.action.IContributionItem;
15 import org.eclipse.jface.action.IMenuManager;
16 import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
17 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
18 import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
19 import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
20 import org.eclipse.ui.IActionBars;
21 import org.eclipse.ui.IViewSite;
22 import org.eclipse.ui.IWorkbenchSite;
23 import org.eclipse.ui.actions.ActionContext;
24
25 /**
26  * General synchronize page actions
27  */

28 public class DefaultSynchronizePageActions extends SynchronizePageActionGroup {
29     
30     // Actions
31
private OpenWithActionGroup openWithActions;
32     private RefactorActionGroup refactorActions;
33     private SyncViewerShowPreferencesAction showPreferences;
34     
35     /* (non-Javadoc)
36      * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
37      */

38     public void initialize(ISynchronizePageConfiguration configuration) {
39         super.initialize(configuration);
40         final ISynchronizePageSite site = configuration.getSite();
41         IWorkbenchSite ws = site.getWorkbenchSite();
42         if (ws instanceof IViewSite) {
43             openWithActions = new OpenWithActionGroup(configuration, true);
44             refactorActions = new RefactorActionGroup(site);
45             configuration.setProperty(SynchronizePageConfiguration.P_OPEN_ACTION, new Action() {
46                 public void run() {
47                     openWithActions.openInCompareEditor();
48                 }
49             });
50             showPreferences = new SyncViewerShowPreferencesAction(configuration);
51         } else {
52             // TODO: Add open menu action which opens in compare editor input
53
}
54     }
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
58      */

59     public void fillActionBars(IActionBars actionBars) {
60         if (openWithActions != null) openWithActions.fillActionBars(actionBars);
61         if (refactorActions != null) refactorActions.fillActionBars(actionBars);
62         if (actionBars != null && showPreferences != null) {
63             IMenuManager menu = actionBars.getMenuManager();
64             appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, showPreferences);
65         }
66     }
67     
68     /* (non-Javadoc)
69      * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
70      */

71     public void updateActionBars() {
72         if (openWithActions != null) openWithActions.updateActionBars();
73         if (refactorActions != null) refactorActions.updateActionBars();
74     }
75     
76     /* (non-Javadoc)
77      * @see org.eclipse.team.ui.synchronize.IActionContribution#fillContextMenu(org.eclipse.jface.action.IMenuManager)
78      */

79     public void fillContextMenu(IMenuManager manager) {
80         
81         final IContributionItem fileGroup = findGroup(manager, ISynchronizePageConfiguration.FILE_GROUP);
82         if (openWithActions != null && fileGroup != null) {
83             openWithActions.fillContextMenu(manager, fileGroup.getId());
84         }
85         
86         final IContributionItem editGroup = findGroup(manager, ISynchronizePageConfiguration.EDIT_GROUP);
87         if (refactorActions != null && editGroup != null) {
88             refactorActions.fillContextMenu(manager, editGroup.getId());
89         }
90     }
91     
92     /* (non-Javadoc)
93      * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#dispose()
94      */

95     public void dispose() {
96         super.dispose();
97         if (refactorActions != null) refactorActions.dispose();
98         if (openWithActions != null) openWithActions.dispose();
99     }
100     
101     /* (non-Javadoc)
102      * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
103      */

104     public void setContext(ActionContext context) {
105         if (openWithActions != null) openWithActions.setContext(context);
106         if (refactorActions != null) refactorActions.setContext(context);
107     }
108 }
109
Popular Tags