blob: 7d48737e4966cec086976a695cd22f9acbc9d88b (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*******************************************************************************
* Copyright (c) 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.pagedesigner.editors.actions;
import org.eclipse.jst.pagedesigner.editors.HTMLEditor;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.wst.xml.ui.internal.actions.ActionContributorXML;
/**
* SourcePageActionContributor
*
* This class is for multi page editor's source page contributor.
*
* Use XMLEditorActionContributor for single page editor.
*/
public class SourcePageActionContributor extends ActionContributorXML {
private IActionBars fBars;
/**
* This method calls:
* <ul>
* <li><code>contributeToMenu</code> with <code>bars</code>' menu
* manager</li>
* <li><code>contributeToToolBar</code> with <code>bars</code>' tool
* bar manager</li>
* <li><code>contributeToStatusLine</code> with <code>bars</code>'
* status line manager</li>
* </ul>
* The given action bars are also remembered and made accessible via
* <code>getActionBars</code>.
*
* @param bars
* the action bars
*
*/
public void init(IActionBars bars) {
fBars = bars;
contributeToMenu(bars.getMenuManager());
contributeToToolBar(bars.getToolBarManager());
contributeToStatusLine(bars.getStatusLineManager());
}
/**
* Returns this contributor's action bars.
*
* @return the action bars
*/
public IActionBars getActionBars() {
return fBars;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor#setViewerSpecificContributionsEnabled(boolean)
*/
public void setViewerSpecificContributionsEnabled(boolean enabled) {
super.setViewerSpecificContributionsEnabled(enabled);
IEditorPart editor = getActiveEditorPart();
ITextEditor targetEditor = null;
if (editor instanceof ITextEditor) {
targetEditor = (ITextEditor) editor;
} else if (editor instanceof HTMLEditor) {
targetEditor = ((HTMLEditor) editor).getTextEditor();
}
if (targetEditor != null) {
if (enabled) {
getActionBars()
.setGlobalActionHandler(
ITextEditorActionConstants.UNDO,
targetEditor
.getAction(ITextEditorActionConstants.UNDO));
getActionBars()
.setGlobalActionHandler(
ITextEditorActionConstants.REDO,
targetEditor
.getAction(ITextEditorActionConstants.REDO));
} else {
getActionBars().setGlobalActionHandler(
ITextEditorActionConstants.UNDO, null);
getActionBars().setGlobalActionHandler(
ITextEditorActionConstants.REDO, null);
}
}
}
}
|