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.php.HTMLCodeScanner;
18 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
19 import org.eclipse.jface.text.rules.RuleBasedScanner;
21 /** The PHPEditorEnvironment maintains singletons used by the php editor
23 public class PHPEditorEnvironment {
25 private static PHPColorProvider fgColorProvider;
26 private static PHPCodeScanner fgPHPCodeScanner;
27 private static HTMLCodeScanner fgHTMLCodeScanner;
28 //private static JavaDocScanner fgDocScanner;
30 private static int fgRefCount = 0;
33 * A connection has occured - initialize the receiver if it is the first activation.
35 public static void connect(Object client) {
36 if (++fgRefCount == 1) {
37 fgColorProvider = new PHPColorProvider();
38 fgPHPCodeScanner = new PHPCodeScanner(fgColorProvider);
39 fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider);
40 // fgDocScanner= new JavaDocScanner(fgColorProvider);
45 * A disconnection has occured - clear the receiver if it is the last deactivation.
47 public static void disconnect(Object client) {
48 if (--fgRefCount == 0) {
49 fgPHPCodeScanner = null;
50 fgHTMLCodeScanner = null;
51 // fgDocScanner= null;
52 fgColorProvider.dispose();
53 fgColorProvider = null;
58 * Returns the singleton scanner.
60 public static PHPCodeScanner getPHPCodeScanner() {
61 return fgPHPCodeScanner;
64 public static HTMLCodeScanner getHTMLCodeScanner() {
65 return fgHTMLCodeScanner;
69 * Returns the singleton color provider.
71 public static PHPColorProvider getPHPColorProvider() {
72 return fgColorProvider;
76 * Returns the singleton document scanner.
78 // public static RuleBasedScanner getJavaDocScanner() {
79 // return fgDocScanner;