id="net.sourceforge.phpeclipse.actions.showAction">
</action>
</objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.html"
+ id="net.sourceforge.phpeclipse.actions.popupShowAction">
+ <action
+ label="Open PHP Browser"
+ class="net.sourceforge.phpeclipse.actions.PHPEclipseShowAction"
+ menubarPath="additions"
+ id="net.sourceforge.phpeclipse.actions.showAction">
+ </action>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.htm"
+ id="net.sourceforge.phpeclipse.actions.popupShowAction">
+ <action
+ label="Open PHP Browser"
+ class="net.sourceforge.phpeclipse.actions.PHPEclipseShowAction"
+ menubarPath="additions"
+ id="net.sourceforge.phpeclipse.actions.showAction">
+ </action>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.xml"
+ id="net.sourceforge.phpeclipse.actions.popupShowAction">
+ <action
+ label="Open PHP Browser"
+ class="net.sourceforge.phpeclipse.actions.PHPEclipseShowAction"
+ menubarPath="additions"
+ id="net.sourceforge.phpeclipse.actions.showAction">
+ </action>
+ </objectContribution>
<viewerContribution
targetID="#PHPRulerContext"
id="net.sourceforge.phpdt.ui.PHPEditorPopupActions">
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";
StringFieldEditor localHostSFE;
DirectoryFieldEditor documentRootDFE;
+ BooleanFieldEditor showExternalPreviewBFE;
BooleanFieldEditor externalBrowserBFE;
StringFieldEditor externalBrowserSFE;
StringFieldEditor apacheStartSFE;
protected void performDefaults() {
localHostSFE.loadDefault();
documentRootDFE.loadDefault();
+ showExternalPreviewBFE.loadDefault();
externalBrowserBFE.loadDefault();
externalBrowserSFE.loadDefault();
apacheStartSFE.loadDefault();
public boolean performOk() {
localHostSFE.store();
documentRootDFE.store();
+ showExternalPreviewBFE.store();
externalBrowserBFE.store();
externalBrowserSFE.store();
apacheStartSFE.store();
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,
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,
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,
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();
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.
}
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();
}
// 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");
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.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;
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();
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 };
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) {
}
}
}
- } /**
- * @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$
+ }
}
}
}
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
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
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
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
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;
/**
private List fRetargetToolbarActions = new ArrayList();
protected PHPParserAction parserAction;
+ protected ShowExternalPreviewAction showExternalPreviewAction;
/**
* Default constructor.
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);
// fTogglePresentation = new PresentationAction();
parserAction = PHPParserAction.getInstance();
+ if (SWT.getPlatform().equals("win32")) {
+ showExternalPreviewAction = ShowExternalPreviewAction.getInstance();
+ }
}
/*
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());
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;
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();
+ }
+ }
}
/*
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;
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 */
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());
* 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()
*/
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));
}
};
* @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();
}
// 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(
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);
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)});
* disposal actions required by the php editor.
*/
public void dispose() {
- // PHPEditorEnvironment.disconnect(this);
+ // PHPEditorEnvironment.disconnect(this);
if (fOutlinePage != null)
fOutlinePage.setInput(null);
if (a != null)
a.run();
}
+// if (SWT.getPlatform().equals("win32")) {
+// IAction a = ShowExternalPreviewAction.getInstance();
+// if (a != null)
+// a.run();
+// }
if (fOutlinePage != null)
fOutlinePage.update();
}
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);
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;
}
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));
*/
protected void initializeEditor() {
IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
- // PHPEditorEnvironment.connect(this);
+ // PHPEditorEnvironment.connect(this);
// store.addPropertyChangeListener(new IPropertyChangeListener() {
// public void propertyChange(PropertyChangeEvent event) {
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;
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) {
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) {
* @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);
}
* @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]);
}
/*
* @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() {
/*
* @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);
}
}
--- /dev/null
+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