From: khartlage Date: Sat, 17 Jul 2004 11:39:44 +0000 (+0000) Subject: Improved "Open Include" and "Open Include List" for external workspaces X-Git-Url: http://git.phpeclipse.com?hp=4dba50a264bb1a2a13612e2258d20d548b9124af Improved "Open Include" and "Open Include List" for external workspaces --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LocalhostExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LocalhostExpander.java index 80e6d74..5bd3b47 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LocalhostExpander.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LocalhostExpander.java @@ -14,7 +14,7 @@ public class LocalhostExpander implements IVariableTextExpander { public String getText(String varTag, String varValue, ExpandVariableContext context) { IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - return store.getString(PHPeclipsePlugin.LOCALHOST_PREF); + return store.getString(PHPeclipsePlugin.PHP_LOCALHOST_PREF); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java index 9ff6c61..66ae19d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java @@ -32,13 +32,13 @@ public class UrlExpander extends ResourceExpander { //implements IVariableTextEx IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); String localhostURL = path.toString(); String lowerCaseFileName = localhostURL.toLowerCase(); - String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + String documentRoot = store.getString(PHPeclipsePlugin.PHP_DOCUMENTROOT_PREF); documentRoot = documentRoot.replace('\\', '/'); documentRoot = documentRoot.toLowerCase(); if (lowerCaseFileName.startsWith(documentRoot)) { localhostURL = localhostURL.substring(documentRoot.length()); - localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF)+ localhostURL; + localhostURL = store.getString(PHPeclipsePlugin.PHP_LOCALHOST_PREF)+ localhostURL; } return localhostURL; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java index 0352e0c..7fd5ac4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java @@ -31,8 +31,8 @@ public interface IPreferenceConstants { */ public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$ - public static final String LOCALHOST_PREF = "_localhost"; - public static final String DOCUMENTROOT_PREF = "_documentroot"; +// 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"; @@ -215,6 +215,8 @@ public interface IPreferenceConstants { public static final String PHP_OBFUSCATOR_DEFAULT = "_php_obfuscator_default"; public static final String PHP_BOOKMARK_DEFAULT = "_php_bookmark_default"; + public static final String PHP_LOCALHOST_PREF = "_php_localhost"; + public static final String PHP_DOCUMENTROOT_PREF = "_php_documentroot"; public static final String PHP_AUTO_PREVIEW_DEFAULT = "_auto_preview"; public static final String PHP_BRING_TO_TOP_PREVIEW_DEFAULT = "_bring_to_top_preview"; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java index 78879bf..5dee0b0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java @@ -29,8 +29,8 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor // private ArrayList TextBoxes = new ArrayList(); // private ArrayList RadioButtons = new ArrayList(); - StringFieldEditor localHostSFE; - DirectoryFieldEditor documentRootDFE; +// StringFieldEditor localHostSFE; +// DirectoryFieldEditor documentRootDFE; // BooleanFieldEditor showExternalPreviewBFE; BooleanFieldEditor externalBrowserBFE; StringFieldEditor externalBrowserSFE; @@ -57,8 +57,8 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor public void init(IWorkbench workbench) { } protected void performDefaults() { - localHostSFE.loadDefault(); - documentRootDFE.loadDefault(); +// localHostSFE.loadDefault(); +// documentRootDFE.loadDefault(); // showExternalPreviewBFE.loadDefault(); externalBrowserBFE.loadDefault(); externalBrowserSFE.loadDefault(); @@ -80,8 +80,8 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor } public boolean performOk() { - localHostSFE.store(); - documentRootDFE.store(); +// localHostSFE.store(); +// documentRootDFE.store(); // showExternalPreviewBFE.store(); externalBrowserBFE.store(); externalBrowserSFE.store(); @@ -160,24 +160,24 @@ public class PHPEclipseBasePreferencePage extends PreferencePage implements IWor externalBrowserSFE.load(); new Label(webSettingsGroup, SWT.NONE); - localHostSFE = - new StringFieldEditor( - IPreferenceConstants.LOCALHOST_PREF, - PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"), - webSettingsGroup); - localHostSFE.setPreferencePage(this); - localHostSFE.setPreferenceStore(getPreferenceStore()); - localHostSFE.load(); +// localHostSFE = +// new StringFieldEditor( +// IPreferenceConstants.LOCALHOST_PREF, +// PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"), +// webSettingsGroup); +// localHostSFE.setPreferencePage(this); +// localHostSFE.setPreferenceStore(getPreferenceStore()); +// localHostSFE.load(); new Label(webSettingsGroup, SWT.NONE); - documentRootDFE = - new DirectoryFieldEditor( - IPreferenceConstants.DOCUMENTROOT_PREF, - PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"), - webSettingsGroup); - documentRootDFE.setPreferencePage(this); - documentRootDFE.setPreferenceStore(getPreferenceStore()); - documentRootDFE.load(); +// documentRootDFE = +// new DirectoryFieldEditor( +// IPreferenceConstants.DOCUMENTROOT_PREF, +// PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"), +// webSettingsGroup); +// documentRootDFE.setPreferencePage(this); +// documentRootDFE.setPreferenceStore(getPreferenceStore()); +// documentRootDFE.load(); //Create apache Composite apacheSettingsComposite = new Composite(composite, SWT.NULL); apacheSettingsComposite.setLayout(new GridLayout()); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 8ba1bbb..aa056a3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -640,7 +640,11 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements // } protected void initializeDefaultPreferences(IPreferenceStore store) { // windows preferences: - store.setDefault(LOCALHOST_PREF, "http://localhost"); +// store.setDefault(LOCALHOST_PREF, "http://localhost"); +// store.setDefault(DOCUMENTROOT_PREF, getWorkspace().getRoot().getLocation().toString()); + store.setDefault(PHP_LOCALHOST_PREF, "http://localhost"); + store.setDefault(PHP_DOCUMENTROOT_PREF, getWorkspace().getRoot().getLocation().toString()); + // store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true"); store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false"); store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true"); @@ -665,8 +669,6 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements store.setDefault(PHP_OBFUSCATOR_DEFAULT, "/tmp"); store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}"); } - store.setDefault(DOCUMENTROOT_PREF, getWorkspace().getRoot().getLocation() - .toString()); // if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) { // if (windowsSystem.equals(Platform.WS_WIN32)) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java index 839d1e7..3f48e2b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java @@ -26,7 +26,7 @@ public class IncludesScanner implements ITerminalSymbols { // private final PHPOpenAllIncludesEditorAction fOpenAllIncludesAction; private IProject fProject; private IFileEditorInput fEditorInput; - HashSet fSet; + private HashSet fSet; public IncludesScanner(IProject project, IFileEditorInput editorInput) { fProject = project; // fOpenAllIncludesAction = action; @@ -41,7 +41,7 @@ public class IncludesScanner implements ITerminalSymbols { try { if (fileToParse.exists()) { - addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString()); + addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getProjectRelativePath().toString()); } } catch (CoreException e1) { e1.printStackTrace(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java index dcc2a39..2d68785 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java @@ -15,7 +15,10 @@ import java.net.MalformedURLException; import java.net.URL; import java.text.MessageFormat; import java.util.Iterator; + +import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.overlaypages.Util; import net.sourceforge.phpeclipse.views.PHPConsole; import net.sourceforge.phpeclipse.views.browser.BrowserView; import org.eclipse.core.resources.IFile; @@ -120,15 +123,20 @@ public class PHPEclipseShowAction implements IObjectActionDelegate { // IPath path = file.getFullPath(); String localhostURL = file.getLocation().toString(); String lowerCaseFileName = localhostURL.toLowerCase(); - String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + // String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + String documentRoot = Util.getMiscProjectsPreferenceValue( + file.getProject(), IPreferenceConstants.PHP_DOCUMENTROOT_PREF); + documentRoot = documentRoot.replace('\\', '/'); documentRoot = documentRoot.toLowerCase(); + if (lowerCaseFileName.startsWith(documentRoot)) { localhostURL = localhostURL.substring(documentRoot.length()); } else { - return null; + return null; } - return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL; +// return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL; + return Util.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL; } public static void open(final URL url, final Shell shell, diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java index aec734b..a3cc1bc 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java @@ -8,6 +8,7 @@ ******************************************************************************/ package net.sourceforge.phpeclipse.actions; +import java.io.File; import java.util.List; import net.sourceforge.phpeclipse.PHPeclipsePlugin; @@ -126,8 +127,9 @@ public class PHPOpenAllIncludesEditorAction extends ActionDelegate implements IE List list = fIncludesScanner.getList(); if (list != null && list.size() > 0) { - String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); - +// String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); + String workspaceLocation = fProject.getLocation().toString()+File.separatorChar; + ListSelectionDialog listSelectionDialog = new ListSelectionDialog(PHPeclipsePlugin.getDefault().getWorkbench() .getActiveWorkbenchWindow().getShell(), list, new ListContentProvider(), new LabelProvider(), "Select the includes to open."); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenIncludeEditorAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenIncludeEditorAction.java index 77173a7..542faee 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenIncludeEditorAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenIncludeEditorAction.java @@ -8,6 +8,7 @@ ******************************************************************************/ package net.sourceforge.phpeclipse.actions; +import java.io.File; import java.util.List; import net.sourceforge.phpeclipse.PHPeclipsePlugin; @@ -130,9 +131,10 @@ public class PHPOpenIncludeEditorAction extends ActionDelegate implements IEdito IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault().getIndexManager(fProject); // filename = StringUtil.replaceRegExChars(filename); List list = indexManager.getFileList(filename); - if (list != null && list.size() > 0) { - String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); - + if (list != null && list.size() > 0) { + //String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); + String workspaceLocation = fProject.getLocation().toString()+File.separatorChar; + ListSelectionDialog listSelectionDialog = new ListSelectionDialog(PHPeclipsePlugin.getDefault().getWorkbench() .getActiveWorkbenchWindow().getShell(), list, new ListContentProvider(), new LabelProvider(), "Select the includes to open."); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java index 72e579e..6e253c8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java @@ -29,7 +29,7 @@ public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate { public void run(IAction action) { final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + String documentRoot = store.getString(PHPeclipsePlugin.PHP_DOCUMENTROOT_PREF); // replace backslash with slash in the DocumentRoot under Windows documentRoot = documentRoot.replace('\\', '/'); String[] arguments = { documentRoot }; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPMiscProjectPreferences.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPMiscProjectPreferences.java index 4a865a4..d158491 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPMiscProjectPreferences.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPMiscProjectPreferences.java @@ -31,17 +31,19 @@ public class PHPMiscProjectPreferences extends FieldEditorOverlayPage protected String getPageId() { return PREF_ID; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ + protected void createFieldEditors() { Composite composite = getFieldEditorParent(); + + addField(new StringFieldEditor(IPreferenceConstants.PHP_LOCALHOST_PREF, + PHPPreferencesMessages.getString("PHPMiscProjectPreferences.localhost"), + composite)); + addField(new StringFieldEditor(IPreferenceConstants.PHP_DOCUMENTROOT_PREF, + PHPPreferencesMessages.getString("PHPMiscProjectPreferences.documentroot"), + composite)); addField(new StringFieldEditor(IPreferenceConstants.PHP_BOOKMARK_DEFAULT, PHPPreferencesMessages.getString("PHPMiscProjectPreferences.bookmark"), composite)); - //if (!isPropertyPage)) { // //} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties index 1157f93..b13bd34 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.properties @@ -1,5 +1,5 @@ ######################################### -# PHPProjectLibraryPage +# PHPProjectLibraryPage ######################################### PHPProjectLibraryPage.elementNotIProject=ERROR: Element not IProject @@ -15,7 +15,10 @@ PHPProjectPropertyPage.phpProjectClosed=The project selected is a PHP project, b PHPProjectPropertyPage.performOkExceptionDialogTitle=Unable to save PHPProjectPropertyPage.performOkExceptionDialogMessage=ERROR: Unable to save project properties. +PHPMiscProjectPreferences.localhost=Localhost +PHPMiscProjectPreferences.documentroot=DocumentRoot PHPMiscProjectPreferences.bookmark=SQL default bookmark: + PHPMiscProjectPreferences.obfuscator=Obfuscator directory: PHPPreviewProjectPreferences.auto_preview=Refresh PHP browser view when opening editor