Improved Outline view for PHP function names
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPEditorEnvironment.java
1 package net.sourceforge.phpeclipse.phpeditor;
2
3 /**********************************************************************
4 Copyright (c) 2000, 2002 IBM Corp. and others.
5 All rights reserved. This program and the accompanying materials
6 are made available under the terms of the Common Public License v1.0
7 which accompanies this distribution, and is available at
8 http://www.eclipse.org/legal/cpl-v10.html
9
10 Contributors:
11     IBM Corporation - Initial implementation
12     Klaus Hartlage - www.eclipseproject.de
13 **********************************************************************/
14
15 import org.eclipse.jface.text.rules.RuleBasedScanner;
16 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
17 //import net.sourceforge.phpeclipse.phpeditor.html.JavaDocScanner;
18 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
19
20 /** The JavaEditorEnvironment maintains singletons used by the java editor
21  * examples.
22  */
23 public class PHPEditorEnvironment {
24
25         private static PHPColorProvider fgColorProvider;
26         private static PHPCodeScanner fgCodeScanner;
27         //private static JavaDocScanner fgDocScanner;
28
29         private static int fgRefCount= 0;
30
31         /**
32          * A connection has occured - initialize the receiver if it is the first activation.
33          */
34         public static void connect(Object client) {
35                 if (++fgRefCount == 1) {
36                         fgColorProvider= new PHPColorProvider();
37                         fgCodeScanner= new PHPCodeScanner(fgColorProvider);
38         //              fgDocScanner= new JavaDocScanner(fgColorProvider);
39                 }
40         }
41         
42         /**
43          * A disconnection has occured - clear the receiver if it is the last deactivation.
44          */
45          public static void disconnect(Object client) {
46                 if (--fgRefCount == 0) {
47                         fgCodeScanner= null;
48 //                      fgDocScanner= null;
49                         fgColorProvider.dispose();
50                         fgColorProvider= null;
51                 }
52         }
53         
54         /**
55          * Returns the singleton scanner.
56          */
57          public static RuleBasedScanner getPHPCodeScanner() {
58                 return fgCodeScanner;
59         }
60         
61         /**
62          * Returns the singleton color provider.
63          */
64          public static PHPColorProvider getJavaColorProvider() {
65                 return fgColorProvider;
66         }
67         
68         /**
69          * Returns the singleton document scanner.
70          */
71 //       public static RuleBasedScanner getJavaDocScanner() {
72 //              return fgDocScanner;
73 //      }
74 }