01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.examples.javaeditor;
11:
12: import org.eclipse.ui.texteditor.ITextEditor;
13: import org.eclipse.ui.texteditor.TextEditorAction;
14:
15: /**
16: * A toolbar action which toggles the presentation model of the
17: * connected text editor. The editor shows either the highlight range
18: * only or always the whole document.
19: */
20: public class PresentationAction extends TextEditorAction {
21:
22: /**
23: * Constructs and updates the action.
24: */
25: public PresentationAction() {
26: super (JavaEditorMessages.getResourceBundle(),
27: "TogglePresentation.", null); //$NON-NLS-1$
28: update();
29: }
30:
31: /* (non-Javadoc)
32: * Method declared on IAction
33: */
34: public void run() {
35:
36: ITextEditor editor = getTextEditor();
37:
38: editor.resetHighlightRange();
39: boolean show = editor.showsHighlightRangeOnly();
40: setChecked(!show);
41: editor.showHighlightRangeOnly(!show);
42: }
43:
44: /* (non-Javadoc)
45: * Method declared on TextEditorAction
46: */
47: public void update() {
48: setChecked(getTextEditor() != null
49: && getTextEditor().showsHighlightRangeOnly());
50: setEnabled(true);
51: }
52: }
|