Added: PreferencePage; External Browser startup; extended syntax highlighting
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPEditorEnvironment.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java
new file mode 100644 (file)
index 0000000..47760a9
--- /dev/null
@@ -0,0 +1,74 @@
+package net.sourceforge.phpeclipse.phpeditor;
+
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+    IBM Corporation - Initial implementation
+    Klaus Hartlage - www.eclipseproject.de
+**********************************************************************/
+
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
+//import net.sourceforge.phpeclipse.phpeditor.html.JavaDocScanner;
+import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
+
+/** The JavaEditorEnvironment maintains singletons used by the java editor
+ * examples.
+ */
+public class PHPEditorEnvironment {
+
+       private static PHPColorProvider fgColorProvider;
+       private static PHPCodeScanner fgCodeScanner;
+       //private static JavaDocScanner fgDocScanner;
+
+       private static int fgRefCount= 0;
+
+       /**
+        * A connection has occured - initialize the receiver if it is the first activation.
+        */
+       public static void connect(Object client) {
+               if (++fgRefCount == 1) {
+                       fgColorProvider= new PHPColorProvider();
+                       fgCodeScanner= new PHPCodeScanner(fgColorProvider);
+       //              fgDocScanner= new JavaDocScanner(fgColorProvider);
+               }
+       }
+       
+       /**
+        * A disconnection has occured - clear the receiver if it is the last deactivation.
+        */
+        public static void disconnect(Object client) {
+               if (--fgRefCount == 0) {
+                       fgCodeScanner= null;
+//                     fgDocScanner= null;
+                       fgColorProvider.dispose();
+                       fgColorProvider= null;
+               }
+       }
+       
+       /**
+        * Returns the singleton scanner.
+        */
+        public static RuleBasedScanner getPHPCodeScanner() {
+               return fgCodeScanner;
+       }
+       
+       /**
+        * Returns the singleton color provider.
+        */
+        public static PHPColorProvider getJavaColorProvider() {
+               return fgColorProvider;
+       }
+       
+       /**
+        * Returns the singleton document scanner.
+        */
+//      public static RuleBasedScanner getJavaDocScanner() {
+//             return fgDocScanner;
+//     }
+}