| Revision | 132 (tree) |
|---|---|
| Time | 2015-10-18 16:22:59 |
| Author | t_nakayama1971 |
findbugs warning修正
| @@ -104,7 +104,7 @@ | ||
| 104 | 104 | |
| 105 | 105 | try { |
| 106 | 106 | this.isTomcatProjectCheck.setSelection( |
| 107 | - this.javaProject.getProject().hasNature(TomcatLauncherPlugin.NATURE_ID)); | |
| 107 | + this.javaProject.getProject().hasNature(TomcatPluginResources.NATURE_ID)); | |
| 108 | 108 | } catch (final CoreException ex) { |
| 109 | 109 | TomcatLauncherPlugin.log(ex.getMessage()); |
| 110 | 110 | } |
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 | /** |
| 40 | 40 | * TomcatProject |
| 41 | 41 | */ |
| 42 | -public class TomcatProject extends PlatformObject implements IProjectNature { | |
| 42 | +public class TomcatProject extends PlatformObject implements IProjectNature, ITomcatProject { | |
| 43 | 43 | |
| 44 | 44 | // Persistence properties of projects |
| 45 | 45 | /** PROPERTIES_FILENAME */ |
| @@ -137,6 +137,7 @@ | ||
| 137 | 137 | * @see IProjectNature#setProject(IProject) |
| 138 | 138 | * @param prj IJavaProject |
| 139 | 139 | */ |
| 140 | + @Override | |
| 140 | 141 | public void setJavaProject(final IJavaProject prj) { |
| 141 | 142 | this.javaProject = prj; |
| 142 | 143 | setProject(prj.getProject()); |
| @@ -148,7 +149,7 @@ | ||
| 148 | 149 | */ |
| 149 | 150 | public static void addTomcatNature(final IJavaProject project) { |
| 150 | 151 | try { |
| 151 | - JDTUtil.addNatureToProject(project.getProject(), TomcatLauncherPlugin.NATURE_ID); | |
| 152 | + JDTUtil.addNatureToProject(project.getProject(), TomcatPluginResources.NATURE_ID); | |
| 152 | 153 | } catch (final CoreException ex) { |
| 153 | 154 | TomcatLauncherPlugin.log(ex.getMessage()); |
| 154 | 155 | } |
| @@ -160,7 +161,7 @@ | ||
| 160 | 161 | */ |
| 161 | 162 | public static void removeTomcatNature(final IJavaProject project) { |
| 162 | 163 | try { |
| 163 | - JDTUtil.removeNatureToProject(project.getProject(), TomcatLauncherPlugin.NATURE_ID); | |
| 164 | + JDTUtil.removeNatureToProject(project.getProject(), TomcatPluginResources.NATURE_ID); | |
| 164 | 165 | } catch (final CoreException ex) { |
| 165 | 166 | TomcatLauncherPlugin.log(ex.getMessage()); |
| 166 | 167 | } |
| @@ -176,7 +177,7 @@ | ||
| 176 | 177 | public static TomcatProject create(final IJavaProject javaProject) { |
| 177 | 178 | TomcatProject result = null; |
| 178 | 179 | try { |
| 179 | - result = (TomcatProject)javaProject.getProject().getNature(TomcatLauncherPlugin.NATURE_ID); | |
| 180 | + result = (TomcatProject)javaProject.getProject().getNature(TomcatPluginResources.NATURE_ID); | |
| 180 | 181 | if (result != null) { |
| 181 | 182 | result.setJavaProject(javaProject); |
| 182 | 183 | } |
| @@ -406,6 +407,7 @@ | ||
| 406 | 407 | * return the webclasspath entries |
| 407 | 408 | * @return WebClassPathEntries |
| 408 | 409 | */ |
| 410 | + @Override | |
| 409 | 411 | public WebClassPathEntries getWebClassPathEntries() { |
| 410 | 412 | try { |
| 411 | 413 | return WebClassPathEntries.xmlUnmarshal(FileUtil.readTextFile(getPropertiesFile())); |
| @@ -507,7 +509,7 @@ | ||
| 507 | 509 | cp.add(entry); |
| 508 | 510 | } |
| 509 | 511 | } |
| 510 | - cp.addAll(tb.getTomcatJars()); | |
| 512 | + cp.addAll(tb.getTomcatJars(TomcatLauncherPlugin.getTomcatIPath())); | |
| 511 | 513 | |
| 512 | 514 | this.javaProject.setRawClasspath(cp.toArray(new IClasspathEntry[cp.size()]), null); |
| 513 | 515 | } |
| @@ -563,6 +565,7 @@ | ||
| 563 | 565 | * |
| 564 | 566 | * @return IFolder |
| 565 | 567 | */ |
| 568 | + @Override | |
| 566 | 569 | public IFolder getRootDirFolder() { |
| 567 | 570 | if (this.rootDirFolder == null) { |
| 568 | 571 | initRootDirFolder(false); |
| @@ -732,7 +735,7 @@ | ||
| 732 | 735 | * @throws CoreException CoreException |
| 733 | 736 | */ |
| 734 | 737 | public void updateContext() throws CoreException { |
| 735 | - if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) { | |
| 738 | + if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) { | |
| 736 | 739 | updateServerXML(); |
| 737 | 740 | } else { |
| 738 | 741 | try { |
| @@ -813,11 +816,12 @@ | ||
| 813 | 816 | * |
| 814 | 817 | * @throws CoreException CoreException |
| 815 | 818 | */ |
| 819 | + @Override | |
| 816 | 820 | public void removeContext() throws CoreException { |
| 817 | 821 | // Always call removeContext file because Tomcat create it automatically when using server.xml |
| 818 | 822 | removeContextFile(); |
| 819 | 823 | |
| 820 | - if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) { | |
| 824 | + if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) { | |
| 821 | 825 | removeContextInServerXML(); |
| 822 | 826 | } |
| 823 | 827 | } |
| @@ -81,7 +81,7 @@ | ||
| 81 | 81 | |
| 82 | 82 | this.oldVersion = TomcatLauncherPlugin.getTomcatVersion(); |
| 83 | 83 | this.version = new RadioGroupFieldEditor( |
| 84 | - TomcatLauncherPlugin.TOMCAT_PREF_VERSION_KEY, | |
| 84 | + TomcatPluginResources.TOMCAT_PREF_VERSION_KEY, | |
| 85 | 85 | PREF_PAGE_CHOOSEVERSION_LABEL, 1, |
| 86 | 86 | new String[][] { |
| 87 | 87 | // {PREF_PAGE_VERSION3_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION3}, |
| @@ -90,14 +90,14 @@ | ||
| 90 | 90 | // {PREF_PAGE_VERSION5_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION5}, |
| 91 | 91 | // {PREF_PAGE_VERSION6_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION6}, |
| 92 | 92 | |
| 93 | - {PREF_PAGE_VERSION7_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION7}, | |
| 94 | - {PREF_PAGE_VERSION8_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION8} | |
| 93 | + {PREF_PAGE_VERSION7_LABEL, TomcatPluginResources.TOMCAT_VERSION7}, | |
| 94 | + {PREF_PAGE_VERSION8_LABEL, TomcatPluginResources.TOMCAT_VERSION8} | |
| 95 | 95 | }, |
| 96 | 96 | composite, true); |
| 97 | 97 | |
| 98 | 98 | Group homeGroup = new Group(composite, SWT.NONE); |
| 99 | 99 | this.home = new DirectoryFieldEditor( |
| 100 | - TomcatLauncherPlugin.TOMCAT_PREF_HOME_KEY, | |
| 100 | + TomcatPluginResources.TOMCAT_PREF_HOME_KEY, | |
| 101 | 101 | PREF_PAGE_HOME_LABEL, homeGroup); |
| 102 | 102 | |
| 103 | 103 | //blank |
| @@ -108,11 +108,11 @@ | ||
| 108 | 108 | |
| 109 | 109 | Composite configGroup = new Composite(modeGroup, SWT.NULL); |
| 110 | 110 | this.configMode = new RadioGroupFieldEditor( |
| 111 | - TomcatLauncherPlugin.TOMCAT_PREF_CONFMODE_KEY, | |
| 111 | + TomcatPluginResources.TOMCAT_PREF_CONFMODE_KEY, | |
| 112 | 112 | PREF_PAGE_CHOOSECONFMODE_LABEL, 1, |
| 113 | 113 | new String[][] { |
| 114 | - {PREF_PAGE_SERVERXML_LABEL, TomcatLauncherPlugin.SERVERXML_MODE}, | |
| 115 | - {PREF_PAGE_CONTEXTFILES_LABEL, TomcatLauncherPlugin.CONTEXTFILES_MODE}, | |
| 114 | + {PREF_PAGE_SERVERXML_LABEL, TomcatPluginResources.SERVERXML_MODE}, | |
| 115 | + {PREF_PAGE_CONTEXTFILES_LABEL, TomcatPluginResources.CONTEXTFILES_MODE}, | |
| 116 | 116 | }, |
| 117 | 117 | configGroup, false); |
| 118 | 118 |
| @@ -121,12 +121,12 @@ | ||
| 121 | 121 | |
| 122 | 122 | this.configLocationGroup = new Composite(modeGroup, SWT.NULL); |
| 123 | 123 | this.configFile = new TomcatFileFieldEditor( |
| 124 | - TomcatLauncherPlugin.TOMCAT_PREF_CONFIGFILE_KEY, | |
| 124 | + TomcatPluginResources.TOMCAT_PREF_CONFIGFILE_KEY, | |
| 125 | 125 | PREF_PAGE_CONFIGFILE_LABEL, |
| 126 | 126 | this.configLocationGroup); |
| 127 | 127 | |
| 128 | 128 | this.contextsDir = new TomcatDirectoryFieldEditor( |
| 129 | - TomcatLauncherPlugin.TOMCAT_PREF_CONTEXTSDIR_KEY, | |
| 129 | + TomcatPluginResources.TOMCAT_PREF_CONTEXTSDIR_KEY, | |
| 130 | 130 | PREF_PAGE_CONTEXTSDIR_LABEL, |
| 131 | 131 | this.configLocationGroup); |
| 132 | 132 |
| @@ -145,7 +145,7 @@ | ||
| 145 | 145 | this.initField(this.home); |
| 146 | 146 | this.initField(this.configMode); |
| 147 | 147 | modeChanged(this.configLocationGroup, |
| 148 | - getPreferenceStore().getString(TomcatLauncherPlugin.TOMCAT_PREF_CONFMODE_KEY)); | |
| 148 | + getPreferenceStore().getString(TomcatPluginResources.TOMCAT_PREF_CONFMODE_KEY)); | |
| 149 | 149 | |
| 150 | 150 | this.configMode.setPropertyChangeListener(this); |
| 151 | 151 |
| @@ -204,7 +204,7 @@ | ||
| 204 | 204 | this.contextsDir.store(); |
| 205 | 205 | TomcatLauncherPlugin.initTomcatClasspathVariable(); |
| 206 | 206 | try { |
| 207 | - InstanceScope.INSTANCE.getNode(TomcatLauncherPlugin.PLUGIN_ID).flush(); | |
| 207 | + InstanceScope.INSTANCE.getNode(TomcatPluginResources.PLUGIN_ID).flush(); | |
| 208 | 208 | } catch (final BackingStoreException e) { |
| 209 | 209 | TomcatLauncherPlugin.log(e); |
| 210 | 210 | return false; |
| @@ -225,7 +225,7 @@ | ||
| 225 | 225 | |
| 226 | 226 | try { |
| 227 | 227 | for (final IProject project : root.getProjects()) { |
| 228 | - if (project.hasNature(TomcatLauncherPlugin.NATURE_ID)) { | |
| 228 | + if (project.hasNature(TomcatPluginResources.NATURE_ID)) { | |
| 229 | 229 | TomcatProject.create(project).addTomcatJarToProjectClasspath(); |
| 230 | 230 | } |
| 231 | 231 | } |
| @@ -259,7 +259,7 @@ | ||
| 259 | 259 | private void computeContextsDir() { |
| 260 | 260 | if (this.selectedVersion == null) { |
| 261 | 261 | this.selectedVersion = TomcatLauncherPlugin.getDefault().getPreferenceStore(). |
| 262 | - getString(TomcatLauncherPlugin.TOMCAT_PREF_VERSION_KEY); | |
| 262 | + getString(TomcatPluginResources.TOMCAT_PREF_VERSION_KEY); | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | String contextDirName = this.home.getStringValue() + File.separator + "conf" |
| @@ -295,7 +295,7 @@ | ||
| 295 | 295 | * @param value String |
| 296 | 296 | */ |
| 297 | 297 | private void modeChanged(final Composite composite, final String value) { |
| 298 | - if (value.equals(TomcatLauncherPlugin.SERVERXML_MODE)) { | |
| 298 | + if (value.equals(TomcatPluginResources.SERVERXML_MODE)) { | |
| 299 | 299 | this.contextsDir.setEnabled(false, composite); |
| 300 | 300 | this.configFile.setEnabled(true, composite); |
| 301 | 301 | } else { |
| @@ -0,0 +1,33 @@ | ||
| 1 | +package com.sysdeo.eclipse.tomcat; | |
| 2 | + | |
| 3 | +import org.eclipse.core.resources.IFolder; | |
| 4 | +import org.eclipse.core.runtime.CoreException; | |
| 5 | +import org.eclipse.jdt.core.IJavaProject; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * TomcatSetting Interface | |
| 9 | + */ | |
| 10 | +public interface ITomcatProject { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * | |
| 14 | + * @return WebClassPathEntries | |
| 15 | + */ | |
| 16 | + WebClassPathEntries getWebClassPathEntries(); | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * | |
| 20 | + * @return IFolder | |
| 21 | + */ | |
| 22 | + IFolder getRootDirFolder(); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * @throws CoreException CoreException | |
| 26 | + */ | |
| 27 | + void removeContext() throws CoreException; | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * @param prj IJavaProject | |
| 31 | + */ | |
| 32 | + void setJavaProject(final IJavaProject prj); | |
| 33 | +} |
| @@ -8,9 +8,11 @@ | ||
| 8 | 8 | import java.io.PrintWriter; |
| 9 | 9 | import java.io.StringWriter; |
| 10 | 10 | import java.util.ArrayList; |
| 11 | +import java.util.HashMap; | |
| 11 | 12 | import java.util.HashSet; |
| 12 | 13 | import java.util.Iterator; |
| 13 | 14 | import java.util.List; |
| 15 | +import java.util.Map; | |
| 14 | 16 | import java.util.MissingResourceException; |
| 15 | 17 | import java.util.ResourceBundle; |
| 16 | 18 | import java.util.Set; |
| @@ -32,6 +34,8 @@ | ||
| 32 | 34 | import org.eclipse.jdt.core.IJavaProject; |
| 33 | 35 | import org.eclipse.jdt.core.JavaCore; |
| 34 | 36 | import org.eclipse.jdt.core.JavaModelException; |
| 37 | +import org.eclipse.jdt.launching.IVMInstall; | |
| 38 | +import org.eclipse.jdt.launching.IVMInstallType; | |
| 35 | 39 | import org.eclipse.jdt.launching.JavaRuntime; |
| 36 | 40 | import org.eclipse.jface.dialogs.MessageDialog; |
| 37 | 41 | import org.eclipse.jface.preference.IPreferenceStore; |
| @@ -47,58 +51,12 @@ | ||
| 47 | 51 | */ |
| 48 | 52 | public class TomcatLauncherPlugin extends AbstractUIPlugin { |
| 49 | 53 | |
| 50 | - /** PLUGIN_ID */ | |
| 51 | - public static final String PLUGIN_ID = "com.sysdeo.eclipse.tomcat"; | |
| 52 | - /** NATURE_ID */ | |
| 53 | - public static final String NATURE_ID = PLUGIN_ID + ".tomcatnature"; | |
| 54 | - | |
| 55 | - /** TOMCAT_PREF_HOME_KEY */ | |
| 56 | - static final String TOMCAT_PREF_HOME_KEY = "tomcatDir"; | |
| 57 | - /** TOMCAT_PREF_BASE_KEY */ | |
| 58 | - static final String TOMCAT_PREF_BASE_KEY = "tomcatBase"; | |
| 59 | - /** TOMCAT_PREF_CONFIGFILE_KEY */ | |
| 60 | - static final String TOMCAT_PREF_CONFIGFILE_KEY = "tomcatConfigFile"; | |
| 61 | - /** TOMCAT_PREF_VERSION_KEY */ | |
| 62 | - static final String TOMCAT_PREF_VERSION_KEY = "tomcatVersion"; | |
| 63 | - /** TOMCAT_PREF_JRE_KEY */ | |
| 64 | - static final String TOMCAT_PREF_JRE_KEY = "tomcatJRE"; | |
| 65 | - /** TOMCAT_PREF_JVM_PARAMETERS_KEY */ | |
| 66 | - static final String TOMCAT_PREF_JVM_PARAMETERS_KEY = "jvmParameters"; | |
| 67 | - /** TOMCAT_PREF_JVM_CLASSPATH_KEY */ | |
| 68 | - static final String TOMCAT_PREF_JVM_CLASSPATH_KEY = "jvmClasspath"; | |
| 69 | - /** TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY */ | |
| 70 | - static final String TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY = "jvmBootClasspath"; | |
| 71 | 54 | /** TOMCAT_PREF_PROJECTSINCP_KEY */ |
| 72 | - static final String TOMCAT_PREF_PROJECTSINCP_KEY = "projectsInCp"; | |
| 55 | + private static final String TOMCAT_PREF_PROJECTSINCP_KEY = "projectsInCp"; | |
| 73 | 56 | /** TOMCAT_PREF_PROJECTSINSOURCEPATH_KEY */ |
| 74 | - static final String TOMCAT_PREF_PROJECTSINSOURCEPATH_KEY = "projectsInSourcePath"; | |
| 75 | - /** TOMCAT_PREF_COMPUTESOURCEPATH_KEY */ | |
| 76 | - static final String TOMCAT_PREF_COMPUTESOURCEPATH_KEY = "computeSourcePath"; | |
| 77 | - /** TOMCAT_PREF_DEBUGMODE_KEY */ | |
| 78 | - static final String TOMCAT_PREF_DEBUGMODE_KEY = "tomcatDebugMode"; | |
| 57 | + private static final String TOMCAT_PREF_PROJECTSINSOURCEPATH_KEY = "projectsInSourcePath"; | |
| 79 | 58 | /** TOMCAT_PREF_TARGETPERSPECTIVE */ |
| 80 | - static final String TOMCAT_PREF_TARGETPERSPECTIVE = "targetPerspective"; | |
| 81 | - /** TOMCAT_PREF_SECURITYMANAGER */ | |
| 82 | - static final String TOMCAT_PREF_SECURITYMANAGER = "enabledSecurityManager"; | |
| 83 | - /** TOMCAT_PREF_MANAGER_URL */ | |
| 84 | - static final String TOMCAT_PREF_MANAGER_URL = "managerUrl"; | |
| 85 | - /** TOMCAT_PREF_MANAGER_USER */ | |
| 86 | - static final String TOMCAT_PREF_MANAGER_USER = "managerUser"; | |
| 87 | - /** TOMCAT_PREF_MANAGER_PASSWORD */ | |
| 88 | - static final String TOMCAT_PREF_MANAGER_PASSWORD = "managerPassword"; | |
| 89 | - /** TOMCAT_VERSION7 */ | |
| 90 | - static final String TOMCAT_VERSION7 = "tomcatV7"; | |
| 91 | - /** TOMCAT_VERSION8 */ | |
| 92 | - static final String TOMCAT_VERSION8 = "tomcatV8"; | |
| 93 | - /** TOMCAT_PREF_CONFMODE_KEY */ | |
| 94 | - static final String TOMCAT_PREF_CONFMODE_KEY = "configMode"; | |
| 95 | - /** SERVERXML_MODE */ | |
| 96 | - static final String SERVERXML_MODE = "serverFile"; | |
| 97 | - /** CONTEXTFILES_MODE */ | |
| 98 | - static final String CONTEXTFILES_MODE = "contextFiles"; | |
| 99 | - /** TOMCAT_PREF_CONTEXTSDIR_KEY */ | |
| 100 | - static final String TOMCAT_PREF_CONTEXTSDIR_KEY = "contextsDir"; | |
| 101 | - | |
| 59 | + private static final String TOMCAT_PREF_TARGETPERSPECTIVE = "targetPerspective"; | |
| 102 | 60 | /** TOMCAT_HOME_CLASSPATH_VARIABLE */ |
| 103 | 61 | private static final String TOMCAT_HOME_CLASSPATH_VARIABLE = "TOMCAT_HOME"; |
| 104 | 62 | /** The shared instance. */ |
| @@ -133,7 +91,7 @@ | ||
| 133 | 91 | |
| 134 | 92 | try { |
| 135 | 93 | for (final IProject project : root.getProjects()) { |
| 136 | - if (project.hasNature(NATURE_ID)) { | |
| 94 | + if (project.hasNature(TomcatPluginResources.NATURE_ID)) { | |
| 137 | 95 | IJavaProject javaProject = JavaCore.create(project); |
| 138 | 96 | |
| 139 | 97 | List<IClasspathEntry> cp = new ArrayList<>(); |
| @@ -213,7 +171,7 @@ | ||
| 213 | 171 | */ |
| 214 | 172 | public static String getTomcatDir() { |
| 215 | 173 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 216 | - return pref.getString(TOMCAT_PREF_HOME_KEY); | |
| 174 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_HOME_KEY); | |
| 217 | 175 | } |
| 218 | 176 | |
| 219 | 177 | /** |
| @@ -222,7 +180,7 @@ | ||
| 222 | 180 | */ |
| 223 | 181 | public static String getTomcatBase() { |
| 224 | 182 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 225 | - return pref.getString(TOMCAT_PREF_BASE_KEY); | |
| 183 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_BASE_KEY); | |
| 226 | 184 | } |
| 227 | 185 | |
| 228 | 186 | /** |
| @@ -231,7 +189,7 @@ | ||
| 231 | 189 | */ |
| 232 | 190 | public static String getConfigFile() { |
| 233 | 191 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 234 | - return pref.getString(TOMCAT_PREF_CONFIGFILE_KEY); | |
| 192 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_CONFIGFILE_KEY); | |
| 235 | 193 | } |
| 236 | 194 | |
| 237 | 195 | /** |
| @@ -240,7 +198,7 @@ | ||
| 240 | 198 | */ |
| 241 | 199 | public static String getConfigMode() { |
| 242 | 200 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 243 | - return pref.getString(TOMCAT_PREF_CONFMODE_KEY); | |
| 201 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_CONFMODE_KEY); | |
| 244 | 202 | } |
| 245 | 203 | |
| 246 | 204 | /** |
| @@ -249,7 +207,7 @@ | ||
| 249 | 207 | */ |
| 250 | 208 | public static String getContextsDir() { |
| 251 | 209 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 252 | - return pref.getString(TOMCAT_PREF_CONTEXTSDIR_KEY); | |
| 210 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_CONTEXTSDIR_KEY); | |
| 253 | 211 | } |
| 254 | 212 | |
| 255 | 213 | /** |
| @@ -258,7 +216,7 @@ | ||
| 258 | 216 | */ |
| 259 | 217 | public static String getTomcatVersion() { |
| 260 | 218 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 261 | - String result = pref.getString(TOMCAT_PREF_VERSION_KEY); | |
| 219 | + String result = pref.getString(TomcatPluginResources.TOMCAT_PREF_VERSION_KEY); | |
| 262 | 220 | return result; |
| 263 | 221 | } |
| 264 | 222 |
| @@ -268,7 +226,7 @@ | ||
| 268 | 226 | */ |
| 269 | 227 | public static String getTomcatJRE() { |
| 270 | 228 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 271 | - String result = pref.getString(TOMCAT_PREF_JRE_KEY); | |
| 229 | + String result = pref.getString(TomcatPluginResources.TOMCAT_PREF_JRE_KEY); | |
| 272 | 230 | if (result.isEmpty()) { |
| 273 | 231 | result = JavaRuntime.getDefaultVMInstall().getId(); |
| 274 | 232 | } |
| @@ -281,7 +239,7 @@ | ||
| 281 | 239 | */ |
| 282 | 240 | public static boolean isDebugMode() { |
| 283 | 241 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 284 | - return !pref.getBoolean(TOMCAT_PREF_DEBUGMODE_KEY); | |
| 242 | + return !pref.getBoolean(TomcatPluginResources.TOMCAT_PREF_DEBUGMODE_KEY); | |
| 285 | 243 | } |
| 286 | 244 | |
| 287 | 245 | /** |
| @@ -299,7 +257,7 @@ | ||
| 299 | 257 | */ |
| 300 | 258 | public static boolean isSecurityManagerEnabled() { |
| 301 | 259 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 302 | - return pref.getBoolean(TOMCAT_PREF_SECURITYMANAGER); | |
| 260 | + return pref.getBoolean(TomcatPluginResources.TOMCAT_PREF_SECURITYMANAGER); | |
| 303 | 261 | } |
| 304 | 262 | |
| 305 | 263 | /** |
| @@ -308,7 +266,7 @@ | ||
| 308 | 266 | */ |
| 309 | 267 | public static String getJvmParamaters() { |
| 310 | 268 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 311 | - return pref.getString(TOMCAT_PREF_JVM_PARAMETERS_KEY); | |
| 269 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_JVM_PARAMETERS_KEY); | |
| 312 | 270 | } |
| 313 | 271 | |
| 314 | 272 | /** |
| @@ -317,7 +275,7 @@ | ||
| 317 | 275 | */ |
| 318 | 276 | public static String getJvmClasspath() { |
| 319 | 277 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 320 | - return pref.getString(TOMCAT_PREF_JVM_CLASSPATH_KEY); | |
| 278 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_JVM_CLASSPATH_KEY); | |
| 321 | 279 | } |
| 322 | 280 | |
| 323 | 281 | /** |
| @@ -326,7 +284,7 @@ | ||
| 326 | 284 | */ |
| 327 | 285 | public static String getJvmBootClasspath() { |
| 328 | 286 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 329 | - return pref.getString(TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY); | |
| 287 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY); | |
| 330 | 288 | } |
| 331 | 289 | |
| 332 | 290 | /** |
| @@ -334,7 +292,7 @@ | ||
| 334 | 292 | * @return TomcatBootstrap |
| 335 | 293 | */ |
| 336 | 294 | public static TomcatBootstrap getTomcatBootstrap() { |
| 337 | - TomcatBootstrap tomcatBootsrap = null; | |
| 295 | + TomcatBootstrap tomcatBootstrap = null; | |
| 338 | 296 | |
| 339 | 297 | // if (getTomcatVersion().equals(TOMCAT_VERSION3)) { |
| 340 | 298 | // tomcatBootsrap = new Tomcat3Bootstrap(); |
| @@ -352,16 +310,43 @@ | ||
| 352 | 310 | // tomcatBootsrap = new Tomcat6Bootstrap(); |
| 353 | 311 | // } |
| 354 | 312 | |
| 313 | + String[] classpath = addPreferenceJvmToClasspath(new String[0]); | |
| 314 | + classpath = addPreferenceProjectListToClasspath(classpath); | |
| 315 | + String[] vArgs = addPreferenceParameters(new String[0]); | |
| 316 | + String[] bootClasspath = addPreferenceJvmToBootClasspath(new String[0]); | |
| 355 | 317 | |
| 356 | - if (getTomcatVersion().equals(TOMCAT_VERSION7)) { | |
| 357 | - tomcatBootsrap = new Tomcat7Bootstrap(getConfigMode().equals(SERVERXML_MODE), getConfigFile(), | |
| 318 | + if (getTomcatVersion().equals(TomcatPluginResources.TOMCAT_VERSION7)) { | |
| 319 | + | |
| 320 | + tomcatBootstrap = new Tomcat7Bootstrap( | |
| 321 | + getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE), getConfigFile(), | |
| 358 | 322 | isSecurityManagerEnabled(), getTomcatIPath()); |
| 359 | - } else if (getTomcatVersion().equals(TOMCAT_VERSION8)) { | |
| 360 | - tomcatBootsrap = new Tomcat8Bootstrap(getConfigMode().equals(SERVERXML_MODE), getConfigFile(), | |
| 323 | + tomcatBootstrap.setDebugMode(isDebugMode()); | |
| 324 | + tomcatBootstrap.setTomcatDir(getTomcatDir()); | |
| 325 | + tomcatBootstrap.setTomcatBase(getTomcatBase()); | |
| 326 | + tomcatBootstrap.setProjects(getProjectMap()); | |
| 327 | + tomcatBootstrap.setClasspath(classpath); | |
| 328 | + tomcatBootstrap.setVmArgs(vArgs); | |
| 329 | + tomcatBootstrap.setBootClasspath(bootClasspath); | |
| 330 | + tomcatBootstrap.setVmInstalled(getVMInstall()); | |
| 331 | + tomcatBootstrap.setElements(PLUGIN.getProjectsInSourcePath()); | |
| 332 | + | |
| 333 | + } else if (getTomcatVersion().equals(TomcatPluginResources.TOMCAT_VERSION8)) { | |
| 334 | + tomcatBootstrap = new Tomcat8Bootstrap( | |
| 335 | + getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE), getConfigFile(), | |
| 361 | 336 | isSecurityManagerEnabled(), getTomcatIPath()); |
| 337 | + tomcatBootstrap.setDebugMode(isDebugMode()); | |
| 338 | + tomcatBootstrap.setTomcatDir(getTomcatDir()); | |
| 339 | + tomcatBootstrap.setTomcatBase(getTomcatBase()); | |
| 340 | + tomcatBootstrap.setProjects(getProjectMap()); | |
| 341 | + tomcatBootstrap.setClasspath(classpath); | |
| 342 | + tomcatBootstrap.setVmArgs(vArgs); | |
| 343 | + tomcatBootstrap.setBootClasspath(bootClasspath); | |
| 344 | + tomcatBootstrap.setVmInstalled(getVMInstall()); | |
| 345 | + tomcatBootstrap.setElements(PLUGIN.getProjectsInSourcePath()); | |
| 346 | + | |
| 362 | 347 | } |
| 363 | 348 | |
| 364 | - return tomcatBootsrap; | |
| 349 | + return tomcatBootstrap; | |
| 365 | 350 | } |
| 366 | 351 | |
| 367 | 352 | /** |
| @@ -370,7 +355,7 @@ | ||
| 370 | 355 | */ |
| 371 | 356 | public static String getManagerAppUrl() { |
| 372 | 357 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 373 | - return pref.getString(TOMCAT_PREF_MANAGER_URL); | |
| 358 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_MANAGER_URL); | |
| 374 | 359 | } |
| 375 | 360 | |
| 376 | 361 | /** |
| @@ -379,7 +364,7 @@ | ||
| 379 | 364 | */ |
| 380 | 365 | public static String getManagerAppUser() { |
| 381 | 366 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 382 | - return pref.getString(TOMCAT_PREF_MANAGER_USER); | |
| 367 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_MANAGER_USER); | |
| 383 | 368 | } |
| 384 | 369 | |
| 385 | 370 | /** |
| @@ -388,7 +373,7 @@ | ||
| 388 | 373 | */ |
| 389 | 374 | public static String getManagerAppPassword() { |
| 390 | 375 | IPreferenceStore pref = PLUGIN.getPreferenceStore(); |
| 391 | - return pref.getString(TOMCAT_PREF_MANAGER_PASSWORD); | |
| 376 | + return pref.getString(TomcatPluginResources.TOMCAT_PREF_MANAGER_PASSWORD); | |
| 392 | 377 | } |
| 393 | 378 | |
| 394 | 379 | /** |
| @@ -484,7 +469,7 @@ | ||
| 484 | 469 | */ |
| 485 | 470 | public List<ProjectListElement> getProjectsInSourcePath() { |
| 486 | 471 | IPreferenceStore pref = getPreferenceStore(); |
| 487 | - boolean automaticallyComputed = pref.getBoolean(TOMCAT_PREF_COMPUTESOURCEPATH_KEY); | |
| 472 | + boolean automaticallyComputed = pref.getBoolean(TomcatPluginResources.TOMCAT_PREF_COMPUTESOURCEPATH_KEY); | |
| 488 | 473 | if (automaticallyComputed) { |
| 489 | 474 | return computeProjectsInSourcePath(); |
| 490 | 475 | } |
| @@ -499,7 +484,7 @@ | ||
| 499 | 484 | IPreferenceStore pref = getPreferenceStore(); |
| 500 | 485 | if (!(pref.contains(TOMCAT_PREF_PROJECTSINSOURCEPATH_KEY))) { |
| 501 | 486 | // Compute source path for a new workspace |
| 502 | - pref.setValue(TOMCAT_PREF_COMPUTESOURCEPATH_KEY, true); | |
| 487 | + pref.setValue(TomcatPluginResources.TOMCAT_PREF_COMPUTESOURCEPATH_KEY, true); | |
| 503 | 488 | return computeProjectsInSourcePath(); |
| 504 | 489 | } |
| 505 | 490 | return readProjectsFromPreferenceStore(TOMCAT_PREF_PROJECTSINSOURCEPATH_KEY); |
| @@ -601,4 +586,113 @@ | ||
| 601 | 586 | super.start(context); |
| 602 | 587 | fixTomcatHomeBug(); |
| 603 | 588 | } |
| 589 | + | |
| 590 | + /** | |
| 591 | + * | |
| 592 | + * @param previouscp String[] | |
| 593 | + * @return String[] | |
| 594 | + */ | |
| 595 | + private static String[] addPreferenceProjectListToClasspath(final String[] previouscp) { | |
| 596 | + List<ProjectListElement> projectsList = getProjectsInCP(); | |
| 597 | + String[] result = previouscp; | |
| 598 | + Iterator<ProjectListElement> it = projectsList.iterator(); | |
| 599 | + while (it.hasNext()) { | |
| 600 | + try { | |
| 601 | + ProjectListElement ple = it.next(); | |
| 602 | + IJavaProject jproject = JavaCore.create(ple.getProject()); | |
| 603 | + result = addProjectToClasspath(result, jproject); | |
| 604 | + } catch (final CoreException e) { | |
| 605 | + // nothing will be added to classpath | |
| 606 | + log(e); | |
| 607 | + } | |
| 608 | + } | |
| 609 | + return result; | |
| 610 | + } | |
| 611 | + | |
| 612 | + /** | |
| 613 | + * | |
| 614 | + * @param previouscp String[] | |
| 615 | + * @param project IJavaProject | |
| 616 | + * @return String[] | |
| 617 | + * @throws CoreException CoreException | |
| 618 | + */ | |
| 619 | + private static String[] addProjectToClasspath(final String[] previouscp, | |
| 620 | + final IJavaProject project) throws CoreException { | |
| 621 | + if ((project != null) && (project.exists() && project.isOpen())) { | |
| 622 | + String[] projectcp = JavaRuntime.computeDefaultRuntimeClassPath(project); | |
| 623 | + return StringUtil.concatUniq(projectcp, previouscp); | |
| 624 | + } | |
| 625 | + return previouscp; | |
| 626 | + } | |
| 627 | + | |
| 628 | + /** | |
| 629 | + * | |
| 630 | + * @param previous String[] | |
| 631 | + * @return String[] | |
| 632 | + */ | |
| 633 | + private static String[] addPreferenceParameters(final String[] previous) { | |
| 634 | + String[] prefParams = StringUtil.cutString(getJvmParamaters(), | |
| 635 | + TomcatPluginResources.PREF_PAGE_LIST_SEPARATOR); | |
| 636 | + return StringUtil.concat(previous, prefParams); | |
| 637 | + } | |
| 638 | + | |
| 639 | + /** | |
| 640 | + * | |
| 641 | + * @param previous String[] | |
| 642 | + * @return String[] | |
| 643 | + */ | |
| 644 | + private static String[] addPreferenceJvmToClasspath(final String[] previous) { | |
| 645 | + String[] prefClasspath = StringUtil.cutString(getJvmClasspath(), | |
| 646 | + TomcatPluginResources.PREF_PAGE_LIST_SEPARATOR); | |
| 647 | + return StringUtil.concatUniq(previous, prefClasspath); | |
| 648 | + } | |
| 649 | + | |
| 650 | + /** | |
| 651 | + * | |
| 652 | + * @param previous String[] | |
| 653 | + * @return String[] | |
| 654 | + */ | |
| 655 | + private static String[] addPreferenceJvmToBootClasspath(final String[] previous) { | |
| 656 | + String[] prefBootClasspath = StringUtil.cutString(getJvmBootClasspath(), | |
| 657 | + TomcatPluginResources.PREF_PAGE_LIST_SEPARATOR); | |
| 658 | + return StringUtil.concatUniq(previous, prefBootClasspath); | |
| 659 | + } | |
| 660 | + | |
| 661 | + /** | |
| 662 | + * | |
| 663 | + * @return projectMap | |
| 664 | + */ | |
| 665 | + private static Map<IProject, IProjectNature> getProjectMap() { | |
| 666 | + Map<IProject, IProjectNature> ret = new HashMap<>(); | |
| 667 | + | |
| 668 | + IProject[] projects = getWorkspace().getRoot().getProjects(); | |
| 669 | + for (final IProject project: projects) { | |
| 670 | + if (project.isOpen()) { | |
| 671 | + try { | |
| 672 | + IProjectNature nature = project.getNature(TomcatPluginResources.NATURE_ID); | |
| 673 | + if (nature != null && IJavaProject.class.isInstance(project.getNature(JavaCore.NATURE_ID))) { | |
| 674 | + ret.put(project, nature); | |
| 675 | + } | |
| 676 | + } catch (final CoreException e) { | |
| 677 | + log(e); | |
| 678 | + } | |
| 679 | + } | |
| 680 | + } | |
| 681 | + return ret; | |
| 682 | + } | |
| 683 | + | |
| 684 | + /** | |
| 685 | + * | |
| 686 | + * @return VMInstall | |
| 687 | + */ | |
| 688 | + private static IVMInstall getVMInstall() { | |
| 689 | + for (IVMInstallType type : JavaRuntime.getVMInstallTypes()) { | |
| 690 | + for (final IVMInstall vms : type.getVMInstalls()) { | |
| 691 | + if (vms.getId().equals(getTomcatJRE())) { | |
| 692 | + return vms; | |
| 693 | + } | |
| 694 | + } | |
| 695 | + } | |
| 696 | + return JavaRuntime.getDefaultVMInstall(); | |
| 697 | + } | |
| 604 | 698 | } |
| @@ -12,6 +12,8 @@ | ||
| 12 | 12 | import org.eclipse.core.resources.IResourceChangeEvent; |
| 13 | 13 | import org.eclipse.core.resources.IResourceChangeListener; |
| 14 | 14 | import org.eclipse.core.runtime.CoreException; |
| 15 | +import org.eclipse.jdt.core.IJavaProject; | |
| 16 | +import org.eclipse.jdt.core.JavaCore; | |
| 15 | 17 | import org.eclipse.jface.dialogs.IDialogConstants; |
| 16 | 18 | import org.eclipse.jface.dialogs.MessageDialog; |
| 17 | 19 | import org.eclipse.jface.window.Window; |
| @@ -31,7 +33,7 @@ | ||
| 31 | 33 | @Override |
| 32 | 34 | public void resourceChanged(final IResourceChangeEvent event) { |
| 33 | 35 | if (event.getResource() instanceof IProject) { |
| 34 | - final TomcatProject project = TomcatProject.create((IProject)event.getResource()); | |
| 36 | + final ITomcatProject project = create((IProject)event.getResource()); | |
| 35 | 37 | if (project != null) { |
| 36 | 38 | Display.getDefault().syncExec(new Runnable() { |
| 37 | 39 | @Override |
| @@ -47,7 +49,7 @@ | ||
| 47 | 49 | try { |
| 48 | 50 | project.removeContext(); |
| 49 | 51 | } catch (final CoreException ex) { |
| 50 | - ex.printStackTrace(); | |
| 52 | + ex.printStackTrace(System.err); | |
| 51 | 53 | } |
| 52 | 54 | } |
| 53 | 55 | } |
| @@ -56,4 +58,28 @@ | ||
| 56 | 58 | } |
| 57 | 59 | } |
| 58 | 60 | } |
| 61 | + | |
| 62 | + /** | |
| 63 | + * Return a TomcatProject if this Project has the tomcat nature | |
| 64 | + * Return null if Project has not tomcat nature | |
| 65 | + * @param project IProject | |
| 66 | + * @return TomcatProject | |
| 67 | + */ | |
| 68 | + private static ITomcatProject create(final IProject project) { | |
| 69 | + | |
| 70 | + IJavaProject javaProject = JavaCore.create(project); | |
| 71 | + if (javaProject != null) { | |
| 72 | + try { | |
| 73 | + ITomcatProject result = (ITomcatProject)javaProject.getProject().getNature( | |
| 74 | + TomcatPluginResources.NATURE_ID); | |
| 75 | + if (result != null) { | |
| 76 | + result.setJavaProject(javaProject); | |
| 77 | + } | |
| 78 | + return result; | |
| 79 | + } catch (final CoreException ex) { | |
| 80 | + ex.printStackTrace(System.err); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + return null; | |
| 84 | + } | |
| 59 | 85 | } |
| @@ -83,10 +83,10 @@ | ||
| 83 | 83 | |
| 84 | 84 | String[][] namesAndValues = collectAllJres(); |
| 85 | 85 | this.jvmChoice = new ComboFieldEditor( |
| 86 | - TomcatLauncherPlugin.TOMCAT_PREF_JRE_KEY, PREF_PAGE_JRE_LABEL, namesAndValues, composite); | |
| 86 | + TomcatPluginResources.TOMCAT_PREF_JRE_KEY, PREF_PAGE_JRE_LABEL, namesAndValues, composite); | |
| 87 | 87 | |
| 88 | 88 | this.debugModeEditor = new BooleanFieldEditor( |
| 89 | - TomcatLauncherPlugin.TOMCAT_PREF_DEBUGMODE_KEY, PREF_PAGE_DEBUGMODE_LABEL, composite); | |
| 89 | + TomcatPluginResources.TOMCAT_PREF_DEBUGMODE_KEY, PREF_PAGE_DEBUGMODE_LABEL, composite); | |
| 90 | 90 | initField(this.debugModeEditor); |
| 91 | 91 | |
| 92 | 92 | new Label(composite, SWT.NULL); |
| @@ -106,11 +106,11 @@ | ||
| 106 | 106 | this.btLog.addSelectionListener(this); |
| 107 | 107 | |
| 108 | 108 | this.jvmParamaters = new ListFieldEditor( |
| 109 | - TomcatLauncherPlugin.TOMCAT_PREF_JVM_PARAMETERS_KEY, PREF_PAGE_PARAMETERS_LABEL, composite); | |
| 109 | + TomcatPluginResources.TOMCAT_PREF_JVM_PARAMETERS_KEY, PREF_PAGE_PARAMETERS_LABEL, composite); | |
| 110 | 110 | this.jvmClasspath = new ClasspathFieldEditor( |
| 111 | - TomcatLauncherPlugin.TOMCAT_PREF_JVM_CLASSPATH_KEY, PREF_PAGE_CLASSPATH_LABEL, composite); | |
| 111 | + TomcatPluginResources.TOMCAT_PREF_JVM_CLASSPATH_KEY, PREF_PAGE_CLASSPATH_LABEL, composite); | |
| 112 | 112 | this.jvmBootClasspath = new ClasspathFieldEditor( |
| 113 | - TomcatLauncherPlugin.TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY, PREF_PAGE_BOOTCLASSPATH_LABEL, composite); | |
| 113 | + TomcatPluginResources.TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY, PREF_PAGE_BOOTCLASSPATH_LABEL, composite); | |
| 114 | 114 | |
| 115 | 115 | initField(this.jvmChoice); |
| 116 | 116 | initField(this.jvmParamaters); |
| @@ -188,7 +188,7 @@ | ||
| 188 | 188 | this.debugModeEditor.store(); |
| 189 | 189 | |
| 190 | 190 | try { |
| 191 | - InstanceScope.INSTANCE.getNode(TomcatLauncherPlugin.PLUGIN_ID).flush(); | |
| 191 | + InstanceScope.INSTANCE.getNode(TomcatPluginResources.PLUGIN_ID).flush(); | |
| 192 | 192 | } catch (final BackingStoreException e) { |
| 193 | 193 | TomcatLauncherPlugin.log(e); |
| 194 | 194 | return false; |
| @@ -11,6 +11,52 @@ | ||
| 11 | 11 | */ |
| 12 | 12 | public final class TomcatPluginResources { |
| 13 | 13 | |
| 14 | + /** PLUGIN_ID */ | |
| 15 | + public static final String PLUGIN_ID = "com.sysdeo.eclipse.tomcat"; | |
| 16 | + /** NATURE_ID */ | |
| 17 | + public static final String NATURE_ID = PLUGIN_ID + ".tomcatnature"; | |
| 18 | + | |
| 19 | + /** TOMCAT_PREF_HOME_KEY */ | |
| 20 | + public static final String TOMCAT_PREF_HOME_KEY = "tomcatDir"; | |
| 21 | + /** TOMCAT_PREF_BASE_KEY */ | |
| 22 | + public static final String TOMCAT_PREF_BASE_KEY = "tomcatBase"; | |
| 23 | + /** TOMCAT_PREF_CONFIGFILE_KEY */ | |
| 24 | + public static final String TOMCAT_PREF_CONFIGFILE_KEY = "tomcatConfigFile"; | |
| 25 | + /** TOMCAT_PREF_VERSION_KEY */ | |
| 26 | + public static final String TOMCAT_PREF_VERSION_KEY = "tomcatVersion"; | |
| 27 | + /** TOMCAT_PREF_JRE_KEY */ | |
| 28 | + public static final String TOMCAT_PREF_JRE_KEY = "tomcatJRE"; | |
| 29 | + /** TOMCAT_PREF_JVM_PARAMETERS_KEY */ | |
| 30 | + public static final String TOMCAT_PREF_JVM_PARAMETERS_KEY = "jvmParameters"; | |
| 31 | + /** TOMCAT_PREF_JVM_CLASSPATH_KEY */ | |
| 32 | + public static final String TOMCAT_PREF_JVM_CLASSPATH_KEY = "jvmClasspath"; | |
| 33 | + /** TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY */ | |
| 34 | + public static final String TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY = "jvmBootClasspath"; | |
| 35 | + /** TOMCAT_PREF_COMPUTESOURCEPATH_KEY */ | |
| 36 | + public static final String TOMCAT_PREF_COMPUTESOURCEPATH_KEY = "computeSourcePath"; | |
| 37 | + /** TOMCAT_PREF_DEBUGMODE_KEY */ | |
| 38 | + public static final String TOMCAT_PREF_DEBUGMODE_KEY = "tomcatDebugMode"; | |
| 39 | + /** TOMCAT_PREF_SECURITYMANAGER */ | |
| 40 | + public static final String TOMCAT_PREF_SECURITYMANAGER = "enabledSecurityManager"; | |
| 41 | + /** TOMCAT_PREF_MANAGER_URL */ | |
| 42 | + public static final String TOMCAT_PREF_MANAGER_URL = "managerUrl"; | |
| 43 | + /** TOMCAT_PREF_MANAGER_USER */ | |
| 44 | + public static final String TOMCAT_PREF_MANAGER_USER = "managerUser"; | |
| 45 | + /** TOMCAT_PREF_MANAGER_PASSWORD */ | |
| 46 | + public static final String TOMCAT_PREF_MANAGER_PASSWORD = "managerPassword"; | |
| 47 | + /** TOMCAT_VERSION7 */ | |
| 48 | + public static final String TOMCAT_VERSION7 = "tomcatV7"; | |
| 49 | + /** TOMCAT_VERSION8 */ | |
| 50 | + public static final String TOMCAT_VERSION8 = "tomcatV8"; | |
| 51 | + /** TOMCAT_PREF_CONFMODE_KEY */ | |
| 52 | + public static final String TOMCAT_PREF_CONFMODE_KEY = "configMode"; | |
| 53 | + /** SERVERXML_MODE */ | |
| 54 | + public static final String SERVERXML_MODE = "serverFile"; | |
| 55 | + /** CONTEXTFILES_MODE */ | |
| 56 | + public static final String CONTEXTFILES_MODE = "contextFiles"; | |
| 57 | + /** TOMCAT_PREF_CONTEXTSDIR_KEY */ | |
| 58 | + public static final String TOMCAT_PREF_CONTEXTSDIR_KEY = "contextsDir"; | |
| 59 | + | |
| 14 | 60 | /** WIZARD_PROJECT_TITLE */ |
| 15 | 61 | public static final String WIZARD_PROJECT_TITLE = |
| 16 | 62 | TomcatLauncherPlugin.getResourceString("wizard.project.title"); |
| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | public String[] getClasspath() { |
| 28 | 28 | String[] classpath = new String[1]; |
| 29 | 29 | |
| 30 | - String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 31 | - + File.separator + "lib" + File.separator + "tools.jar"; | |
| 32 | - classpath[0] = toolsJarLocation; | |
| 30 | + // String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 31 | + // + File.separator + "lib" + File.separator + "tools.jar"; | |
| 32 | + // classpath[0] = toolsJarLocation; | |
| 33 | 33 | |
| 34 | 34 | File libDir = new File(getTomcatDir() + File.separator + "lib"); |
| 35 | 35 | classpath = addJarsOfDirectory(classpath, libDir); |
| @@ -25,11 +25,11 @@ | ||
| 25 | 25 | ArrayList<String> classpath = new ArrayList<>(); |
| 26 | 26 | classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar"); |
| 27 | 27 | // Add tools.jar JDK file to classpath |
| 28 | - String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 29 | - + File.separator + "lib" + File.separator + "tools.jar"; | |
| 30 | - if (new File(toolsJarLocation).exists()) { | |
| 31 | - classpath.add(toolsJarLocation); | |
| 32 | - } | |
| 28 | + // String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 29 | + // + File.separator + "lib" + File.separator + "tools.jar"; | |
| 30 | + // if (new File(toolsJarLocation).exists()) { | |
| 31 | + // classpath.add(toolsJarLocation); | |
| 32 | + // } | |
| 33 | 33 | return classpath.toArray(new String[classpath.size()]); |
| 34 | 34 | } |
| 35 | 35 |
| @@ -63,7 +63,7 @@ | ||
| 63 | 63 | @Override |
| 64 | 64 | public String[] getPrgArgs(final String command) { |
| 65 | 65 | String[] prgArgs; |
| 66 | - if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) { | |
| 66 | + if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) { | |
| 67 | 67 | prgArgs = new String[3]; |
| 68 | 68 | prgArgs[0] = command; |
| 69 | 69 | prgArgs[1] = "-config"; |
| @@ -25,11 +25,11 @@ | ||
| 25 | 25 | ArrayList<String> classpath = new ArrayList<>(); |
| 26 | 26 | classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar"); |
| 27 | 27 | // Add tools.jar JDK file to classpath |
| 28 | - String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 29 | - + File.separator + "lib" + File.separator + "tools.jar"; | |
| 30 | - if (new File(toolsJarLocation).exists()) { | |
| 31 | - classpath.add(toolsJarLocation); | |
| 32 | - } | |
| 28 | + // String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 29 | + // + File.separator + "lib" + File.separator + "tools.jar"; | |
| 30 | + // if (new File(toolsJarLocation).exists()) { | |
| 31 | + // classpath.add(toolsJarLocation); | |
| 32 | + // } | |
| 33 | 33 | return classpath.toArray(new String[classpath.size()]); |
| 34 | 34 | } |
| 35 | 35 |
| @@ -63,7 +63,7 @@ | ||
| 63 | 63 | @Override |
| 64 | 64 | public String[] getPrgArgs(final String command) { |
| 65 | 65 | String[] prgArgs; |
| 66 | - if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) { | |
| 66 | + if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) { | |
| 67 | 67 | prgArgs = new String[3]; |
| 68 | 68 | prgArgs[0] = "-config"; |
| 69 | 69 | prgArgs[1] = "\"" + TomcatLauncherPlugin.getConfigFile() + "\""; |
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | ArrayList<String> classpath = new ArrayList<>(); |
| 52 | 52 | classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar"); |
| 53 | 53 | // Add tools.jar JDK file to classpath |
| 54 | - String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 54 | + String toolsJarLocation = super.getVmInstalled().getInstallLocation() | |
| 55 | 55 | + File.separator + "lib" + File.separator + "tools.jar"; |
| 56 | 56 | if (new File(toolsJarLocation).exists()) { |
| 57 | 57 | classpath.add(toolsJarLocation); |
| @@ -184,8 +184,8 @@ | ||
| 184 | 184 | * @return Collection<IClasspathEntry> |
| 185 | 185 | */ |
| 186 | 186 | @Override |
| 187 | - public Collection<IClasspathEntry> getTomcatJars() { | |
| 188 | - ArrayList<IClasspathEntry> jars = new ArrayList<>(super.getTomcatJars()); | |
| 187 | + public Collection<IClasspathEntry> getTomcatJars(final IPath homePath) { | |
| 188 | + ArrayList<IClasspathEntry> jars = new ArrayList<>(super.getTomcatJars(homePath)); | |
| 189 | 189 | jars.add(JavaCore.newVariableEntry(this.tomcatHomePath.append(getElJarPath()), null, null)); |
| 190 | 190 | jars.add(JavaCore.newVariableEntry(this.tomcatHomePath.append(getAnnotationsJarPath()), null, null)); |
| 191 | 191 | return jars; |
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar"); |
| 32 | 32 | classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "tomcat-juli.jar"); |
| 33 | 33 | // Add tools.jar JDK file to classpath |
| 34 | - String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation() | |
| 34 | + String toolsJarLocation = super.getVmInstalled().getInstallLocation() | |
| 35 | 35 | + File.separator + "lib" + File.separator + "tools.jar"; |
| 36 | 36 | if (new File(toolsJarLocation).exists()) { |
| 37 | 37 | classpath.add(toolsJarLocation); |
| @@ -5,11 +5,11 @@ | ||
| 5 | 5 | |
| 6 | 6 | package com.sysdeo.eclipse.tomcat; |
| 7 | 7 | |
| 8 | +import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_ADDUSER; | |
| 8 | 9 | import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_BANNER; |
| 10 | +import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_PASSWORD; | |
| 9 | 11 | import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_URL; |
| 10 | 12 | import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_USER; |
| 11 | -import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_PASSWORD; | |
| 12 | -import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_ADDUSER; | |
| 13 | 13 | |
| 14 | 14 | import java.io.File; |
| 15 | 15 | import java.io.IOException; |
| @@ -68,7 +68,7 @@ | ||
| 68 | 68 | new Label(getFieldEditorParent(), SWT.NULL); |
| 69 | 69 | |
| 70 | 70 | this.urlEditor = new StringFieldEditor( |
| 71 | - TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_URL, | |
| 71 | + TomcatPluginResources.TOMCAT_PREF_MANAGER_URL, | |
| 72 | 72 | PREF_PAGE_MANAGER_URL, |
| 73 | 73 | getFieldEditorParent()); |
| 74 | 74 | addField(this.urlEditor); |
| @@ -77,13 +77,13 @@ | ||
| 77 | 77 | new Label(getFieldEditorParent(), SWT.NULL); |
| 78 | 78 | |
| 79 | 79 | this.userEditor = new StringFieldEditor( |
| 80 | - TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_USER, | |
| 80 | + TomcatPluginResources.TOMCAT_PREF_MANAGER_USER, | |
| 81 | 81 | PREF_PAGE_MANAGER_USER, |
| 82 | 82 | getFieldEditorParent()); |
| 83 | 83 | addField(this.userEditor); |
| 84 | 84 | |
| 85 | 85 | this.pwdEditor = new StringFieldEditor( |
| 86 | - TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_PASSWORD, | |
| 86 | + TomcatPluginResources.TOMCAT_PREF_MANAGER_PASSWORD, | |
| 87 | 87 | PREF_PAGE_MANAGER_PASSWORD, |
| 88 | 88 | getFieldEditorParent()); |
| 89 | 89 | addField(this.pwdEditor); |
| @@ -100,8 +100,8 @@ | ||
| 100 | 100 | */ |
| 101 | 101 | @Override |
| 102 | 102 | public void init(final IWorkbench workbench) { |
| 103 | - if (!(getPreferenceStore().contains(TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_URL))) { | |
| 104 | - getPreferenceStore().setValue(TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_URL, | |
| 103 | + if (!(getPreferenceStore().contains(TomcatPluginResources.TOMCAT_PREF_MANAGER_URL))) { | |
| 104 | + getPreferenceStore().setValue(TomcatPluginResources.TOMCAT_PREF_MANAGER_URL, | |
| 105 | 105 | DEFAULT_MANAGER_URL); |
| 106 | 106 | } |
| 107 | 107 | } |
| @@ -52,7 +52,7 @@ | ||
| 52 | 52 | composite.setLayout(new GridLayout()); |
| 53 | 53 | |
| 54 | 54 | this.automaticEditor = new BooleanFieldEditor( |
| 55 | - TomcatLauncherPlugin.TOMCAT_PREF_COMPUTESOURCEPATH_KEY, | |
| 55 | + TomcatPluginResources.TOMCAT_PREF_COMPUTESOURCEPATH_KEY, | |
| 56 | 56 | PREF_PAGE_COMPUTESOURCEPATH_LABEL, |
| 57 | 57 | composite); |
| 58 | 58 | this.initField(this.automaticEditor); |
| @@ -26,6 +26,6 @@ | ||
| 26 | 26 | @Override |
| 27 | 27 | public void initializeDefaultPreferences() { |
| 28 | 28 | IPreferenceStore prefStore = TomcatLauncherPlugin.getDefault().getPreferenceStore(); |
| 29 | - prefStore.setDefault(TomcatLauncherPlugin.TOMCAT_PREF_CONFMODE_KEY, TomcatLauncherPlugin.CONTEXTFILES_MODE); | |
| 29 | + prefStore.setDefault(TomcatPluginResources.TOMCAT_PREF_CONFMODE_KEY, TomcatPluginResources.CONTEXTFILES_MODE); | |
| 30 | 30 | } |
| 31 | 31 | } |
| @@ -11,8 +11,10 @@ | ||
| 11 | 11 | import java.nio.charset.StandardCharsets; |
| 12 | 12 | import java.util.ArrayList; |
| 13 | 13 | import java.util.Collection; |
| 14 | -import java.util.Iterator; | |
| 14 | +import java.util.Collections; | |
| 15 | 15 | import java.util.List; |
| 16 | +import java.util.Map; | |
| 17 | +import java.util.Map.Entry; | |
| 16 | 18 | |
| 17 | 19 | import org.eclipse.core.resources.IFile; |
| 18 | 20 | import org.eclipse.core.resources.IProject; |
| @@ -21,12 +23,13 @@ | ||
| 21 | 23 | import org.eclipse.core.runtime.CoreException; |
| 22 | 24 | import org.eclipse.core.runtime.IPath; |
| 23 | 25 | import org.eclipse.core.runtime.Path; |
| 26 | +import org.eclipse.debug.core.ILaunch; | |
| 24 | 27 | import org.eclipse.jdt.core.IClasspathContainer; |
| 25 | 28 | import org.eclipse.jdt.core.IClasspathEntry; |
| 26 | 29 | import org.eclipse.jdt.core.IJavaProject; |
| 27 | 30 | import org.eclipse.jdt.core.JavaCore; |
| 28 | 31 | import org.eclipse.jdt.core.JavaModelException; |
| 29 | -import org.eclipse.jdt.launching.JavaRuntime; | |
| 32 | +import org.eclipse.jdt.launching.IVMInstall; | |
| 30 | 33 | |
| 31 | 34 | import com.sysdeo.eclipse.tomcat.editors.ProjectListElement; |
| 32 | 35 |
| @@ -45,8 +48,122 @@ | ||
| 45 | 48 | /** ADD_LAUNCH */ |
| 46 | 49 | private static final int ADD_LAUNCH = 3; |
| 47 | 50 | |
| 51 | + /** debugMode */ | |
| 52 | + private boolean debugMode; | |
| 53 | + /** tomcatDir */ | |
| 54 | + private String tomcatDir = ""; | |
| 55 | + /** tomcatBase */ | |
| 56 | + private String tomcatBase = ""; | |
| 57 | + /** projectMap */ | |
| 58 | + private Map<IProject, IProjectNature> projects = Collections.emptyMap(); | |
| 59 | + /** classpath */ | |
| 60 | + private String[] classpath = new String[0]; | |
| 61 | + /** vmArgs */ | |
| 62 | + private String[] vmArgs = new String[0]; | |
| 63 | + /** bootClasspath */ | |
| 64 | + private String[] bootClasspath = new String[0]; | |
| 65 | + /** IVMInstall */ | |
| 66 | + private IVMInstall vmInstalled; | |
| 67 | + /** ProjectListElement */ | |
| 68 | + private List<ProjectListElement> elements; | |
| 69 | + | |
| 48 | 70 | /** |
| 71 | + * set DebugMode | |
| 72 | + * @param val DebugMode | |
| 73 | + */ | |
| 74 | + public void setDebugMode(final boolean val) { | |
| 75 | + this.debugMode = val; | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 49 | 79 | * |
| 80 | + * @return boolean | |
| 81 | + */ | |
| 82 | + private boolean isDebugMode() { | |
| 83 | + return this.debugMode; | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * @param val the tomcatDir to set | |
| 88 | + */ | |
| 89 | + public void setTomcatDir(final String val) { | |
| 90 | + this.tomcatDir = val; | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * | |
| 95 | + * @return TomcatDir | |
| 96 | + */ | |
| 97 | + protected String getTomcatDir() { | |
| 98 | + return this.tomcatDir; | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * @param val the tomcatBase to set | |
| 103 | + */ | |
| 104 | + public void setTomcatBase(final String val) { | |
| 105 | + this.tomcatBase = val; | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * | |
| 110 | + * @return TomcatBase | |
| 111 | + */ | |
| 112 | + protected String getTomcatBase() { | |
| 113 | + return this.tomcatBase; | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * @param val the projects to set | |
| 118 | + */ | |
| 119 | + public void setProjects(final Map<IProject, IProjectNature> val) { | |
| 120 | + this.projects = val; | |
| 121 | + } | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * @param val the classpath to set | |
| 125 | + */ | |
| 126 | + public void setClasspath(final String[] val) { | |
| 127 | + this.classpath = val.clone(); | |
| 128 | + } | |
| 129 | + | |
| 130 | + /** | |
| 131 | + * @param val the vmArgs to set | |
| 132 | + */ | |
| 133 | + public void setVmArgs(final String[] val) { | |
| 134 | + this.vmArgs = val.clone(); | |
| 135 | + } | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * @param val the bootClasspath to set | |
| 139 | + */ | |
| 140 | + public void setBootClasspath(final String[] val) { | |
| 141 | + this.bootClasspath = val.clone(); | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * @return the vmInstalled | |
| 146 | + */ | |
| 147 | + protected IVMInstall getVmInstalled() { | |
| 148 | + return this.vmInstalled; | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * @param val the vmInstalled to set | |
| 153 | + */ | |
| 154 | + public void setVmInstalled(final IVMInstall val) { | |
| 155 | + this.vmInstalled = val; | |
| 156 | + } | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * @param val the elements to set | |
| 160 | + */ | |
| 161 | + public void setElements(final List<ProjectListElement> val) { | |
| 162 | + this.elements = val; | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * | |
| 50 | 167 | * @return String[] |
| 51 | 168 | */ |
| 52 | 169 | public abstract String[] getClasspath(); |
| @@ -127,10 +244,10 @@ | ||
| 127 | 244 | |
| 128 | 245 | /** |
| 129 | 246 | * |
| 247 | + * @param tomcatHomePath IPath | |
| 130 | 248 | * @return Collection<IClasspathEntry> |
| 131 | 249 | */ |
| 132 | - public Collection<IClasspathEntry> getTomcatJars() { | |
| 133 | - IPath tomcatHomePath = TomcatLauncherPlugin.getTomcatIPath(); | |
| 250 | + public Collection<IClasspathEntry> getTomcatJars(final IPath tomcatHomePath) { | |
| 134 | 251 | ArrayList<IClasspathEntry> jars = new ArrayList<>(); |
| 135 | 252 | |
| 136 | 253 | if (getServletJarPath() != null) { |
| @@ -182,7 +299,7 @@ | ||
| 182 | 299 | Thread.sleep(5000); |
| 183 | 300 | } catch (final InterruptedException ex) { |
| 184 | 301 | Thread.interrupted(); |
| 185 | - TomcatLauncherPlugin.log(ex); | |
| 302 | + ex.printStackTrace(System.err); | |
| 186 | 303 | } |
| 187 | 304 | |
| 188 | 305 | start(); |
| @@ -216,37 +333,31 @@ | ||
| 216 | 333 | private void runTomcatBootsrap(final String tomcatBootOption, final int action, |
| 217 | 334 | final boolean saveConfig) throws CoreException { |
| 218 | 335 | |
| 219 | - IProject[] projects = TomcatLauncherPlugin.getWorkspace().getRoot().getProjects(); | |
| 220 | - for (final IProject project: projects) { | |
| 221 | - if (!project.isOpen()) { | |
| 336 | + for (final Entry<IProject, IProjectNature> ent: this.projects.entrySet()) { | |
| 337 | + IProject project = ent.getKey(); | |
| 338 | + IProjectNature setting = ent.getValue(); | |
| 339 | + IProjectNature nature = project.getNature(JavaCore.NATURE_ID); | |
| 340 | + | |
| 341 | + if (!ITomcatProject.class.isInstance(setting) | |
| 342 | + || !IJavaProject.class.isInstance(nature)) { | |
| 222 | 343 | continue; |
| 223 | 344 | } |
| 224 | 345 | |
| 225 | - TomcatProject tomcatProject = (TomcatProject) project.getNature(TomcatLauncherPlugin.NATURE_ID); | |
| 226 | - if (tomcatProject != null) { | |
| 227 | - // IMC | |
| 228 | - IProjectNature nature = project.getNature(JavaCore.NATURE_ID); | |
| 229 | - if (IJavaProject.class.isInstance(nature)) { | |
| 230 | - ArrayList<String> al = new ArrayList<>(); | |
| 231 | - ArrayList<String> visitedProjects = new ArrayList<>(); | |
| 232 | - IJavaProject javaProject = (IJavaProject) nature; | |
| 233 | - WebClassPathEntries entries = tomcatProject.getWebClassPathEntries(); | |
| 234 | - if (entries != null) { | |
| 235 | - getClassPathEntries(javaProject, al, entries.getList(), visitedProjects); | |
| 236 | - print(tomcatProject, project, al); | |
| 237 | - } | |
| 238 | - } | |
| 346 | + ITomcatProject tomcatProject = (ITomcatProject) setting; | |
| 347 | + IJavaProject javaProject = (IJavaProject) nature; | |
| 348 | + | |
| 349 | + ArrayList<String> al = new ArrayList<>(); | |
| 350 | + ArrayList<String> visitedProjects = new ArrayList<>(); | |
| 351 | + WebClassPathEntries entries = tomcatProject.getWebClassPathEntries(); | |
| 352 | + if (entries != null) { | |
| 353 | + getClassPathEntries(javaProject, al, entries.getList(), visitedProjects); | |
| 354 | + print(tomcatProject, project, al); | |
| 239 | 355 | } |
| 240 | 356 | } |
| 241 | 357 | |
| 242 | - String[] classpath = addPreferenceJvmToClasspath(new String[0]); | |
| 243 | - classpath = addPreferenceProjectListToClasspath(classpath); | |
| 244 | - classpath = StringUtil.concatUniq(classpath, getClasspath()); | |
| 358 | + String[] cp = StringUtil.concatUniq(this.classpath, getClasspath()); | |
| 359 | + String[] args = StringUtil.concat(getVmArgs(), this.vmArgs); | |
| 245 | 360 | |
| 246 | - String[] vmArgs = addPreferenceParameters(getVmArgs()); | |
| 247 | - | |
| 248 | - String[] bootClasspath = addPreferenceJvmToBootClasspath(new String[0]); | |
| 249 | - | |
| 250 | 361 | String[] prgArgs = getPrgArgs(tomcatBootOption); |
| 251 | 362 | StringBuilder programArguments = new StringBuilder(); |
| 252 | 363 | for (final String arg : prgArgs) { |
| @@ -254,20 +365,24 @@ | ||
| 254 | 365 | } |
| 255 | 366 | |
| 256 | 367 | StringBuilder jvmArguments = new StringBuilder(); |
| 257 | - for (final String arg : vmArgs) { | |
| 368 | + for (final String arg : args) { | |
| 258 | 369 | jvmArguments.append(" ").append(arg); |
| 259 | 370 | } |
| 260 | 371 | |
| 261 | 372 | if (action == RUN) { |
| 262 | - VMLauncherUtility.runVM(getLabel(), getMainClass(), classpath, bootClasspath, | |
| 263 | - jvmArguments.toString(), programArguments.toString(), isDebugMode(), saveConfig); | |
| 264 | - } | |
| 265 | - if (action == LOG) { | |
| 266 | - VMLauncherUtility.log(getLabel(), getMainClass(), classpath, bootClasspath, | |
| 267 | - jvmArguments.toString(), programArguments.toString()); | |
| 268 | - } | |
| 269 | - if (action == ADD_LAUNCH) { | |
| 270 | - VMLauncherUtility.createConfig(getLabel(), getMainClass(), classpath, bootClasspath, | |
| 373 | + VMLauncherUtility launcher = new VMLauncherUtility(this.tomcatDir, this.tomcatBase, | |
| 374 | + cp, this.bootClasspath, this.vmInstalled, this.elements); | |
| 375 | + ILaunch launch = launcher.runVM(getLabel(), getMainClass(), jvmArguments.toString(), | |
| 376 | + programArguments.toString(), isDebugMode(), saveConfig); | |
| 377 | + VMLauncherUtility.setILaunch(launch); | |
| 378 | + } else if (action == LOG) { | |
| 379 | + VMLauncherUtility launcher = new VMLauncherUtility(this.tomcatDir, this.tomcatBase, | |
| 380 | + cp, this.bootClasspath, this.vmInstalled, this.elements); | |
| 381 | + launcher.log(getLabel(), getMainClass(), jvmArguments.toString(), programArguments.toString()); | |
| 382 | + } else if (action == ADD_LAUNCH) { | |
| 383 | + VMLauncherUtility launcher = new VMLauncherUtility(this.tomcatDir, this.tomcatBase, | |
| 384 | + cp, this.bootClasspath, this.vmInstalled, this.elements); | |
| 385 | + launcher.createConfig(getLabel(), getMainClass(), | |
| 271 | 386 | jvmArguments.toString(), programArguments.toString(), true); |
| 272 | 387 | } |
| 273 | 388 | } |
| @@ -278,7 +393,7 @@ | ||
| 278 | 393 | * @param project IProject |
| 279 | 394 | * @param al ArrayList<String> |
| 280 | 395 | */ |
| 281 | - private void print(final TomcatProject tomcatProject, final IProject project, final ArrayList<String> al) { | |
| 396 | + private void print(final ITomcatProject tomcatProject, final IProject project, final ArrayList<String> al) { | |
| 282 | 397 | IFile file = null; |
| 283 | 398 | if (tomcatProject.getRootDirFolder() == null) { |
| 284 | 399 | file = project.getFile(new Path(WEBAPP_CLASSPATH_FILENAME)); |
| @@ -338,21 +453,18 @@ | ||
| 338 | 453 | * @param data ArrayList<String> |
| 339 | 454 | * @param selectedPaths List<String> |
| 340 | 455 | * @param visitedProjects ArrayList<String> |
| 456 | + * @throws JavaModelException JavaModelException | |
| 341 | 457 | */ |
| 342 | 458 | private void getClassPathEntries(final IJavaProject prj, final ArrayList<String> data, |
| 343 | - final List<String> selectedPaths, final ArrayList<String> visitedProjects) { | |
| 344 | - IClasspathEntry[] entries = null; | |
| 345 | - IPath outputPath = null; | |
| 346 | - try { | |
| 347 | - outputPath = prj.getOutputLocation(); | |
| 348 | - if (selectedPaths.contains(outputPath.toFile().toString().replace('\\', '/'))) { | |
| 349 | - add(data, prj.getProject().getWorkspace().getRoot().findMember(outputPath)); | |
| 350 | - } | |
| 351 | - entries = prj.getRawClasspath(); | |
| 352 | - } catch (final JavaModelException e) { | |
| 353 | - TomcatLauncherPlugin.log(e); | |
| 459 | + final List<String> selectedPaths, final ArrayList<String> visitedProjects) | |
| 460 | + throws JavaModelException { | |
| 461 | + IPath outputPath = prj.getOutputLocation(); | |
| 462 | + if (selectedPaths.contains(outputPath.toFile().toString().replace('\\', '/'))) { | |
| 463 | + add(data, prj.getProject().getWorkspace().getRoot().findMember(outputPath)); | |
| 354 | 464 | } |
| 355 | 465 | |
| 466 | + IClasspathEntry[] entries = prj.getRawClasspath(); | |
| 467 | + | |
| 356 | 468 | if (entries != null) { |
| 357 | 469 | getClassPathEntries(entries, prj, data, selectedPaths, visitedProjects, outputPath); |
| 358 | 470 | } |
| @@ -366,10 +478,11 @@ | ||
| 366 | 478 | * @param selectedPaths List<String> |
| 367 | 479 | * @param visitedProjects ArrayList<String> |
| 368 | 480 | * @param outputPath IPath |
| 481 | + * @throws JavaModelException JavaModelException | |
| 369 | 482 | */ |
| 370 | 483 | private void getClassPathEntries(final IClasspathEntry[] entries, final IJavaProject prj, |
| 371 | 484 | final ArrayList<String> data, final List<String> selectedPaths, |
| 372 | - final ArrayList<String> visitedProjects, final IPath outputPath) { | |
| 485 | + final ArrayList<String> visitedProjects, final IPath outputPath) throws JavaModelException { | |
| 373 | 486 | for (final IClasspathEntry entry : entries) { |
| 374 | 487 | IPath path = entry.getPath(); |
| 375 | 488 | if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { |
| @@ -413,7 +526,6 @@ | ||
| 413 | 526 | add(data, prj.getProject().getWorkspace().getRoot().findMember(srcPath)); |
| 414 | 527 | } |
| 415 | 528 | } else { |
| 416 | - TomcatLauncherPlugin.log(">>> " + tmp); | |
| 417 | 529 | if (tmp.getPath() != null) { |
| 418 | 530 | add(data, tmp.getPath()); |
| 419 | 531 | } |
| @@ -430,19 +542,17 @@ | ||
| 430 | 542 | * @param selectedPaths List<String> |
| 431 | 543 | * @param visitedProjects ArrayList<String> |
| 432 | 544 | * @param outputPath IPath |
| 545 | + * @throws JavaModelException JavaModelException | |
| 433 | 546 | */ |
| 434 | 547 | private void classPathEntries(final IPath path, final IJavaProject prj, final ArrayList<String> data, |
| 435 | - final List<String> selectedPaths, final ArrayList<String> visitedProjects, final IPath outputPath) { | |
| 548 | + final List<String> selectedPaths, final ArrayList<String> visitedProjects, | |
| 549 | + final IPath outputPath) throws JavaModelException { | |
| 436 | 550 | // entires in container are only processed individually |
| 437 | 551 | // if container itself is not selected |
| 438 | - try { | |
| 439 | - IClasspathContainer container = JavaCore.getClasspathContainer(path, prj); | |
| 440 | - if (container != null) { | |
| 441 | - getClassPathEntries(container.getClasspathEntries(), prj, data, | |
| 442 | - selectedPaths, visitedProjects, outputPath); | |
| 443 | - } | |
| 444 | - } catch (final JavaModelException e) { | |
| 445 | - TomcatLauncherPlugin.log(e); | |
| 552 | + IClasspathContainer container = JavaCore.getClasspathContainer(path, prj); | |
| 553 | + if (container != null) { | |
| 554 | + getClassPathEntries(container.getClasspathEntries(), prj, data, | |
| 555 | + selectedPaths, visitedProjects, outputPath); | |
| 446 | 556 | } |
| 447 | 557 | } |
| 448 | 558 |
| @@ -452,15 +562,13 @@ | ||
| 452 | 562 | * @param path IPath |
| 453 | 563 | * @param prj IJavaProject |
| 454 | 564 | * @return IClasspathEntry[] |
| 565 | + * @throws JavaModelException JavaModelException | |
| 455 | 566 | */ |
| 456 | - private IClasspathEntry[] getTmpEntry(final IClasspathEntry entry, final IPath path, final IJavaProject prj) { | |
| 567 | + private IClasspathEntry[] getTmpEntry(final IClasspathEntry entry, final IPath path, | |
| 568 | + final IJavaProject prj) throws JavaModelException { | |
| 457 | 569 | IClasspathEntry[] tmpEntry = null; |
| 458 | 570 | if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { |
| 459 | - try { | |
| 460 | - tmpEntry = JavaCore.getClasspathContainer(path, prj).getClasspathEntries(); | |
| 461 | - } catch (final JavaModelException e1) { | |
| 462 | - TomcatLauncherPlugin.log(e1); | |
| 463 | - } | |
| 571 | + tmpEntry = JavaCore.getClasspathContainer(path, prj).getClasspathEntries(); | |
| 464 | 572 | } else { |
| 465 | 573 | tmpEntry = new IClasspathEntry[1]; |
| 466 | 574 | tmpEntry[0] = JavaCore.getResolvedClasspathEntry(entry); |
| @@ -467,98 +575,4 @@ | ||
| 467 | 575 | } |
| 468 | 576 | return tmpEntry; |
| 469 | 577 | } |
| 470 | - | |
| 471 | - /** | |
| 472 | - * | |
| 473 | - * @return boolean | |
| 474 | - */ | |
| 475 | - private static boolean isDebugMode() { | |
| 476 | - return TomcatLauncherPlugin.isDebugMode(); | |
| 477 | - } | |
| 478 | - | |
| 479 | - /** | |
| 480 | - * | |
| 481 | - * @return TomcatDir | |
| 482 | - */ | |
| 483 | - protected static String getTomcatDir() { | |
| 484 | - return TomcatLauncherPlugin.getTomcatDir(); | |
| 485 | - } | |
| 486 | - | |
| 487 | - /** | |
| 488 | - * | |
| 489 | - * @return TomcatBase | |
| 490 | - */ | |
| 491 | - protected static String getTomcatBase() { | |
| 492 | - return TomcatLauncherPlugin.getTomcatBase(); | |
| 493 | - } | |
| 494 | - | |
| 495 | - /** | |
| 496 | - * | |
| 497 | - * @param previouscp String[] | |
| 498 | - * @return String[] | |
| 499 | - */ | |
| 500 | - private String[] addPreferenceProjectListToClasspath(final String[] previouscp) { | |
| 501 | - List<ProjectListElement> projectsList = TomcatLauncherPlugin.getProjectsInCP(); | |
| 502 | - String[] result = previouscp; | |
| 503 | - Iterator<ProjectListElement> it = projectsList.iterator(); | |
| 504 | - while (it.hasNext()) { | |
| 505 | - try { | |
| 506 | - ProjectListElement ple = it.next(); | |
| 507 | - IJavaProject jproject = JavaCore.create(ple.getProject()); | |
| 508 | - result = addProjectToClasspath(result, jproject); | |
| 509 | - } catch (final CoreException e) { | |
| 510 | - // nothing will be added to classpath | |
| 511 | - TomcatLauncherPlugin.log(e); | |
| 512 | - } | |
| 513 | - } | |
| 514 | - return result; | |
| 515 | - } | |
| 516 | - | |
| 517 | - /** | |
| 518 | - * | |
| 519 | - * @param previouscp String[] | |
| 520 | - * @param project IJavaProject | |
| 521 | - * @return String[] | |
| 522 | - * @throws CoreException CoreException | |
| 523 | - */ | |
| 524 | - private String[] addProjectToClasspath(final String[] previouscp, final IJavaProject project) throws CoreException { | |
| 525 | - if ((project != null) && (project.exists() && project.isOpen())) { | |
| 526 | - String[] projectcp = JavaRuntime.computeDefaultRuntimeClassPath(project); | |
| 527 | - return StringUtil.concatUniq(projectcp, previouscp); | |
| 528 | - } | |
| 529 | - return previouscp; | |
| 530 | - } | |
| 531 | - | |
| 532 | - /** | |
| 533 | - * | |
| 534 | - * @param previous String[] | |
| 535 | - * @return String[] | |
| 536 | - */ | |
| 537 | - private String[] addPreferenceParameters(final String[] previous) { | |
| 538 | - String[] prefParams = StringUtil.cutString(TomcatLauncherPlugin.getJvmParamaters(), | |
| 539 | - TomcatPluginResources.PREF_PAGE_LIST_SEPARATOR); | |
| 540 | - return StringUtil.concat(previous, prefParams); | |
| 541 | - } | |
| 542 | - | |
| 543 | - /** | |
| 544 | - * | |
| 545 | - * @param previous String[] | |
| 546 | - * @return String[] | |
| 547 | - */ | |
| 548 | - private String[] addPreferenceJvmToClasspath(final String[] previous) { | |
| 549 | - String[] prefClasspath = StringUtil.cutString(TomcatLauncherPlugin.getJvmClasspath(), | |
| 550 | - TomcatPluginResources.PREF_PAGE_LIST_SEPARATOR); | |
| 551 | - return StringUtil.concatUniq(previous, prefClasspath); | |
| 552 | - } | |
| 553 | - | |
| 554 | - /** | |
| 555 | - * | |
| 556 | - * @param previous String[] | |
| 557 | - * @return String[] | |
| 558 | - */ | |
| 559 | - private String[] addPreferenceJvmToBootClasspath(final String[] previous) { | |
| 560 | - String[] prefBootClasspath = StringUtil.cutString(TomcatLauncherPlugin.getJvmBootClasspath(), | |
| 561 | - TomcatPluginResources.PREF_PAGE_LIST_SEPARATOR); | |
| 562 | - return StringUtil.concatUniq(previous, prefBootClasspath); | |
| 563 | - } | |
| 564 | 578 | } |
| @@ -36,7 +36,6 @@ | ||
| 36 | 36 | import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
| 37 | 37 | import org.eclipse.jdt.launching.IRuntimeClasspathEntry; |
| 38 | 38 | import org.eclipse.jdt.launching.IVMInstall; |
| 39 | -import org.eclipse.jdt.launching.IVMInstallType; | |
| 40 | 39 | import org.eclipse.jdt.launching.JavaRuntime; |
| 41 | 40 | import org.eclipse.jdt.launching.sourcelookup.containers.JavaProjectSourceContainer; |
| 42 | 41 | import org.eclipse.jdt.launching.sourcelookup.containers.PackageFragmentRootSourceContainer; |
| @@ -49,16 +48,41 @@ | ||
| 49 | 48 | * It might exist better way to implements those operations, |
| 50 | 49 | * or they might already exist in other form JDT |
| 51 | 50 | */ |
| 52 | -public final class VMLauncherUtility { | |
| 51 | +public class VMLauncherUtility { | |
| 53 | 52 | |
| 54 | 53 | /** ILAUNCH */ |
| 55 | 54 | private static ILaunch ilaunch = null; |
| 56 | 55 | |
| 56 | + /** tomcatDir */ | |
| 57 | + private final String tomcatDir; | |
| 58 | + /** tomcatBase */ | |
| 59 | + private final String tomcatBase; | |
| 60 | + /** classpath */ | |
| 61 | + private final String[] classpath; | |
| 62 | + /** bootClasspath */ | |
| 63 | + private final String[] bootClasspath; | |
| 64 | + /** IVMInstall */ | |
| 65 | + private final IVMInstall vmInstalled; | |
| 66 | + /** ProjectListElement */ | |
| 67 | + private final List<ProjectListElement> elements; | |
| 68 | + | |
| 57 | 69 | /** |
| 58 | 70 | * Constructor |
| 71 | + * @param dir tomcatDir | |
| 72 | + * @param base tomcatBase | |
| 73 | + * @param cp classpath | |
| 74 | + * @param boot bootClasspath | |
| 75 | + * @param vm vmInstalled | |
| 76 | + * @param list List<ProjectListElement> | |
| 59 | 77 | */ |
| 60 | - private VMLauncherUtility() { | |
| 61 | - throw new AssertionError(); | |
| 78 | + VMLauncherUtility(final String dir, final String base, final String[] cp, | |
| 79 | + final String[] boot, final IVMInstall vm, final List<ProjectListElement> list) { | |
| 80 | + this.tomcatDir = dir; | |
| 81 | + this.tomcatBase = base; | |
| 82 | + this.classpath = cp; | |
| 83 | + this.bootClasspath = boot; | |
| 84 | + this.vmInstalled = vm; | |
| 85 | + this.elements = list; | |
| 62 | 86 | } |
| 63 | 87 | |
| 64 | 88 | /** |
| @@ -70,18 +94,10 @@ | ||
| 70 | 94 | } |
| 71 | 95 | |
| 72 | 96 | /** |
| 73 | - * | |
| 74 | - * @return VMInstall | |
| 97 | + * @param val the ilaunch to set | |
| 75 | 98 | */ |
| 76 | - public static IVMInstall getVMInstall() { | |
| 77 | - for (IVMInstallType type : JavaRuntime.getVMInstallTypes()) { | |
| 78 | - for (final IVMInstall vms : type.getVMInstalls()) { | |
| 79 | - if (vms.getId().equals(TomcatLauncherPlugin.getTomcatJRE())) { | |
| 80 | - return vms; | |
| 81 | - } | |
| 82 | - } | |
| 83 | - } | |
| 84 | - return JavaRuntime.getDefaultVMInstall(); | |
| 99 | + static void setILaunch(final ILaunch val) { | |
| 100 | + ilaunch = val; | |
| 85 | 101 | } |
| 86 | 102 | |
| 87 | 103 | /** |
| @@ -88,16 +104,14 @@ | ||
| 88 | 104 | * |
| 89 | 105 | * @param label String |
| 90 | 106 | * @param classToLaunch String |
| 91 | - * @param classpath String[] | |
| 92 | - * @param bootClasspath String[] | |
| 93 | 107 | * @param vmArgs String |
| 94 | 108 | * @param prgArgs String |
| 95 | 109 | * @param debug boolean |
| 96 | 110 | * @param saveConfig boolean |
| 111 | + * @return ILaunch | |
| 97 | 112 | * @throws CoreException CoreException |
| 98 | 113 | */ |
| 99 | - static void runVM(final String label, final String classToLaunch, final String[] classpath, | |
| 100 | - final String[] bootClasspath, final String vmArgs, final String prgArgs, | |
| 114 | + ILaunch runVM(final String label, final String classToLaunch, final String vmArgs, final String prgArgs, | |
| 101 | 115 | final boolean debug, final boolean saveConfig) throws CoreException { |
| 102 | 116 | |
| 103 | 117 | String mode = ""; |
| @@ -107,9 +121,8 @@ | ||
| 107 | 121 | mode = ILaunchManager.RUN_MODE; |
| 108 | 122 | } |
| 109 | 123 | |
| 110 | - ILaunchConfigurationWorkingCopy config = createConfig(label, classToLaunch, classpath, | |
| 111 | - bootClasspath, vmArgs, prgArgs, saveConfig); | |
| 112 | - ilaunch = config.launch(mode, null); | |
| 124 | + ILaunchConfigurationWorkingCopy config = createConfig(label, classToLaunch, vmArgs, prgArgs, saveConfig); | |
| 125 | + return config.launch(mode, null); | |
| 113 | 126 | } |
| 114 | 127 | |
| 115 | 128 | /** |
| @@ -116,37 +129,29 @@ | ||
| 116 | 129 | * |
| 117 | 130 | * @param label String |
| 118 | 131 | * @param classToLaunch String |
| 119 | - * @param classpath String[] | |
| 120 | - * @param bootClasspath String[] | |
| 121 | 132 | * @param vmArgs String |
| 122 | 133 | * @param prgArgs String |
| 134 | + * @throws CoreException CoreException | |
| 123 | 135 | */ |
| 124 | - public static void log(final String label, final String classToLaunch, final String[] classpath, | |
| 125 | - final String[] bootClasspath, final String vmArgs, final String prgArgs) { | |
| 136 | + void log(final String label, final String classToLaunch, final String vmArgs, | |
| 137 | + final String prgArgs) throws CoreException { | |
| 126 | 138 | StringBuilder trace = new StringBuilder("\n-------- Sysdeo Tomcat Launcher settings --------"); |
| 127 | 139 | trace.append("\n-> Label : ").append(label); |
| 128 | 140 | trace.append("\n-> ClassToLaunch : ").append(classToLaunch); |
| 129 | 141 | trace.append("\n-> Classpath : "); |
| 130 | - for (final String path : classpath) { | |
| 142 | + for (final String path : this.classpath) { | |
| 131 | 143 | trace.append(" | ").append(path).append(" | "); |
| 132 | 144 | } |
| 133 | 145 | trace.append("\n-> BootClasspath : "); |
| 134 | - for (final String boot : bootClasspath) { | |
| 146 | + for (final String boot : this.bootClasspath) { | |
| 135 | 147 | trace.append(" | ").append(boot).append(" | "); |
| 136 | 148 | } |
| 137 | 149 | trace.append("\n-> Vmargs : ").append(vmArgs); |
| 138 | 150 | trace.append("\n-> PrgArgs : ").append(prgArgs); |
| 139 | 151 | trace.append("\n-> Source lookup : \n"); |
| 140 | - TomcatLauncherPlugin.log(trace.toString()); | |
| 141 | 152 | |
| 142 | - try { | |
| 143 | - createConfig(label, classToLaunch, classpath, bootClasspath, vmArgs, prgArgs, false); | |
| 144 | - getSourceLocator(true); | |
| 145 | - } catch (final CoreException e) { | |
| 146 | - TomcatLauncherPlugin.log(e.getMessage() + "getSourceLocator failed"); | |
| 147 | - } | |
| 148 | - | |
| 149 | - TomcatLauncherPlugin.log("\n-------- Sysdeo Tomcat Launcher settings--------"); | |
| 153 | + createConfig(label, classToLaunch, vmArgs, prgArgs, false); | |
| 154 | + getSourceLocator(); | |
| 150 | 155 | } |
| 151 | 156 | |
| 152 | 157 | /** |
| @@ -153,8 +158,6 @@ | ||
| 153 | 158 | * |
| 154 | 159 | * @param label String |
| 155 | 160 | * @param classToLaunch String |
| 156 | - * @param classpath String[] | |
| 157 | - * @param bootClasspath String[] | |
| 158 | 161 | * @param vmArgs String |
| 159 | 162 | * @param prgArgs String |
| 160 | 163 | * @param saveConfig boolean |
| @@ -161,8 +164,8 @@ | ||
| 161 | 164 | * @return ILaunchConfigurationWorkingCopy |
| 162 | 165 | * @throws CoreException CoreException |
| 163 | 166 | */ |
| 164 | - public static ILaunchConfigurationWorkingCopy createConfig(final String label, final String classToLaunch, | |
| 165 | - final String[] classpath, final String[] bootClasspath, final String vmArgs, final String prgArgs, | |
| 167 | + ILaunchConfigurationWorkingCopy createConfig(final String label, final String classToLaunch, | |
| 168 | + final String vmArgs, final String prgArgs, | |
| 166 | 169 | final boolean saveConfig) throws CoreException { |
| 167 | 170 | |
| 168 | 171 | ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType( |
| @@ -172,28 +175,28 @@ | ||
| 172 | 175 | config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, |
| 173 | 176 | "org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"); |
| 174 | 177 | |
| 175 | - ISourceLookupDirector locator = (ISourceLookupDirector) getSourceLocator(false); | |
| 178 | + ISourceLookupDirector locator = (ISourceLookupDirector) getSourceLocator(); | |
| 176 | 179 | config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento()); |
| 177 | 180 | |
| 178 | - IVMInstall vmInstall = getVMInstall(); | |
| 181 | + IVMInstall vmInstall = this.vmInstalled; | |
| 179 | 182 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, |
| 180 | 183 | vmInstall.getVMInstallType().getId()); |
| 181 | 184 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, vmInstall.getName()); |
| 182 | 185 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false); |
| 183 | 186 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, |
| 184 | - getClasspathMementos(classpath, bootClasspath)); | |
| 187 | + getClasspathMementos(this.classpath, this.bootClasspath)); | |
| 185 | 188 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, prgArgs); |
| 186 | 189 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs); |
| 187 | 190 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, classToLaunch); |
| 188 | 191 | |
| 189 | - String catalinaBase = TomcatLauncherPlugin.getTomcatBase(); | |
| 192 | + String catalinaBase = this.tomcatBase; | |
| 190 | 193 | if (catalinaBase.isEmpty()) { |
| 191 | - catalinaBase = TomcatLauncherPlugin.getTomcatDir(); | |
| 194 | + catalinaBase = this.tomcatDir; | |
| 192 | 195 | } |
| 193 | 196 | config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, catalinaBase); |
| 194 | 197 | |
| 195 | 198 | if (saveConfig) { |
| 196 | - getSourceLocator(false); | |
| 199 | + getSourceLocator(); | |
| 197 | 200 | config.doSave(); |
| 198 | 201 | } |
| 199 | 202 |
| @@ -218,15 +221,11 @@ | ||
| 218 | 221 | |
| 219 | 222 | if (bootClasspath.length == 0) { |
| 220 | 223 | IPath path = new Path(JavaRuntime.JRE_CONTAINER); |
| 221 | - try { | |
| 222 | - IClasspathEntry cpEntry = JavaCore.newContainerEntry(path); | |
| 223 | - // from org.eclipse.jdt.internal.debug.ui.actions.AddLibraryAction run() | |
| 224 | - IRuntimeClasspathEntry rcpEntry = JavaRuntime.newRuntimeContainerClasspathEntry( | |
| 225 | - cpEntry.getPath(), IRuntimeClasspathEntry.STANDARD_CLASSES); | |
| 226 | - classpathMementos.add(rcpEntry.getMemento()); | |
| 227 | - } catch (final CoreException ex) { | |
| 228 | - TomcatLauncherPlugin.log(ex); | |
| 229 | - } | |
| 224 | + IClasspathEntry cpEntry = JavaCore.newContainerEntry(path); | |
| 225 | + // from org.eclipse.jdt.internal.debug.ui.actions.AddLibraryAction run() | |
| 226 | + IRuntimeClasspathEntry rcpEntry = JavaRuntime.newRuntimeContainerClasspathEntry( | |
| 227 | + cpEntry.getPath(), IRuntimeClasspathEntry.STANDARD_CLASSES); | |
| 228 | + classpathMementos.add(rcpEntry.getMemento()); | |
| 230 | 229 | |
| 231 | 230 | } else { |
| 232 | 231 | for (final String boot : bootClasspath) { |
| @@ -241,16 +240,15 @@ | ||
| 241 | 240 | |
| 242 | 241 | /** |
| 243 | 242 | * |
| 244 | - * @param trace boolean | |
| 245 | 243 | * @return SourceLocator |
| 246 | 244 | * @throws CoreException CoreException |
| 247 | 245 | */ |
| 248 | - private static ISourceLocator getSourceLocator(final boolean trace) throws CoreException { | |
| 246 | + private ISourceLocator getSourceLocator() throws CoreException { | |
| 249 | 247 | ArrayList<IProjectNature> tempList = new ArrayList<>(); |
| 250 | 248 | StringBuilder traceBuffer = new StringBuilder(); |
| 251 | 249 | traceBuffer.append("Projects in source path :\n"); |
| 252 | 250 | |
| 253 | - for (final ProjectListElement element : TomcatLauncherPlugin.getDefault().getProjectsInSourcePath()) { | |
| 251 | + for (final ProjectListElement element : this.elements) { | |
| 254 | 252 | IProject project = element.getProject(); |
| 255 | 253 | traceBuffer.append("Project " + project.getName()); |
| 256 | 254 | if ((project.isOpen()) && project.hasNature(JavaCore.NATURE_ID)) { |
| @@ -266,9 +264,6 @@ | ||
| 266 | 264 | sourceLocator.setSourceContainers(getSourceContainers(tempList, traceBuffer)); |
| 267 | 265 | sourceLocator.initializeParticipants(); |
| 268 | 266 | |
| 269 | - if (trace) { | |
| 270 | - TomcatLauncherPlugin.log(traceBuffer.toString()); | |
| 271 | - } | |
| 272 | 267 | return sourceLocator; |
| 273 | 268 | } |
| 274 | 269 |
| @@ -58,19 +58,19 @@ | ||
| 58 | 58 | |
| 59 | 59 | Group homeGroup = new Group(composite, SWT.NONE); |
| 60 | 60 | this.base = new DirectoryFieldEditor( |
| 61 | - TomcatLauncherPlugin.TOMCAT_PREF_BASE_KEY, | |
| 61 | + TomcatPluginResources.TOMCAT_PREF_BASE_KEY, | |
| 62 | 62 | PREF_PAGE_BASE_LABEL, homeGroup); |
| 63 | 63 | initLayoutAndData(homeGroup, 3); |
| 64 | 64 | |
| 65 | 65 | Group securityGroup = new Group(composite, SWT.NONE); |
| 66 | 66 | this.securityEditor = new BooleanFieldEditor( |
| 67 | - TomcatLauncherPlugin.TOMCAT_PREF_SECURITYMANAGER, | |
| 67 | + TomcatPluginResources.TOMCAT_PREF_SECURITYMANAGER, | |
| 68 | 68 | PREF_PAGE_SECURITYMANAGER_LABEL, securityGroup); |
| 69 | 69 | initField(this.securityEditor); |
| 70 | 70 | initLayoutAndData(securityGroup, 1); |
| 71 | 71 | |
| 72 | 72 | Group projectListGroup = new Group(composite, SWT.NONE); |
| 73 | - String[] excludedProjectsNature = {TomcatLauncherPlugin.NATURE_ID}; | |
| 73 | + String[] excludedProjectsNature = {TomcatPluginResources.NATURE_ID}; | |
| 74 | 74 | this.projectListEditor = new ProjectListEditor(excludedProjectsNature); |
| 75 | 75 | this.projectListEditor.setLabel(PREF_PAGE_PROJECTINCP_LABEL); |
| 76 | 76 | Control projectList = this.projectListEditor.getControl(projectListGroup); |
| @@ -104,7 +104,7 @@ | ||
| 104 | 104 | this.securityEditor.store(); |
| 105 | 105 | TomcatLauncherPlugin.setProjectsInCP(this.projectListEditor.getCheckedElements()); |
| 106 | 106 | try { |
| 107 | - InstanceScope.INSTANCE.getNode(TomcatLauncherPlugin.PLUGIN_ID).flush(); | |
| 107 | + InstanceScope.INSTANCE.getNode(TomcatPluginResources.PLUGIN_ID).flush(); | |
| 108 | 108 | } catch (final BackingStoreException e) { |
| 109 | 109 | TomcatLauncherPlugin.log(e); |
| 110 | 110 | return false; |