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
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.compare.internal;
import java.util.ResourceBundle;
import org.eclipse.jface.action.*;
import org.eclipse.ui.*;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.help.WorkbenchHelp;
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;
private NavigationAction fToolbarNext;
private NavigationAction fToolbarPrevious;
public CompareEditorContributor() {
ResourceBundle bundle= CompareUIPlugin.getResourceBundle();
fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, null);
WorkbenchHelp.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION);
fNext= new NavigationAction(bundle, true);
WorkbenchHelp.setHelp(fNext, ICompareContextIds.GLOBAL_NEXT_DIFF_ACTION);
fPrevious= new NavigationAction(bundle, false);
WorkbenchHelp.setHelp(fPrevious, ICompareContextIds.GLOBAL_PREVIOUS_DIFF_ACTION);
fToolbarNext= new NavigationAction(bundle, true);
WorkbenchHelp.setHelp(fToolbarNext, ICompareContextIds.NEXT_DIFF_ACTION);
fToolbarPrevious= new NavigationAction(bundle, false);
WorkbenchHelp.setHelp(fToolbarPrevious, ICompareContextIds.PREVIOUS_DIFF_ACTION);
}
/*
* @see EditorActionBarContributor#contributeToToolBar(IToolBarManager)
*/
public void contributeToToolBar(IToolBarManager tbm) {
tbm.add(new Separator());
tbm.add(fIgnoreWhitespace);
tbm.add(fToolbarNext);
tbm.add(fToolbarPrevious);
}
/*
* @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);
// Begin fix http://bugs.eclipse.org/bugs/show_bug.cgi?id=20105
fToolbarNext.setCompareEditorInput(compareInput);
fToolbarPrevious.setCompareEditorInput(compareInput);
// End fix http://bugs.eclipse.org/bugs/show_bug.cgi?id=20105
}
}
if (targetEditor instanceof CompareEditor) {
IActionBars actionBars= getActionBars();
CompareEditor editor= (CompareEditor) targetEditor;
editor.setActionBars(actionBars);
actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNext);
actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPrevious);
CompareConfiguration cc= editor.getCompareConfiguration();
fIgnoreWhitespace.setCompareConfiguration(cc);
}
}
}
|