blob: 5ed4e2309279c1ee2eb3947f7a65972b7580bd76 (
plain) (
blame)
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
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.compare.internal;
import java.util.ResourceBundle;
import org.eclipse.jface.action.*;
import org.eclipse.ui.*;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.compare.*;
public class CompareEditorContributor extends EditorActionBarContributor {
private IEditorPart fActiveEditorPart= null;
private IgnoreWhiteSpaceAction fIgnoreWhitespace;
private NavigationAction fNext;
private NavigationAction fPrevious;
public CompareEditorContributor() {
ResourceBundle bundle= CompareUIPlugin.getResourceBundle();
fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, null);
fNext= new NavigationAction(bundle, true);
fPrevious= new NavigationAction(bundle, false);
}
/*
* @see EditorActionBarContributor#contributeToToolBar(IToolBarManager)
*/
public void contributeToToolBar(IToolBarManager tbm) {
tbm.add(new Separator());
tbm.add(fIgnoreWhitespace);
tbm.add(fNext);
tbm.add(fPrevious);
}
/*
* @see EditorActionBarContributor#contributeToMenu(IMenuManager)
*/
public void contributeToMenu(IMenuManager menuManager) {
}
public void setActiveEditor(IEditorPart targetEditor) {
if (fActiveEditorPart == targetEditor)
return;
fActiveEditorPart= targetEditor;
if (fActiveEditorPart != null) {
IEditorInput input= fActiveEditorPart.getEditorInput();
if (input instanceof CompareEditorInput) {
CompareEditorInput compareInput= (CompareEditorInput) input;
fNext.setCompareEditorInput(compareInput);
fPrevious.setCompareEditorInput(compareInput);
}
}
if (targetEditor instanceof CompareEditor) {
IActionBars actionBars= getActionBars();
CompareEditor editor= (CompareEditor) targetEditor;
editor.setActionBars(actionBars);
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.NEXT, fNext);
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.PREVIOUS, fPrevious);
CompareConfiguration cc= editor.getCompareConfiguration();
fIgnoreWhitespace.setCompareConfiguration(cc);
}
}
}
|