Author: fbricon
Date: 2012-01-10 08:04:24 -0500 (Tue, 10 Jan 2012)
New Revision: 37740
Added:
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/ClasspathContainersHelper.java
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/GradleLibraryMaterializationPostProcessor.java
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/Messages.java
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryWarningFactory.java
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/messages.properties
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/LibraryMaterializationPostProcessorFactory.java
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/MavenLibraryMaterializationPostProcessor.java
Log:
JBIDE-10363 : Remove the gradle nature when materializing
com.springsource.sts.gradle.classpathcontainer
Added:
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/ClasspathContainersHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/ClasspathContainersHelper.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/ClasspathContainersHelper.java 2012-01-10
13:04:24 UTC (rev 37740)
@@ -0,0 +1,34 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.common.jdt.core.buildpath;
+
+import org.eclipse.jdt.core.IClasspathContainer;
+
+public class ClasspathContainersHelper {
+
+ public static final String MAVEN_CONTAINER_ID =
"org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER";
+
+ public static final String GRADLE_CONTAINER_ID =
"com.springsource.sts.gradle.classpathcontainer";
+
+ public static final String JRE_CONTAINER_ID =
"org.eclipse.jdt.launching.JRE_CONTAINER";
+
+
+ private ClasspathContainersHelper() {
+ //We don't want to instanciate that class
+ }
+
+ public static boolean applies(IClasspathContainer classpathLibrary, String libPrefix) {
+ return classpathLibrary != null
+ && classpathLibrary.getPath() != null
+ && classpathLibrary.getPath().toPortableString().startsWith(libPrefix);
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/GradleLibraryMaterializationPostProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/GradleLibraryMaterializationPostProcessor.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/GradleLibraryMaterializationPostProcessor.java 2012-01-10
13:04:24 UTC (rev 37740)
@@ -0,0 +1,39 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.common.jdt.core.internal.buildpath;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.jdt.core.buildpath.ClasspathContainersHelper;
+import org.jboss.tools.common.jdt.core.buildpath.ILibraryMaterializationPostProcessor;
+
+class GradleLibraryMaterializationPostProcessor implements
ILibraryMaterializationPostProcessor {
+
+ private static final String GRADLE_NATURE_ID =
"com.springsource.sts.gradle.core.nature";
+
+ public boolean applies(IJavaProject javaProject, IPath containerPath) throws
CoreException {
+ boolean applies = javaProject != null
+ && javaProject.getProject().hasNature(GRADLE_NATURE_ID)
+ && (ClasspathContainersHelper.GRADLE_CONTAINER_ID
+ .equals(containerPath.toPortableString()));
+ return applies;
+ }
+
+ public void execute(IJavaProject javaProject, IPath containerPath,
+ IProgressMonitor monitor) throws CoreException {
+ if (applies(javaProject, containerPath)) {
+ EclipseUtil.removeNatureFromProject(javaProject.getProject(), GRADLE_NATURE_ID);
+ }
+ }
+}
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/LibraryMaterializationPostProcessorFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/LibraryMaterializationPostProcessorFactory.java 2012-01-10
10:36:02 UTC (rev 37739)
+++
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/LibraryMaterializationPostProcessorFactory.java 2012-01-10
13:04:24 UTC (rev 37740)
@@ -15,12 +15,12 @@
public class LibraryMaterializationPostProcessorFactory implements
ILibraryMaterializationPostProcessorFactory {
- /* (non-Javadoc)
- * @see
org.jboss.tools.common.jdt.core.buildpath.ILibraryMaterializationPostProcessorFactory#getLibraryMaterializationPostProcessors()
- */
@Override
public ILibraryMaterializationPostProcessor[] getLibraryMaterializationPostProcessors()
{
- return new ILibraryMaterializationPostProcessor[]{new
MavenLibraryMaterializationPostProcessor()};
+ return new ILibraryMaterializationPostProcessor[]{
+ new MavenLibraryMaterializationPostProcessor(),
+ new GradleLibraryMaterializationPostProcessor()
+ };
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/MavenLibraryMaterializationPostProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/MavenLibraryMaterializationPostProcessor.java 2012-01-10
10:36:02 UTC (rev 37739)
+++
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/internal/buildpath/MavenLibraryMaterializationPostProcessor.java 2012-01-10
13:04:24 UTC (rev 37740)
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.jdt.core.buildpath.ClasspathContainersHelper;
import org.jboss.tools.common.jdt.core.buildpath.ILibraryMaterializationPostProcessor;
class MavenLibraryMaterializationPostProcessor implements
ILibraryMaterializationPostProcessor {
@@ -29,7 +30,7 @@
public boolean applies(IJavaProject javaProject, IPath containerPath) throws
CoreException {
boolean applies = javaProject != null
&& javaProject.getProject().hasNature(MAVEN_NATURE_ID)
- && ("org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"
+ && (ClasspathContainersHelper.MAVEN_CONTAINER_ID
.equals(containerPath.toPortableString()));
return applies;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/Messages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/Messages.java 2012-01-10
10:36:02 UTC (rev 37739)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/Messages.java 2012-01-10
13:04:24 UTC (rev 37740)
@@ -30,6 +30,10 @@
public static String Jre_Dialog_Warning;
+ public static String Gradle_Configuration_Warning;
+
+ public static String Gradle_Configuration_Dialog_Warning;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java 2012-01-10
10:36:02 UTC (rev 37739)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java 2012-01-10
13:04:24 UTC (rev 37740)
@@ -49,7 +49,6 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryWarningFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryWarningFactory.java 2012-01-10
10:36:02 UTC (rev 37739)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryWarningFactory.java 2012-01-10
13:04:24 UTC (rev 37740)
@@ -10,8 +10,10 @@
************************************************************************************/
package org.jboss.tools.common.jdt.ui.buildpath.dialog;
+import static
org.jboss.tools.common.jdt.core.buildpath.ClasspathContainersHelper.applies;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.common.jdt.core.buildpath.ClasspathContainersHelper;
import org.jboss.tools.common.jdt.ui.Messages;
public class MaterializeLibraryWarningFactory implements
IMaterializeLibraryWarningFactory {
@@ -20,9 +22,13 @@
public String getWarning(IClasspathContainer classpathLibrary) {
if (isMavenLibrary(classpathLibrary)) {
return Messages.Maven_Configuration_Warning;
- } else if (isJreLibrary(classpathLibrary)) {
+ }
+ if (isJreLibrary(classpathLibrary)) {
return NLS.bind(Messages.Jre_Warning, classpathLibrary.getDescription());
}
+ if (isGradleLibrary(classpathLibrary)) {
+ return Messages.Gradle_Configuration_Warning;
+ }
return null;
}
@@ -30,24 +36,26 @@
public String getDialogWarning(IClasspathContainer classpathLibrary) {
if (isMavenLibrary(classpathLibrary)) {
return Messages.Maven_Configuration_Dialog_Warning;
- } else if (isJreLibrary(classpathLibrary)) {
+ }
+ if (isJreLibrary(classpathLibrary)) {
return NLS.bind(Messages.Jre_Dialog_Warning, classpathLibrary.getDescription());
}
+ if (isGradleLibrary(classpathLibrary)) {
+ return Messages.Gradle_Configuration_Dialog_Warning;
+ }
return null;
}
private boolean isJreLibrary(IClasspathContainer classpathLibrary) {
- return applies(classpathLibrary, "org.eclipse.jdt.launching.JRE_CONTAINER");
+ return applies(classpathLibrary, ClasspathContainersHelper.JRE_CONTAINER_ID);
}
private boolean isMavenLibrary(IClasspathContainer classpathLibrary) {
- return applies(classpathLibrary,
"org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER");
+ return applies(classpathLibrary, ClasspathContainersHelper.MAVEN_CONTAINER_ID);
}
- private boolean applies(IClasspathContainer classpathLibrary, String libPrefix) {
- return classpathLibrary != null
- && classpathLibrary.getPath() != null
- && classpathLibrary.getPath().toPortableString().startsWith(libPrefix);
+ private boolean isGradleLibrary(IClasspathContainer classpathLibrary) {
+ return applies(classpathLibrary, ClasspathContainersHelper.GRADLE_CONTAINER_ID);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/messages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/messages.properties 2012-01-10
10:36:02 UTC (rev 37739)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/messages.properties 2012-01-10
13:04:24 UTC (rev 37740)
@@ -2,6 +2,8 @@
Maven_Configuration_Warning =This will also remove the Maven configuration from this
project.
Maven_Configuration_Dialog_Warning = This will also remove the Maven configuration from
this project.\nThis operation cannot be undone, are you sure ?
+Gradle_Configuration_Warning =This will also remove the Gradle configuration from this
project.
+Gradle_Configuration_Dialog_Warning = This will also remove the Gradle configuration from
this project.\nThis operation cannot be undone, are you sure ?
Jre_Warning = Materializing {0} might have unexpected consequences and is not
recommended.
Jre_Dialog_Warning = Materializing {0} might have unexpected consequences and is not
recommended. Are you sure?