Author: adietish
Date: 2010-09-02 12:01:38 -0400 (Thu, 02 Sep 2010)
New Revision: 24668
Modified:
trunk/gwt/plugins/org.jboss.tools.gwt.core/META-INF/MANIFEST.MF
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/GWTInstallFacetDelegate.java
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/IGoogleEclipsePluginConstants.java
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/util/ProjectUtils.java
Log:
[JBIDE-6954] throws now exceptions correctly
Modified: trunk/gwt/plugins/org.jboss.tools.gwt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/gwt/plugins/org.jboss.tools.gwt.core/META-INF/MANIFEST.MF 2010-09-02 15:49:03
UTC (rev 24667)
+++ trunk/gwt/plugins/org.jboss.tools.gwt.core/META-INF/MANIFEST.MF 2010-09-02 16:01:38
UTC (rev 24668)
@@ -26,4 +26,5 @@
Export-Package: org.jboss.tools.gwt.core,
org.jboss.tools.gwt.core.util
Bundle-ActivationPolicy: lazy
+Import-Package: org.jboss.tools.common.model.project
Modified:
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/GWTInstallFacetDelegate.java
===================================================================
---
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/GWTInstallFacetDelegate.java 2010-09-02
15:49:03 UTC (rev 24667)
+++
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/GWTInstallFacetDelegate.java 2010-09-02
16:01:38 UTC (rev 24668)
@@ -48,8 +48,10 @@
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.log.LogHelper;
+import org.jboss.tools.common.model.project.ProjectHome;
import org.jboss.tools.gwt.core.internal.GWTCoreActivator;
import org.jboss.tools.gwt.core.util.ProjectUtils;
+import org.jboss.tools.usage.util.StatusUtils;
import org.osgi.service.prefs.BackingStoreException;
/**
@@ -60,38 +62,27 @@
public void execute(IProject project, IProjectFacetVersion projectFacetVersion, Object
config,
IProgressMonitor monitor) throws CoreException {
try {
-
- GWTInstallDataModelProvider dataModel = (GWTInstallDataModelProvider) config;
IJavaProject javaProject = JavaCore.create(project);
addNature(javaProject, monitor);
-
addClasspathContainer(javaProject, monitor);
- IPath webContentPath = ProjectUtils.getWebContentRootPath(javaProject.getProject());
+ IPath webContentPath = ProjectHome.getFirstWebContentPath(project);
+// IPath webContentPath =
ProjectUtils.getWebContentRootPath(javaProject.getProject());
Assert.isTrue(webContentPath != null && !webContentPath.isEmpty(),
MessageFormat
.format("no web content folder was found in project {0}",
javaProject.getElementName()));
- IScopeContext projectScope = new ProjectScope(project);
- createWebApplicationPreferences(
- projectScope.getNode(IGoogleEclipsePluginConstants.GDT_PLUGIN_ID),
- webContentPath, javaProject, monitor);
-
+ createWebApplicationPreferences(project, webContentPath, javaProject, monitor);
configureOutputFolder(webContentPath, javaProject, monitor);
List<IPath> srcFolderPaths = ProjectUtils.getSourceFolders(javaProject);
- Assert.isTrue(srcFolderPaths.size() > 0,
- MessageFormat.format("no source folders were found in project {0}",
javaProject.getElementName()));
+ GWTInstallDataModelProvider dataModel = (GWTInstallDataModelProvider) config;
createSample(srcFolderPaths, webContentPath, dataModel, javaProject, monitor);
configureWebXml(project, monitor);
-
- } catch (BackingStoreException e) {
- LogHelper.logError(GWTCoreActivator.getDefault(), "Could not store
preferences.", e);
} catch (Exception e) {
-
- LogHelper.logError(GWTCoreActivator.getDefault(), "Could not create gwt
facet.", e);
+ throw new CoreException(StatusUtils.getErrorStatus(GWTCoreActivator.PLUGIN_ID,
"Could not create gwt facet.", e));
}
}
@@ -109,12 +100,15 @@
ProjectUtils.addClasspathEntry(javaProject, entry, monitor);
}
- private void createWebApplicationPreferences(IEclipsePreferences preferences, IPath
webContentPath,
+ private void createWebApplicationPreferences(IProject project, IPath webContentPath,
IJavaProject javaProject, IProgressMonitor monitor) throws BackingStoreException,
CoreException {
monitor.subTask("creating web application preferences");
- preferences.put(IGoogleEclipsePluginConstants.WAR_SRCDIR_KEY,
webContentPath.makeRelativeTo(
- javaProject.getPath()).toString());
+ IScopeContext projectScope = new ProjectScope(project);
+ IEclipsePreferences preferences =
projectScope.getNode(IGoogleEclipsePluginConstants.GDT_PLUGIN_ID);
+
+ preferences.put(IGoogleEclipsePluginConstants.WAR_SRCDIR_KEY,
+ webContentPath.makeRelativeTo(javaProject.getPath()).toString());
preferences.put(IGoogleEclipsePluginConstants.WAR_SRCDIR_ISOUTPUT_KEY,
IGoogleEclipsePluginConstants.WAR_SRCDIR_ISOUTPUT_DEFAULTVALUE);
preferences.flush();
@@ -137,8 +131,12 @@
GWTInstallDataModelProvider dataModel, final IJavaProject javaProject,
IProgressMonitor monitor)
throws IOException, CoreException {
- if (dataModel.isGenerateSampleCode()) {
+ if (srcPaths.size() <= 0) {
+ LogHelper.logWarning(GWTCoreActivator.PLUGIN_ID, MessageFormat.format("no source
folders were found in project {0}", javaProject.getElementName()));
+ return;
+ }
+ if (dataModel.isGenerateSampleCode()) {
monitor.subTask("creating sample code");
javaProject.getProject().getWorkspace().run(new IWorkspaceRunnable() {
@@ -153,7 +151,7 @@
unzipWebContent(webContentPath, javaProject);
} catch (IOException e) {
- LogHelper.logError(GWTCoreActivator.getDefault(), "Could not create gwt
facet", e);
+ LogHelper.logError(GWTCoreActivator.PLUGIN_ID, "Could not create gwt
facet", e);
}
}
@@ -228,7 +226,6 @@
}, webXmlPath);
}
- @SuppressWarnings("unchecked")
private void createServletMapping(String urlPattern, Servlet servlet, WebApp webApp) {
ServletMapping mapping = WebFactory.eINSTANCE.createServletMapping();
mapping.setServletName(servlet.getServletName());
@@ -238,7 +235,6 @@
webApp.getServletMappings().add(mapping);
}
- @SuppressWarnings("unchecked")
private Servlet createServlet(String servletName, String servletClass, WebApp webApp) {
Servlet servlet = WebFactory.eINSTANCE.createServlet();
servlet.setServletName(servletName);
@@ -247,7 +243,6 @@
return servlet;
}
- @SuppressWarnings("unchecked")
private void addWelcomePage(String welcomeFileUrl, WebApp webApp) {
List<WelcomeFileList> welcomeList = webApp.getWelcomeFileLists();
WelcomeFileList welcomeFileList = null;
Modified:
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/IGoogleEclipsePluginConstants.java
===================================================================
---
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/IGoogleEclipsePluginConstants.java 2010-09-02
15:49:03 UTC (rev 24667)
+++
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/IGoogleEclipsePluginConstants.java 2010-09-02
16:01:38 UTC (rev 24668)
@@ -18,7 +18,7 @@
*/
public class IGoogleEclipsePluginConstants {
- public static final String GWT_NATURE =
"com.google.gwt.eclipse.core.gwtNature";
+ public static final String GWT_NATURE =
"com.google.gwt.eclipse.core.gwtNature"; //$NON-NLS-1$
/** The gwt class path container id. */
public static final String GWT_CONTAINER_ID =
"com.google.gwt.eclipse.core.GWT_CONTAINER"; //$NON-NLS-1$
Modified:
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/util/ProjectUtils.java
===================================================================
---
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/util/ProjectUtils.java 2010-09-02
15:49:03 UTC (rev 24667)
+++
trunk/gwt/plugins/org.jboss.tools.gwt.core/src/org/jboss/tools/gwt/core/util/ProjectUtils.java 2010-09-02
16:01:38 UTC (rev 24668)
@@ -39,7 +39,7 @@
/**
* A class that holds various utility methods that help to deal with projects.
*
- * @author adietish.
+ * @author Andre Dietisheim
*
* @see IProject
*/
@@ -81,26 +81,27 @@
javaProject.setRawClasspath(newClasspath, monitor);
}
- /**
- * Returns the path of the web content folder in the given project. The path
- * returned is relative to the workspace.
- *
- * @param project
- * the project to return the web content folder for
- * @return the path of the web content folder (relative to the workspace)
- */
- public static IPath getWebContentRootPath(IProject project) {
- if (!ModuleCoreNature.isFlexibleProject(project))
- return project.getFullPath();
- IPath path = null;
- IVirtualComponent component = ComponentCore.createComponent(project);
- if (component != null && component.exists()) {
- path = component.getRootFolder().getWorkspaceRelativePath();
- } else {
- path = project.getFullPath();
- }
- return path;
- }
+// /**
+// * Returns the path of the web content folder in the given project. The path
+// * returned is relative to the workspace.
+// *
+// * @param project
+// * the project to return the web content folder for
+// * @return the path of the web content folder (relative to the workspace)
+// */
+// public static IPath getWebContentRootPath(IProject project) {
+// if (!ModuleCoreNature.isFlexibleProject(project)) {
+// return project.getFullPath();
+// }
+// IPath path = null;
+// IVirtualComponent component = ComponentCore.createComponent(project);
+// if (component != null && component.exists()) {
+// path = component.getRootFolder().getWorkspaceRelativePath();
+// } else {
+// path = project.getFullPath();
+// }
+// return path;
+// }
/**
* Unzips the given ZipInputStream to the given folder.