Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPeclipsePlugin.java
index 04d04fc..8cdd585 100644 (file)
@@ -12,9 +12,13 @@ Contributors:
 package net.sourceforge.phpeclipse;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
 import net.sourceforge.phpdt.externaltools.internal.model.ColorManager;
 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin;
@@ -78,17 +82,17 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
   /** 
    * id of builder - matches plugin.xml (concatenate pluginid.builderid) 
    */
-  public static final String BUILDER_INDEX_ID = PLUGIN_ID + ".indexbuilder";
   public static final String BUILDER_PARSER_ID = PLUGIN_ID + ".parserbuilder";
+//public static final String BUILDER_INDEX_ID = PLUGIN_ID + ".indexbuilder";
 
   /** General debug flag*/
   public static final boolean DEBUG = false;
 
-       /**
-        * The maximum number of allowed proposals by category
-        */
-       public final static int MAX_PROPOSALS = 200;
-       
+  /**
+   * The maximum number of allowed proposals by category
+   */
+  public final static int MAX_PROPOSALS = 200;
+
   private static ExternalToolsPlugin externalTools;
 
   /**
@@ -131,7 +135,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
   /** Windows NT  */
   private static final int WINDOWS_NT = 5;
   private PHPDocumentProvider fCompilationUnitDocumentProvider;
+
   private ImageDescriptorRegistry fImageDescriptorRegistry;
   private HashMap fIndexManagerMap = new HashMap();
 
@@ -161,6 +165,34 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     return getActiveWorkbenchWindow().getShell();
   }
 
+  /**
+        * Returns an array of all editors that have an unsaved content. If the identical content is 
+        * presented in more than one editor, only one of those editor parts is part of the result.
+        * 
+        * @return an array of all dirty editor parts.
+        */
+  public static IEditorPart[] getDirtyEditors() {
+    Set inputs = new HashSet();
+    List result = new ArrayList(0);
+    IWorkbench workbench = getDefault().getWorkbench();
+    IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
+    for (int i = 0; i < windows.length; i++) {
+      IWorkbenchPage[] pages = windows[i].getPages();
+      for (int x = 0; x < pages.length; x++) {
+        IEditorPart[] editors = pages[x].getDirtyEditors();
+        for (int z = 0; z < editors.length; z++) {
+          IEditorPart ep = editors[z];
+          IEditorInput input = ep.getEditorInput();
+          if (!inputs.contains(input)) {
+            inputs.add(input);
+            result.add(ep);
+          }
+        }
+      }
+    }
+    return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]);
+  }
+
   public static IWorkbenchWindow getActiveWorkbenchWindow() {
     return getDefault().getWorkbench().getActiveWorkbenchWindow();
   }
@@ -393,6 +425,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
 
     PreferenceConverter.setDefault(store, PHP_MULTILINE_COMMENT, PHPColorProvider.MULTI_LINE_COMMENT);
     PreferenceConverter.setDefault(store, PHP_SINGLELINE_COMMENT, PHPColorProvider.SINGLE_LINE_COMMENT);
+               PreferenceConverter.setDefault(store, PHP_TAG, PHPColorProvider.TAG);
     PreferenceConverter.setDefault(store, PHP_KEYWORD, PHPColorProvider.KEYWORD);
     PreferenceConverter.setDefault(store, PHP_VARIABLE, PHPColorProvider.VARIABLE);
     PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME, PHPColorProvider.FUNCTION_NAME);
@@ -400,12 +433,12 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE);
     PreferenceConverter.setDefault(store, PHP_STRING, PHPColorProvider.STRING);
     PreferenceConverter.setDefault(store, PHP_DEFAULT, PHPColorProvider.DEFAULT);
-    
-               PreferenceConverter.setDefault(store, PHPDOC_KEYWORD, PHPColorProvider.PHPDOC_KEYWORD);
-               PreferenceConverter.setDefault(store, PHPDOC_TAG, PHPColorProvider.PHPDOC_TAG);
-               PreferenceConverter.setDefault(store, PHPDOC_LINK, PHPColorProvider.PHPDOC_LINK);
-               PreferenceConverter.setDefault(store, PHPDOC_DEFAULT, PHPColorProvider.PHPDOC_DEFAULT);
-                       
+
+    PreferenceConverter.setDefault(store, PHPDOC_KEYWORD, PHPColorProvider.PHPDOC_KEYWORD);
+    PreferenceConverter.setDefault(store, PHPDOC_TAG, PHPColorProvider.PHPDOC_TAG);
+    PreferenceConverter.setDefault(store, PHPDOC_LINK, PHPColorProvider.PHPDOC_LINK);
+    PreferenceConverter.setDefault(store, PHPDOC_DEFAULT, PHPColorProvider.PHPDOC_DEFAULT);
+
     //    PreferenceConverter.setDefault(
     //      store,
     //      PHP_EDITOR_BACKGROUND,