From 9843ad11b42617e72032744b23f7513de6a4f5d1 Mon Sep 17 00:00:00 2001 From: axelcl Date: Sat, 12 Feb 2005 23:21:46 +0000 Subject: [PATCH] Start the debugger through setting the url with "?DBGSESSID=1@clienthost:10001" in the internal browser --- net.sourceforge.phpeclipse.debug.ui/plugin.xml | 3 +- .../debug/ui/PHPDebugUiMessages.properties | 1 + .../debug/ui/launcher/PHPEnvironmentTab.java | 1155 ++++++++++---------- net.sourceforge.phpeclipse.launching/plugin.xml | 3 +- .../phpdt/internal/launching/DebuggerRunner.java | 174 ++-- .../launching/InterpreterRunnerConfiguration.java | 9 + .../launching/PHPLaunchConfigurationAttribute.java | 3 +- .../launching/PHPLaunchConfigurationDelegate.java | 5 + .../src/net/sourceforge/phpeclipse/ui/WebUI.java | 22 +- .../phpeclipse/ui/editor/BrowserUtil.java | 66 ++ .../ui/editor/ShowExternalPreviewAction.java | 48 +- .../ui/preferences/PHPMiscProjectPreferences.java | 14 +- net.sourceforge.phpeclipse/plugin.xml | 3 +- 13 files changed, 791 insertions(+), 715 deletions(-) create mode 100644 net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java diff --git a/net.sourceforge.phpeclipse.debug.ui/plugin.xml b/net.sourceforge.phpeclipse.debug.ui/plugin.xml index c195348..05b0c36 100644 --- a/net.sourceforge.phpeclipse.debug.ui/plugin.xml +++ b/net.sourceforge.phpeclipse.debug.ui/plugin.xml @@ -3,7 +3,7 @@ @@ -22,6 +22,7 @@ + diff --git a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPDebugUiMessages.properties b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPDebugUiMessages.properties index e6d1827..4aa4f7b 100644 --- a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPDebugUiMessages.properties +++ b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPDebugUiMessages.properties @@ -30,6 +30,7 @@ LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message=No LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label=Remote &Debug LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label=Remote &Debug LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label=Remote &Sourcepath: +LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label=Open with DBGSession URL in internal Browser LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label=Mapped Path: LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote=remote LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local=local diff --git a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEnvironmentTab.java b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEnvironmentTab.java index 4536b17..e404e63 100644 --- a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEnvironmentTab.java +++ b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEnvironmentTab.java @@ -3,11 +3,8 @@ package net.sourceforge.phpdt.internal.debug.ui.launcher; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import java.util.List; import java.util.Map; -import net.sourceforge.phpdt.core.JavaCore; -import net.sourceforge.phpdt.internal.core.JavaProject; import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiMessages; import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin; import net.sourceforge.phpdt.internal.debug.ui.preferences.EditInterpreterDialog; @@ -16,10 +13,7 @@ import net.sourceforge.phpdt.internal.launching.PHPInterpreter; import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute; import net.sourceforge.phpdt.internal.launching.PHPRuntime; import net.sourceforge.phpdt.internal.ui.PHPUiImages; -import net.sourceforge.phpeclipse.LoadPathEntry; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -48,574 +42,589 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.internal.dialogs.ListContentProvider; public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab { - protected ListViewer loadPathListViewer; - protected java.util.List installedInterpretersWorkingCopy; - protected Combo interpreterCombo; - protected Button loadPathDefaultButton; - protected Button fRemoteDebugCheckBox; - protected Button fPathMapRemoveButton; - protected Button fPathMapAddButton; - protected Button fPathMapEditButton; - protected Text fRemoteSourcePath; - protected Table fRemoteDebugPathMapTable; - protected TabFolder tabFolder; - - private class RemoteDebugTabListener extends SelectionAdapter implements ModifyListener { - - /* (non-Javadoc) - * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) - */ - public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); - } - - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - Object source= e.getSource(); - if (source == fRemoteDebugPathMapTable) { - setPathMapButtonsEnableState(); - } else if (source == fPathMapAddButton) { - handlePathMapAddButtonSelected(); - } else if (source == fPathMapEditButton) { - handlePathMapEditButtonSelected(); - } else if (source == fPathMapRemoveButton) { - handlePathMapRemoveButtonSelected(); - } else if (source == fRemoteDebugCheckBox) { - setRemoteTabEnableState(); - } else { - updateLaunchConfigurationDialog();; - } - - } - - } - - private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - private RemoteDebugTabListener fListener= new RemoteDebugTabListener(); - - private static final boolean DEFAULT_REMOTE_DEBUG= false; - static String [] columnTitles = { PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"), - PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote") - }; - public PHPEnvironmentTab() { - super(); - } - - public void createControl(Composite parent) { - Composite composite = createPageRoot(parent); - - tabFolder = new TabFolder(composite, SWT.NONE); - GridData gridData = new GridData(GridData.FILL_BOTH); - tabFolder.setLayoutData(gridData); - - addLoadPathTab(tabFolder); - addInterpreterTab(tabFolder); - addRemoteDebugTab(tabFolder); - } - - protected void addRemoteDebugTab(TabFolder tabFolder) - { - Label label; - - TabItem remoteDebugTab = new TabItem(tabFolder, SWT.NONE, 0); - remoteDebugTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label")); - - Composite comp = new Composite(tabFolder, SWT.NONE); - comp.setLayout(new GridLayout()); - remoteDebugTab.setControl(comp); - GridData gd; - - fRemoteDebugCheckBox = new Button(comp, SWT.CHECK); - fRemoteDebugCheckBox.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label")); - fRemoteDebugCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - fRemoteDebugCheckBox.addSelectionListener(fListener); - - label = new Label(comp, SWT.NONE); - label.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label")); - fRemoteSourcePath = new Text(comp, SWT.BORDER | SWT.SINGLE); - gd = new GridData(GridData.FILL_HORIZONTAL); - fRemoteSourcePath.setLayoutData(gd); - fRemoteSourcePath.addModifyListener(fListener); - - createVerticalSpacer(comp,1); - - Composite pathMapComp = new Composite(comp, SWT.NONE); - gd = new GridData(GridData.FILL_BOTH); - pathMapComp.setLayoutData(gd); - GridLayout parametersLayout = new GridLayout(); - parametersLayout.numColumns = 2; - parametersLayout.marginHeight = 0; - parametersLayout.marginWidth = 0; - pathMapComp.setLayout(parametersLayout); - - - Label pathMapLabel = new Label(pathMapComp, SWT.NONE); - pathMapLabel.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label")); - gd = new GridData(); - gd.horizontalSpan = 2; - pathMapLabel.setLayoutData(gd); - - - fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER | SWT.MULTI); - TableLayout tableLayout = new TableLayout(); - fRemoteDebugPathMapTable.setLayout(tableLayout); - - gd = new GridData(GridData.FILL_BOTH); - fRemoteDebugPathMapTable.setLayoutData(gd); - TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE); - column1.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$ - TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE); - column2.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$ - tableLayout.addColumnData(new ColumnWeightData(100)); - tableLayout.addColumnData(new ColumnWeightData(100)); - fRemoteDebugPathMapTable.setHeaderVisible(true); - fRemoteDebugPathMapTable.setLinesVisible(true); - fRemoteDebugPathMapTable.addSelectionListener(fListener); - fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - setPathMapButtonsEnableState(); - if (fPathMapEditButton.isEnabled()) { - handlePathMapEditButtonSelected(); - } - } - }); -// fRemoteDebugPathMapTable.setEnabled(false); - - Composite envButtonComp = new Composite(pathMapComp, SWT.NONE); - GridLayout envButtonLayout = new GridLayout(); - envButtonLayout.marginHeight = 0; - envButtonLayout.marginWidth = 0; - envButtonComp.setLayout(envButtonLayout); - gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL); - envButtonComp.setLayoutData(gd); - - - fPathMapAddButton = createPushButton(envButtonComp ,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$ - fPathMapAddButton.addSelectionListener(fListener); -// fPathMapAddButton.setEnabled(false); - - fPathMapEditButton = createPushButton(envButtonComp,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$ - fPathMapEditButton.addSelectionListener(fListener); -// fPathMapEditButton.setEnabled(false); - - fPathMapRemoveButton = createPushButton(envButtonComp,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$ - fPathMapRemoveButton.addSelectionListener(fListener); -// fPathMapRemoveButton.setEnabled(false); - - - } - - void handlePathMapAddButtonSelected() - { - EditPathMapDialog dialog= - new EditPathMapDialog( - getShell(), - "Edit File Map", - new String[] {EMPTY_STRING, EMPTY_STRING}); - openNewPathMapDialog(dialog,null); -// dialog.create(); -// if (dialog.open()==EditPathMapDialog.OK) -// { -// TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE); -// item.setText(0,dialog.getLocalPath()); -// item.setText(1,dialog.getRemotePath()); -// updateLaunchConfigurationDialog(); -// } -// updateLaunchConfigurationDialog(); - setPathMapButtonsEnableState(); - } - - void handlePathMapRemoveButtonSelected() - { - int[] selectedIndices = this.fRemoteDebugPathMapTable.getSelectionIndices(); - this.fRemoteDebugPathMapTable.remove(selectedIndices); - setPathMapButtonsEnableState(); - updateLaunchConfigurationDialog(); - } - - void handlePathMapEditButtonSelected() - { - TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0]; - String local = selectedItem.getText(0); - String remote = selectedItem.getText(1); - EditPathMapDialog dialog= - new EditPathMapDialog( - getShell(), - "Edit File Map", - new String[] {local, remote}); - openNewPathMapDialog(dialog, selectedItem); - } - - - /** - * Set the enabled state of whole tab. - */ - private void setRemoteTabEnableState() { - boolean state=fRemoteDebugCheckBox.getSelection(); - fRemoteSourcePath.setEnabled(state); - - fRemoteDebugPathMapTable.setEnabled(state); - if (!state) - { - fPathMapEditButton.setEnabled(false); - fPathMapRemoveButton.setEnabled(false); - fPathMapAddButton.setEnabled(false); - } else { - setPathMapButtonsEnableState(); - } - - updateLaunchConfigurationDialog(); - } - - - /** - * Set the enabled state of the three environment variable-related buttons based on the - * selection in the PathMapTable widget. - */ - private void setPathMapButtonsEnableState() { -// just do nothing for now -// - if(fRemoteDebugCheckBox.getSelection()) - { - int selectCount = this.fRemoteDebugPathMapTable.getSelectionIndices().length; - if (selectCount < 1) { - fPathMapEditButton.setEnabled(false); - fPathMapRemoveButton.setEnabled(false); - } else { - fPathMapRemoveButton.setEnabled(true); - if (selectCount == 1) { - fPathMapEditButton.setEnabled(true); - } else { - fPathMapEditButton.setEnabled(false); - } - } - fPathMapAddButton.setEnabled(true); - } - } - - /** - * Show the specified dialog and update the pathMapTable table based on its results. - * - * @param updateItem the item to update, or null if - * adding a new item - */ - private void openNewPathMapDialog(EditPathMapDialog dialog, TableItem updateItem) { - if (dialog.open() != EditPathMapDialog.OK) { - return; - } - String[] pathPair = dialog.getPathPair(); - TableItem tableItem = updateItem; - if (tableItem == null) { - tableItem = getTableItemForName(pathPair[0]); - if (tableItem == null) { - tableItem = new TableItem(this.fRemoteDebugPathMapTable, SWT.NONE); - } - } - tableItem.setText(pathPair); - this.fRemoteDebugPathMapTable.setSelection(new TableItem[] {tableItem}); - updateLaunchConfigurationDialog(); - } - - /** - * Helper method that indicates whether the specified parameter name is already present - * in the parameters table. - */ - private TableItem getTableItemForName(String candidateName) { - TableItem[] items = this.fRemoteDebugPathMapTable.getItems(); - for (int i = 0; i < items.length; i++) { - String name = items[i].getText(0); - if (name.equals(candidateName)) { - return items[i]; - } - } - return null; - } - - - - protected void addLoadPathTab(TabFolder tabFolder) { - Composite loadPathComposite = new Composite(tabFolder, SWT.NONE); - loadPathComposite.setLayout(new GridLayout()); - - loadPathListViewer = new ListViewer(loadPathComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); - loadPathListViewer.setContentProvider(new ListContentProvider()); - loadPathListViewer.setLabelProvider(new LoadPathEntryLabelProvider()); - loadPathListViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH)); - - TabItem loadPathTab = new TabItem(tabFolder, SWT.NONE, 0); - loadPathTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathTab.label")); - loadPathTab.setControl(loadPathComposite); - loadPathTab.setData(loadPathListViewer); - - loadPathDefaultButton = new Button(loadPathComposite, SWT.CHECK); - loadPathDefaultButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathDefaultButton.label")); - loadPathDefaultButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - loadPathDefaultButton.addSelectionListener(getLoadPathDefaultButtonSelectionListener()); - - loadPathDefaultButton.setEnabled(false); //for now, until the load path is customizable on the configuration - } - - protected SelectionListener getLoadPathSelectionListener() { - return new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - System.out.println("Loadpath list selection occurred: " + e.getSource()); - } - }; - } - - - - protected SelectionListener getLoadPathDefaultButtonSelectionListener() { - return new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setUseLoadPathDefaults(((Button) e.getSource()).getSelection()); - } - }; - } - - protected void addInterpreterTab(TabFolder tabFolder) { - Composite interpreterComposite = new Composite(tabFolder, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginWidth = 0; - interpreterComposite.setLayout(layout); - interpreterComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - createVerticalSpacer(interpreterComposite, 2); - - interpreterCombo = new Combo(interpreterComposite, SWT.READ_ONLY); - interpreterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - initializeInterpreterCombo(interpreterCombo); - interpreterCombo.addModifyListener(getInterpreterComboModifyListener()); - - Button interpreterAddButton = new Button(interpreterComposite, SWT.PUSH); - interpreterAddButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterAddButton.label")); - interpreterAddButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent evt) { - PHPInterpreter newInterpreter = new PHPInterpreter(null, null); - EditInterpreterDialog editor = new EditInterpreterDialog(getShell(), PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.editInterpreterDialog.title")); - editor.create(); - editor.setInterpreterToEdit(newInterpreter); - if (EditInterpreterDialog.OK == editor.open()) { - PHPRuntime.getDefault().addInstalledInterpreter(newInterpreter); - interpreterCombo.add(newInterpreter.getName()); - interpreterCombo.select(interpreterCombo.indexOf(newInterpreter.getName())); - } - } - }); - - TabItem interpreterTab = new TabItem(tabFolder, SWT.NONE); - interpreterTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterTab.label")); - interpreterTab.setControl(interpreterComposite); - } - - protected ModifyListener getInterpreterComboModifyListener() { - return new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }; - } - - protected void createVerticalSpacer(Composite comp, int colSpan) { - Label label = new Label(comp, SWT.NONE); - GridData gd = new GridData(); - gd.horizontalSpan = colSpan; - label.setLayoutData(gd); - } - - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - } - - public void initializeFrom(ILaunchConfiguration configuration) { - initializeLoadPath(configuration); - initializeInterpreterSelection(configuration); - initializeRemoteDebug(configuration); - } - - protected void initializeRemoteDebug(ILaunchConfiguration configuration) - { - String s[]; - int startIdx =0; - int idx; - try{ - fRemoteDebugCheckBox.setSelection( - configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG,DEFAULT_REMOTE_DEBUG)); - } catch(CoreException ce) { - fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG); - } - setRemoteTabEnableState(); - try{ - fRemoteSourcePath.setText( - configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH,"")); - } catch(CoreException ce) { - fRemoteSourcePath.setText(""); - } - - updatePathMapFromConfig(configuration); - - } - - private void updatePathMapFromConfig(ILaunchConfiguration config) { - Map envVars = null; - try { - if (config != null) { - envVars = config.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map)null); - } - updatePathMapTable(envVars, this.fRemoteDebugPathMapTable); - setPathMapButtonsEnableState(); - } catch (CoreException ce) { - log(ce); - } - } - - private void updatePathMapTable(Map map, Table tableWidget) { - tableWidget.removeAll(); - if (map == null) { - return; - } - Iterator iterator = map.keySet().iterator(); - while (iterator.hasNext()) { - String key = (String) iterator.next(); - String value = (String) map.get(key); - TableItem tableItem = new TableItem(tableWidget, SWT.NONE); - tableItem.setText(new String[] {key, value}); - } - } - - protected void initializeLoadPath(ILaunchConfiguration configuration) { - boolean useDefaultLoadPath = true; - try { - useDefaultLoadPath = configuration.getAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, true); - setUseLoadPathDefaults(useDefaultLoadPath); - if (useDefaultLoadPath) { - String projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, ""); - if (projectName != "") { - IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName); - if ((aProject != null) && JavaCore.isPHPProject(aProject)) { - JavaProject thePHPProject = new JavaProject(); - thePHPProject.setProject(aProject); - List loadPathEntries = thePHPProject.getLoadPathEntries(); - loadPathListViewer.setInput(loadPathEntries); - } - } - } - } catch (CoreException e) { - log(e); - } - } - - protected void setUseLoadPathDefaults(boolean useDefaults) { - loadPathListViewer.getList().setEnabled(!useDefaults); - loadPathDefaultButton.setSelection(useDefaults); - } - - protected void initializeInterpreterSelection(ILaunchConfiguration configuration) { - String interpreterName = null; - try { - interpreterName = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, ""); - } catch (CoreException e) { - log(e); - } - if (interpreterName != null && !interpreterName.equals("")) - interpreterCombo.select(interpreterCombo.indexOf(interpreterName)); - } - - protected void initializeInterpreterCombo(Combo interpreterCombo) { - installedInterpretersWorkingCopy = new ArrayList(); - installedInterpretersWorkingCopy.addAll(PHPRuntime.getDefault().getInstalledInterpreters()); - - String[] interpreterNames = new String[installedInterpretersWorkingCopy.size()]; - for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy.size(); interpreterIndex++) { - PHPInterpreter interpreter = (PHPInterpreter) installedInterpretersWorkingCopy.get(interpreterIndex); - interpreterNames[interpreterIndex] = interpreter.getName(); - } - interpreterCombo.setItems(interpreterNames); - - PHPInterpreter selectedInterpreter = PHPRuntime.getDefault().getSelectedInterpreter(); - if (selectedInterpreter != null) - interpreterCombo.select(interpreterCombo.indexOf(selectedInterpreter.getName())); - } - - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - int selectionIndex = interpreterCombo.getSelectionIndex(); - if (selectionIndex >= 0) - configuration.setAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, interpreterCombo.getItem(selectionIndex)); - - configuration.setAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, loadPathDefaultButton.getSelection()); - - if (!loadPathDefaultButton.getSelection()) { - List loadPathEntries = (List) loadPathListViewer.getInput(); - List loadPathStrings = new ArrayList(); - for (Iterator iterator = loadPathEntries.iterator(); iterator.hasNext();) { - LoadPathEntry entry = (LoadPathEntry) iterator.next(); - loadPathStrings.add(entry.getPath().toString()); - } - configuration.setAttribute(PHPLaunchConfigurationAttribute.CUSTOM_LOAD_PATH, loadPathStrings); - } - - configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, fRemoteDebugCheckBox.getSelection()); - configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromPathMapTable()); - configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, fRemoteSourcePath.getText()); - } - - protected Composite createPageRoot(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - createVerticalSpacer(composite, 2); - setControl(composite); - - return composite; - } - - private Map getMapFromPathMapTable() { - TableItem[] items = fRemoteDebugPathMapTable.getItems(); - if (items.length == 0) { - return null; - } - Map map = new HashMap(items.length); - for (int i = 0; i < items.length; i++) { - TableItem item = items[i]; - String key = item.getText(0); - String value = item.getText(1); - map.put(key, value); - } - return map; - } - - public String getName() { - return PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.name"); - } - - public boolean isValid(ILaunchConfiguration launchConfig) { - try { - String selectedInterpreter = launchConfig.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, ""); - if (selectedInterpreter.length() == 0) { - setErrorMessage(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message")); - return false; - } - } catch (CoreException e) { - log(e); - } - - setErrorMessage(null); - return true; - } - - protected void log(Throwable t) { - PHPDebugUiPlugin.log(t); - } - - public Image getImage() { - return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP); - } + protected ListViewer loadPathListViewer; + + protected java.util.List installedInterpretersWorkingCopy; + + protected Combo interpreterCombo; + + // protected Button loadPathDefaultButton; + protected Button fRemoteDebugCheckBox; + + protected Button fOpenDBGSessionInBrowserCheckBox; + + protected Button fPathMapRemoveButton; + + protected Button fPathMapAddButton; + + protected Button fPathMapEditButton; + + protected Text fRemoteSourcePath; + + protected Table fRemoteDebugPathMapTable; + + protected TabFolder tabFolder; + + private class RemoteDebugTabListener extends SelectionAdapter implements ModifyListener { + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) + */ + public void modifyText(ModifyEvent e) { + updateLaunchConfigurationDialog(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { + Object source = e.getSource(); + if (source == fRemoteDebugPathMapTable) { + setPathMapButtonsEnableState(); + } else if (source == fPathMapAddButton) { + handlePathMapAddButtonSelected(); + } else if (source == fPathMapEditButton) { + handlePathMapEditButtonSelected(); + } else if (source == fPathMapRemoveButton) { + handlePathMapRemoveButtonSelected(); + } else if (source == fRemoteDebugCheckBox) { + setRemoteTabEnableState(); + } else { + updateLaunchConfigurationDialog(); + ; + } + + } + + } + + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ + + private RemoteDebugTabListener fListener = new RemoteDebugTabListener(); + + private static final boolean DEFAULT_REMOTE_DEBUG = false; + + private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true; + + static String[] columnTitles = { + PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"), + PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote") }; + + public PHPEnvironmentTab() { + super(); + } + + public void createControl(Composite parent) { + Composite composite = createPageRoot(parent); + + tabFolder = new TabFolder(composite, SWT.NONE); + GridData gridData = new GridData(GridData.FILL_BOTH); + tabFolder.setLayoutData(gridData); + + // addLoadPathTab(tabFolder); + addInterpreterTab(tabFolder); + addRemoteDebugTab(tabFolder); + } + + protected void addRemoteDebugTab(TabFolder tabFolder) { + Label label; + + TabItem remoteDebugTab = new TabItem(tabFolder, SWT.NONE, 0); + remoteDebugTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label")); + + Composite comp = new Composite(tabFolder, SWT.NONE); + comp.setLayout(new GridLayout()); + remoteDebugTab.setControl(comp); + GridData gd; + + fRemoteDebugCheckBox = new Button(comp, SWT.CHECK); + fRemoteDebugCheckBox.setText(PHPDebugUiMessages + .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label")); + fRemoteDebugCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + fRemoteDebugCheckBox.addSelectionListener(fListener); + + fOpenDBGSessionInBrowserCheckBox = new Button(comp, SWT.CHECK); + fOpenDBGSessionInBrowserCheckBox.setText(PHPDebugUiMessages + .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label")); + fOpenDBGSessionInBrowserCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + fOpenDBGSessionInBrowserCheckBox.addSelectionListener(fListener); + + label = new Label(comp, SWT.NONE); + label.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label")); + fRemoteSourcePath = new Text(comp, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + fRemoteSourcePath.setLayoutData(gd); + fRemoteSourcePath.addModifyListener(fListener); + + createVerticalSpacer(comp, 1); + + Composite pathMapComp = new Composite(comp, SWT.NONE); + gd = new GridData(GridData.FILL_BOTH); + pathMapComp.setLayoutData(gd); + GridLayout parametersLayout = new GridLayout(); + parametersLayout.numColumns = 2; + parametersLayout.marginHeight = 0; + parametersLayout.marginWidth = 0; + pathMapComp.setLayout(parametersLayout); + + Label pathMapLabel = new Label(pathMapComp, SWT.NONE); + pathMapLabel.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label")); + gd = new GridData(); + gd.horizontalSpan = 2; + pathMapLabel.setLayoutData(gd); + + fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER | SWT.MULTI); + TableLayout tableLayout = new TableLayout(); + fRemoteDebugPathMapTable.setLayout(tableLayout); + + gd = new GridData(GridData.FILL_BOTH); + fRemoteDebugPathMapTable.setLayoutData(gd); + TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE); + column1.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$ + TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE); + column2 + .setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$ + tableLayout.addColumnData(new ColumnWeightData(100)); + tableLayout.addColumnData(new ColumnWeightData(100)); + fRemoteDebugPathMapTable.setHeaderVisible(true); + fRemoteDebugPathMapTable.setLinesVisible(true); + fRemoteDebugPathMapTable.addSelectionListener(fListener); + fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() { + public void mouseDoubleClick(MouseEvent e) { + setPathMapButtonsEnableState(); + if (fPathMapEditButton.isEnabled()) { + handlePathMapEditButtonSelected(); + } + } + }); + // fRemoteDebugPathMapTable.setEnabled(false); + + Composite envButtonComp = new Composite(pathMapComp, SWT.NONE); + GridLayout envButtonLayout = new GridLayout(); + envButtonLayout.marginHeight = 0; + envButtonLayout.marginWidth = 0; + envButtonComp.setLayout(envButtonLayout); + gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL); + envButtonComp.setLayoutData(gd); + + fPathMapAddButton = createPushButton(envButtonComp, PHPDebugUiMessages + .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$ + fPathMapAddButton.addSelectionListener(fListener); + // fPathMapAddButton.setEnabled(false); + + fPathMapEditButton = createPushButton(envButtonComp, PHPDebugUiMessages + .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$ + fPathMapEditButton.addSelectionListener(fListener); + // fPathMapEditButton.setEnabled(false); + + fPathMapRemoveButton = createPushButton(envButtonComp, PHPDebugUiMessages + .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$ + fPathMapRemoveButton.addSelectionListener(fListener); + // fPathMapRemoveButton.setEnabled(false); + + } + + void handlePathMapAddButtonSelected() { + EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { EMPTY_STRING, EMPTY_STRING }); + openNewPathMapDialog(dialog, null); + // dialog.create(); + // if (dialog.open()==EditPathMapDialog.OK) + // { + // TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE); + // item.setText(0,dialog.getLocalPath()); + // item.setText(1,dialog.getRemotePath()); + // updateLaunchConfigurationDialog(); + // } + // updateLaunchConfigurationDialog(); + setPathMapButtonsEnableState(); + } + + void handlePathMapRemoveButtonSelected() { + int[] selectedIndices = this.fRemoteDebugPathMapTable.getSelectionIndices(); + this.fRemoteDebugPathMapTable.remove(selectedIndices); + setPathMapButtonsEnableState(); + updateLaunchConfigurationDialog(); + } + + void handlePathMapEditButtonSelected() { + TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0]; + String local = selectedItem.getText(0); + String remote = selectedItem.getText(1); + EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { local, remote }); + openNewPathMapDialog(dialog, selectedItem); + } + + /** + * Set the enabled state of whole tab. + */ + private void setRemoteTabEnableState() { + boolean state = fRemoteDebugCheckBox.getSelection(); + fRemoteSourcePath.setEnabled(state); + + fRemoteDebugPathMapTable.setEnabled(state); + if (!state) { + fPathMapEditButton.setEnabled(false); + fPathMapRemoveButton.setEnabled(false); + fPathMapAddButton.setEnabled(false); + fOpenDBGSessionInBrowserCheckBox.setEnabled(false); + } else { + setPathMapButtonsEnableState(); + } + + updateLaunchConfigurationDialog(); + } + + /** + * Set the enabled state of the three environment variable-related buttons based on the selection in the PathMapTable widget. + */ + private void setPathMapButtonsEnableState() { + // just do nothing for now + // + if (fRemoteDebugCheckBox.getSelection()) { + fOpenDBGSessionInBrowserCheckBox.setEnabled(true); + int selectCount = this.fRemoteDebugPathMapTable.getSelectionIndices().length; + if (selectCount < 1) { + fPathMapEditButton.setEnabled(false); + fPathMapRemoveButton.setEnabled(false); + } else { + fPathMapRemoveButton.setEnabled(true); + if (selectCount == 1) { + fPathMapEditButton.setEnabled(true); + } else { + fPathMapEditButton.setEnabled(false); + } + } + fPathMapAddButton.setEnabled(true); + } + } + + /** + * Show the specified dialog and update the pathMapTable table based on its results. + * + * @param updateItem + * the item to update, or null if adding a new item + */ + private void openNewPathMapDialog(EditPathMapDialog dialog, TableItem updateItem) { + if (dialog.open() != EditPathMapDialog.OK) { + return; + } + String[] pathPair = dialog.getPathPair(); + TableItem tableItem = updateItem; + if (tableItem == null) { + tableItem = getTableItemForName(pathPair[0]); + if (tableItem == null) { + tableItem = new TableItem(this.fRemoteDebugPathMapTable, SWT.NONE); + } + } + tableItem.setText(pathPair); + this.fRemoteDebugPathMapTable.setSelection(new TableItem[] { tableItem }); + updateLaunchConfigurationDialog(); + } + + /** + * Helper method that indicates whether the specified parameter name is already present in the parameters table. + */ + private TableItem getTableItemForName(String candidateName) { + TableItem[] items = this.fRemoteDebugPathMapTable.getItems(); + for (int i = 0; i < items.length; i++) { + String name = items[i].getText(0); + if (name.equals(candidateName)) { + return items[i]; + } + } + return null; + } + + // protected void addLoadPathTab(TabFolder tabFolder) { + // Composite loadPathComposite = new Composite(tabFolder, SWT.NONE); + // loadPathComposite.setLayout(new GridLayout()); + // + // loadPathListViewer = new ListViewer(loadPathComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); + // loadPathListViewer.setContentProvider(new ListContentProvider()); + // loadPathListViewer.setLabelProvider(new LoadPathEntryLabelProvider()); + // loadPathListViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH)); + // + // TabItem loadPathTab = new TabItem(tabFolder, SWT.NONE, 0); + // loadPathTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathTab.label")); + // loadPathTab.setControl(loadPathComposite); + // loadPathTab.setData(loadPathListViewer); + + // loadPathDefaultButton = new Button(loadPathComposite, SWT.CHECK); + // loadPathDefaultButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathDefaultButton.label")); + // loadPathDefaultButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + // loadPathDefaultButton.addSelectionListener(getLoadPathDefaultButtonSelectionListener()); + // + // loadPathDefaultButton.setEnabled(false); //for now, until the load path is customizable on the configuration + // } + + protected SelectionListener getLoadPathSelectionListener() { + return new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + System.out.println("Loadpath list selection occurred: " + e.getSource()); + } + }; + } + + protected SelectionListener getLoadPathDefaultButtonSelectionListener() { + return new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + setUseLoadPathDefaults(((Button) e.getSource()).getSelection()); + } + }; + } + + protected void addInterpreterTab(TabFolder tabFolder) { + Composite interpreterComposite = new Composite(tabFolder, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 0; + layout.marginWidth = 0; + interpreterComposite.setLayout(layout); + interpreterComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + createVerticalSpacer(interpreterComposite, 2); + + interpreterCombo = new Combo(interpreterComposite, SWT.READ_ONLY); + interpreterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + initializeInterpreterCombo(interpreterCombo); + interpreterCombo.addModifyListener(getInterpreterComboModifyListener()); + + Button interpreterAddButton = new Button(interpreterComposite, SWT.PUSH); + interpreterAddButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterAddButton.label")); + interpreterAddButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + PHPInterpreter newInterpreter = new PHPInterpreter(null, null); + EditInterpreterDialog editor = new EditInterpreterDialog(getShell(), PHPDebugUiMessages + .getString("LaunchConfigurationTab.PHPEnvironment.editInterpreterDialog.title")); + editor.create(); + editor.setInterpreterToEdit(newInterpreter); + if (EditInterpreterDialog.OK == editor.open()) { + PHPRuntime.getDefault().addInstalledInterpreter(newInterpreter); + interpreterCombo.add(newInterpreter.getName()); + interpreterCombo.select(interpreterCombo.indexOf(newInterpreter.getName())); + } + } + }); + + TabItem interpreterTab = new TabItem(tabFolder, SWT.NONE); + interpreterTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterTab.label")); + interpreterTab.setControl(interpreterComposite); + } + + protected ModifyListener getInterpreterComboModifyListener() { + return new ModifyListener() { + public void modifyText(ModifyEvent evt) { + updateLaunchConfigurationDialog(); + } + }; + } + + protected void createVerticalSpacer(Composite comp, int colSpan) { + Label label = new Label(comp, SWT.NONE); + GridData gd = new GridData(); + gd.horizontalSpan = colSpan; + label.setLayoutData(gd); + } + + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + } + + public void initializeFrom(ILaunchConfiguration configuration) { + // initializeLoadPath(configuration); + initializeInterpreterSelection(configuration); + initializeRemoteDebug(configuration); + } + + protected void initializeRemoteDebug(ILaunchConfiguration configuration) { + String s[]; + int startIdx = 0; + int idx; + try { + fRemoteDebugCheckBox.setSelection(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, + DEFAULT_REMOTE_DEBUG)); + } catch (CoreException ce) { + fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG); + } + try { + fOpenDBGSessionInBrowserCheckBox.setSelection(configuration.getAttribute( + PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, DEFAULT_OPEN_DBGSESSION_IN_BROWSER)); + } catch (CoreException ce) { + fOpenDBGSessionInBrowserCheckBox.setSelection(DEFAULT_OPEN_DBGSESSION_IN_BROWSER); + } + setRemoteTabEnableState(); + try { + fRemoteSourcePath.setText(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, "")); + } catch (CoreException ce) { + fRemoteSourcePath.setText(""); + } + + updatePathMapFromConfig(configuration); + + } + + private void updatePathMapFromConfig(ILaunchConfiguration config) { + Map envVars = null; + try { + if (config != null) { + envVars = config.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null); + } + updatePathMapTable(envVars, this.fRemoteDebugPathMapTable); + setPathMapButtonsEnableState(); + } catch (CoreException ce) { + log(ce); + } + } + + private void updatePathMapTable(Map map, Table tableWidget) { + tableWidget.removeAll(); + if (map == null) { + return; + } + Iterator iterator = map.keySet().iterator(); + while (iterator.hasNext()) { + String key = (String) iterator.next(); + String value = (String) map.get(key); + TableItem tableItem = new TableItem(tableWidget, SWT.NONE); + tableItem.setText(new String[] { key, value }); + } + } + + // protected void initializeLoadPath(ILaunchConfiguration configuration) { + // boolean useDefaultLoadPath = true; + // try { + // useDefaultLoadPath = configuration.getAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, true); + // setUseLoadPathDefaults(useDefaultLoadPath); + // if (useDefaultLoadPath) { + // String projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, ""); + // if (projectName != "") { + // IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName); + // if ((aProject != null) && JavaCore.isPHPProject(aProject)) { + // JavaProject thePHPProject = new JavaProject(); + // thePHPProject.setProject(aProject); + // List loadPathEntries = thePHPProject.getLoadPathEntries(); + // loadPathListViewer.setInput(loadPathEntries); + // } + // } + // } + // } catch (CoreException e) { + // log(e); + // } + // } + + protected void setUseLoadPathDefaults(boolean useDefaults) { + loadPathListViewer.getList().setEnabled(!useDefaults); + // loadPathDefaultButton.setSelection(useDefaults); + } + + protected void initializeInterpreterSelection(ILaunchConfiguration configuration) { + String interpreterName = null; + try { + interpreterName = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, ""); + } catch (CoreException e) { + log(e); + } + if (interpreterName != null && !interpreterName.equals("")) + interpreterCombo.select(interpreterCombo.indexOf(interpreterName)); + } + + protected void initializeInterpreterCombo(Combo interpreterCombo) { + installedInterpretersWorkingCopy = new ArrayList(); + installedInterpretersWorkingCopy.addAll(PHPRuntime.getDefault().getInstalledInterpreters()); + + String[] interpreterNames = new String[installedInterpretersWorkingCopy.size()]; + for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy.size(); interpreterIndex++) { + PHPInterpreter interpreter = (PHPInterpreter) installedInterpretersWorkingCopy.get(interpreterIndex); + interpreterNames[interpreterIndex] = interpreter.getName(); + } + interpreterCombo.setItems(interpreterNames); + + PHPInterpreter selectedInterpreter = PHPRuntime.getDefault().getSelectedInterpreter(); + if (selectedInterpreter != null) + interpreterCombo.select(interpreterCombo.indexOf(selectedInterpreter.getName())); + } + + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + int selectionIndex = interpreterCombo.getSelectionIndex(); + if (selectionIndex >= 0) + configuration.setAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, interpreterCombo.getItem(selectionIndex)); + + // configuration.setAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, loadPathDefaultButton.getSelection()); + + // if (!loadPathDefaultButton.getSelection()) { + // List loadPathEntries = (List) loadPathListViewer.getInput(); + // List loadPathStrings = new ArrayList(); + // for (Iterator iterator = loadPathEntries.iterator(); iterator.hasNext();) { + // LoadPathEntry entry = (LoadPathEntry) iterator.next(); + // loadPathStrings.add(entry.getPath().toString()); + // } + // configuration.setAttribute(PHPLaunchConfigurationAttribute.CUSTOM_LOAD_PATH, loadPathStrings); + // } + + configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, fRemoteDebugCheckBox.getSelection()); + configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromPathMapTable()); + configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, fRemoteSourcePath.getText()); + configuration.setAttribute(PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, fOpenDBGSessionInBrowserCheckBox + .getSelection()); + } + + protected Composite createPageRoot(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + composite.setLayout(layout); + createVerticalSpacer(composite, 2); + setControl(composite); + + return composite; + } + + private Map getMapFromPathMapTable() { + TableItem[] items = fRemoteDebugPathMapTable.getItems(); + if (items.length == 0) { + return null; + } + Map map = new HashMap(items.length); + for (int i = 0; i < items.length; i++) { + TableItem item = items[i]; + String key = item.getText(0); + String value = item.getText(1); + map.put(key, value); + } + return map; + } + + public String getName() { + return PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.name"); + } + + public boolean isValid(ILaunchConfiguration launchConfig) { + try { + String selectedInterpreter = launchConfig.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, ""); + if (selectedInterpreter.length() == 0) { + setErrorMessage(PHPDebugUiMessages + .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message")); + return false; + } + } catch (CoreException e) { + log(e); + } + + setErrorMessage(null); + return true; + } + + protected void log(Throwable t) { + PHPDebugUiPlugin.log(t); + } + + public Image getImage() { + return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP); + } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.launching/plugin.xml b/net.sourceforge.phpeclipse.launching/plugin.xml index cff3602..ca346bd 100644 --- a/net.sourceforge.phpeclipse.launching/plugin.xml +++ b/net.sourceforge.phpeclipse.launching/plugin.xml @@ -3,7 +3,7 @@ @@ -22,6 +22,7 @@ + diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java index 461bf7b..ac75a7c 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java @@ -1,15 +1,10 @@ -/********************************************************************** -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 - Vicente Fernando - www.alfersoft.com.ar - Christian Perkonig - remote Debug -**********************************************************************/ +/*********************************************************************************************************************************** + * 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 Vicente Fernando - www.alfersoft.com.ar Christian Perkonig - remote Debug + **********************************************************************************************************************************/ package net.sourceforge.phpdt.internal.launching; import java.util.Iterator; @@ -17,94 +12,101 @@ import java.util.Iterator; import net.sourceforge.phpdt.internal.core.JavaProject; import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy; import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget; +import net.sourceforge.phpeclipse.ui.editor.BrowserUtil; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IProcess; +import org.eclipse.swt.widgets.Display; + //import net.sourceforge.phpeclipse.resourcesview.PHPProject; public class DebuggerRunner extends InterpreterRunner { - public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) { - String[] env; - String name, value; - PHPDBGProxy newPHPDBGProxy= new PHPDBGProxy(configuration.useRemoteDebugger(), - configuration.getRemoteSourcePath()); - int pos; + public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) { + String[] env; + String name, value; + PHPDBGProxy newPHPDBGProxy = new PHPDBGProxy(configuration.useRemoteDebugger(), configuration.getRemoteSourcePath()); + int pos; + IProcess process = null; + PHPDebugTarget debugTarget = new PHPDebugTarget(launch, process); + newPHPDBGProxy.setDebugTarget(debugTarget); + newPHPDBGProxy.start(); + if (configuration.useRemoteDebugger()) { + // listener for remote debuger is started + if (configuration.useDBGSessionInBrowser()) { + activateDBGSESSIDPreview(configuration,newPHPDBGProxy.getPort()); + } + } else { + setEnvironmentVariables(configuration, newPHPDBGProxy.getPort()); + // env=configuration.getEnvironment(); + process = super.run(configuration, launch); + debugTarget.setProcess(process); + } + launch.addDebugTarget(debugTarget); - IProcess process =null; - PHPDebugTarget debugTarget = new PHPDebugTarget(launch, process); - newPHPDBGProxy.setDebugTarget(debugTarget); - newPHPDBGProxy.start(); - if (configuration.useRemoteDebugger()) - { - // listener for remote debuger is started - } - else - { - setEnvironmentVariables(configuration,newPHPDBGProxy.getPort()); -// env=configuration.getEnvironment(); - process = super.run(configuration, launch); - debugTarget.setProcess(process); - } - launch.addDebugTarget(debugTarget); + return process; + } - return process; - } - - protected void setEnvironmentVariables(InterpreterRunnerConfiguration configuration,int listenPort) { - String DBGSessID; - String env[]= new String[18]; - long id = Math.round(Math.random()*100000); - + /** + * Open the browser in the UI thread with the current debugger URL + * + * @param configuration + * @param port + */ + protected static void activateDBGSESSIDPreview(final InterpreterRunnerConfiguration configuration, final int port) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + String fileName = configuration.getFileName(); + JavaProject jproject = configuration.getProject(); + IProject project = jproject.getProject(); + IFile file = project.getFile(fileName); + BrowserUtil.showPreview(file, true, "?DBGSESSID=1@clienthost:"+port); + } + }); + } + protected void setEnvironmentVariables(InterpreterRunnerConfiguration configuration, int listenPort) { + String DBGSessID; + String env[] = new String[18]; + long id = Math.round(Math.random() * 100000); - DBGSessID = "DBGSESSID="+id+"@clienthost:" + listenPort; - configuration.addEnvironmentValue("HTTP_COOKIE",DBGSessID,false); -/* configuration.addEnvironmentValue("REDIRECT_URL",OSFilePath,true); - configuration.addEnvironmentValue("REQUEST_URI",OSFilePath,true); - configuration.addEnvironmentValue("PATH_INFO",OSFilePath,true); - configuration.addEnvironmentValue("PATH_TRANSLATED",OSFilePath,true); - configuration.addEnvironmentValue("SCRIPT_FILENAME",interpreter,true); - configuration.addEnvironmentValue("SERVER_PROTOCOL","HTTP / 1.1",true); -*/ -/* - env[0]= "HTTP_COOKIE=" + DBGSessID; - env[1]= "REDIRECT_QUERY_STRING="; - env[2]= "REDIRECT_STATUS=200"; - env[3]= "REDIRECT_URL=" + OSFilePath; - env[4]= "SERVER_SOFTWARE=DBG / 2.1"; - env[5]= "SERVER_NAME=localhost"; - env[6]= "SERVER_ADDR=127.0.0.1"; - env[7]= "SERVER_PORT=80"; - env[8]= "REMOTE_ADDR=127.0.0.1"; - env[9]= "SCRIPT_FILENAME=" + interpreter; - env[10]= "GATEWAY_INTERFACE=CGI / 1.1"; - env[11]= "SERVER_PROTOCOL=HTTP / 1.1"; - env[12]= "REQUEST_METHOD=GET"; - env[13]= "QUERY_STRING=test=1"; - env[14]= "REQUEST_URI=" + OSFilePath; - env[15]= "PATH_INFO=" + OSFilePath; - env[16]= "PATH_TRANSLATED=" + OSFilePath; - env[17]= "SystemRoot=" + Environment.getenv("SystemRoot"); -*/ - // return env; - } + DBGSessID = "DBGSESSID=" + id + "@clienthost:" + listenPort; + configuration.addEnvironmentValue("HTTP_COOKIE", DBGSessID, false); + /* + * configuration.addEnvironmentValue("REDIRECT_URL",OSFilePath,true); + * configuration.addEnvironmentValue("REQUEST_URI",OSFilePath,true); + * configuration.addEnvironmentValue("PATH_INFO",OSFilePath,true); + * configuration.addEnvironmentValue("PATH_TRANSLATED",OSFilePath,true); + * configuration.addEnvironmentValue("SCRIPT_FILENAME",interpreter,true); + * configuration.addEnvironmentValue("SERVER_PROTOCOL","HTTP / 1.1",true); + */ + /* + * env[0]= "HTTP_COOKIE=" + DBGSessID; env[1]= "REDIRECT_QUERY_STRING="; env[2]= "REDIRECT_STATUS=200"; env[3]= "REDIRECT_URL=" + + * OSFilePath; env[4]= "SERVER_SOFTWARE=DBG / 2.1"; env[5]= "SERVER_NAME=localhost"; env[6]= "SERVER_ADDR=127.0.0.1"; env[7]= + * "SERVER_PORT=80"; env[8]= "REMOTE_ADDR=127.0.0.1"; env[9]= "SCRIPT_FILENAME=" + interpreter; env[10]= "GATEWAY_INTERFACE=CGI / + * 1.1"; env[11]= "SERVER_PROTOCOL=HTTP / 1.1"; env[12]= "REQUEST_METHOD=GET"; env[13]= "QUERY_STRING=test=1"; env[14]= + * "REQUEST_URI=" + OSFilePath; env[15]= "PATH_INFO=" + OSFilePath; env[16]= "PATH_TRANSLATED=" + OSFilePath; env[17]= + * "SystemRoot=" + Environment.getenv("SystemRoot"); + */ + // return env; + } - protected String getDebugCommandLineArgument() { - return ""; - } + protected String getDebugCommandLineArgument() { + return ""; + } - protected String renderLoadPath(InterpreterRunnerConfiguration configuration) { - StringBuffer loadPath = new StringBuffer(); + protected String renderLoadPath(InterpreterRunnerConfiguration configuration) { + StringBuffer loadPath = new StringBuffer(); - JavaProject project = configuration.getProject(); - addToLoadPath(loadPath, project.getProject()); + JavaProject project = configuration.getProject(); + addToLoadPath(loadPath, project.getProject()); - Iterator referencedProjects = project.getReferencedProjects().iterator(); - while (referencedProjects.hasNext()) - addToLoadPath(loadPath, (IProject) referencedProjects.next()); + Iterator referencedProjects = project.getReferencedProjects().iterator(); + while (referencedProjects.hasNext()) + addToLoadPath(loadPath, (IProject) referencedProjects.next()); - return loadPath.toString(); - } -} + return loadPath.toString(); + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java index d33e69e..b2950d7 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java @@ -103,6 +103,15 @@ public class InterpreterRunnerConfiguration { return false; } + public boolean useDBGSessionInBrowser() { + try { + return configuration.getAttribute(PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, true); + } catch(CoreException e) { + PHPLaunchingPlugin.log(e); + } + return false; + } + public void setEnvironment(String[] envp) { if (envp== null) diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java index 04b1516..098a059 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java @@ -13,9 +13,10 @@ public interface PHPLaunchConfigurationAttribute { static final String PROJECT_NAME = PHPLaunchingPlugin.PLUGIN_ID + ".PROJECT_NAME"; static final String SELECTED_INTERPRETER = PHPLaunchingPlugin.PLUGIN_ID + ".SELECTED_INTERPRETER"; static final String WORKING_DIRECTORY = PHPLaunchingPlugin.PLUGIN_ID + ".WORKING_DIRECTORY"; - static final String USE_DEFAULT_LOAD_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_LOAD_PATH"; +// static final String USE_DEFAULT_LOAD_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_LOAD_PATH"; static final String USE_DEFAULT_WORKING_DIRECTORY = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_WORKING_DIRECTORY"; static final String REMOTE_DEBUG = PHPLaunchingPlugin.PLUGIN_ID + ".REMOTE_DEBUG"; static final String REMOTE_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".REMOTE_PATH"; + static final String OPEN_DBGSESSION_IN_BROWSER = PHPLaunchingPlugin.PLUGIN_ID + ".OPEN_DBGSESSION_IN_BROWSER"; static final String FILE_MAP = PHPLaunchingPlugin.PLUGIN_ID + ".FILE_MAP"; } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java index 483229d..e9db3d1 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java @@ -14,6 +14,11 @@ package net.sourceforge.phpdt.internal.launching; //import java.io.OutputStream; +import net.sourceforge.phpdt.internal.core.JavaProject; +import net.sourceforge.phpeclipse.ui.editor.BrowserUtil; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java index b45dc5f..eb7b852 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java @@ -8,7 +8,7 @@ * Contributors: * Christopher Lenz - initial implementation * - * $Id: WebUI.java,v 1.3 2004-09-03 19:58:36 jsurfer Exp $ + * $Id: WebUI.java,v 1.4 2005-02-12 23:21:46 axelcl Exp $ */ package net.sourceforge.phpeclipse.ui; @@ -53,17 +53,22 @@ public class WebUI extends AbstractUIPlugin implements IPreferenceConstants { /** The shared instance. */ private static WebUI plugin; + public static IWorkbenchPage getActivePage() { return getDefault().internalGetActivePage(); } + private IWorkbenchPage internalGetActivePage() { + return getWorkbench().getActiveWorkbenchWindow().getActivePage(); + } + public static Shell getActiveWorkbenchShell() { return getActiveWorkbenchWindow().getShell(); } + public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } - // Public Methods ---------------------------------------------------------- /** @@ -157,6 +162,7 @@ public class WebUI extends AbstractUIPlugin implements IPreferenceConstants { store.setDefault(PHP_SHOW_HTML_FILES_LOCAL, "true"); store.setDefault(PHP_SHOW_XML_FILES_LOCAL, "false"); } + /* * @see AbstractUIPlugin#initializeImageRegistry(ImageRegistry) */ @@ -164,10 +170,10 @@ public class WebUI extends AbstractUIPlugin implements IPreferenceConstants { reg.put(ICON_OVERLAY_ERROR, getImageDescriptor(ICON_OVERLAY_ERROR)); reg.put(ICON_OVERLAY_WARNING, getImageDescriptor(ICON_OVERLAY_WARNING)); } - private IWorkbenchPage internalGetActivePage() { - IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow(); - if (window != null) - return window.getActivePage(); - return null; - } + // private IWorkbenchPage internalGetActivePage() { + // IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow(); + // if (window != null) + // return window.getActivePage(); + // return null; + // } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java new file mode 100644 index 0000000..a2b5786 --- /dev/null +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java @@ -0,0 +1,66 @@ +package net.sourceforge.phpeclipse.ui.editor; + +import net.sourceforge.phpeclipse.ui.IPreferenceConstants; +import net.sourceforge.phpeclipse.ui.WebUI; +import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil; +import net.sourceforge.phpeclipse.webbrowser.views.BrowserView; + +import org.eclipse.core.resources.IFile; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; + + +public class BrowserUtil { + + public static void showPreview(IFile previewFile, boolean forceDBGPreview, String postFix) { + if (previewFile == null) { + // should never happen + return; + } + String extension = previewFile.getFileExtension().toLowerCase(); + boolean autoPreview = forceDBGPreview; + boolean bringToTopPreview = true; + boolean showHTMLFilesLocal = false; + boolean showXMLFilesLocal = false; + boolean isHTMLFileName = false; + boolean isXMLFileName = false; + if (!forceDBGPreview) { + autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); + + bringToTopPreview = ProjectPrefUtil + .getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); + showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL); + showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL); + isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension); + isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension); + } + if (autoPreview) { + String localhostURL; + if (showHTMLFilesLocal && isHTMLFileName) { + localhostURL = previewFile.getLocation().toString(); + } else if (showXMLFilesLocal && isXMLFileName) { + localhostURL = previewFile.getLocation().toString(); + } else if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(null, previewFile)) == null) { + return; + } + localhostURL += postFix; + + try { + IWorkbenchPage page = WebUI.getActivePage(); + IViewPart part = page.findView(BrowserView.ID_BROWSER); + if (part == null) { + part = page.showView(BrowserView.ID_BROWSER); + } else { + if (bringToTopPreview) { + page.bringToTop(part); + } + } + ((BrowserView) part).setUrl(localhostURL); + + } catch (Exception e) { +// PHPeclipsePlugin.log(e); + } + } + } + +} diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java index 5cfaeb7..bef108a 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java @@ -50,45 +50,9 @@ public class ShowExternalPreviewAction extends TextEditorAction { public void doRun(int type) { IFile previewFile = getFile(); - if (previewFile == null) { - // should never happen - return; - } - String extension = previewFile.getFileExtension().toLowerCase(); - boolean autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); - boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); - boolean showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL); - boolean showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL); - boolean isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension); - boolean isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension); - - if (autoPreview) { - String localhostURL; - if (showHTMLFilesLocal && isHTMLFileName) { - localhostURL = previewFile.getLocation().toString(); - } else if (showXMLFilesLocal && isXMLFileName) { - localhostURL = previewFile.getLocation().toString(); - } else if ((localhostURL = getLocalhostURL(null, previewFile)) == null) { - return; - } - IWorkbenchPage page = WebUI.getActivePage(); - try { - IViewPart part = page.findView(BrowserView.ID_BROWSER); - if (part == null) { - part = page.showView(BrowserView.ID_BROWSER); - } else { - if (bringToTopPreview) { - page.bringToTop(part); - } - } - ((BrowserView) part).setUrl(localhostURL); - - } catch (Exception e) { - //PHPeclipsePlugin.log(e); - } - } + BrowserUtil.showPreview(previewFile, false, ""); } - + public void refresh(int type) { IFile fileToParse = getFile(); if (fileToParse == null) { @@ -96,10 +60,11 @@ public class ShowExternalPreviewAction extends TextEditorAction { return; } boolean autoPreview = ProjectPrefUtil.getPreviewBooleanValue(fileToParse, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); - boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue(fileToParse, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); + boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue(fileToParse, + IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); if (autoPreview) { - IWorkbenchPage page = WebUI.getActivePage(); + IWorkbenchPage page = WebUI.getDefault().getActivePage(); try { IViewPart part = page.findView(BrowserView.ID_BROWSER); if (part == null) { @@ -149,6 +114,7 @@ public class ShowExternalPreviewAction extends TextEditorAction { return null; } // return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL; - return ProjectPrefUtil.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL; + return ProjectPrefUtil.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + + localhostURL; } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java index c8b8145..c0073b1 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java @@ -6,6 +6,9 @@ import net.sourceforge.phpeclipse.ui.overlaypages.FieldEditorOverlayPage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PathEditor; import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; @@ -34,7 +37,7 @@ public class PHPMiscProjectPreferences extends FieldEditorOverlayPage protected void createFieldEditors() { Composite composite = getFieldEditorParent(); - + addField(new StringFieldEditor(IPreferenceConstants.PHP_LOCALHOST_PREF, PHPPreferencesMessages.getString("PHPMiscProjectPreferences.localhost"), composite)); @@ -44,10 +47,15 @@ public class PHPMiscProjectPreferences extends FieldEditorOverlayPage addField(new StringFieldEditor(IPreferenceConstants.PHP_DOCUMENTROOT_PREF, PHPPreferencesMessages.getString("PHPMiscProjectPreferences.documentroot"), composite)); - addField(new PathEditor(IPreferenceConstants.PHP_INCLUDE_PATHS, + + PathEditor pe = new PathEditor(IPreferenceConstants.PHP_INCLUDE_PATHS, PHPPreferencesMessages.getString("PHPMiscProjectPreferences.include_paths"), "Choose Path...", - composite)); + composite); + addField(pe); + + + //if (!isPropertyPage)) { // //} diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 18d2b57..b23549f 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -34,7 +34,8 @@ - + + -- 1.7.1