1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*******************************************************************************
* Copyright (c) 2006, 2011 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.ui.history;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.team.internal.ui.PropertyChangeHandler;
import org.eclipse.ui.part.Page;
/**
* Abstract HistoryPage class that keeps track of the history page site.
* <p>
* Clients may subclass this class.
* @see IHistoryPage
* @since 3.2
*/
public abstract class HistoryPage extends Page implements IHistoryPage, IAdaptable {
private IHistoryPageSite site;
private Object input;
private IHistoryView historyView;
private PropertyChangeHandler fChangeHandler;
/* (non-Javadoc)
* @see org.eclipse.team.ui.history.IHistoryPage#setSite(org.eclipse.team.ui.history.IHistoryPageSite)
*/
@Override
public void setSite(IHistoryPageSite site) {
this.site = site;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.history.IHistoryPage#getHistoryPageSite()
*/
@Override
public IHistoryPageSite getHistoryPageSite() {
return site;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.history.IHistoryPage#getInput()
*/
@Override
public Object getInput() {
return input;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.history.IHistoryPage#setInput(java.lang.Object, boolean)
*/
@Override
public boolean setInput(Object object) {
this.input = object;
return inputSet();
}
/**
* Called by HistoryPage after {@link #setInput(Object)}. Clients can
* gain access to the input by using {@link #getInput()}.
*
* @return <code>true</code> if the page was able to display the contents, <code>false</code> otherwise
*/
public abstract boolean inputSet();
public void setHistoryView(IHistoryView historyView) {
this.historyView = historyView;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.history.IHistoryPage#getHistoryView()
*/
@Override
public IHistoryView getHistoryView() {
if (historyView != null)
return historyView;
return null;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.history.IHistoryPage#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
@Override
public synchronized void addPropertyChangeListener(IPropertyChangeListener listener) {
if (fChangeHandler == null) {
fChangeHandler = new PropertyChangeHandler();
}
fChangeHandler.addPropertyChangeListener(listener);
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.history.IHistoryPage#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
@Override
public void removePropertyChangeListener(IPropertyChangeListener listener) {
if (fChangeHandler != null) {
fChangeHandler.removePropertyChangeListener(listener);
}
}
/**
* Notify all listeners that the given property has changed.
*
* @param source the object on which a property has changed
* @param property identifier of the property that has changed
* @param oldValue the old value of the property, or <code>null</code>
* @param newValue the new value of the property, or <code>null</code>
* @since 3.3
*/
protected void firePropertyChange(Object source, String property, Object oldValue, Object newValue) {
if (fChangeHandler == null) {
return;
}
fChangeHandler.firePropertyChange(source, property, oldValue, newValue);
}
}
|