Added patch for #1589521 "3 character function names invalid?"
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PresentationAction.java
1 /**********************************************************************
2  Copyright (c) 2000, 2002 IBM Corp. and others.
3  All rights reserved. This program and the accompanying materials
4  are made available under the terms of the Common Public License v1.0
5  which accompanies this distribution, and is available at
6  http://www.eclipse.org/legal/cpl-v10.html
7
8  Contributors:
9  IBM Corporation - Initial implementation
10  www.phpeclipse.de
11  **********************************************************************/
12 package net.sourceforge.phpeclipse.phpeditor;
13
14 import org.eclipse.ui.texteditor.ITextEditor;
15 import org.eclipse.ui.texteditor.TextEditorAction;
16
17 /**
18  * A toolbar action which toggles the presentation model of the connected text
19  * editor. The editor shows either the highlight range only or always the whole
20  * document.
21  */
22 public class PresentationAction extends TextEditorAction {
23
24         /**
25          * Constructs and updates the action.
26          */
27         public PresentationAction() {
28                 super(PHPEditorMessages.getResourceBundle(),
29                                 "TogglePresentation.", null); //$NON-NLS-1$
30                 update();
31         }
32
33         /*
34          * (non-Javadoc) Method declared on IAction
35          */
36         public void run() {
37
38                 ITextEditor editor = getTextEditor();
39
40                 editor.resetHighlightRange();
41                 boolean show = editor.showsHighlightRangeOnly();
42                 setChecked(!show);
43                 editor.showHighlightRangeOnly(!show);
44         }
45
46         /*
47          * (non-Javadoc) Method declared on TextEditorAction
48          */
49         public void update() {
50                 setChecked(getTextEditor() != null
51                                 && getTextEditor().showsHighlightRangeOnly());
52                 setEnabled(true);
53         }
54 }