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.phpdt.internal.ui.text.JavaColorManager;
16 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
17 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
18 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
19 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
20 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
22 /** The PHPEditorEnvironment maintains singletons used by the php editor
24 public class PHPEditorEnvironment {
26 private static JavaColorManager fgColorProvider;
27 private static PHPCodeScanner fgPHPCodeScanner;
28 private static HTMLCodeScanner fgHTMLCodeScanner;
29 private static PHPDocCodeScanner fgDocScanner;
31 private static int fgRefCount = 0;
34 * A connection has occured - initialize the receiver if it is the first activation.
36 public static void connect(Object client) {
37 if (++fgRefCount == 1) {
38 fgColorProvider = new JavaColorManager(); // new PHPColorProvider();
39 fgPHPCodeScanner = new PHPCodeScanner(fgColorProvider, PHPeclipsePlugin.getDefault().getPreferenceStore() );
40 fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider, PHPeclipsePlugin.getDefault().getPreferenceStore());
41 fgDocScanner = new PHPDocCodeScanner(fgColorProvider, PHPeclipsePlugin.getDefault().getPreferenceStore() );
46 * A disconnection has occured - clear the receiver if it is the last deactivation.
48 public static void disconnect(Object client) {
49 if (--fgRefCount == 0) {
50 fgPHPCodeScanner = null;
51 fgHTMLCodeScanner = null;
53 fgColorProvider.dispose();
54 fgColorProvider = null;
59 * Returns the singleton scanner.
61 public static PHPCodeScanner getPHPCodeScanner() {
62 return fgPHPCodeScanner;
66 * Returns the singleton scanner.
68 public static HTMLCodeScanner getHTMLCodeScanner() {
69 return fgHTMLCodeScanner;
73 * Returns the singleton PHPDoc scanner.
75 public static PHPDocCodeScanner getPHPDocCodeScanner() {
80 * Returns the singleton color provider.
82 public static JavaColorManager getPHPColorProvider() {
83 return fgColorProvider;