import java.text.MessageFormat;
import java.util.Iterator;
-import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.overlaypages.Util;
+import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
import net.sourceforge.phpeclipse.views.PHPConsole;
-import net.sourceforge.phpeclipse.views.browser.BrowserView;
+import net.sourceforge.phpeclipse.webbrowser.views.BrowserView;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
//import org.eclipse.update.internal.ui.UpdatePerspective;
//import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
public class PHPEclipseShowAction implements IObjectActionDelegate {
// single file:
IFile file = (IFile) resource;
String localhostURL;
- if ((localhostURL = getLocalhostURL(store, (IFile) resource)) == null) {
+ if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(store, (IFile) resource)) == null) {
MessageDialog.openInformation(shell,
"Couldn't create localhost URL",
"Please configure your localhost and documentRoot");
*/
public void selectionChanged(IAction action, ISelection selection) {
}
- public static String getLocalhostURL(IPreferenceStore store, IFile file) {
- if (store == null) {
- store = PHPeclipsePlugin.getDefault().getPreferenceStore();
- }
- // IPath path = file.getFullPath();
- String localhostURL = file.getLocation().toString();
- String lowerCaseFileName = localhostURL.toLowerCase();
- // String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
- String documentRoot = Util.getMiscProjectsPreferenceValue(
- file.getProject(), IPreferenceConstants.PHP_DOCUMENTROOT_PREF);
-
- documentRoot = documentRoot.replace('\\', '/');
- documentRoot = documentRoot.toLowerCase();
-
- if (lowerCaseFileName.startsWith(documentRoot)) {
- localhostURL = localhostURL.substring(documentRoot.length());
- } else {
- return null;
- }
-// return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
- return Util.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL;
- }
+// public static String getLocalhostURL(IPreferenceStore store, IFile file) {
+// if (store == null) {
+// store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+// }
+// // IPath path = file.getFullPath();
+// String localhostURL = file.getLocation().toString();
+// String lowerCaseFileName = localhostURL.toLowerCase();
+// // String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
+// String documentRoot = Util.getMiscProjectsPreferenceValue(
+// file.getProject(), IPreferenceConstants.PHP_DOCUMENTROOT_PREF);
+//
+// documentRoot = documentRoot.replace('\\', '/');
+// documentRoot = documentRoot.toLowerCase();
+//
+// if (lowerCaseFileName.startsWith(documentRoot)) {
+// localhostURL = localhostURL.substring(documentRoot.length());
+// } else {
+// return null;
+// }
+//// return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
+// return Util.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL;
+// }
public static void open(final URL url, final Shell shell,
final String dialogTitle) {
page.bringToTop(part);
}
((BrowserView) part).setUrl(url.toExternalForm());
- } catch (PartInitException e) {
- PHPeclipsePlugin.log(e);
+ } catch (Exception e) {
}
}
}