• 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

Revision190 (tree)
Time2016-01-02 01:31:14
Authort_nakayama1971

Log Message

add workdir property

Change Summary

Incremental Difference

--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProject.java (revision 189)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProject.java (revision 190)
@@ -27,6 +27,7 @@
2727 import org.eclipse.core.runtime.CoreException;
2828 import org.eclipse.core.runtime.IPath;
2929 import org.eclipse.core.runtime.IStatus;
30+import org.eclipse.core.runtime.Path;
3031 import org.eclipse.core.runtime.PlatformObject;
3132 import org.eclipse.core.runtime.QualifiedName;
3233 import org.eclipse.core.runtime.Status;
@@ -58,6 +59,8 @@
5859 private static final String KEY_WARLOCATION = "warLocation";
5960 /** KEY_ROOTDIR */
6061 private static final String KEY_ROOTDIR = "rootDir";
62+ /** KEY_WORKDIR */
63+ private static final String KEY_WORKDIR = "workDir";
6164 /** KEY_EXTRAINFO */
6265 private static final String KEY_EXTRAINFO = "extraInfo";
6366 /** EXTRA_BEGIN_TAG */
@@ -76,6 +79,8 @@
7679 private String warLocation = "";
7780 /** rootDir */
7881 private String rootDir = "";
82+ /** workDir */
83+ private String workDir = "";
7984 /** extraInfo */
8085 private String extraInfo = "";
8186 /** updateXml */
@@ -255,6 +260,22 @@
255260 }
256261
257262 /**
263+ * Gets the workDir.
264+ * @return Returns a String
265+ */
266+ public String getWorkDir() {
267+ return readProperty(KEY_WORKDIR);
268+ }
269+
270+ /**
271+ * Sets the workDir.
272+ * @param wd The workDir to set
273+ */
274+ public void setWorkDir(final String wd) {
275+ this.workDir = wd;
276+ }
277+
278+ /**
258279 * Gets the webpath.
259280 * @return Returns a String
260281 */
@@ -426,6 +447,7 @@
426447 fileContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
427448 fileContent.append("<tomcatProjectProperties>\n");
428449 fileContent.append(" <rootDir>" + this.rootDir + "</rootDir>\n");
450+ fileContent.append(" <workDir>" + this.workDir + "</workDir>\n");
429451 fileContent.append(" <exportSource>" + this.exportSource + "</exportSource>\n");
430452 fileContent.append(" <reloadable>" + this.reloadable + "</reloadable>\n");
431453 fileContent.append(" <redirectLogger>" + this.redirectLogger + "</redirectLogger>\n");
@@ -550,15 +572,12 @@
550572 *
551573 * @return IFolder
552574 */
553- public IFolder getWorkFolder() {
554- // TODO:
555- // if (getRootDirFolder() == null) {
556- // return project.getFolder("work");
557- // } else {
558- // return getRootDirFolder().getFolder("work");
559- // }
560-
561- return this.project.getFolder("work");
575+ public IPath getWorkFolder() {
576+ String workFolder = getWorkDir();
577+ if (workFolder.isEmpty()) {
578+ workFolder = TomcatLauncherPlugin.getTomcatDir() + "/work";
579+ }
580+ return new Path(workFolder);
562581 }
563582
564583 /**
@@ -627,11 +646,17 @@
627646 * @throws CoreException CoreException
628647 */
629648 public void createWorkFolder() throws CoreException {
630- IFolder folderHandle = getWorkFolder();
631- createFolder(folderHandle);
649+ IPath folderHandle = getWorkFolder();
650+ if (!folderHandle.toFile().exists()) {
651+ if (!folderHandle.toFile().mkdirs()) {
652+ throw new CoreException(new Status(IStatus.ERROR,
653+ TomcatLauncherPlugin.getDefault().getBundle().getSymbolicName(),
654+ " create directory failed.:" + folderHandle.toFile().toString()));
655+ }
656+ }
632657
633658 // Add a .cvsignore file in work directory
634- createFile(this.project.getFile(".cvsignore"), "work");
659+ //createFile(this.project.getFile(".cvsignore"), "work");
635660 }
636661
637662 /**
@@ -677,12 +702,10 @@
677702 try {
678703 // Create the folder resource in the workspace
679704 folderHandle.create(false, true, null);
680- //new SubProgressMonitor(monitor, 500));
681705 } catch (final CoreException e) {
682706 // If the folder already existed locally, just refresh to get contents
683707 if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED) {
684708 folderHandle.refreshLocal(IResource.DEPTH_INFINITE, null);
685- //new SubProgressMonitor(monitor, 500));
686709 }
687710 throw e;
688711 }
@@ -701,7 +724,6 @@
701724 // If the file already existed locally, just refresh to get contents
702725 if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED) {
703726 fileHandle.refreshLocal(IResource.DEPTH_INFINITE, null);
704- //new SubProgressMonitor(monitor, 500));
705727 }
706728 throw e;
707729 }
@@ -715,16 +737,26 @@
715737 * @throws CoreException CoreException
716738 */
717739 private void setFolderAsSourceEntry(final IFolder folderHandle, final IFolder output) throws CoreException {
718- IClasspathEntry[] entries = this.javaProject.getRawClasspath();
719- IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
720- System.arraycopy(entries, 0, newEntries, 0, entries.length);
721740 IPath outputPath = null;
722741 if (output != null) {
723742 outputPath = output.getFullPath();
724743 }
744+ setFolderAsSourceEntry(folderHandle.getFullPath(), outputPath);
745+ }
725746
747+
748+ /**
749+ * ouput could be null (project default output will be used)
750+ * @param folderPath IPath
751+ * @param outputPath IPath
752+ * @throws CoreException CoreException
753+ */
754+ private void setFolderAsSourceEntry(final IPath folderPath, final IPath outputPath) throws CoreException {
755+ IClasspathEntry[] entries = this.javaProject.getRawClasspath();
756+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
757+ System.arraycopy(entries, 0, newEntries, 0, entries.length);
726758 IPath[] emptyPath = {};
727- newEntries[entries.length] = JavaCore.newSourceEntry(folderHandle.getFullPath(), emptyPath, outputPath);
759+ newEntries[entries.length] = JavaCore.newSourceEntry(folderPath, emptyPath, outputPath);
728760
729761 this.javaProject.setRawClasspath(newEntries, null);
730762 }
@@ -1435,10 +1467,7 @@
14351467 * @return String
14361468 */
14371469 private String getContextWorkDir() {
1438- String workFolderLocation = TomcatLauncherPlugin.getTomcatDir() + "/work";
1439- if (getWorkFolder().exists()) {
1440- workFolderLocation = getWorkFolder().getLocation().toOSString();
1441- }
1470+ String workFolderLocation = getWorkFolder().toOSString();
14421471 return TomcatLauncherPlugin.getTomcatBootstrap().getContextWorkDir(workFolderLocation);
14431472 }
14441473
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProjectGeneralPropertyPage.java (revision 189)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatProjectGeneralPropertyPage.java (revision 190)
@@ -5,6 +5,7 @@
55
66 package com.sysdeo.eclipse.tomcat;
77
8+import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.NATURE_ID;
89 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PROPERTIES_PAGE_PROJECT_EXTRAINFO_LABEL;
910 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.PROPERTIES_PAGE_PROJECT_ISTOMCATPROJECT_LABEL;
1011 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.WIZARD_PROJECT_REDIRECTLOGGER_LABEL;
@@ -12,9 +13,11 @@
1213 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.WIZARD_PROJECT_ROOTDIR_LABEL;
1314 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.WIZARD_PROJECT_UPDATEXML_LABEL;
1415 import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.WIZARD_PROJECT_WEBPATH_LABEL;
16+import static com.sysdeo.eclipse.tomcat.TomcatPluginResources.WIZARD_PROJECT_WORKDIR_LABEL;
1517
1618 import org.eclipse.core.runtime.CoreException;
1719 import org.eclipse.jdt.core.IJavaProject;
20+import org.eclipse.jface.preference.DirectoryFieldEditor;
1821 import org.eclipse.swt.SWT;
1922 import org.eclipse.swt.layout.GridData;
2023 import org.eclipse.swt.layout.GridLayout;
@@ -48,6 +51,8 @@
4851 private Text rootDirText;
4952 /** extraInfoText */
5053 private Text extraInfoText;
54+ /** DirectoryFieldEditor */
55+ private DirectoryFieldEditor workDir;
5156
5257 /** IJavaProject */
5358 private final IJavaProject javaProject;
@@ -80,10 +85,6 @@
8085 createWebpathGroup(group);
8186 createExtraInformationGroup(group);
8287
83- //blank
84- Label lbl = new Label(group, SWT.NULL);
85- lbl.setParent(composite);
86-
8788 createRootDirGroup(group);
8889
8990 return composite;
@@ -104,8 +105,7 @@
104105 this.isTomcatProjectCheck.setEnabled(true);
105106
106107 try {
107- this.isTomcatProjectCheck.setSelection(
108- this.javaProject.getProject().hasNature(TomcatPluginResources.NATURE_ID));
108+ this.isTomcatProjectCheck.setSelection(this.javaProject.getProject().hasNature(NATURE_ID));
109109 } catch (final CoreException ex) {
110110 TomcatLauncherPlugin.log(ex.getMessage());
111111 }
@@ -171,6 +171,14 @@
171171 * @param parent Composite
172172 */
173173 public void createRootDirGroup(final Composite parent) {
174+ Composite workDirGroup = new Composite(parent, SWT.NONE);
175+ workDirGroup.setLayout(new GridLayout(3, false));
176+ workDirGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
177+
178+ this.workDir = new DirectoryFieldEditor("",
179+ WIZARD_PROJECT_WORKDIR_LABEL, workDirGroup);
180+ this.workDir.setStringValue(getWorkDir());
181+
174182 Composite rootDirGroup = new Composite(parent, SWT.NONE);
175183 rootDirGroup.setLayout(new GridLayout(2, false));
176184 rootDirGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -242,6 +250,19 @@
242250
243251 /**
244252 *
253+ * @return WorkDir
254+ */
255+ protected String getWorkDir() {
256+ String result = "";
257+ TomcatProject prj = this.tomcatProject;
258+ if (prj != null) {
259+ result = prj.getWorkDir();
260+ }
261+ return result;
262+ }
263+
264+ /**
265+ *
245266 * @return ExtraInfo
246267 */
247268 protected String getExtraInfo() {
@@ -307,6 +328,7 @@
307328 prj.setRedirectLogger(this.redirectLoggerCheck.getSelection());
308329 prj.setExtraInfo(this.extraInfoText.getText());
309330 prj.setRootDir(this.rootDirText.getText());
331+ prj.setWorkDir(this.workDir.getStringValue());
310332 prj.saveProperties();
311333 } else {
312334 this.tomcatProject.removeContext();
--- trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatPluginResources.java (revision 189)
+++ trunk/plugin/com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/TomcatPluginResources.java (revision 190)
@@ -164,6 +164,9 @@
164164 /** WIZARD_PROJECT_WEBPATH_LABEL */
165165 public static final String WIZARD_PROJECT_WEBPATH_LABEL =
166166 TomcatLauncherPlugin.getResourceString("wizard.project.webpath.label");
167+ /** WIZARD_PROJECT_WORKDIR_LABEL */
168+ public static final String WIZARD_PROJECT_WORKDIR_LABEL =
169+ TomcatLauncherPlugin.getResourceString("wizard.project.workdir.label");
167170 /** WIZARD_PROJECT_ROOTDIR_LABEL */
168171 public static final String WIZARD_PROJECT_ROOTDIR_LABEL =
169172 TomcatLauncherPlugin.getResourceString("wizard.project.rootdir.label");