*** empty log message ***
[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 net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
16 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
17 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
18
19 /** The PHPEditorEnvironment maintains singletons used by the php editor
20  */
21 public class PHPEditorEnvironment {
22
23   private static PHPColorProvider fgColorProvider;
24   private static PHPCodeScanner fgPHPCodeScanner;
25   private static HTMLCodeScanner fgHTMLCodeScanner;
26   //private static JavaDocScanner fgDocScanner;
27
28   private static int fgRefCount = 0;
29
30   /**
31    * A connection has occured - initialize the receiver if it is the first activation.
32    */
33   public static void connect(Object client) {
34     if (++fgRefCount == 1) {
35       fgColorProvider = new PHPColorProvider();
36       fgPHPCodeScanner = new PHPCodeScanner(fgColorProvider);
37       fgHTMLCodeScanner = new HTMLCodeScanner(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       fgPHPCodeScanner = null;
48       fgHTMLCodeScanner = null;
49       //                        fgDocScanner= null;
50       fgColorProvider.dispose();
51       fgColorProvider = null;
52     }
53   }
54
55   /**
56    * Returns the singleton scanner.
57    */
58   public static PHPCodeScanner getPHPCodeScanner() {
59     return fgPHPCodeScanner;
60   }
61
62   public static HTMLCodeScanner getHTMLCodeScanner() {
63     return fgHTMLCodeScanner;
64   }
65
66   /**
67    * Returns the singleton color provider.
68    */
69   public static PHPColorProvider getPHPColorProvider() {
70     return fgColorProvider;
71   }
72
73   /**
74    * Returns the singleton document scanner.
75    */
76   //     public static RuleBasedScanner getJavaDocScanner() {
77   //            return fgDocScanner;
78   //    }
79 }