1 package net.sourceforge.phpeclipse.phpeditor;
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
11 IBM Corporation - Initial implementation
12 Klaus Hartlage - www.eclipseproject.de
13 **********************************************************************/
15 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
16 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
17 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
19 /** The PHPEditorEnvironment maintains singletons used by the php editor
21 public class PHPEditorEnvironment {
23 private static PHPColorProvider fgColorProvider;
24 private static PHPCodeScanner fgPHPCodeScanner;
25 private static HTMLCodeScanner fgHTMLCodeScanner;
26 //private static JavaDocScanner fgDocScanner;
28 private static int fgRefCount = 0;
31 * A connection has occured - initialize the receiver if it is the first activation.
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);
43 * A disconnection has occured - clear the receiver if it is the last deactivation.
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;
56 * Returns the singleton scanner.
58 public static PHPCodeScanner getPHPCodeScanner() {
59 return fgPHPCodeScanner;
62 public static HTMLCodeScanner getHTMLCodeScanner() {
63 return fgHTMLCodeScanner;
67 * Returns the singleton color provider.
69 public static PHPColorProvider getPHPColorProvider() {
70 return fgColorProvider;
74 * Returns the singleton document scanner.
76 // public static RuleBasedScanner getJavaDocScanner() {
77 // return fgDocScanner;