Added: PreferencePage; External Browser startup; extended syntax highlighting
[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     Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.phpeditor;
13
14 import java.util.ResourceBundle;
15 import org.eclipse.ui.texteditor.ITextEditor;
16 import org.eclipse.ui.texteditor.TextEditorAction;
17
18 /**
19  * A toolbar action which toggles the presentation model of the
20  * connected text editor. The editor shows either the highlight range
21  * only or always the whole document.
22  */
23 public class PresentationAction extends TextEditorAction {
24
25         /**
26          * Constructs and updates the action.
27          */
28         public PresentationAction() {
29                 super(PHPEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
30                 update();
31         }
32         
33         /* (non-Javadoc)
34          * 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         /* (non-Javadoc)
47          * Method declared on TextEditorAction
48          */
49         public void update() {
50                 setChecked(getTextEditor() != null && getTextEditor().showsHighlightRangeOnly());
51                 setEnabled(true);
52         }
53 }