X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java deleted file mode 100644 index a7c633c..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java +++ /dev/null @@ -1,150 +0,0 @@ -/********************************************************************** -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 -**********************************************************************/ -package net.sourceforge.phpeclipse.actions; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.MessageFormat; -import java.util.Iterator; - -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.views.PHPConsole; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.help.IHelp; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.help.WorkbenchHelp; -//import org.eclipse.jdt.internal.ui.actions.OpenBrowserUtil; -// import org.eclipse.help.ui.browser.LaunchURL; - -public class PHPEclipseShowAction implements IObjectActionDelegate { - private IWorkbenchPart workbenchPart; - /** - * Constructor for Action1. - */ - public PHPEclipseShowAction() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - workbenchPart = targetPart; - } - - // public static void open(final URL url, final Shell shell, final String dialogTitle) { - // IHelp help= WorkbenchHelp.getHelpSupport(); - // if (help != null) { - // WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm()); - // } else { - // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$ - // } - // } - - public void run(IAction action) { - ISelectionProvider selectionProvider = null; - selectionProvider = workbenchPart.getSite().getSelectionProvider(); - - StructuredSelection selection = null; - selection = (StructuredSelection) selectionProvider.getSelection(); - - IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - - Shell shell = null; - Iterator iterator = null; - iterator = selection.iterator(); - while (iterator.hasNext()) { - // obj => selected object in the view - Object obj = iterator.next(); - - // is it a resource - if (obj instanceof IResource) { - IResource resource = (IResource) obj; - - // check if it's a file resource - switch (resource.getType()) { - - case IResource.FILE : - // single file: - IFile file = (IFile) resource; - IPath path = file.getFullPath(); - - String localhostURL = file.getLocation().toString(); - String lowerCaseFileName = localhostURL.toLowerCase(); - // fileName = "http://localhost"+fileName.replaceAll("c:", ""); - String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); - documentRoot = documentRoot.replace('\\', '/'); - documentRoot = documentRoot.toLowerCase(); - - if (lowerCaseFileName.startsWith(documentRoot)) { - localhostURL = localhostURL.substring(documentRoot.length()); - } else { - MessageDialog.openInformation(shell, "Wrong DocumentRoot", "Adjust DocumentRoot: " + documentRoot); - return; - } - - localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, ""); - - try { - if (store.getBoolean(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF)) { - String[] arguments = { localhostURL }; - MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF)); - - Runtime runtime = Runtime.getRuntime(); - String command = form.format(arguments); - PHPConsole.write("External Browser command: "+command+"\n"); - runtime.exec(command); - // runtime.exec(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF) + " " + fileName); - // runtime.exec("command.com /c start iexplore " + fileName); - } else { - // MessageDialog.openInformation(shell, "localhostURL", "localhostURL: " + localhostURL); - // this doesn't work under win98 ? - // Program.launch(localhostURL); - PHPConsole.write("Internal Browser URL: "+localhostURL+"\n"); - open(new URL(localhostURL), shell, localhostURL); - } - } catch (MalformedURLException e) { - MessageDialog.openInformation(shell, "MalformedURLException: ", e.toString()); - } catch (IOException e) { - MessageDialog.openInformation(shell, "IOException", "Cannot show: " + localhostURL); - - } - } - } - } - } /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - public static void open(final URL url, final Shell shell, final String dialogTitle) { - IHelp help = WorkbenchHelp.getHelpSupport(); - if (help != null) { - WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm()); - } else { - // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$ - } - } -}