KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > ui > TeamUI


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.ui;
12
13 import org.eclipse.jface.util.IPropertyChangeListener;
14 import org.eclipse.team.internal.ui.TeamUIPlugin;
15 import org.eclipse.team.internal.ui.history.GenericHistoryView;
16 import org.eclipse.team.internal.ui.registry.TeamContentProviderManager;
17 import org.eclipse.team.ui.history.IHistoryPageSource;
18 import org.eclipse.team.ui.history.IHistoryView;
19 import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
20 import org.eclipse.team.ui.synchronize.ISynchronizeManager;
21 import org.eclipse.ui.*;
22
23 /**
24  * TeamUI contains public API for generic UI-based Team functionality.
25  * <p>
26  * This class is not intended to be subclassed or instantiated by clients
27  */

28 public class TeamUI {
29     
30     /**
31      * Property constant indicating the global ignores list has changed.
32      */

33     public static final String JavaDoc GLOBAL_IGNORES_CHANGED = TeamUIPlugin.ID + "global_ignores_changed"; //$NON-NLS-1$
34

35     /**
36      * Property constant indicating the global file types list has changed.
37      * @since 3.1
38      */

39     public static final String JavaDoc GLOBAL_FILE_TYPES_CHANGED = TeamUIPlugin.ID + "global_file_types_changed"; //$NON-NLS-1$
40

41     /**
42      * Return the synchronize manager.
43      *
44      * @return the synchronize manager
45      * @since 3.0
46      */

47     public static ISynchronizeManager getSynchronizeManager() {
48         return TeamUIPlugin.getPlugin().getSynchronizeManager();
49     }
50
51     /**
52      * Register for changes made to Team properties.
53      *
54      * @param listener the listener to add
55      */

56     public static void addPropertyChangeListener(IPropertyChangeListener listener) {
57         TeamUIPlugin.addPropertyChangeListener(listener);
58     }
59
60     /**
61      * Remove the listener from Team property change listener list.
62      *
63      * @param listener the listener to remove
64      */

65     public static void removePropertyChangeListener(IPropertyChangeListener listener) {
66         TeamUIPlugin.removePropertyChangeListener(listener);
67     }
68     
69     /**
70      * Shows the history view and returns a handle to it. Note that in the case of many
71      * history views, the main history view is the one returned here.
72      *
73      * @return an IHistoryView which is the main history view if it is found or null if it can't be found
74      * @since 3.2
75      */

76     public static IHistoryView getHistoryView() {
77         try {
78             TeamUIPlugin.getActivePage().showView(IHistoryView.VIEW_ID);
79             return (IHistoryView) TeamUIPlugin.getActivePage().findView(IHistoryView.VIEW_ID);
80         } catch (PartInitException e) {
81         }
82
83         return null;
84     }
85     
86     /**
87      * Shows a history view containing the given input and returns a handle to the view
88      * or <code>null</code> if no history was available for the given input. If an appropriate
89      * instance of a history view is already opened, its input will be changed and the view will
90      * be activated. Otherwise a new view will be opened.
91      * @param page the workbench page containing the history view
92      * @param input the input whose history is to be displayed
93      * @param pageSource the history page source from which to obtain the page or <code>null</code>
94      * if the page source should be determined using the Adapter manager.
95      *
96      * @return an IHistoryView which is the main history view if it is found or null if it can't be found
97      * @since 3.3
98      */

99     public static IHistoryView showHistoryFor(IWorkbenchPage page, Object JavaDoc input, IHistoryPageSource pageSource) {
100         try {
101             IHistoryView view = (IHistoryView) page.findView(IHistoryView.VIEW_ID);
102             if (view == null) {
103                 page.showView(IHistoryView.VIEW_ID);
104                 view = (IHistoryView) TeamUIPlugin.getActivePage().findView(IHistoryView.VIEW_ID);
105                 return showInputInView(page, input, view, pageSource);
106             } else {
107                 view = ((GenericHistoryView)view).findAppropriateHistoryViewFor(input, pageSource);
108                 if (view == null) {
109                     view = (IHistoryView) page.showView(IHistoryView.VIEW_ID, IHistoryView.VIEW_ID + System.currentTimeMillis(), IWorkbenchPage.VIEW_CREATE);
110                     return showInputInView(page, input, view, pageSource);
111                 } else {
112                     return showInputInView(page, input, view, pageSource);
113                 }
114             }
115         } catch (PartInitException e) {
116         }
117
118         return null;
119     }
120
121     private static IHistoryView showInputInView(IWorkbenchPage page,
122             Object JavaDoc input, IHistoryView view, IHistoryPageSource pageSource) {
123         page.activate((IWorkbenchPart)view);
124         ((GenericHistoryView)view).showHistoryPageFor(input, true, false, pageSource);
125         return view;
126     }
127     
128     /**
129      * Return the team content provider manager which gives access to the team
130      * content proivders registered with the
131      * <code>org.eclipse.team.ui.teamContentProviders</code> extension point.
132      *
133      * @return the team content provider manager
134      * @since 3.2
135      */

136     public static ITeamContentProviderManager getTeamContentProviderManager() {
137         return TeamContentProviderManager.getInstance();
138     }
139 }
140
Popular Tags