From 7623d0d3f13ef5dfc7a74b47d3bc34b512bdb304 Mon Sep 17 00:00:00 2001 From: khartlage Date: Wed, 7 May 2003 15:51:32 +0000 Subject: [PATCH] Open preview on editor open --- net.sourceforge.phpeclipse/plugin.xml | 33 ++++ .../phpeclipse/IPreferenceConstants.java | 1 + .../phpeclipse/PHPEclipseBasePreferencePage.java | 50 +++++-- .../sourceforge/phpeclipse/PHPeclipsePlugin.java | 10 +- .../phpeclipse/actions/PHPEclipseShowAction.java | 118 ++++++++++----- .../newPHPPreferencesMessages_DE.properties | 1 + .../newPHPPreferencesMessages_FR.properties | 1 + .../newPHPPreferencesMessages_en_GB.properties | 1 + .../newPHPPreferencesMessages_es_ES.properties | 1 + .../phpeclipse/phpeditor/PHPActionContributor.java | 53 ++++--- .../phpeclipse/phpeditor/PHPEditor.java | 157 ++++++++------------ .../phpeditor/ShowExternalPreviewAction.java | 100 +++++++++++++ 12 files changed, 350 insertions(+), 176 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 884496a..40c6b18 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -516,6 +516,39 @@ Temporarily replaced until errors can be ironed out... id="net.sourceforge.phpeclipse.actions.showAction"> + + + + + + + + + + + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java index 481b7d5..25c7648 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java @@ -18,6 +18,7 @@ public interface IPreferenceConstants { public static final String LOCALHOST_PREF = "_localhost"; public static final String DOCUMENTROOT_PREF = "_documentroot"; public static final String USE_EXTERNAL_BROWSER_PREF = "_use_external_browser"; + public static final String SHOW_EXTERNAL_PREVIEW_PREF = "_show_external_preview"; public static final String EXTERNAL_BROWSER_PREF = "_external_browser"; public static final String MYSQL_PREF = "_my_sql"; public static final String APACHE_START_PREF = "_apache_start"; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java index 8df6345..7042c26 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java @@ -35,6 +35,7 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor StringFieldEditor localHostSFE; DirectoryFieldEditor documentRootDFE; + BooleanFieldEditor showExternalPreviewBFE; BooleanFieldEditor externalBrowserBFE; StringFieldEditor externalBrowserSFE; StringFieldEditor apacheStartSFE; @@ -55,6 +56,7 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor protected void performDefaults() { localHostSFE.loadDefault(); documentRootDFE.loadDefault(); + showExternalPreviewBFE.loadDefault(); externalBrowserBFE.loadDefault(); externalBrowserSFE.loadDefault(); apacheStartSFE.loadDefault(); @@ -70,6 +72,7 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor public boolean performOk() { localHostSFE.store(); documentRootDFE.store(); + showExternalPreviewBFE.store(); externalBrowserBFE.store(); externalBrowserSFE.store(); apacheStartSFE.store(); @@ -95,7 +98,7 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE); webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup")); webSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - webSettingsGroup.setLayout(new GridLayout()); + webSettingsGroup.setLayout(new GridLayout()); localHostSFE = new StringFieldEditor( IPreferenceConstants.LOCALHOST_PREF, @@ -112,7 +115,17 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor documentRootDFE.setPreferencePage(this); documentRootDFE.setPreferenceStore(getPreferenceStore()); documentRootDFE.load(); -new Label(webSettingsGroup, SWT.NONE); + + new Label(webSettingsGroup, SWT.NONE); + showExternalPreviewBFE = + new BooleanFieldEditor( + IPreferenceConstants.SHOW_EXTERNAL_PREVIEW_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.showexternalpreview"), + webSettingsGroup); + showExternalPreviewBFE.setPreferencePage(this); + showExternalPreviewBFE.setPreferenceStore(getPreferenceStore()); + showExternalPreviewBFE.load(); + new Label(webSettingsGroup, SWT.NONE); externalBrowserBFE = new BooleanFieldEditor( IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF, @@ -121,7 +134,7 @@ new Label(webSettingsGroup, SWT.NONE); externalBrowserBFE.setPreferencePage(this); externalBrowserBFE.setPreferenceStore(getPreferenceStore()); externalBrowserBFE.load(); -new Label(webSettingsGroup, SWT.NONE); + new Label(webSettingsGroup, SWT.NONE); externalBrowserSFE = new StringFieldEditor( IPreferenceConstants.EXTERNAL_BROWSER_PREF, @@ -204,19 +217,24 @@ new Label(webSettingsGroup, SWT.NONE); chooseParser.setPreferencePage(this); chooseParser.setPreferenceStore(getPreferenceStore()); chooseParser.load(); - //create a copmposte just for the StringEditor - makes layout simpler - Composite externalParserCompo = new Composite(parserSettingsGroup, SWT.NONE); - externalParserSFE = - new StringFieldEditor( - IPreferenceConstants.EXTERNAL_PARSER_PREF, - PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"), - externalParserCompo/*parserSettingsGroup*/); - externalParserSFE.setPreferencePage(this); - externalParserSFE.setPreferenceStore(getPreferenceStore()); - externalParserSFE.load(); - - parseOnSave = new BooleanFieldEditor(PHPeclipsePlugin.PHP_PARSE_ON_SAVE, - PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.pos"), parserSettingsGroup); + //create a copmposte just for the StringEditor - makes layout simpler + Composite externalParserCompo = new Composite(parserSettingsGroup, SWT.NONE); + externalParserSFE = + new StringFieldEditor( + IPreferenceConstants.EXTERNAL_PARSER_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"), + externalParserCompo + /*parserSettingsGroup*/ + ); + externalParserSFE.setPreferencePage(this); + externalParserSFE.setPreferenceStore(getPreferenceStore()); + externalParserSFE.load(); + + parseOnSave = + new BooleanFieldEditor( + PHPeclipsePlugin.PHP_PARSE_ON_SAVE, + PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.pos"), + parserSettingsGroup); parseOnSave.setPreferencePage(this); parseOnSave.setPreferenceStore(getPreferenceStore()); parseOnSave.load(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 555e20f..e4dba1d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -40,6 +40,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.update.internal.ui.UpdateUIPlugin; /** * The main plugin class to be used in the desktop. @@ -192,9 +193,15 @@ public class PHPeclipsePlugin } public static IWorkbenchPage getActivePage() { - return PHPeclipsePlugin.getActivePage(); + return getDefault().internalGetActivePage(); } + private IWorkbenchPage internalGetActivePage() { + IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow(); + if (window!=null) return window.getActivePage(); + return null; + } + public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } @@ -275,6 +282,7 @@ public class PHPeclipsePlugin // windows preferences: store.setDefault(LOCALHOST_PREF, "http://localhost"); + store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true"); store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false"); store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true"); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java index 13efe64..29a88f5 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java @@ -19,6 +19,7 @@ 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; @@ -29,10 +30,17 @@ 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.SWT; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.help.WorkbenchHelp; +import org.eclipse.update.internal.ui.UpdatePerspective; +import org.eclipse.update.internal.ui.UpdateUIPlugin; +import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser; //import org.eclipse.jdt.internal.ui.actions.OpenBrowserUtil; // import org.eclipse.help.ui.browser.LaunchURL; @@ -52,15 +60,6 @@ public class PHPEclipseShowAction implements IObjectActionDelegate { 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(); @@ -88,24 +87,29 @@ public class PHPEclipseShowAction implements IObjectActionDelegate { 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); + String localhostURL; +// 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, ""); + + if ((localhostURL=getLocalhostURL(store, (IFile) resource)) == null) { + MessageDialog.openInformation(shell, "Couldn't create localhost URL", "Please configure your localhost and documentRoot"); return; } - - localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, ""); - try { if (store.getBoolean(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF)) { String[] arguments = { localhostURL }; @@ -113,15 +117,15 @@ public class PHPEclipseShowAction implements IObjectActionDelegate { Runtime runtime = Runtime.getRuntime(); String command = form.format(arguments); - console.write("External Browser command: "+command+"\n"); + console.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); - console.write("Internal Browser URL: "+localhostURL+"\n"); + // MessageDialog.openInformation(shell, "localhostURL", "localhostURL: " + localhostURL); + // this doesn't work under win98 ? + // Program.launch(localhostURL); + console.write("Internal Browser URL: " + localhostURL + "\n"); open(new URL(localhostURL), shell, localhostURL); } } catch (MalformedURLException e) { @@ -133,18 +137,58 @@ public class PHPEclipseShowAction implements IObjectActionDelegate { } } } - } /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ 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(); + // 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 { + return null; + } + + return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, ""); + + } + 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()); + if (SWT.getPlatform().equals("win32")) { + IWorkbenchPage page = PHPeclipsePlugin.getActivePage(); + try { + IViewPart part = page.findView(UpdatePerspective.ID_BROWSER); + if (part == null) { + part = page.showView(UpdatePerspective.ID_BROWSER); + } else + page.bringToTop(part); + ((IEmbeddedWebBrowser) part).openTo(url.toExternalForm()); + } catch (PartInitException e) { + UpdateUIPlugin.logException(e); + } } else { - // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$ + 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$ + } } } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties index 7088b03..c7765b1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties @@ -24,6 +24,7 @@ PHPBasePreferencePage.websettingsGroup.localhost=Localhost PHPBasePreferencePage.websettingsGroup.docroot=DocumentRoot PHPBasePreferencePage.websettingsGroup.browser=Externes Browser Kommando PHPBasePreferencePage.websettingsGroup.useexternal=Benutze externen Browser +PHPBasePreferencePage.websettingsGroup.showexternalpreview=Vorschau beim Öffnen des Editors (nur win32) PHPBasePreferencePage.apacheGroup=Apache Einstellungen PHPBasePreferencePage.apacheGroup.start=Start Apache PHPBasePreferencePage.apacheGroup.stop=Stop Apache diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties index c380d9a..1ab93fc 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties @@ -24,6 +24,7 @@ PHPBasePreferencePage.websettingsGroup.localhost=Localhost PHPBasePreferencePage.websettingsGroup.docroot=DocumentRoot PHPBasePreferencePage.websettingsGroup.browser=Commande du navigateur externe PHPBasePreferencePage.websettingsGroup.useexternal=Utiliser navigateur externe +PHPBasePreferencePage.websettingsGroup.showexternalpreview=Show preview on editor load (win32 only) PHPBasePreferencePage.apacheGroup=Configuration Apache PHPBasePreferencePage.apacheGroup.start=Lancer Apache PHPBasePreferencePage.apacheGroup.stop=Stopper Apache diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties index a0bce66..bca7333 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties @@ -24,6 +24,7 @@ PHPBasePreferencePage.websettingsGroup.localhost=Localhost PHPBasePreferencePage.websettingsGroup.docroot=DocumentRoot PHPBasePreferencePage.websettingsGroup.browser=External browser command PHPBasePreferencePage.websettingsGroup.useexternal=Use external browser +PHPBasePreferencePage.websettingsGroup.showexternalpreview=Show preview on editor load (win32 only) PHPBasePreferencePage.apacheGroup=Apache Settings PHPBasePreferencePage.apacheGroup.start=Start Apache PHPBasePreferencePage.apacheGroup.stop=Stop Apache diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_es_ES.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_es_ES.properties index 0a98fc3..a6804ca 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_es_ES.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_es_ES.properties @@ -24,6 +24,7 @@ PHPBasePreferencePage.websettingsGroup.localhost=Localhost PHPBasePreferencePage.websettingsGroup.docroot=DocumentRoot PHPBasePreferencePage.websettingsGroup.browser=Comando navegador externo PHPBasePreferencePage.websettingsGroup.useexternal=Usar navegador externo +PHPBasePreferencePage.websettingsGroup.showexternalpreview=Show preview on editor load (win32 only) PHPBasePreferencePage.apacheGroup=Configuración Apache PHPBasePreferencePage.apacheGroup.start=Arrancar Apache PHPBasePreferencePage.apacheGroup.stop=Parar Apache diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java index 999ec19..9cbd2c9 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java @@ -19,19 +19,22 @@ import java.util.ResourceBundle; import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction; import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.SWT; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.RetargetAction; +import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.BasicTextEditorActionContributor; import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.RetargetTextEditorAction; /** @@ -48,6 +51,7 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { private List fRetargetToolbarActions = new ArrayList(); protected PHPParserAction parserAction; + protected ShowExternalPreviewAction showExternalPreviewAction; /** * Default constructor. @@ -58,16 +62,13 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { ResourceBundle b = PHPEditorMessages.getResourceBundle(); fRetargetContentAssist = new RetargetAction(PHPdtActionConstants.CONTENT_ASSIST, PHPEditorMessages.getString("ContentAssistProposal.label")); //$NON-NLS-1$ - fRetargetContentAssist.setActionDefinitionId( - PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); + fRetargetContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); fContentAssist = new RetargetTextEditorAction(b, "ContentAssistProposal."); //$NON-NLS-1$ - fContentAssist.setActionDefinitionId( - PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); + fContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); fGotoMatchingBracket = new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$ - fGotoMatchingBracket.setActionDefinitionId( - PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET); + fGotoMatchingBracket.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET); // fContentAssist.setImageDescriptor(JavaPluginImages.DESC_CLCL_CODE_ASSIST); // fContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST); @@ -77,6 +78,9 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { // fTogglePresentation = new PresentationAction(); parserAction = PHPParserAction.getInstance(); + if (SWT.getPlatform().equals("win32")) { + showExternalPreviewAction = ShowExternalPreviewAction.getInstance(); + } } /* @@ -132,19 +136,16 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { super.init(bars); IMenuManager menuManager = bars.getMenuManager(); - IMenuManager editMenu = - menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); + IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); if (editMenu != null) { editMenu.add(new Separator()); editMenu.add(fContentAssist); editMenu.add(fGotoMatchingBracket); - + // editMenu.add(fContentAssistTip); } - bars.setGlobalActionHandler( - PHPdtActionConstants.CONTENT_ASSIST, - fContentAssist); + bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST, fContentAssist); // IToolBarManager toolBarManager = bars.getToolBarManager(); // if (toolBarManager != null) { // toolBarManager.add(new Separator()); @@ -161,19 +162,12 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$ // fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$ - fGotoMatchingBracket.setAction( - getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET)); + fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET)); IActionBars bars = getActionBars(); - bars.setGlobalActionHandler( - PHPdtActionConstants.COMMENT, - getAction(textEditor, "Comment")); - bars.setGlobalActionHandler( - PHPdtActionConstants.UNCOMMENT, - getAction(textEditor, "Uncomment")); - bars.setGlobalActionHandler( - PHPdtActionConstants.FORMAT, - getAction(textEditor, "Format")); + bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment")); + bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); + bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(textEditor, "Format")); if (part instanceof PHPEditor) { PHPEditor cuEditor = (PHPEditor) part; @@ -186,6 +180,17 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { parserAction.setEditor(textEditor); parserAction.update(); + if (SWT.getPlatform().equals("win32") && + textEditor instanceof AbstractTextEditor) { + showExternalPreviewAction.setEditor(textEditor); + showExternalPreviewAction.update(); + IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + if (store.getBoolean(PHPeclipsePlugin.SHOW_EXTERNAL_PREVIEW_PREF)) { + IAction a = ShowExternalPreviewAction.getInstance(); + if (a != null) + a.run(); + } + } } /* diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index e1e0261..6979732 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -65,6 +65,9 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.texteditor.ContentAssistAction; @@ -75,22 +78,20 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.StatusTextEditor; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; +import org.eclipse.update.internal.ui.UpdatePerspective; +import org.eclipse.update.internal.ui.UpdateUIPlugin; +import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser; /** * PHP specific text editor. */ -public class PHPEditor - extends StatusTextEditor - implements IViewPartInputProvider { // extends TextEditor { +public class PHPEditor extends StatusTextEditor implements IViewPartInputProvider { // extends TextEditor { /** Preference key for showing the line number ruler */ - private final static String LINE_NUMBER_RULER = - PreferenceConstants.EDITOR_LINE_NUMBER_RULER; + private final static String LINE_NUMBER_RULER = PreferenceConstants.EDITOR_LINE_NUMBER_RULER; /** Preference key for the foreground color of the line numbers */ - private final static String LINE_NUMBER_COLOR = - PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR; + private final static String LINE_NUMBER_COLOR = PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR; /** Preference key for the link color */ - private final static String LINK_COLOR = - PreferenceConstants.EDITOR_LINK_COLOR; + private final static String LINK_COLOR = PreferenceConstants.EDITOR_LINK_COLOR; // protected PHPActionGroup fActionGroups; /** The outline page */ @@ -119,8 +120,7 @@ public class PHPEditor public PHPEditor() { super(); JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools(); - setSourceViewerConfiguration( - new PHPSourceViewerConfiguration(textTools, this)); + setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); setRangeIndicator(new DefaultRangeIndicator()); setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); @@ -149,32 +149,32 @@ public class PHPEditor * Update the hovering behavior depending on the preferences. */ private void updateHoverBehavior() { - SourceViewerConfiguration configuration= getSourceViewerConfiguration(); - String[] types= configuration.getConfiguredContentTypes(getSourceViewer()); + SourceViewerConfiguration configuration = getSourceViewerConfiguration(); + String[] types = configuration.getConfiguredContentTypes(getSourceViewer()); - for (int i= 0; i < types.length; i++) { - - String t= types[i]; - - int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t); + for (int i = 0; i < types.length; i++) { - ISourceViewer sourceViewer= getSourceViewer(); + String t = types[i]; + + int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t); + + ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension2) { if (stateMasks != null) { - for (int j= 0; j < stateMasks.length; j++) { - int stateMask= stateMasks[j]; - ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask); - ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, stateMask); + for (int j = 0; j < stateMasks.length; j++) { + int stateMask = stateMasks[j]; + ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask); + ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask); } } else { - ITextHover textHover= configuration.getTextHover(sourceViewer, t); - ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); + ITextHover textHover = configuration.getTextHover(sourceViewer, t); + ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); } } else sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t); } } - + /* * @see net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput() */ @@ -189,16 +189,11 @@ public class PHPEditor public void createPartControl(Composite parent) { super.createPartControl(parent); - IInformationControlCreator informationControlCreator = - new IInformationControlCreator() { + IInformationControlCreator informationControlCreator = new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { boolean cutDown = false; int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL); - return new DefaultInformationControl( - parent, - SWT.RESIZE, - style, - new HTMLTextPresenter(cutDown)); + return new DefaultInformationControl(parent, SWT.RESIZE, style, new HTMLTextPresenter(cutDown)); } }; @@ -213,8 +208,7 @@ public class PHPEditor * @return the document's complete text */ public String get() { - IDocument doc = - this.getDocumentProvider().getDocument(this.getEditorInput()); + IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput()); return doc.get(); } @@ -245,8 +239,7 @@ public class PHPEditor // this, // ISourceViewer.CONTENTASSIST_PROPOSALS)); action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$ - action.setActionDefinitionId( - PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); + action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); setAction("ContentAssistProposal", action); //$NON-NLS-1$ setAction( @@ -257,21 +250,11 @@ public class PHPEditor this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION)); - action = - new TextOperationAction( - PHPEditorMessages.getResourceBundle(), - "Comment.", - this, - ITextOperationTarget.PREFIX); + action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT); setAction("Comment", action); - action = - new TextOperationAction( - PHPEditorMessages.getResourceBundle(), - "Uncomment.", - this, - ITextOperationTarget.STRIP_PREFIX); + action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT); setAction("Uncomment", action); @@ -285,19 +268,15 @@ public class PHPEditor markAsStateDependentAction("Format", true); //$NON-NLS-1$ action = new GotoMatchingBracketAction(this); - action.setActionDefinitionId( - PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET); + action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET); setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action); - fGenerateActionGroup = - new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); + fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); - fActionGroups = - new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); + fActionGroups = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); // We have to keep the context menu group separate to have better control over positioning - fContextMenuGroup = - new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); + fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); // rg, // new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)}); @@ -317,7 +296,7 @@ public class PHPEditor * disposal actions required by the php editor. */ public void dispose() { - // PHPEditorEnvironment.disconnect(this); + // PHPEditorEnvironment.disconnect(this); if (fOutlinePage != null) fOutlinePage.setInput(null); @@ -350,6 +329,11 @@ public class PHPEditor if (a != null) a.run(); } +// if (SWT.getPlatform().equals("win32")) { +// IAction a = ShowExternalPreviewAction.getInstance(); +// if (a != null) +// a.run(); +// } if (fOutlinePage != null) fOutlinePage.update(); } @@ -390,8 +374,7 @@ public class PHPEditor addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$ - ActionContext context = - new ActionContext(getSelectionProvider().getSelection()); + ActionContext context = new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); @@ -470,8 +453,7 @@ public class PHPEditor if (value instanceof Integer) { sourceViewer.getTextWidget().setTabs(((Integer) value).intValue()); } else if (value instanceof String) { - sourceViewer.getTextWidget().setTabs( - Integer.parseInt((String) value)); + sourceViewer.getTextWidget().setTabs(Integer.parseInt((String) value)); } return; } @@ -616,13 +598,9 @@ public class PHPEditor if (!store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) { if (store.contains(PREFERENCE_COLOR_BACKGROUND)) { if (store.isDefault(PREFERENCE_COLOR_BACKGROUND)) - rgb = - PreferenceConverter.getDefaultColor( - store, - PREFERENCE_COLOR_BACKGROUND); + rgb = PreferenceConverter.getDefaultColor(store, PREFERENCE_COLOR_BACKGROUND); else - rgb = - PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND); + rgb = PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND); } } rulerColumn.setBackground(manager.getColor(rgb)); @@ -654,7 +632,7 @@ public class PHPEditor */ protected void initializeEditor() { IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - // PHPEditorEnvironment.connect(this); + // PHPEditorEnvironment.connect(this); // store.addPropertyChangeListener(new IPropertyChangeListener() { // public void propertyChange(PropertyChangeEvent event) { @@ -708,15 +686,12 @@ public class PHPEditor return false; } - private static boolean isSurroundedByBrackets( - IDocument document, - int offset) { + private static boolean isSurroundedByBrackets(IDocument document, int offset) { if (offset == 0 || offset == document.getLength()) return false; try { - return isBracket(document.getChar(offset - 1)) - && isBracket(document.getChar(offset)); + return isBracket(document.getChar(offset - 1)) && isBracket(document.getChar(offset)); } catch (BadLocationException e) { return false; @@ -763,8 +738,7 @@ public class PHPEditor return; int anchor = fBracketMatcher.getAnchor(); - int targetOffset = - (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1; + int targetOffset = (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1; boolean visible = false; if (sourceViewer instanceof ITextViewerExtension3) { @@ -772,9 +746,7 @@ public class PHPEditor visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1); } else { IRegion visibleRegion = sourceViewer.getVisibleRegion(); - visible = - (targetOffset >= visibleRegion.getOffset() - && targetOffset < visibleRegion.getOffset() + visibleRegion.getLength()); + visible = (targetOffset >= visibleRegion.getOffset() && targetOffset < visibleRegion.getOffset() + visibleRegion.getLength()); } if (!visible) { @@ -794,8 +766,7 @@ public class PHPEditor * @param msg message to be set */ protected void setStatusLineErrorMessage(String msg) { - IEditorStatusLine statusLine = - (IEditorStatusLine) getAdapter(IEditorStatusLine.class); + IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, msg, null); } @@ -809,18 +780,14 @@ public class PHPEditor * @return the line's bidi segmentation * @throws BadLocationException in case lineOffset is not valid in document */ - public static int[] getBidiLineSegments(IDocument document, int lineOffset) - throws BadLocationException { + public static int[] getBidiLineSegments(IDocument document, int lineOffset) throws BadLocationException { IRegion line = document.getLineInformationOfOffset(lineOffset); - ITypedRegion[] linePartitioning = - document.computePartitioning(lineOffset, line.getLength()); + ITypedRegion[] linePartitioning = document.computePartitioning(lineOffset, line.getLength()); List segmentation = new ArrayList(); for (int i = 0; i < linePartitioning.length; i++) { - if (IPHPPartitionScannerConstants - .PHP_STRING - .equals(linePartitioning[i].getType())) + if (IPHPPartitionScannerConstants.PHP_STRING.equals(linePartitioning[i].getType())) segmentation.add(linePartitioning[i]); } @@ -880,10 +847,7 @@ public class PHPEditor /* * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int) */ - protected final ISourceViewer createSourceViewer( - Composite parent, - IVerticalRuler ruler, - int styles) { + protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ISourceViewer viewer = createJavaSourceViewer(parent, ruler, styles); StyledText text = viewer.getTextWidget(); text.addBidiSegmentListener(new BidiSegmentListener() { @@ -898,18 +862,15 @@ public class PHPEditor /* * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int) */ - protected ISourceViewer createJavaSourceViewer( - Composite parent, - IVerticalRuler ruler, - int styles) { + protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { return super.createSourceViewer(parent, ruler, styles); } - + /* * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent) */ protected boolean affectsTextPresentation(PropertyChangeEvent event) { - JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools(); + JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools(); return textTools.affectsBehavior(event); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java new file mode 100644 index 0000000..c00e308 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java @@ -0,0 +1,100 @@ +package net.sourceforge.phpeclipse.phpeditor; + +/********************************************************************** +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 +**********************************************************************/ + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.actions.PHPEclipseShowAction; + +import org.eclipse.core.resources.IFile; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.ui.texteditor.TextEditorAction; +import org.eclipse.update.internal.ui.UpdatePerspective; +import org.eclipse.update.internal.ui.UpdateUIPlugin; +import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser; + +/** + * ClassDeclaration that defines the action for parsing the current PHP file + */ +public class ShowExternalPreviewAction extends TextEditorAction { + + private static ShowExternalPreviewAction instance = new ShowExternalPreviewAction(); + + protected IFile fileToParse; + + /** + * Constructs and updates the action. + */ + private ShowExternalPreviewAction() { + super(PHPEditorMessages.getResourceBundle(), "ParserAction.", null); //$NON-NLS-1$ + update(); + } + + public static ShowExternalPreviewAction getInstance() { + return instance; + } + + /** + * Code called when the action is fired. + */ + public void run() { + fileToParse = getFile(); + if (fileToParse == null) { + // should never happen + return; + } + + if (SWT.getPlatform().equals("win32")) { + String localhostURL; + if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, fileToParse)) == null) { + return; + } + IWorkbenchPage page = PHPeclipsePlugin.getActivePage(); + try { + IViewPart part = page.findView(UpdatePerspective.ID_BROWSER); + if (part == null) { + part = page.showView(UpdatePerspective.ID_BROWSER); + } else + page.bringToTop(part); + ((IEmbeddedWebBrowser) part).openTo(localhostURL); + } catch (PartInitException e) { + UpdateUIPlugin.logException(e); + } + } + + } + + /** + * Finds the file that's currently opened in the PHP Text Editor + */ + protected IFile getFile() { + ITextEditor editor = getTextEditor(); + + IEditorInput editorInput = null; + if (editor != null) { + editorInput = editor.getEditorInput(); + } + + if (editorInput instanceof IFileEditorInput) + return ((IFileEditorInput) editorInput).getFile(); + + // if nothing was found, which should never happen + return null; + } + +} \ No newline at end of file -- 1.7.1