• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision132 (tree)
Time2015-10-18 16:22:59
Authort_nakayama1971

Log Message

findbugs warning修正

Change Summary

Incremental Difference

--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProjectGeneralPropertyPage.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProjectGeneralPropertyPage.java (revision 132)
@@ -104,7 +104,7 @@
104104
105105 try {
106106 this.isTomcatProjectCheck.setSelection(
107- this.javaProject.getProject().hasNature(TomcatLauncherPlugin.NATURE_ID));
107+ this.javaProject.getProject().hasNature(TomcatPluginResources.NATURE_ID));
108108 } catch (final CoreException ex) {
109109 TomcatLauncherPlugin.log(ex.getMessage());
110110 }
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProject.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProject.java (revision 132)
@@ -39,7 +39,7 @@
3939 /**
4040 * TomcatProject
4141 */
42-public class TomcatProject extends PlatformObject implements IProjectNature {
42+public class TomcatProject extends PlatformObject implements IProjectNature, ITomcatProject {
4343
4444 // Persistence properties of projects
4545 /** PROPERTIES_FILENAME */
@@ -137,6 +137,7 @@
137137 * @see IProjectNature#setProject(IProject)
138138 * @param prj IJavaProject
139139 */
140+ @Override
140141 public void setJavaProject(final IJavaProject prj) {
141142 this.javaProject = prj;
142143 setProject(prj.getProject());
@@ -148,7 +149,7 @@
148149 */
149150 public static void addTomcatNature(final IJavaProject project) {
150151 try {
151- JDTUtil.addNatureToProject(project.getProject(), TomcatLauncherPlugin.NATURE_ID);
152+ JDTUtil.addNatureToProject(project.getProject(), TomcatPluginResources.NATURE_ID);
152153 } catch (final CoreException ex) {
153154 TomcatLauncherPlugin.log(ex.getMessage());
154155 }
@@ -160,7 +161,7 @@
160161 */
161162 public static void removeTomcatNature(final IJavaProject project) {
162163 try {
163- JDTUtil.removeNatureToProject(project.getProject(), TomcatLauncherPlugin.NATURE_ID);
164+ JDTUtil.removeNatureToProject(project.getProject(), TomcatPluginResources.NATURE_ID);
164165 } catch (final CoreException ex) {
165166 TomcatLauncherPlugin.log(ex.getMessage());
166167 }
@@ -176,7 +177,7 @@
176177 public static TomcatProject create(final IJavaProject javaProject) {
177178 TomcatProject result = null;
178179 try {
179- result = (TomcatProject)javaProject.getProject().getNature(TomcatLauncherPlugin.NATURE_ID);
180+ result = (TomcatProject)javaProject.getProject().getNature(TomcatPluginResources.NATURE_ID);
180181 if (result != null) {
181182 result.setJavaProject(javaProject);
182183 }
@@ -406,6 +407,7 @@
406407 * return the webclasspath entries
407408 * @return WebClassPathEntries
408409 */
410+ @Override
409411 public WebClassPathEntries getWebClassPathEntries() {
410412 try {
411413 return WebClassPathEntries.xmlUnmarshal(FileUtil.readTextFile(getPropertiesFile()));
@@ -507,7 +509,7 @@
507509 cp.add(entry);
508510 }
509511 }
510- cp.addAll(tb.getTomcatJars());
512+ cp.addAll(tb.getTomcatJars(TomcatLauncherPlugin.getTomcatIPath()));
511513
512514 this.javaProject.setRawClasspath(cp.toArray(new IClasspathEntry[cp.size()]), null);
513515 }
@@ -563,6 +565,7 @@
563565 *
564566 * @return IFolder
565567 */
568+ @Override
566569 public IFolder getRootDirFolder() {
567570 if (this.rootDirFolder == null) {
568571 initRootDirFolder(false);
@@ -732,7 +735,7 @@
732735 * @throws CoreException CoreException
733736 */
734737 public void updateContext() throws CoreException {
735- if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) {
738+ if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) {
736739 updateServerXML();
737740 } else {
738741 try {
@@ -813,11 +816,12 @@
813816 *
814817 * @throws CoreException CoreException
815818 */
819+ @Override
816820 public void removeContext() throws CoreException {
817821 // Always call removeContext file because Tomcat create it automatically when using server.xml
818822 removeContextFile();
819823
820- if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) {
824+ if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) {
821825 removeContextInServerXML();
822826 }
823827 }
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatPreferencePage.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatPreferencePage.java (revision 132)
@@ -81,7 +81,7 @@
8181
8282 this.oldVersion = TomcatLauncherPlugin.getTomcatVersion();
8383 this.version = new RadioGroupFieldEditor(
84- TomcatLauncherPlugin.TOMCAT_PREF_VERSION_KEY,
84+ TomcatPluginResources.TOMCAT_PREF_VERSION_KEY,
8585 PREF_PAGE_CHOOSEVERSION_LABEL, 1,
8686 new String[][] {
8787 // {PREF_PAGE_VERSION3_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION3},
@@ -90,14 +90,14 @@
9090 // {PREF_PAGE_VERSION5_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION5},
9191 // {PREF_PAGE_VERSION6_LABEL, TomcatLauncherPlugin.TOMCAT_VERSION6},
9292
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}
9595 },
9696 composite, true);
9797
9898 Group homeGroup = new Group(composite, SWT.NONE);
9999 this.home = new DirectoryFieldEditor(
100- TomcatLauncherPlugin.TOMCAT_PREF_HOME_KEY,
100+ TomcatPluginResources.TOMCAT_PREF_HOME_KEY,
101101 PREF_PAGE_HOME_LABEL, homeGroup);
102102
103103 //blank
@@ -108,11 +108,11 @@
108108
109109 Composite configGroup = new Composite(modeGroup, SWT.NULL);
110110 this.configMode = new RadioGroupFieldEditor(
111- TomcatLauncherPlugin.TOMCAT_PREF_CONFMODE_KEY,
111+ TomcatPluginResources.TOMCAT_PREF_CONFMODE_KEY,
112112 PREF_PAGE_CHOOSECONFMODE_LABEL, 1,
113113 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},
116116 },
117117 configGroup, false);
118118
@@ -121,12 +121,12 @@
121121
122122 this.configLocationGroup = new Composite(modeGroup, SWT.NULL);
123123 this.configFile = new TomcatFileFieldEditor(
124- TomcatLauncherPlugin.TOMCAT_PREF_CONFIGFILE_KEY,
124+ TomcatPluginResources.TOMCAT_PREF_CONFIGFILE_KEY,
125125 PREF_PAGE_CONFIGFILE_LABEL,
126126 this.configLocationGroup);
127127
128128 this.contextsDir = new TomcatDirectoryFieldEditor(
129- TomcatLauncherPlugin.TOMCAT_PREF_CONTEXTSDIR_KEY,
129+ TomcatPluginResources.TOMCAT_PREF_CONTEXTSDIR_KEY,
130130 PREF_PAGE_CONTEXTSDIR_LABEL,
131131 this.configLocationGroup);
132132
@@ -145,7 +145,7 @@
145145 this.initField(this.home);
146146 this.initField(this.configMode);
147147 modeChanged(this.configLocationGroup,
148- getPreferenceStore().getString(TomcatLauncherPlugin.TOMCAT_PREF_CONFMODE_KEY));
148+ getPreferenceStore().getString(TomcatPluginResources.TOMCAT_PREF_CONFMODE_KEY));
149149
150150 this.configMode.setPropertyChangeListener(this);
151151
@@ -204,7 +204,7 @@
204204 this.contextsDir.store();
205205 TomcatLauncherPlugin.initTomcatClasspathVariable();
206206 try {
207- InstanceScope.INSTANCE.getNode(TomcatLauncherPlugin.PLUGIN_ID).flush();
207+ InstanceScope.INSTANCE.getNode(TomcatPluginResources.PLUGIN_ID).flush();
208208 } catch (final BackingStoreException e) {
209209 TomcatLauncherPlugin.log(e);
210210 return false;
@@ -225,7 +225,7 @@
225225
226226 try {
227227 for (final IProject project : root.getProjects()) {
228- if (project.hasNature(TomcatLauncherPlugin.NATURE_ID)) {
228+ if (project.hasNature(TomcatPluginResources.NATURE_ID)) {
229229 TomcatProject.create(project).addTomcatJarToProjectClasspath();
230230 }
231231 }
@@ -259,7 +259,7 @@
259259 private void computeContextsDir() {
260260 if (this.selectedVersion == null) {
261261 this.selectedVersion = TomcatLauncherPlugin.getDefault().getPreferenceStore().
262- getString(TomcatLauncherPlugin.TOMCAT_PREF_VERSION_KEY);
262+ getString(TomcatPluginResources.TOMCAT_PREF_VERSION_KEY);
263263 }
264264
265265 String contextDirName = this.home.getStringValue() + File.separator + "conf"
@@ -295,7 +295,7 @@
295295 * @param value String
296296 */
297297 private void modeChanged(final Composite composite, final String value) {
298- if (value.equals(TomcatLauncherPlugin.SERVERXML_MODE)) {
298+ if (value.equals(TomcatPluginResources.SERVERXML_MODE)) {
299299 this.contextsDir.setEnabled(false, composite);
300300 this.configFile.setEnabled(true, composite);
301301 } else {
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/ITomcatProject.java (nonexistent)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/ITomcatProject.java (revision 132)
@@ -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+}
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatLauncherPlugin.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatLauncherPlugin.java (revision 132)
@@ -8,9 +8,11 @@
88 import java.io.PrintWriter;
99 import java.io.StringWriter;
1010 import java.util.ArrayList;
11+import java.util.HashMap;
1112 import java.util.HashSet;
1213 import java.util.Iterator;
1314 import java.util.List;
15+import java.util.Map;
1416 import java.util.MissingResourceException;
1517 import java.util.ResourceBundle;
1618 import java.util.Set;
@@ -32,6 +34,8 @@
3234 import org.eclipse.jdt.core.IJavaProject;
3335 import org.eclipse.jdt.core.JavaCore;
3436 import org.eclipse.jdt.core.JavaModelException;
37+import org.eclipse.jdt.launching.IVMInstall;
38+import org.eclipse.jdt.launching.IVMInstallType;
3539 import org.eclipse.jdt.launching.JavaRuntime;
3640 import org.eclipse.jface.dialogs.MessageDialog;
3741 import org.eclipse.jface.preference.IPreferenceStore;
@@ -47,58 +51,12 @@
4751 */
4852 public class TomcatLauncherPlugin extends AbstractUIPlugin {
4953
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";
7154 /** TOMCAT_PREF_PROJECTSINCP_KEY */
72- static final String TOMCAT_PREF_PROJECTSINCP_KEY = "projectsInCp";
55+ private static final String TOMCAT_PREF_PROJECTSINCP_KEY = "projectsInCp";
7356 /** 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";
7958 /** 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";
10260 /** TOMCAT_HOME_CLASSPATH_VARIABLE */
10361 private static final String TOMCAT_HOME_CLASSPATH_VARIABLE = "TOMCAT_HOME";
10462 /** The shared instance. */
@@ -133,7 +91,7 @@
13391
13492 try {
13593 for (final IProject project : root.getProjects()) {
136- if (project.hasNature(NATURE_ID)) {
94+ if (project.hasNature(TomcatPluginResources.NATURE_ID)) {
13795 IJavaProject javaProject = JavaCore.create(project);
13896
13997 List<IClasspathEntry> cp = new ArrayList<>();
@@ -213,7 +171,7 @@
213171 */
214172 public static String getTomcatDir() {
215173 IPreferenceStore pref = PLUGIN.getPreferenceStore();
216- return pref.getString(TOMCAT_PREF_HOME_KEY);
174+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_HOME_KEY);
217175 }
218176
219177 /**
@@ -222,7 +180,7 @@
222180 */
223181 public static String getTomcatBase() {
224182 IPreferenceStore pref = PLUGIN.getPreferenceStore();
225- return pref.getString(TOMCAT_PREF_BASE_KEY);
183+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_BASE_KEY);
226184 }
227185
228186 /**
@@ -231,7 +189,7 @@
231189 */
232190 public static String getConfigFile() {
233191 IPreferenceStore pref = PLUGIN.getPreferenceStore();
234- return pref.getString(TOMCAT_PREF_CONFIGFILE_KEY);
192+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_CONFIGFILE_KEY);
235193 }
236194
237195 /**
@@ -240,7 +198,7 @@
240198 */
241199 public static String getConfigMode() {
242200 IPreferenceStore pref = PLUGIN.getPreferenceStore();
243- return pref.getString(TOMCAT_PREF_CONFMODE_KEY);
201+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_CONFMODE_KEY);
244202 }
245203
246204 /**
@@ -249,7 +207,7 @@
249207 */
250208 public static String getContextsDir() {
251209 IPreferenceStore pref = PLUGIN.getPreferenceStore();
252- return pref.getString(TOMCAT_PREF_CONTEXTSDIR_KEY);
210+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_CONTEXTSDIR_KEY);
253211 }
254212
255213 /**
@@ -258,7 +216,7 @@
258216 */
259217 public static String getTomcatVersion() {
260218 IPreferenceStore pref = PLUGIN.getPreferenceStore();
261- String result = pref.getString(TOMCAT_PREF_VERSION_KEY);
219+ String result = pref.getString(TomcatPluginResources.TOMCAT_PREF_VERSION_KEY);
262220 return result;
263221 }
264222
@@ -268,7 +226,7 @@
268226 */
269227 public static String getTomcatJRE() {
270228 IPreferenceStore pref = PLUGIN.getPreferenceStore();
271- String result = pref.getString(TOMCAT_PREF_JRE_KEY);
229+ String result = pref.getString(TomcatPluginResources.TOMCAT_PREF_JRE_KEY);
272230 if (result.isEmpty()) {
273231 result = JavaRuntime.getDefaultVMInstall().getId();
274232 }
@@ -281,7 +239,7 @@
281239 */
282240 public static boolean isDebugMode() {
283241 IPreferenceStore pref = PLUGIN.getPreferenceStore();
284- return !pref.getBoolean(TOMCAT_PREF_DEBUGMODE_KEY);
242+ return !pref.getBoolean(TomcatPluginResources.TOMCAT_PREF_DEBUGMODE_KEY);
285243 }
286244
287245 /**
@@ -299,7 +257,7 @@
299257 */
300258 public static boolean isSecurityManagerEnabled() {
301259 IPreferenceStore pref = PLUGIN.getPreferenceStore();
302- return pref.getBoolean(TOMCAT_PREF_SECURITYMANAGER);
260+ return pref.getBoolean(TomcatPluginResources.TOMCAT_PREF_SECURITYMANAGER);
303261 }
304262
305263 /**
@@ -308,7 +266,7 @@
308266 */
309267 public static String getJvmParamaters() {
310268 IPreferenceStore pref = PLUGIN.getPreferenceStore();
311- return pref.getString(TOMCAT_PREF_JVM_PARAMETERS_KEY);
269+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_JVM_PARAMETERS_KEY);
312270 }
313271
314272 /**
@@ -317,7 +275,7 @@
317275 */
318276 public static String getJvmClasspath() {
319277 IPreferenceStore pref = PLUGIN.getPreferenceStore();
320- return pref.getString(TOMCAT_PREF_JVM_CLASSPATH_KEY);
278+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_JVM_CLASSPATH_KEY);
321279 }
322280
323281 /**
@@ -326,7 +284,7 @@
326284 */
327285 public static String getJvmBootClasspath() {
328286 IPreferenceStore pref = PLUGIN.getPreferenceStore();
329- return pref.getString(TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY);
287+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_JVM_BOOTCLASSPATH_KEY);
330288 }
331289
332290 /**
@@ -334,7 +292,7 @@
334292 * @return TomcatBootstrap
335293 */
336294 public static TomcatBootstrap getTomcatBootstrap() {
337- TomcatBootstrap tomcatBootsrap = null;
295+ TomcatBootstrap tomcatBootstrap = null;
338296
339297 // if (getTomcatVersion().equals(TOMCAT_VERSION3)) {
340298 // tomcatBootsrap = new Tomcat3Bootstrap();
@@ -352,16 +310,43 @@
352310 // tomcatBootsrap = new Tomcat6Bootstrap();
353311 // }
354312
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]);
355317
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(),
358322 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(),
361336 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+
362347 }
363348
364- return tomcatBootsrap;
349+ return tomcatBootstrap;
365350 }
366351
367352 /**
@@ -370,7 +355,7 @@
370355 */
371356 public static String getManagerAppUrl() {
372357 IPreferenceStore pref = PLUGIN.getPreferenceStore();
373- return pref.getString(TOMCAT_PREF_MANAGER_URL);
358+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_MANAGER_URL);
374359 }
375360
376361 /**
@@ -379,7 +364,7 @@
379364 */
380365 public static String getManagerAppUser() {
381366 IPreferenceStore pref = PLUGIN.getPreferenceStore();
382- return pref.getString(TOMCAT_PREF_MANAGER_USER);
367+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_MANAGER_USER);
383368 }
384369
385370 /**
@@ -388,7 +373,7 @@
388373 */
389374 public static String getManagerAppPassword() {
390375 IPreferenceStore pref = PLUGIN.getPreferenceStore();
391- return pref.getString(TOMCAT_PREF_MANAGER_PASSWORD);
376+ return pref.getString(TomcatPluginResources.TOMCAT_PREF_MANAGER_PASSWORD);
392377 }
393378
394379 /**
@@ -484,7 +469,7 @@
484469 */
485470 public List<ProjectListElement> getProjectsInSourcePath() {
486471 IPreferenceStore pref = getPreferenceStore();
487- boolean automaticallyComputed = pref.getBoolean(TOMCAT_PREF_COMPUTESOURCEPATH_KEY);
472+ boolean automaticallyComputed = pref.getBoolean(TomcatPluginResources.TOMCAT_PREF_COMPUTESOURCEPATH_KEY);
488473 if (automaticallyComputed) {
489474 return computeProjectsInSourcePath();
490475 }
@@ -499,7 +484,7 @@
499484 IPreferenceStore pref = getPreferenceStore();
500485 if (!(pref.contains(TOMCAT_PREF_PROJECTSINSOURCEPATH_KEY))) {
501486 // Compute source path for a new workspace
502- pref.setValue(TOMCAT_PREF_COMPUTESOURCEPATH_KEY, true);
487+ pref.setValue(TomcatPluginResources.TOMCAT_PREF_COMPUTESOURCEPATH_KEY, true);
503488 return computeProjectsInSourcePath();
504489 }
505490 return readProjectsFromPreferenceStore(TOMCAT_PREF_PROJECTSINSOURCEPATH_KEY);
@@ -601,4 +586,113 @@
601586 super.start(context);
602587 fixTomcatHomeBug();
603588 }
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+ }
604698 }
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProjectChangeListener.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProjectChangeListener.java (revision 132)
@@ -12,6 +12,8 @@
1212 import org.eclipse.core.resources.IResourceChangeEvent;
1313 import org.eclipse.core.resources.IResourceChangeListener;
1414 import org.eclipse.core.runtime.CoreException;
15+import org.eclipse.jdt.core.IJavaProject;
16+import org.eclipse.jdt.core.JavaCore;
1517 import org.eclipse.jface.dialogs.IDialogConstants;
1618 import org.eclipse.jface.dialogs.MessageDialog;
1719 import org.eclipse.jface.window.Window;
@@ -31,7 +33,7 @@
3133 @Override
3234 public void resourceChanged(final IResourceChangeEvent event) {
3335 if (event.getResource() instanceof IProject) {
34- final TomcatProject project = TomcatProject.create((IProject)event.getResource());
36+ final ITomcatProject project = create((IProject)event.getResource());
3537 if (project != null) {
3638 Display.getDefault().syncExec(new Runnable() {
3739 @Override
@@ -47,7 +49,7 @@
4749 try {
4850 project.removeContext();
4951 } catch (final CoreException ex) {
50- ex.printStackTrace();
52+ ex.printStackTrace(System.err);
5153 }
5254 }
5355 }
@@ -56,4 +58,28 @@
5658 }
5759 }
5860 }
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+ }
5985 }
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatJVMPreferencePage.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatJVMPreferencePage.java (revision 132)
@@ -83,10 +83,10 @@
8383
8484 String[][] namesAndValues = collectAllJres();
8585 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);
8787
8888 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);
9090 initField(this.debugModeEditor);
9191
9292 new Label(composite, SWT.NULL);
@@ -106,11 +106,11 @@
106106 this.btLog.addSelectionListener(this);
107107
108108 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);
110110 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);
112112 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);
114114
115115 initField(this.jvmChoice);
116116 initField(this.jvmParamaters);
@@ -188,7 +188,7 @@
188188 this.debugModeEditor.store();
189189
190190 try {
191- InstanceScope.INSTANCE.getNode(TomcatLauncherPlugin.PLUGIN_ID).flush();
191+ InstanceScope.INSTANCE.getNode(TomcatPluginResources.PLUGIN_ID).flush();
192192 } catch (final BackingStoreException e) {
193193 TomcatLauncherPlugin.log(e);
194194 return false;
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatPluginResources.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatPluginResources.java (revision 132)
@@ -11,6 +11,52 @@
1111 */
1212 public final class TomcatPluginResources {
1313
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+
1460 /** WIZARD_PROJECT_TITLE */
1561 public static final String WIZARD_PROJECT_TITLE =
1662 TomcatLauncherPlugin.getResourceString("wizard.project.title");
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat3Bootstrap.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat3Bootstrap.java (revision 132)
@@ -27,9 +27,9 @@
2727 public String[] getClasspath() {
2828 String[] classpath = new String[1];
2929
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;
3333
3434 File libDir = new File(getTomcatDir() + File.separator + "lib");
3535 classpath = addJarsOfDirectory(classpath, libDir);
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat4Bootstrap.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat4Bootstrap.java (revision 132)
@@ -25,11 +25,11 @@
2525 ArrayList<String> classpath = new ArrayList<>();
2626 classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar");
2727 // 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+ // }
3333 return classpath.toArray(new String[classpath.size()]);
3434 }
3535
@@ -63,7 +63,7 @@
6363 @Override
6464 public String[] getPrgArgs(final String command) {
6565 String[] prgArgs;
66- if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) {
66+ if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) {
6767 prgArgs = new String[3];
6868 prgArgs[0] = command;
6969 prgArgs[1] = "-config";
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat5Bootstrap.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat5Bootstrap.java (revision 132)
@@ -25,11 +25,11 @@
2525 ArrayList<String> classpath = new ArrayList<>();
2626 classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar");
2727 // 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+ // }
3333 return classpath.toArray(new String[classpath.size()]);
3434 }
3535
@@ -63,7 +63,7 @@
6363 @Override
6464 public String[] getPrgArgs(final String command) {
6565 String[] prgArgs;
66- if (TomcatLauncherPlugin.getConfigMode().equals(TomcatLauncherPlugin.SERVERXML_MODE)) {
66+ if (TomcatLauncherPlugin.getConfigMode().equals(TomcatPluginResources.SERVERXML_MODE)) {
6767 prgArgs = new String[3];
6868 prgArgs[0] = "-config";
6969 prgArgs[1] = "\"" + TomcatLauncherPlugin.getConfigFile() + "\"";
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat6Bootstrap.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat6Bootstrap.java (revision 132)
@@ -51,7 +51,7 @@
5151 ArrayList<String> classpath = new ArrayList<>();
5252 classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar");
5353 // Add tools.jar JDK file to classpath
54- String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation()
54+ String toolsJarLocation = super.getVmInstalled().getInstallLocation()
5555 + File.separator + "lib" + File.separator + "tools.jar";
5656 if (new File(toolsJarLocation).exists()) {
5757 classpath.add(toolsJarLocation);
@@ -184,8 +184,8 @@
184184 * @return Collection<IClasspathEntry>
185185 */
186186 @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));
189189 jars.add(JavaCore.newVariableEntry(this.tomcatHomePath.append(getElJarPath()), null, null));
190190 jars.add(JavaCore.newVariableEntry(this.tomcatHomePath.append(getAnnotationsJarPath()), null, null));
191191 return jars;
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat7Bootstrap.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/Tomcat7Bootstrap.java (revision 132)
@@ -31,7 +31,7 @@
3131 classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "bootstrap.jar");
3232 classpath.add(getTomcatDir() + File.separator + "bin" + File.separator + "tomcat-juli.jar");
3333 // Add tools.jar JDK file to classpath
34- String toolsJarLocation = VMLauncherUtility.getVMInstall().getInstallLocation()
34+ String toolsJarLocation = super.getVmInstalled().getInstallLocation()
3535 + File.separator + "lib" + File.separator + "tools.jar";
3636 if (new File(toolsJarLocation).exists()) {
3737 classpath.add(toolsJarLocation);
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatManagerAppPreferencePage.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatManagerAppPreferencePage.java (revision 132)
@@ -5,11 +5,11 @@
55
66 package com.sysdeo.eclipse.tomcat;
77
8+import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_ADDUSER;
89 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_BANNER;
10+import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_PASSWORD;
911 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PREF_PAGE_MANAGER_URL;
1012 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;
1313
1414 import java.io.File;
1515 import java.io.IOException;
@@ -68,7 +68,7 @@
6868 new Label(getFieldEditorParent(), SWT.NULL);
6969
7070 this.urlEditor = new StringFieldEditor(
71- TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_URL,
71+ TomcatPluginResources.TOMCAT_PREF_MANAGER_URL,
7272 PREF_PAGE_MANAGER_URL,
7373 getFieldEditorParent());
7474 addField(this.urlEditor);
@@ -77,13 +77,13 @@
7777 new Label(getFieldEditorParent(), SWT.NULL);
7878
7979 this.userEditor = new StringFieldEditor(
80- TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_USER,
80+ TomcatPluginResources.TOMCAT_PREF_MANAGER_USER,
8181 PREF_PAGE_MANAGER_USER,
8282 getFieldEditorParent());
8383 addField(this.userEditor);
8484
8585 this.pwdEditor = new StringFieldEditor(
86- TomcatLauncherPlugin.TOMCAT_PREF_MANAGER_PASSWORD,
86+ TomcatPluginResources.TOMCAT_PREF_MANAGER_PASSWORD,
8787 PREF_PAGE_MANAGER_PASSWORD,
8888 getFieldEditorParent());
8989 addField(this.pwdEditor);
@@ -100,8 +100,8 @@
100100 */
101101 @Override
102102 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,
105105 DEFAULT_MANAGER_URL);
106106 }
107107 }
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatSourcePathPreferencePage.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatSourcePathPreferencePage.java (revision 132)
@@ -52,7 +52,7 @@
5252 composite.setLayout(new GridLayout());
5353
5454 this.automaticEditor = new BooleanFieldEditor(
55- TomcatLauncherPlugin.TOMCAT_PREF_COMPUTESOURCEPATH_KEY,
55+ TomcatPluginResources.TOMCAT_PREF_COMPUTESOURCEPATH_KEY,
5656 PREF_PAGE_COMPUTESOURCEPATH_LABEL,
5757 composite);
5858 this.initField(this.automaticEditor);
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/PreferenceInitializer.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/PreferenceInitializer.java (revision 132)
@@ -26,6 +26,6 @@
2626 @Override
2727 public void initializeDefaultPreferences() {
2828 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);
3030 }
3131 }
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatBootstrap.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatBootstrap.java (revision 132)
@@ -11,8 +11,10 @@
1111 import java.nio.charset.StandardCharsets;
1212 import java.util.ArrayList;
1313 import java.util.Collection;
14-import java.util.Iterator;
14+import java.util.Collections;
1515 import java.util.List;
16+import java.util.Map;
17+import java.util.Map.Entry;
1618
1719 import org.eclipse.core.resources.IFile;
1820 import org.eclipse.core.resources.IProject;
@@ -21,12 +23,13 @@
2123 import org.eclipse.core.runtime.CoreException;
2224 import org.eclipse.core.runtime.IPath;
2325 import org.eclipse.core.runtime.Path;
26+import org.eclipse.debug.core.ILaunch;
2427 import org.eclipse.jdt.core.IClasspathContainer;
2528 import org.eclipse.jdt.core.IClasspathEntry;
2629 import org.eclipse.jdt.core.IJavaProject;
2730 import org.eclipse.jdt.core.JavaCore;
2831 import org.eclipse.jdt.core.JavaModelException;
29-import org.eclipse.jdt.launching.JavaRuntime;
32+import org.eclipse.jdt.launching.IVMInstall;
3033
3134 import com.sysdeo.eclipse.tomcat.editors.ProjectListElement;
3235
@@ -45,8 +48,122 @@
4548 /** ADD_LAUNCH */
4649 private static final int ADD_LAUNCH = 3;
4750
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+
4870 /**
71+ * set DebugMode
72+ * @param val DebugMode
73+ */
74+ public void setDebugMode(final boolean val) {
75+ this.debugMode = val;
76+ }
77+
78+ /**
4979 *
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+ *
50167 * @return String[]
51168 */
52169 public abstract String[] getClasspath();
@@ -127,10 +244,10 @@
127244
128245 /**
129246 *
247+ * @param tomcatHomePath IPath
130248 * @return Collection<IClasspathEntry>
131249 */
132- public Collection<IClasspathEntry> getTomcatJars() {
133- IPath tomcatHomePath = TomcatLauncherPlugin.getTomcatIPath();
250+ public Collection<IClasspathEntry> getTomcatJars(final IPath tomcatHomePath) {
134251 ArrayList<IClasspathEntry> jars = new ArrayList<>();
135252
136253 if (getServletJarPath() != null) {
@@ -182,7 +299,7 @@
182299 Thread.sleep(5000);
183300 } catch (final InterruptedException ex) {
184301 Thread.interrupted();
185- TomcatLauncherPlugin.log(ex);
302+ ex.printStackTrace(System.err);
186303 }
187304
188305 start();
@@ -216,37 +333,31 @@
216333 private void runTomcatBootsrap(final String tomcatBootOption, final int action,
217334 final boolean saveConfig) throws CoreException {
218335
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)) {
222343 continue;
223344 }
224345
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);
239355 }
240356 }
241357
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);
245360
246- String[] vmArgs = addPreferenceParameters(getVmArgs());
247-
248- String[] bootClasspath = addPreferenceJvmToBootClasspath(new String[0]);
249-
250361 String[] prgArgs = getPrgArgs(tomcatBootOption);
251362 StringBuilder programArguments = new StringBuilder();
252363 for (final String arg : prgArgs) {
@@ -254,20 +365,24 @@
254365 }
255366
256367 StringBuilder jvmArguments = new StringBuilder();
257- for (final String arg : vmArgs) {
368+ for (final String arg : args) {
258369 jvmArguments.append(" ").append(arg);
259370 }
260371
261372 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(),
271386 jvmArguments.toString(), programArguments.toString(), true);
272387 }
273388 }
@@ -278,7 +393,7 @@
278393 * @param project IProject
279394 * @param al ArrayList<String>
280395 */
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) {
282397 IFile file = null;
283398 if (tomcatProject.getRootDirFolder() == null) {
284399 file = project.getFile(new Path(WEBAPP_CLASSPATH_FILENAME));
@@ -338,21 +453,18 @@
338453 * @param data ArrayList<String>
339454 * @param selectedPaths List<String>
340455 * @param visitedProjects ArrayList<String>
456+ * @throws JavaModelException JavaModelException
341457 */
342458 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));
354464 }
355465
466+ IClasspathEntry[] entries = prj.getRawClasspath();
467+
356468 if (entries != null) {
357469 getClassPathEntries(entries, prj, data, selectedPaths, visitedProjects, outputPath);
358470 }
@@ -366,10 +478,11 @@
366478 * @param selectedPaths List<String>
367479 * @param visitedProjects ArrayList<String>
368480 * @param outputPath IPath
481+ * @throws JavaModelException JavaModelException
369482 */
370483 private void getClassPathEntries(final IClasspathEntry[] entries, final IJavaProject prj,
371484 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 {
373486 for (final IClasspathEntry entry : entries) {
374487 IPath path = entry.getPath();
375488 if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
@@ -413,7 +526,6 @@
413526 add(data, prj.getProject().getWorkspace().getRoot().findMember(srcPath));
414527 }
415528 } else {
416- TomcatLauncherPlugin.log(">>> " + tmp);
417529 if (tmp.getPath() != null) {
418530 add(data, tmp.getPath());
419531 }
@@ -430,19 +542,17 @@
430542 * @param selectedPaths List<String>
431543 * @param visitedProjects ArrayList<String>
432544 * @param outputPath IPath
545+ * @throws JavaModelException JavaModelException
433546 */
434547 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 {
436550 // entires in container are only processed individually
437551 // 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);
446556 }
447557 }
448558
@@ -452,15 +562,13 @@
452562 * @param path IPath
453563 * @param prj IJavaProject
454564 * @return IClasspathEntry[]
565+ * @throws JavaModelException JavaModelException
455566 */
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 {
457569 IClasspathEntry[] tmpEntry = null;
458570 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();
464572 } else {
465573 tmpEntry = new IClasspathEntry[1];
466574 tmpEntry[0] = JavaCore.getResolvedClasspathEntry(entry);
@@ -467,98 +575,4 @@
467575 }
468576 return tmpEntry;
469577 }
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- }
564578 }
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/VMLauncherUtility.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/VMLauncherUtility.java (revision 132)
@@ -36,7 +36,6 @@
3636 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
3737 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
3838 import org.eclipse.jdt.launching.IVMInstall;
39-import org.eclipse.jdt.launching.IVMInstallType;
4039 import org.eclipse.jdt.launching.JavaRuntime;
4140 import org.eclipse.jdt.launching.sourcelookup.containers.JavaProjectSourceContainer;
4241 import org.eclipse.jdt.launching.sourcelookup.containers.PackageFragmentRootSourceContainer;
@@ -49,16 +48,41 @@
4948 * It might exist better way to implements those operations,
5049 * or they might already exist in other form JDT
5150 */
52-public final class VMLauncherUtility {
51+public class VMLauncherUtility {
5352
5453 /** ILAUNCH */
5554 private static ILaunch ilaunch = null;
5655
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+
5769 /**
5870 * 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>
5977 */
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;
6286 }
6387
6488 /**
@@ -70,18 +94,10 @@
7094 }
7195
7296 /**
73- *
74- * @return VMInstall
97+ * @param val the ilaunch to set
7598 */
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;
85101 }
86102
87103 /**
@@ -88,16 +104,14 @@
88104 *
89105 * @param label String
90106 * @param classToLaunch String
91- * @param classpath String[]
92- * @param bootClasspath String[]
93107 * @param vmArgs String
94108 * @param prgArgs String
95109 * @param debug boolean
96110 * @param saveConfig boolean
111+ * @return ILaunch
97112 * @throws CoreException CoreException
98113 */
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,
101115 final boolean debug, final boolean saveConfig) throws CoreException {
102116
103117 String mode = "";
@@ -107,9 +121,8 @@
107121 mode = ILaunchManager.RUN_MODE;
108122 }
109123
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);
113126 }
114127
115128 /**
@@ -116,37 +129,29 @@
116129 *
117130 * @param label String
118131 * @param classToLaunch String
119- * @param classpath String[]
120- * @param bootClasspath String[]
121132 * @param vmArgs String
122133 * @param prgArgs String
134+ * @throws CoreException CoreException
123135 */
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 {
126138 StringBuilder trace = new StringBuilder("\n-------- Sysdeo Tomcat Launcher settings --------");
127139 trace.append("\n-> Label : ").append(label);
128140 trace.append("\n-> ClassToLaunch : ").append(classToLaunch);
129141 trace.append("\n-> Classpath : ");
130- for (final String path : classpath) {
142+ for (final String path : this.classpath) {
131143 trace.append(" | ").append(path).append(" | ");
132144 }
133145 trace.append("\n-> BootClasspath : ");
134- for (final String boot : bootClasspath) {
146+ for (final String boot : this.bootClasspath) {
135147 trace.append(" | ").append(boot).append(" | ");
136148 }
137149 trace.append("\n-> Vmargs : ").append(vmArgs);
138150 trace.append("\n-> PrgArgs : ").append(prgArgs);
139151 trace.append("\n-> Source lookup : \n");
140- TomcatLauncherPlugin.log(trace.toString());
141152
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();
150155 }
151156
152157 /**
@@ -153,8 +158,6 @@
153158 *
154159 * @param label String
155160 * @param classToLaunch String
156- * @param classpath String[]
157- * @param bootClasspath String[]
158161 * @param vmArgs String
159162 * @param prgArgs String
160163 * @param saveConfig boolean
@@ -161,8 +164,8 @@
161164 * @return ILaunchConfigurationWorkingCopy
162165 * @throws CoreException CoreException
163166 */
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,
166169 final boolean saveConfig) throws CoreException {
167170
168171 ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(
@@ -172,28 +175,28 @@
172175 config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID,
173176 "org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector");
174177
175- ISourceLookupDirector locator = (ISourceLookupDirector) getSourceLocator(false);
178+ ISourceLookupDirector locator = (ISourceLookupDirector) getSourceLocator();
176179 config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento());
177180
178- IVMInstall vmInstall = getVMInstall();
181+ IVMInstall vmInstall = this.vmInstalled;
179182 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE,
180183 vmInstall.getVMInstallType().getId());
181184 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, vmInstall.getName());
182185 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
183186 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
184- getClasspathMementos(classpath, bootClasspath));
187+ getClasspathMementos(this.classpath, this.bootClasspath));
185188 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, prgArgs);
186189 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs);
187190 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, classToLaunch);
188191
189- String catalinaBase = TomcatLauncherPlugin.getTomcatBase();
192+ String catalinaBase = this.tomcatBase;
190193 if (catalinaBase.isEmpty()) {
191- catalinaBase = TomcatLauncherPlugin.getTomcatDir();
194+ catalinaBase = this.tomcatDir;
192195 }
193196 config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, catalinaBase);
194197
195198 if (saveConfig) {
196- getSourceLocator(false);
199+ getSourceLocator();
197200 config.doSave();
198201 }
199202
@@ -218,15 +221,11 @@
218221
219222 if (bootClasspath.length == 0) {
220223 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());
230229
231230 } else {
232231 for (final String boot : bootClasspath) {
@@ -241,16 +240,15 @@
241240
242241 /**
243242 *
244- * @param trace boolean
245243 * @return SourceLocator
246244 * @throws CoreException CoreException
247245 */
248- private static ISourceLocator getSourceLocator(final boolean trace) throws CoreException {
246+ private ISourceLocator getSourceLocator() throws CoreException {
249247 ArrayList<IProjectNature> tempList = new ArrayList<>();
250248 StringBuilder traceBuffer = new StringBuilder();
251249 traceBuffer.append("Projects in source path :\n");
252250
253- for (final ProjectListElement element : TomcatLauncherPlugin.getDefault().getProjectsInSourcePath()) {
251+ for (final ProjectListElement element : this.elements) {
254252 IProject project = element.getProject();
255253 traceBuffer.append("Project " + project.getName());
256254 if ((project.isOpen()) && project.hasNature(JavaCore.NATURE_ID)) {
@@ -266,9 +264,6 @@
266264 sourceLocator.setSourceContainers(getSourceContainers(tempList, traceBuffer));
267265 sourceLocator.initializeParticipants();
268266
269- if (trace) {
270- TomcatLauncherPlugin.log(traceBuffer.toString());
271- }
272267 return sourceLocator;
273268 }
274269
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/AdvancedPreferencePage.java (revision 131)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/AdvancedPreferencePage.java (revision 132)
@@ -58,19 +58,19 @@
5858
5959 Group homeGroup = new Group(composite, SWT.NONE);
6060 this.base = new DirectoryFieldEditor(
61- TomcatLauncherPlugin.TOMCAT_PREF_BASE_KEY,
61+ TomcatPluginResources.TOMCAT_PREF_BASE_KEY,
6262 PREF_PAGE_BASE_LABEL, homeGroup);
6363 initLayoutAndData(homeGroup, 3);
6464
6565 Group securityGroup = new Group(composite, SWT.NONE);
6666 this.securityEditor = new BooleanFieldEditor(
67- TomcatLauncherPlugin.TOMCAT_PREF_SECURITYMANAGER,
67+ TomcatPluginResources.TOMCAT_PREF_SECURITYMANAGER,
6868 PREF_PAGE_SECURITYMANAGER_LABEL, securityGroup);
6969 initField(this.securityEditor);
7070 initLayoutAndData(securityGroup, 1);
7171
7272 Group projectListGroup = new Group(composite, SWT.NONE);
73- String[] excludedProjectsNature = {TomcatLauncherPlugin.NATURE_ID};
73+ String[] excludedProjectsNature = {TomcatPluginResources.NATURE_ID};
7474 this.projectListEditor = new ProjectListEditor(excludedProjectsNature);
7575 this.projectListEditor.setLabel(PREF_PAGE_PROJECTINCP_LABEL);
7676 Control projectList = this.projectListEditor.getControl(projectListGroup);
@@ -104,7 +104,7 @@
104104 this.securityEditor.store();
105105 TomcatLauncherPlugin.setProjectsInCP(this.projectListEditor.getCheckedElements());
106106 try {
107- InstanceScope.INSTANCE.getNode(TomcatLauncherPlugin.PLUGIN_ID).flush();
107+ InstanceScope.INSTANCE.getNode(TomcatPluginResources.PLUGIN_ID).flush();
108108 } catch (final BackingStoreException e) {
109109 TomcatLauncherPlugin.log(e);
110110 return false;