import net.sourceforge.phpeclipse.ui.IPreferenceConstants;
import net.sourceforge.phpeclipse.ui.WebUI;
+import net.sourceforge.phpeclipse.ui.internal.WebUIMessages;
import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil;
import net.sourceforge.phpeclipse.webbrowser.views.BrowserView;
import net.sourceforge.phpeclipse.webbrowser.views.ShowInContextBrowser;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
}
if (view != null) {
IShowInTarget target = getShowInTarget(view);
- if (target != null && target.show(context)) {
- // success
+ boolean stickyBrowserURL = ProjectPrefUtil.getPreviewBooleanValue(
+ previewFile,
+ IPreferenceConstants.PHP_STICKY_BROWSER_URL_DEFAULT);
+ if (target != null) {
+ if (stickyBrowserURL
+ && ((BrowserView) target).getUrl() != null
+ && ((BrowserView) target).getUrl().length() > 0) {
+ ((BrowserView) target).refresh();
+ } else {
+ target.show(context);
+ }
}
((WorkbenchPage) page)
.performedShowIn(BrowserView.ID_BROWSER);
public static void showBrowser(int style, IFile file, String queryString) {
ShowInContextBrowser context = getShowInContext(file, true, queryString);
String url = context.getLocalhostUrl();
+ if (url == null) {
+ String dialogTitle = WebUIMessages
+ .getString("BrowserUtil.error.dialog.title");
+ String message = WebUIMessages
+ .getString("BrowserUtil.null.url.message");
+ String reason = WebUIMessages
+ .getString("BrowserUtil.null.url.reason");
+ IStatus status = new Status(IStatus.ERROR, WebUI.PLUGIN_ID, 0,
+ reason, null);
+ ErrorDialog.openError(new Shell(), dialogTitle, message, status);
+ return;
+ }
String id = BROWSER_ID;
switch (style) {
case IWorkbenchBrowserSupport.AS_EXTERNAL: