More 3.1 compatibility
authoraxelcl <axelcl>
Sat, 9 Jul 2005 08:47:08 +0000 (08:47 +0000)
committeraxelcl <axelcl>
Sat, 9 Jul 2005 08:47:08 +0000 (08:47 +0000)
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/viewsupport/ListContentProvider.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/OpenDeclarationEditorAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java

index a2b5786..4862efa 100644 (file)
@@ -9,58 +9,59 @@ import org.eclipse.core.resources.IFile;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPage;
 
 public class BrowserUtil {
 
-  public static void showPreview(IFile previewFile, boolean forceDBGPreview, String postFix) {
-    if (previewFile == null) {
-      // should never happen
-      return;
-    }
-    String extension = previewFile.getFileExtension().toLowerCase();
-    boolean autoPreview = forceDBGPreview;
-    boolean bringToTopPreview = true;
-    boolean showHTMLFilesLocal = false;
-    boolean showXMLFilesLocal = false;
-    boolean isHTMLFileName = false;
-    boolean isXMLFileName = false;
-    if (!forceDBGPreview) {
-      autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
-  
-      bringToTopPreview = ProjectPrefUtil
-          .getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
-      showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL);
-      showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL);
-      isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension);
-      isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension);
-    }
-    if (autoPreview) {
-      String localhostURL;
-      if (showHTMLFilesLocal && isHTMLFileName) {
-        localhostURL = previewFile.getLocation().toString();
-      } else if (showXMLFilesLocal && isXMLFileName) {
-        localhostURL = previewFile.getLocation().toString();
-      } else if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(null, previewFile)) == null) {
-        return;
-      }
-      localhostURL += postFix;
-      
-      try {
-        IWorkbenchPage page = WebUI.getActivePage();
-        IViewPart part = page.findView(BrowserView.ID_BROWSER);
-        if (part == null) {
-          part = page.showView(BrowserView.ID_BROWSER);
-        } else {
-          if (bringToTopPreview) {
-            page.bringToTop(part);
-          }
-        }
-        ((BrowserView) part).setUrl(localhostURL);
-  
-      } catch (Exception e) {
-//        PHPeclipsePlugin.log(e);
-      }
-    }
-  }
+       public static void showPreview(IFile previewFile, boolean forceDBGPreview, String postFix) {
+               if (previewFile == null) {
+                       // should never happen
+                       return;
+               }
+               String extension = previewFile.getFileExtension().toLowerCase();
+               boolean autoPreview = forceDBGPreview;
+               boolean bringToTopPreview = true;
+               boolean showHTMLFilesLocal = false;
+               boolean showXMLFilesLocal = false;
+               boolean isHTMLFileName = false;
+               boolean isXMLFileName = false;
+               if (!forceDBGPreview) {
+                       autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
+
+                       bringToTopPreview = ProjectPrefUtil
+                                       .getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
+                       showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL);
+                       showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL);
+                       isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension);
+                       isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension);
+               }
+               if (autoPreview) {
+                       String localhostURL;
+                       if (showHTMLFilesLocal && isHTMLFileName) {
+                               localhostURL = previewFile.getLocation().toString();
+                       } else if (showXMLFilesLocal && isXMLFileName) {
+                               localhostURL = previewFile.getLocation().toString();
+                       } else if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(null, previewFile)) == null) {
+                               return;
+                       }
+                       localhostURL += postFix;
+
+                       try {
+                               IWorkbenchPage page = WebUI.getActivePage();
+                               IViewPart part = page.showView(BrowserView.ID_BROWSER, null, IWorkbenchPage.VIEW_VISIBLE);
+                               // if (part == null) {
+                               // part = page.showView(BrowserView.ID_BROWSER);
+                               // } else {
+                               if (part != null) {
+                                       if (bringToTopPreview) { 
+                                               page.bringToTop(part);
+                                       }
+                                       ((BrowserView) part).setUrl(localhostURL);
+                               }
+                               // }
+
+                       } catch (Exception e) {
+                               // PHPeclipsePlugin.log(e);
+                       }
+               }
+       }
 
 }
index af3af2f..cba6401 100644 (file)
             command="net.sourceforge.phpeclipse.ui.edit.text.php.goto.previous.member"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
-      <keyBinding
+   <!--   <keyBinding
             string=""
             scope="net.sourceforge.phpdt.ui.phpEditorScope"
             command="net.sourceforge.phpdt.ui.edit.text.java.show.next.problem"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
-      </keyBinding>
+      </keyBinding> -->
       <command
             name="%ActionDefinition.gotoMatchingBracket.name"
             description="%ActionDefinition.gotoMatchingBracket.description"
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/viewsupport/ListContentProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/viewsupport/ListContentProvider.java
new file mode 100644 (file)
index 0000000..3d6fcda
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.viewsupport;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/** 
+ * A specialized content provider to show a list of editor parts.
+ */ 
+public class ListContentProvider implements IStructuredContentProvider {
+       List fContents; 
+
+       public ListContentProvider() {
+       }
+       
+       public Object[] getElements(Object input) {
+               if (fContents != null && fContents == input)
+                       return fContents.toArray();
+               return new Object[0];
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               if (newInput instanceof List) 
+                       fContents= (List)newInput;
+               else
+                       fContents= null;
+               // we use a fixed set.
+       }
+
+       public void dispose() {
+       }
+       
+       public boolean isDeleted(Object o) {
+               return fContents != null && !fContents.contains(o);
+       }
+}
index c16ef85..37f7d5d 100644 (file)
@@ -27,7 +27,7 @@ import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextSelection;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.window.Window;
-import org.eclipse.search.internal.ui.util.ListContentProvider;
+import net.sourceforge.phpdt.internal.ui.viewsupport.ListContentProvider;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.dialogs.ListSelectionDialog;
index 35f949e..c21740f 100644 (file)
@@ -27,7 +27,7 @@ import org.eclipse.jface.text.TextSelection;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.window.Window;
-import org.eclipse.search.internal.ui.util.ListContentProvider;
+import net.sourceforge.phpdt.internal.ui.viewsupport.ListContentProvider;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.ui.IEditorActionDelegate;
 import org.eclipse.ui.IEditorPart;
index f5af618..1e62f92 100644 (file)
@@ -57,8 +57,9 @@ public class CompilationUnitEditorActionContributor extends BasicEditorActionCon
       ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
       fShowExternalPreviewAction.setEditor(textEditor);
       fShowExternalPreviewAction.update();
-      if (fShowExternalPreviewAction != null)
+      if (fShowExternalPreviewAction != null) {
         fShowExternalPreviewAction.doRun(ShowExternalPreviewAction.PHP_TYPE);
+      }
     }
   }
 }
\ No newline at end of file