KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > DialogSynchronizePageSite


1 /*******************************************************************************
2  * Copyright (c) 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;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.jface.action.*;
18 import org.eclipse.jface.dialogs.IDialogSettings;
19 import org.eclipse.jface.viewers.ISelectionProvider;
20 import org.eclipse.swt.widgets.Shell;
21 import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
22 import org.eclipse.ui.*;
23 import org.eclipse.ui.commands.*;
24 import org.eclipse.ui.services.IServiceLocator;
25
26 /**
27  * A synchronize page site for use in dialogs.
28  */

29 public class DialogSynchronizePageSite implements ISynchronizePageSite {
30
31     private final Shell shell;
32     private ISelectionProvider selectionProvider;
33     private IActionBars actionBars;
34     private final boolean isModal;
35     // Keybindings enabled in the dialog, these should be removed
36
// when the dialog is closed.
37
private List JavaDoc actionHandlers = new ArrayList JavaDoc(2);
38     
39     /**
40      * Create a site for use in a dialog
41      * @param shell the shell
42      * @param isModal whether the dialog is model
43      */

44     public DialogSynchronizePageSite(Shell shell, boolean isModal) {
45         this.shell = shell;
46         this.isModal = isModal;
47     }
48     /* (non-Javadoc)
49      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getSelectionProvider()
50      */

51     public ISelectionProvider getSelectionProvider() {
52         return selectionProvider;
53     }
54     /* (non-Javadoc)
55      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getShell()
56      */

57     public Shell getShell() {
58         return shell;
59     }
60     /* (non-Javadoc)
61      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)
62      */

63     public void setSelectionProvider(ISelectionProvider provider) {
64         selectionProvider = provider;
65     }
66     /* (non-Javadoc)
67      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getWorkbenchSite()
68      */

69     public IWorkbenchSite getWorkbenchSite() {
70         return null;
71     }
72     /* (non-Javadoc)
73      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getPart()
74      */

75     public IWorkbenchPart getPart() {
76         return null;
77     }
78     /* (non-Javadoc)
79      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getKeyBindingService()
80      */

81     public IKeyBindingService getKeyBindingService() {
82         return null;
83     }
84     /* (non-Javadoc)
85      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#setFocus()
86      */

87     public void setFocus() {
88     }
89     /* (non-Javadoc)
90      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getPageSettings()
91      */

92     public IDialogSettings getPageSettings() {
93         return null;
94     }
95     /* (non-Javadoc)
96      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getActionBars()
97      */

98     public IActionBars getActionBars() {
99         return actionBars;
100     }
101     /* (non-Javadoc)
102      * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#isModal()
103      */

104     public boolean isModal() {
105         return isModal;
106     }
107     
108     /**
109      * Create the action-bars for this site.
110      * @param toolbar the toolbar for the action bar
111      */

112     public void createActionBars(final IToolBarManager toolbar) {
113         if (actionBars == null) {
114             actionBars = new IActionBars() {
115                 public void clearGlobalActionHandlers() {
116                 }
117                 public IAction getGlobalActionHandler(String JavaDoc actionId) {
118                     return null;
119                 }
120                 public IMenuManager getMenuManager() {
121                     return null;
122                 }
123                 public IStatusLineManager getStatusLineManager() {
124                     return null;
125                 }
126                 public IToolBarManager getToolBarManager() {
127                     return toolbar;
128                 }
129                 public void setGlobalActionHandler(String JavaDoc actionId, IAction action) {
130                     if (actionId != null && !"".equals(actionId)) { //$NON-NLS-1$
131
IHandler handler = new ActionHandler(action);
132                         HandlerSubmission handlerSubmission = new HandlerSubmission(null, shell, null, actionId, handler, Priority.MEDIUM);
133                         PlatformUI.getWorkbench().getCommandSupport().addHandlerSubmission(handlerSubmission);
134                         actionHandlers.add(handlerSubmission);
135                     }
136                 }
137
138                 public void updateActionBars() {
139                 }
140                 public IServiceLocator getServiceLocator() {
141                     return null;
142                 }
143             };
144         }
145     }
146     
147     /**
148      * Cleanup when the dialog is closed
149      */

150     public void dispose() {
151         IWorkbenchCommandSupport cm = PlatformUI.getWorkbench().getCommandSupport();
152         for (Iterator JavaDoc it = actionHandlers.iterator(); it.hasNext();) {
153             HandlerSubmission handler = (HandlerSubmission) it.next();
154             cm.removeHandlerSubmission(handler);
155         }
156     }
157 }
Popular Tags