KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > ui > history > HistoryPage


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.ui.history;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.jface.util.IPropertyChangeListener;
15 import org.eclipse.team.internal.ui.PropertyChangeHandler;
16 import org.eclipse.ui.part.Page;
17
18 /**
19  * Abstract HistoryPage class that keeps track of the history page site.
20  * <p>
21  * Clients may subclass this class.
22  * @see IHistoryPage
23  * @since 3.2
24  */

25 public abstract class HistoryPage extends Page implements IHistoryPage, IAdaptable {
26     
27     private IHistoryPageSite site;
28     private Object JavaDoc input;
29     private IHistoryView historyView;
30     private PropertyChangeHandler fChangeHandler;
31     
32     /* (non-Javadoc)
33      * @see org.eclipse.team.ui.history.IHistoryPage#setSite(org.eclipse.team.ui.history.IHistoryPageSite)
34      */

35     public void setSite(IHistoryPageSite site) {
36         this.site = site;
37     }
38     
39     /* (non-Javadoc)
40      * @see org.eclipse.team.ui.history.IHistoryPage#getHistoryPageSite()
41      */

42     public IHistoryPageSite getHistoryPageSite() {
43         return site;
44     }
45
46     
47     /* (non-Javadoc)
48      * @see org.eclipse.team.ui.history.IHistoryPage#getInput()
49      */

50     public Object JavaDoc getInput() {
51         return input;
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.team.ui.history.IHistoryPage#setInput(java.lang.Object, boolean)
56      */

57     public boolean setInput(Object JavaDoc object) {
58         this.input = object;
59         return inputSet();
60     }
61
62     /**
63      * Called by HistoryPage after {@link #setInput(Object)}. Clients can
64      * gain access to the input by using {@link #getInput()}.
65      *
66      * @return <code>true</code> if the page was able to display the contents, <code>false</code> otherwise
67      */

68     public abstract boolean inputSet();
69     
70     
71     public void setHistoryView(IHistoryView historyView){
72         this.historyView=historyView;
73     }
74     
75     /* (non-Javadoc)
76      * @see org.eclipse.team.ui.history.IHistoryPage#getHistoryView()
77      */

78     public IHistoryView getHistoryView() {
79         if (historyView != null)
80             return historyView;
81         
82         return null;
83     }
84     
85     /* (non-Javadoc)
86      * @see org.eclipse.team.ui.history.IHistoryPage#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
87      */

88     public synchronized void addPropertyChangeListener(IPropertyChangeListener listener) {
89         if (fChangeHandler == null) {
90             fChangeHandler = new PropertyChangeHandler();
91         }
92         fChangeHandler.addPropertyChangeListener(listener);
93     }
94     
95     /* (non-Javadoc)
96      * @see org.eclipse.team.ui.history.IHistoryPage#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
97      */

98     public void removePropertyChangeListener(IPropertyChangeListener listener) {
99         if (fChangeHandler != null) {
100             fChangeHandler.removePropertyChangeListener(listener);
101         }
102     }
103     
104     /**
105      * Notify all listeners that the given property has changed.
106      *
107      * @param source the object on which a property has changed
108      * @param property identifier of the property that has changed
109      * @param oldValue the old value of the property, or <code>null</code>
110      * @param newValue the new value of the property, or <code>null</code>
111      * @since 3.3
112      */

113     protected void firePropertyChange(Object JavaDoc source, String JavaDoc property, Object JavaDoc oldValue, Object JavaDoc newValue) {
114         if (fChangeHandler == null) {
115             return;
116         }
117         fChangeHandler.firePropertyChange(source, property, oldValue, newValue);
118     }
119 }
120
Popular Tags