blob: 8ec3bd55aa05958ce130a2dfb500ccf7ab250797 (
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
|
/*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.examples.javaeditor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
/**
* A toolbar action which toggles the presentation model of the
* connected text editor. The editor shows either the highlight range
* only or always the whole document.
*/
public class PresentationAction extends TextEditorAction {
/**
* Constructs and updates the action.
*/
public PresentationAction() {
super(JavaEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
update();
}
/* (non-Javadoc)
* Method declared on IAction
*/
public void run() {
ITextEditor editor= getTextEditor();
editor.resetHighlightRange();
boolean show= editor.showsHighlightRangeOnly();
setChecked(!show);
editor.showHighlightRangeOnly(!show);
}
/* (non-Javadoc)
* Method declared on TextEditorAction
*/
public void update() {
setChecked(getTextEditor() != null && getTextEditor().showsHighlightRangeOnly());
setEnabled(true);
}
}
|