JBoss Tools SVN: r33415 - in workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite: features and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2011-08-01 10:40:26 -0400 (Mon, 01 Aug 2011)
New Revision: 33415
Added:
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/features/org.jboss.tools.as.sourcelookup.feature_1.0.0.201108011616.jar
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.core_1.0.0.201108011616.jar
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.ui_1.0.0.201108011616.jar
Removed:
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/features/org.jboss.tools.as.sourcelookup.feature_1.0.0.201107280132.jar
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.core_1.0.0.201107280132.jar
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.ui_1.0.0.201107280132.jar
Modified:
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/artifacts.jar
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/content.jar
workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/site.xml
Log:
JBIDE-9309 Easily adding full JBoss AS source
Modified: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/artifacts.jar
===================================================================
(Binary files differ)
Modified: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/content.jar
===================================================================
(Binary files differ)
Deleted: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/features/org.jboss.tools.as.sourcelookup.feature_1.0.0.201107280132.jar
===================================================================
(Binary files differ)
Added: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/features/org.jboss.tools.as.sourcelookup.feature_1.0.0.201108011616.jar
===================================================================
(Binary files differ)
Property changes on: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/features/org.jboss.tools.as.sourcelookup.feature_1.0.0.201108011616.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.core_1.0.0.201107280132.jar
===================================================================
(Binary files differ)
Added: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.core_1.0.0.201108011616.jar
===================================================================
(Binary files differ)
Property changes on: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.core_1.0.0.201108011616.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.ui_1.0.0.201107280132.jar
===================================================================
(Binary files differ)
Added: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.ui_1.0.0.201108011616.jar
===================================================================
(Binary files differ)
Property changes on: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/plugins/org.jboss.tools.as.sourcelookup.ui_1.0.0.201108011616.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/site.xml
===================================================================
--- workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/site.xml 2011-08-01 14:06:47 UTC (rev 33414)
+++ workspace/snjeza/org.jboss.tools.as.sourcelookup.updatesite/site.xml 2011-08-01 14:40:26 UTC (rev 33415)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<site>
- <feature url="features/org.jboss.tools.as.sourcelookup.feature_1.0.0.201107280132.jar" id="org.jboss.tools.as.sourcelookup.feature" version="1.0.0.201107280132">
+ <feature url="features/org.jboss.tools.as.sourcelookup.feature_1.0.0.201108011616.jar" id="org.jboss.tools.as.sourcelookup.feature" version="1.0.0.201108011616">
<category name="org.jboss.tools.as.sourcelookup"/>
</feature>
<category-def name="org.jboss.tools.as.sourcelookup" label="JBoss Tools Source Lookup"/>
13 years, 4 months
JBoss Tools SVN: r33414 - trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2011-08-01 10:06:47 -0400 (Mon, 01 Aug 2011)
New Revision: 33414
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
Log:
JBIDE-9429 JBoss AS Runtime detector doesn't detect correctly JBoss AS 6.1/7.1 version
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2011-08-01 13:39:09 UTC (rev 33413)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2011-08-01 14:06:47 UTC (rev 33414)
@@ -142,9 +142,9 @@
index = 3;
} else if ("5.1".equals(version)) { //$NON-NLS-1$
index = 4;
- } else if ("6.0".equals(version)) { //$NON-NLS-1$
+ } else if ("6.0".equals(version) || "6.1".equals(version)) { //$NON-NLS-1$
index = 5;
- } else if ("7.0".equals(version)) { //$NON-NLS-1$
+ } else if ("7.0".equals(version) || "7.1".equals(version)) { //$NON-NLS-1$
index = 8;
}
createJBossServer(serverDefinition.getLocation(),index,serverDefinition.getName(),serverDefinition.getName() + " " + RUNTIME); //$NON-NLS-1$
13 years, 4 months
JBoss Tools SVN: r33413 - trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config.
by jbosstools-commits@lists.jboss.org
Author: lzoubek(a)redhat.com
Date: 2011-08-01 09:39:09 -0400 (Mon, 01 Aug 2011)
New Revision: 33413
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
Log:
forgotten class
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2011-08-01 12:43:50 UTC (rev 33412)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2011-08-01 13:39:09 UTC (rev 33413)
@@ -103,7 +103,7 @@
*/
boolean required() default true;
/**
- * state (default (default {@link ServerState#ALL}))
+ * state (default (default {@link ServerState#Running}))
* @return
*/
ServerState state() default ServerState.Running;
@@ -113,7 +113,7 @@
*/
ServerType type() default ServerType.ALL;
/**
- * server location (derfault {@link ServerLocation#Any})
+ * server location (default {@link ServerLocation#Any})
* @return
*/
ServerLocation location() default ServerLocation.Any;
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java 2011-08-01 13:39:09 UTC (rev 33413)
@@ -0,0 +1,93 @@
+package org.jboss.tools.ui.bot.ext.config;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+public class RuntimeBean {
+ protected static final Logger log = Logger.getLogger(RuntimeBean.class);
+ protected String key;
+ public String version;
+ public String runtimeHome;
+
+ protected static RuntimeBean fromString(String propValue, RuntimeBean bean) throws Exception{
+ try {
+ if (propValue==null) {
+ return null;
+ }
+ String[] params = propValue.split(",");
+ bean.runtimeHome=params[1];
+ bean.version=params[0];
+ return bean;
+ }
+ catch (Exception ex) {
+ throw new Exception("Cannot parse "+bean.key+" property line",ex);
+ }
+ }
+ @Override
+ public String toString() {
+ return String.format("%s runtime version=%s, home=%s",this.key,
+ this.version, this.runtimeHome);
+ }
+ public static String downloadRuntime(String url) {
+ BufferedInputStream in = null;
+ RandomAccessFile raf = null;
+ String outputFile = System.getProperty("java.io.tmpdir")+System.getProperty("file.separator")+url.replaceAll(".*/", "");
+ log.info(String.format("Downloading %s to %s",url,outputFile));
+ if (new File(outputFile).exists()) {
+ log.info("Output file already exists, skipping");
+ return outputFile;
+ }
+ int BUFFER_SIZE=8196;
+ try {
+ // open Http connection to URL
+ HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection();
+ // connect to server
+ conn.connect();
+
+ // Make sure the response code is in the 200 range.
+ if (conn.getResponseCode() != 200) {
+ log.error("Cannot download file, server returned "+conn.getResponseCode()+" : "+conn.getResponseMessage());
+ return null;
+ }
+
+ // get the input stream
+ in = new BufferedInputStream(conn.getInputStream());
+
+ // open the output file and seek to the start location
+ raf = new RandomAccessFile(outputFile, "rw");
+
+ byte data[] = new byte[BUFFER_SIZE];
+ int numRead;
+ while(((numRead = in.read(data,0,BUFFER_SIZE)) != -1))
+ {
+ // write to buffer
+ raf.write(data,0,numRead);
+ }
+ log.info("DONE");
+ return outputFile;
+
+ } catch (IOException e) {
+ log.error(e);
+ return null;
+ } finally {
+ if (raf != null) {
+ try {
+ raf.close();
+ } catch (IOException e) {}
+ }
+
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {}
+ }
+ }
+ }
+
+}
13 years, 4 months
JBoss Tools SVN: r33412 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core: src/org/jboss/tools/hibernate/jpt/core/internal and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-08-01 08:43:50 -0400 (Mon, 01 Aug 2011)
New Revision: 33412
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java
Log:
https://issues.jboss.org/browse/JBIDE-9435
Added package level annotations support
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2011-08-01 12:43:50 UTC (rev 33412)
@@ -20,7 +20,8 @@
org.eclipse.jpt.jpa.core;bundle-version="3.0.0",
org.eclipse.text;bundle-version="3.5.100",
org.eclipse.jst.j2ee;bundle-version="1.1.500",
- org.eclipse.persistence.jpa.jpql;bundle-version="1.0.0"
+ org.eclipse.persistence.jpa.jpql;bundle-version="1.0.0",
+ org.eclipse.jst.j2ee.core;bundle-version="1.2.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.hibernate.jpt.core.internal,
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -37,6 +37,7 @@
import org.eclipse.jpt.jpa.core.context.java.JavaTable;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaFactory;
import org.eclipse.jpt.jpa.core.resource.java.EntityAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.SecondaryTableAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
@@ -65,18 +66,21 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTypeDefContainerImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryImpl;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernatePackageInfoImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.IndexImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaDiscriminatorFormula;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaDiscriminatorFormulaImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaIndex;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaType;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeConverterImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDef;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDefImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.TypeImpl;
+import org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernateClassRef;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
@@ -235,4 +239,9 @@
return new JavaTypeConverterImpl(parent, converterAnnotation);
}
+ public JavaPackageInfo buildJavaPackageInfo(
+ HibernateClassRef hibernateClassRef, JavaResourcePackage jrpt) {
+ return new HibernatePackageInfoImpl(hibernateClassRef, jrpt);
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -25,6 +25,7 @@
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaPlatformProvider;
import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
+import org.eclipse.jpt.jpa.core.internal.JavaPackageInfoResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
@@ -76,7 +77,9 @@
// ********** resource models **********
public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
- if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
+ if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) {
+ return JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE;
+ } else if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
return JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
}
else if (contentType.equals(JptCommonCorePlugin.JAR_CONTENT_TYPE)) {
@@ -100,6 +103,7 @@
// order should not be important here
protected static final JpaResourceModelProvider[] RESOURCE_MODEL_PROVIDERS = new JpaResourceModelProvider[] {
+ JavaPackageInfoResourceModelProvider.instance(),
JavaResourceModelProvider.instance(),
JarResourceModelProvider.instance(),
PersistenceResourceModelProvider.instance(),
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -28,11 +28,15 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.NotNullFilter;
+import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.QueryContainer;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
@@ -44,7 +48,10 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernatePersistenceUnitProperties;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaQueryContainer;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernatePackageInfo;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDef;
+import org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernateClassRef;
import org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistenceUnitPropertiesBuilder;
/**
@@ -146,6 +153,42 @@
}
}
+ /**
+ * Return the non-<code>null</code> class ref package infos,
+ * both specified and implied.
+ */
+ protected Iterable<JavaPackageInfo> getClassRefPackageInfos() {
+ return new FilteringIterable<JavaPackageInfo>(
+ this.getClassRefPackageInfos_(),
+ NotNullFilter.<JavaPackageInfo>instance()
+ );
+ }
+
+ protected Iterable<JavaPackageInfo> getClassRefPackageInfos_() {
+ return new TransformationIterable<ClassRef, JavaPackageInfo>(this.getClassRefs()) {
+ @Override
+ protected JavaPackageInfo transform(ClassRef classRef) {
+ return ((HibernateClassRef)classRef).getJavaPackageInfo();
+ }
+ };
+ }
+
+ /**
+ * Need to collect also Queries from package-info.java
+ */
+ protected void addJavaQueriesTo(ArrayList<Query> queryList) {
+ super.addJavaQueriesTo(queryList);
+ this.addPackageJavaQueriesTo(this.getClassRefPackageInfos(), queryList);
+ }
+
+ protected void addPackageJavaQueriesTo(Iterable<JavaPackageInfo> packageInfos, ArrayList<Query> queryList) {
+ for (JavaPackageInfo packageInfo : packageInfos) {
+ if (packageInfo instanceof HibernatePackageInfo) {
+ this.addQueriesTo(((HibernatePackageInfo) packageInfo).getQueryContainer(), queryList);
+ }
+ }
+ }
+
@Override
protected void addQueriesTo(QueryContainer queryContainer,
ArrayList<Query> queryList) {
@@ -154,9 +197,24 @@
CollectionTools.addAll(queryList, ((HibernateJavaQueryContainer)queryContainer).hibernateNamedQueries());
CollectionTools.addAll(queryList, ((HibernateJavaQueryContainer)queryContainer).hibernateNamedNativeQueries());
}
-
}
+ /**
+ * Include "overridden" Java generators.
+ */
+ protected void addJavaGeneratorsTo(ArrayList<Generator> generatorList) {
+ super.addJavaGeneratorsTo(generatorList);
+ this.addPackageJavaGeneratorsTo(this.getClassRefPackageInfos(), generatorList);
+ }
+
+ protected void addPackageJavaGeneratorsTo(Iterable<JavaPackageInfo> pacakgeInfos, ArrayList<Generator> generatorList) {
+ for (JavaPackageInfo packageInfo : pacakgeInfos) {
+ if (packageInfo instanceof HibernatePackageInfo) {
+ this.addGeneratorsTo(((HibernatePackageInfo) packageInfo).getGeneratorContainer(), generatorList);
+ }
+ }
+ }
+
@Override
protected void addGeneratorsTo(GeneratorContainer generatorContainer,
ArrayList<Generator> generatorList) {
@@ -228,5 +286,213 @@
super(Messages.class.getName(), severity, message, strings, resource);
}
}
+//
+// // ********** specified package-info refs **********
+//
+// public ListIterator<PackageInfoRef> specifiedPackageInfoRefs() {
+// return this.getSpecifiedPackageInfoRefs().iterator();
+// }
+//
+// protected ListIterable<PackageInfoRef> getSpecifiedPackageInfoRefs() {
+// return new LiveCloneListIterable<PackageInfoRef>(this.specifiedPackageInfoRefs);
+// }
+//
+// public int specifiedPackageInfoRefsSize() {
+// return this.specifiedPackageInfoRefs.size();
+// }
+//
+// public PackageInfoRef addSpecifiedPackageInfoRef(String packageName) {
+// return this.addSpecifiedPackageInfoRef(this.specifiedPackageInfoRefs.size(), packageName);
+// }
+//
+// public PackageInfoRef addSpecifiedPackageInfoRef(int index, String packageName) {
+// XmlPackageInfoRef xmlPackageInfoRef = this.buildXmlPackageInfoRef(packageName);
+// PackageInfoRef classRef = this.addSpecifiedPackageInfoRef_(index, xmlPackageInfoRef);
+// this.xmlPersistenceUnit.getClasses().add(index, xmlPackageInfoRef);
+// return classRef;
+// }
+//
+// protected XmlPackageInfoRef buildXmlPackageInfoRef(String packageName) {
+// XmlPackageInfoRef ref = PersistenceFactory.eINSTANCE.createXmlPackageInfoRef();
+// ref.setJavaClass(packageName);
+// return ref;
+// }
+//
+// protected PackageInfoRef buildPackageInfoRef(XmlPackageInfoRef xmlPackageInfoRef) {
+// return this.getContextNodeFactory().buildPackageInfoRef(this, xmlPackageInfoRef);
+// }
+//
+// public void removeSpecifiedPackageInfoRef(PackageInfoRef classRef) {
+// this.removeSpecifiedPackageInfoRef(this.specifiedPackageInfoRefs.indexOf(classRef));
+// }
+//
+// public void removeSpecifiedPackageInfoRef(int index) {
+// this.removeSpecifiedPackageInfoRef_(index);
+// this.xmlPersistenceUnit.getClasses().remove(index);
+// }
+//
+// /**
+// * dispose the class ref
+// */
+// protected void removeSpecifiedPackageInfoRef_(int index) {
+// this.removeItemFromList(index, this.specifiedPackageInfoRefs, SPECIFIED_CLASS_REFS_LIST).dispose();
+// }
+//
+// protected void initializeSpecifiedPackageInfoRefs() {
+// for (XmlPackageInfoRef xmlJavaPackageInfoRef : this.getXmlPackageInfoRefs()) {
+// this.specifiedPackageInfoRefs.add(this.buildPackageInfoRef(xmlJavaPackageInfoRef));
+// }
+// }
+//
+// protected void syncSpecifiedPackageInfoRefs() {
+// ContextContainerTools.synchronizeWithResourceModel(this.specifiedPackageInfoRefContainerAdapter);
+// }
+//
+// protected Iterable<XmlPackageInfoRef> getXmlPackageInfoRefs() {
+// // clone to reduce chance of concurrency problems
+// return new LiveCloneIterable<XmlPackageInfoRef>(this.xmlPersistenceUnit.getClasses());
+// }
+//
+// protected void moveSpecifiedPackageInfoRef_(int index, PackageInfoRef classRef) {
+// this.moveItemInList(index, classRef, this.specifiedPackageInfoRefs, SPECIFIED_CLASS_REFS_LIST);
+// }
+//
+// protected PackageInfoRef addSpecifiedPackageInfoRef_(int index, XmlPackageInfoRef xmlPackageInfoRef) {
+// PackageInfoRef classRef = this.buildPackageInfoRef(xmlPackageInfoRef);
+// this.addItemToList(index, classRef, this.specifiedPackageInfoRefs, SPECIFIED_CLASS_REFS_LIST);
+// return classRef;
+// }
+//
+// protected void removeSpecifiedPackageInfoRef_(PackageInfoRef classRef) {
+// this.removeSpecifiedPackageInfoRef_(this.specifiedPackageInfoRefs.indexOf(classRef));
+// }
+//
+// /**
+// * specified class ref container adapter
+// */
+// protected class SpecifiedPackageInfoRefContainerAdapter
+// implements ContextContainerTools.Adapter<PackageInfoRef, XmlPackageInfoRef>
+// {
+// public Iterable<PackageInfoRef> getContextElements() {
+// return HibernatePersistenceUnit.this.getSpecifiedPackageInfoRefs();
+// }
+// public Iterable<XmlPackageInfoRef> getResourceElements() {
+// return HibernatePersistenceUnit.this.getXmlPackageInfoRefs();
+// }
+// public XmlPackageInfoRef getResourceElement(PackageInfoRef contextElement) {
+// return contextElement.getXmlPackageInfoRef();
+// }
+// public void moveContextElement(int index, PackageInfoRef element) {
+// HibernatePersistenceUnit.this.moveSpecifiedPackageInfoRef_(index, element);
+// }
+// public void addContextElement(int index, XmlPackageInfoRef resourceElement) {
+// HibernatePersistenceUnit.this.addSpecifiedPackageInfoRef_(index, resourceElement);
+// }
+// public void removeContextElement(PackageInfoRef element) {
+// HibernatePersistenceUnit.this.removeSpecifiedPackageInfoRef_(element);
+// }
+// }
+//
+// // ********** virtual package-info refs **********
+//
+// public Iterator<PackageInfoRef> impliedPackageInfoRefs() {
+// return this.getImpliedPackageInfoRefs().iterator();
+// }
+//
+// protected Iterable<PackageInfoRef> getImpliedPackageInfoRefs() {
+// return new LiveCloneIterable<PackageInfoRef>(this.impliedPackageInfoRefs);
+// }
+//
+// public int impliedPackageInfoRefsSize() {
+// return this.impliedPackageInfoRefs.size();
+// }
+//
+// protected PackageInfoRef addImpliedPackageInfoRef(String packageName) {
+// PackageInfoRef classRef = this.buildPackageInfoRef(packageName);
+// this.addItemToCollection(classRef, this.impliedPackageInfoRefs, IMPLIED_CLASS_REFS_COLLECTION);
+// return classRef;
+// }
+//
+// protected PackageInfoRef buildPackageInfoRef(String packageName) {
+// return this.getContextNodeFactory().buildPackageInfoRef(this, packageName);
+// }
+//
+// protected void removeImpliedPackageInfoRef(PackageInfoRef classRef) {
+// this.impliedPackageInfoRefs.remove(classRef);
+// classRef.dispose();
+// this.fireItemRemoved(IMPLIED_CLASS_REFS_COLLECTION, classRef);
+// }
+//
+// protected void updateImpliedPackageInfoRefs() {
+// ContextContainerTools.update(this.impliedPackageInfoRefContainerAdapter);
+// }
+//
+// protected Iterable<String> getImpliedClassNames() {
+// return this.excludesUnlistedClasses() ?
+// EmptyIterable.<String>instance() :
+// this.getImpliedClassNames_();
+// }
+//
+// /**
+// * Return the names of all the Java classes in the JPA project that are
+// * mapped (i.e. have the appropriate annotation etc.) but not specified
+// * in the persistence unit.
+// */
+// protected Iterable<String> getImpliedClassNames_() {
+// return new FilteringIterable<String>(this.getJpaProject().getMappedJavaSourceClassNames()) {
+// @Override
+// protected boolean accept(String mappedClassName) {
+// return ! HibernatePersistenceUnit.this.specifiesPersistentType(mappedClassName);
+// }
+// };
+// }
+//
+// /**
+// * Virtual class ref container adapter.
+// * <p>
+// * <strong>NB:</strong> The context class ref is matched with a resource
+// * class by name.
+// * <p>
+// * This is used during <strong>both</strong> <em>sync</em> and
+// * <em>update</em> because the list of implied class refs can be modified
+// * in either situation. In particular, we cannot simply rely on
+// * <em>update</em> because there are situations where a <em>sync</em> is
+// * triggered but a follow-up <em>update</em> is not. (Of course, any
+// * change discovered here will trigger an <em>update</em>.)
+// * <p>
+// * The most obvious example is when the JPA project is configured to
+// * discover annotated classes and a Java class is annotated for the first
+// * time (via code editing, not via the context model). This will trigger
+// * a <em>sync</em>; but, since the unannotated class is not yet in the
+// * context model and, as a result, the context model's state is untouched,
+// * an <em>update</em> will not be triggered.
+// * <p>
+// * Obviously, other context model changes can change this collection (e.g.
+// * setting whether the persistence unit excludes unlisted classes); o the
+// * collection must also be synchronized during <em>update</em>.
+// */
+// protected class ImpliedPackageInfoRefContainerAdapter
+// implements ContextContainerTools.Adapter<PackageInfoRef, String>
+// {
+// public Iterable<PackageInfoRef> getContextElements() {
+// return HibernatePersistenceUnit.this.getImpliedPackageInfoRef();
+// }
+// public Iterable<String> getResourceElements() {
+// return HibernatePersistenceUnit.this.getImpliedPackageInfoNames();
+// }
+// public String getResourceElement(PackageInfoRef contextElement) {
+// return contextElement.getPackageName();
+// }
+// public void moveContextElement(int index, PackageInfoRef element) {
+// // ignore moves - we don't care about the order of the implied package-info refs
+// }
+// public void addContextElement(int index, String resourceElement) {
+// // ignore the index - we don't care about the order of the implied package-info refs
+// HibernatePersistenceUnit.this.addImpliedPackageInfoRef(resourceElement);
+// }
+// public void removeContextElement(PackageInfoRef element) {
+// HibernatePersistenceUnit.this.removeImpliedPackageInfoRef(element);
+// }
+// }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -13,7 +13,7 @@
import java.util.ListIterator;
import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
/**
* @author Dmitry Geraskov
@@ -56,12 +56,12 @@
*/
void moveTypeDef(int targetIndex, int sourceIndex);
- void initialize(JavaResourcePersistentMember jrpm);
+ void initialize(JavaResourceAnnotatedElement jrpm);
/**
* Update the JavaGeneratorContainer context model object to match the JavaResourcePersistentMember
* resource model object. see {@link org.eclipse.jpt.jpa.core.JpaProject#update()}
*/
- void update(JavaResourcePersistentMember jrpm);
+ void update(JavaResourceAnnotatedElement jrpm);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -22,7 +22,7 @@
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -37,7 +37,7 @@
public class HibernateJavaTypeDefContainerImpl extends
AbstractJavaJpaContextNode implements HibernateJavaTypeDefContainer {
- protected JavaResourcePersistentMember javaResourcePersistentMember;
+ protected JavaResourceAnnotatedElement javaResourcePersistentElement;
protected final List<JavaTypeDef> typeDefs;
@@ -50,20 +50,20 @@
return (HibernateAbstractJpaFactory)super.getJpaFactory();
}
- public void initialize(JavaResourcePersistentMember jrpm) {
- this.javaResourcePersistentMember = jrpm;
+ public void initialize(JavaResourceAnnotatedElement jrpe) {
+ this.javaResourcePersistentElement = jrpe;
this.initializeTypeDefs();
}
- public void update(JavaResourcePersistentMember jrpm) {
- this.javaResourcePersistentMember = jrpm;
+ public void update(JavaResourceAnnotatedElement jrpm) {
+ this.javaResourcePersistentElement = jrpm;
this.updateTypeDefs();
}
public JavaTypeDef addTypeDef(int index) {
JavaTypeDef newTypeDef = getJpaFactory().buildJavaTypeDef(this);
this.typeDefs.add(index, newTypeDef);
- TypeDefAnnotation typeDefAnnotation = (TypeDefAnnotation)this.javaResourcePersistentMember
+ TypeDefAnnotation typeDefAnnotation = (TypeDefAnnotation)this.javaResourcePersistentElement
.addAnnotation(index, TypeDefAnnotation.ANNOTATION_NAME, TypeDefsAnnotation.ANNOTATION_NAME);
newTypeDef.initialize(typeDefAnnotation);
fireItemAdded(TYPE_DEFS_LIST, index, newTypeDef);
@@ -88,13 +88,13 @@
public void moveTypeDef(int targetIndex, int sourceIndex) {
CollectionTools.move(this.typeDefs, targetIndex, sourceIndex);
- this.javaResourcePersistentMember.moveAnnotation(targetIndex, sourceIndex, TypeDefsAnnotation.ANNOTATION_NAME);
+ this.javaResourcePersistentElement.moveAnnotation(targetIndex, sourceIndex, TypeDefsAnnotation.ANNOTATION_NAME);
fireItemMoved(TYPE_DEFS_LIST, targetIndex, sourceIndex);
}
public void removeTypeDef(int index) {
JavaTypeDef removedTypeDef = this.typeDefs.remove(index);
- this.javaResourcePersistentMember.removeAnnotation(index, TypeDefAnnotation.ANNOTATION_NAME, TypeDefsAnnotation.ANNOTATION_NAME);
+ this.javaResourcePersistentElement.removeAnnotation(index, TypeDefAnnotation.ANNOTATION_NAME, TypeDefsAnnotation.ANNOTATION_NAME);
fireItemRemoved(TYPE_DEFS_LIST, index, removedTypeDef);
}
@@ -107,7 +107,7 @@
}
protected void initializeTypeDefs() {
- for (Iterator<NestableAnnotation> stream = this.javaResourcePersistentMember.annotations(
+ for (Iterator<NestableAnnotation> stream = this.javaResourcePersistentElement.annotations(
TypeDefAnnotation.ANNOTATION_NAME,
TypeDefsAnnotation.ANNOTATION_NAME);
stream.hasNext(); ) {
@@ -130,7 +130,7 @@
protected void updateTypeDefs() {
ListIterator<JavaTypeDef> typeDefs = typeDefs();
Iterator<NestableAnnotation> resourceTypeDefs =
- this.javaResourcePersistentMember.annotations(
+ this.javaResourcePersistentElement.annotations(
TypeDefAnnotation.ANNOTATION_NAME,
TypeDefsAnnotation.ANNOTATION_NAME);
@@ -183,6 +183,6 @@
}
public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.javaResourcePersistentMember.getTextRange(astRoot);
+ return this.javaResourcePersistentElement.getTextRange(astRoot);
}
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
+import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernatePackageInfo extends JavaPackageInfo, JavaGeneratorContainer.Owner, JavaQueryContainer.Owner{
+
+ JavaQueryContainer getQueryContainer();
+ JavaGeneratorContainer getGeneratorContainer();
+ HibernateJavaTypeDefContainer getTypeDefContainer();
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.jpa.core.JpaFile;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
+import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
+import org.eclipse.jpt.jpa.core.context.java.JavaStructureNodes;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceNode;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
+import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernatePackageInfoImpl extends AbstractJavaJpaContextNode implements HibernatePackageInfo {
+
+ //FIXME may be need to create "Mapping" class??
+ protected final HibernateJavaTypeDefContainer typeDefContainer;
+ protected final JavaGeneratorContainer generatorContainer;
+ protected final JavaQueryContainer queryContainer;
+
+ private JavaResourcePackage resourcePackage;
+ protected String name;
+
+ /**
+ * @param parent
+ */
+ public HibernatePackageInfoImpl(PersistentType.Owner owner, JavaResourcePackage resourcePackage) {
+ super(owner);
+ this.resourcePackage = resourcePackage;
+ this.name = resourcePackage.getName();
+ this.typeDefContainer = getJpaFactory().buildJavaTypeDefContainer(this);
+ this.generatorContainer = this.buildGeneratorContainer();
+ this.queryContainer = this.buildQueryContainer();
+ }
+
+ @Override
+ protected HibernateAbstractJpaFactory getJpaFactory() {
+ return (HibernateAbstractJpaFactory) this.getJpaPlatform().getJpaFactory();
+ }
+
+ public HibernateJavaTypeDefContainer getTypeDefContainer() {
+ return this.typeDefContainer;
+ }
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setName(this.resourcePackage.getName());
+ this.typeDefContainer.initialize(this.getResourcePackage());
+ this.generatorContainer.synchronizeWithResourceModel();
+ this.queryContainer.synchronizeWithResourceModel();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.typeDefContainer.update(this.getResourcePackage());
+ this.generatorContainer.update();
+ this.queryContainer.update();
+ }
+
+ // ********** name **********
+
+ public String getName() {
+ return this.name;
+ }
+
+ protected void setName(String name) {
+ String old = this.name;
+ this.name = name;
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ public TextRange getSelectionTextRange() {
+ return this.getSelectionTextRange(this.buildASTRoot());
+ }
+
+ protected TextRange getSelectionTextRange(CompilationUnit astRoot) {
+ return this.resourcePackage.getNameTextRange(astRoot);
+ }
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.getSelectionTextRange(astRoot);
+ }
+
+ public TextRange getValidationTextRange() {
+ return this.getSelectionTextRange();
+ }
+
+ // ********** generator container **********
+
+ public JavaGeneratorContainer getGeneratorContainer() {
+ return this.generatorContainer;
+ }
+
+ protected JavaGeneratorContainer buildGeneratorContainer() {
+ return this.getJpaFactory().buildJavaGeneratorContainer(this, this);
+ }
+
+ // ********** query container **********
+
+ public JavaQueryContainer getQueryContainer() {
+ return this.queryContainer;
+ }
+
+ protected JavaQueryContainer buildQueryContainer() {
+ return this.getJpaFactory().buildJavaQueryContainer(this, this);
+ }
+
+ protected CompilationUnit buildASTRoot() {
+ return this.resourcePackage.getJavaResourceCompilationUnit().buildASTRoot();
+ }
+
+ // it would be nice if the we passed in an astRoot here, but then we
+ // would need to pass it to the XML structure nodes too...
+ public JpaStructureNode getStructureNode(int offset) {
+ CompilationUnit astRoot = this.buildASTRoot();
+
+ if (this.contains(offset, astRoot)) {
+ return this;
+ }
+ return null;
+ }
+
+ protected boolean contains(int offset, CompilationUnit astRoot) {
+ TextRange fullTextRange = this.resourcePackage.getTextRange(astRoot);
+ // 'fullTextRange' will be null if the type no longer exists in the java;
+ // the context model can be out of synch with the resource model
+ // when a selection event occurs before the context model has a
+ // chance to synch with the resource model via the update thread
+ return (fullTextRange == null) ? false : fullTextRange.includes(offset);
+ }
+
+
+ public String getId() {
+ //FIXME check this is correct
+ return JavaStructureNodes.COMPILATION_UNIT_ID;
+ }
+
+ public void dispose() {
+ this.unregisterRootStructureNode();
+ }
+
+ protected void unregisterRootStructureNode() {
+ JpaFile jpaFile = this.getJpaFile();
+ // the JPA file can be null if the .java file was deleted
+ // or the resource type is "external"
+ if (jpaFile != null) {
+ jpaFile.removeRootStructureNode(this.name, this);
+ }
+ }
+
+ protected JpaFile getJpaFile() {
+ return this.getJpaFile(this.resourcePackage.getFile());
+ }
+
+ @Override
+ public JavaResourcePackage getResourcePackage() {
+ return this.resourcePackage;
+ }
+
+ @Override
+ public JavaResourceAnnotatedElement getResourceAnnotatedElement() {
+ return this.resourcePackage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo#validate(java.util.List, org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ if (reporter.isCancelled()) {
+ throw new ValidationCancelledException();
+ }
+ // TODO temporary hack since we don't know yet where to put
+ // any messages for types in another project (e.g. referenced by
+ // persistence.xml)
+ IFile file = this.resourcePackage.getFile();
+ // 'file' will be null if the type is "external" and binary;
+ // the file will be in a different project if the type is "external" and source;
+ // the type will be binary if it is in a JAR in the current project
+ if ((file != null) && file.getProject().equals(this.getJpaProject().getProject()) &&
+ (this.resourcePackage instanceof SourceNode)) {
+ // build the AST root here to pass down
+ this.validate(messages, reporter, this.buildASTRoot());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode#validate(java.util.List, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.typeDefContainer.validate(messages, reporter, astRoot);
+ this.generatorContainer.validate(messages, reporter, astRoot);
+ this.queryContainer.validate(messages, reporter, astRoot);
+ }
+
+ @Override
+ public Iterator<String> javaCompletionProposals(int pos,
+ Filter<String> filter, CompilationUnit astRoot) {
+ Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ result = this.typeDefContainer.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ result = this.generatorContainer.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ result = this.queryContainer.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.List;
+
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+
+/**
+ * When <class>test.some.pack</class> is used and there is
+ * test.some.pack.package-info.java file it should be included in persistent unit.
+ *
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaPackageInfo extends JavaJpaContextNode, JpaContextNode, JpaStructureNode {
+
+ // ********** name **********
+
+ /**
+ * Return the persistent type's [fully-qualified] name.
+ * The enclosing type separator is <code>'.'</code>,
+ * as opposed to <code>'$'</code>.
+ * @see #getSimpleName()
+ */
+ String getName();
+ String NAME_PROPERTY = "name"; //$NON-NLS-1$
+
+ JavaResourcePackage getResourcePackage();
+
+ // ********** validation **********
+
+ /**
+ * Add to the list of current validation messages
+ */
+ void validate(List<IMessage> messages, IReporter reporter);
+
+ /**
+ * Return the text range to be used with any validation messages related
+ * to the persistent type.
+ */
+ TextRange getValidationTextRange();
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef;
+import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateClassRef extends GenericClassRef implements PackageInfoRef{
+
+ /**
+ * When <code><class>test.some.pack</class></code> is used and there is
+ * test.some.pack.package-info.java file it should be included in persistent unit.
+ * This can be <code>null</code> if the name is invalid.
+ */
+ protected JavaPackageInfo javaPackageInfo;
+
+
+ /**
+ * Construct a <em>specified</em> class ref; i.e. a class ref with
+ * an explicit entry in the <code>persistence.xml</code>.
+ */
+ public HibernateClassRef(PersistenceUnit parent, XmlJavaClassRef xmlJavaClassRef) {
+ super(parent, xmlJavaClassRef, xmlJavaClassRef.getJavaClass());
+ }
+
+ /**
+ * Construct an <em>virtual</em> class ref; i.e. a class ref without
+ * an explicit entry in the <code>persistence.xml</code>.
+ */
+ public HibernateClassRef(PersistenceUnit parent, String className) {
+ super(parent, null, className);
+ }
+
+ @Override
+ protected HibernateAbstractJpaFactory getJpaFactory() {
+ return (HibernateAbstractJpaFactory) super.getJpaFactory();
+ }
+
+ @Override
+ protected boolean isInPackage(IPackageFragment packageFragment) {
+ // FIXME recheck this method
+ return super.isInPackage(packageFragment);
+ }
+
+ @Override
+ protected String getPackageName() {
+ // FIXME recheck this method
+ return super.getPackageName();
+ }
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ if (this.javaPackageInfo != null) {
+ this.javaPackageInfo.synchronizeWithResourceModel();
+ }
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.updateJavaPackageInfo();
+ }
+
+ // ********** java persistent type **********
+
+ public JavaPackageInfo getJavaPackageInfo() {
+ return this.javaPackageInfo;
+ }
+
+ protected void setJavaPackageInfo(JavaPackageInfo javaPackageInfo) {
+ JavaPackageInfo old = this.javaPackageInfo;
+ this.javaPackageInfo = javaPackageInfo;
+ this.firePropertyChanged(JAVA_PACKAGE_INFO_PROPERTY, old, javaPackageInfo);
+ }
+
+ protected void updateJavaPackageInfo() {
+ JavaResourcePackage resourcePackage = this.resolveJavaResourcePackage();
+ if (resourcePackage == null) {
+ if (this.javaPackageInfo != null) {
+ this.javaPackageInfo.dispose();
+ this.setJavaPackageInfo(null);
+ }
+ } else {
+ if (this.javaPackageInfo == null) {
+ this.setJavaPackageInfo(this.buildJavaPackageInfo(resourcePackage));
+ } else {
+ if (this.javaPackageInfo.getResourcePackage() == resourcePackage) {
+ this.javaPackageInfo.update();
+ } else {
+ this.javaPackageInfo.dispose();
+ this.setJavaPackageInfo(this.buildJavaPackageInfo(resourcePackage));
+ }
+ }
+ }
+ }
+
+ protected String getJavaPackageInfoName() {
+ return getClassName();//the same name should be used!
+ }
+
+ protected JavaResourcePackage resolveJavaResourcePackage() {
+ String javaPackageInfoName = this.getJavaPackageInfoName();
+ return (javaPackageInfoName == null) ? null : this.getJpaProject().getJavaResourcePackage(javaPackageInfoName);
+ }
+
+ protected JavaPackageInfo buildJavaPackageInfo(JavaResourcePackage jrpt) {
+ return this.getJpaFactory().buildJavaPackageInfo(this, jrpt);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef#validate(java.util.List, org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ if (reporter.isCancelled()) {
+ throw new ValidationCancelledException();
+ }
+ if (StringTools.stringIsEmpty(this.className)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS,
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ return;
+ }
+
+ if (this.javaPersistentType == null
+ && this.javaPackageInfo == null) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS,
+ new String[] {this.getJavaClassName()},
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ return;
+ }
+
+ if (javaPersistentType != null){
+ // 190062 validate Java class only if this is the only reference to it
+ // i.e. the persistence.xml ref is the only ref - none of the mapping
+ // files reference the same class
+ boolean validateJavaPersistentType = true;
+ for (Iterator<MappingFileRef> stream = this.getPersistenceUnit().mappingFileRefsContaining(this.getJavaClassName()); stream.hasNext(); ) {
+ validateJavaPersistentType = false;
+ MappingFileRef mappingFileRef = stream.next();
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.LOW_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS,
+ new String[] {this.getJavaClassName(), mappingFileRef.getFileName()},
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ }
+
+ if (validateJavaPersistentType) {
+ this.validateJavaPersistentType(messages, reporter);
+ }
+ }
+
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistence;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernatePersistence extends GenericPersistence {
+
+ /**
+ * @param parent
+ * @param xmlPersistence
+ */
+ public HibernatePersistence(PersistenceXml parent,
+ XmlPersistence xmlPersistence) {
+ super(parent, xmlPersistence);
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -10,9 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.core.internal.context.persistence.GenericPersistenceXmlContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernatePersistenceUnitProperties;
@@ -31,4 +35,19 @@
public HibernatePersistenceUnitProperties buildHibernatePersistenceUnitProperties(PersistenceUnit parent) {
return new HibernatePersistenceUnitProperties(parent);
}
+
+ public Persistence buildPersistence(PersistenceXml parent, XmlPersistence xmlPersistence) {
+ return new HibernatePersistence(parent, xmlPersistence);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent, String className) {
+ return new HibernateClassRef(parent, className);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent,
+ XmlJavaClassRef classRef) {
+ return new HibernateClassRef(parent, classRef);
+ }
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface PackageInfoRef {
+
+ // ********** java persistent type **********
+
+ /**
+ * String constant associated with changes to the java pacakge info
+ */
+ final static String JAVA_PACKAGE_INFO_PROPERTY = "javaPackageInfo"; //$NON-NLS-1$
+
+ /**
+ * Return the JavaPackageInfo that corresponds to this PackageInfoRef.
+ * This can be null.
+ * This is not settable by users of this API.
+ */
+ JavaPackageInfo getJavaPackageInfo();
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -10,12 +10,18 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.persistence.jpa2;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.Generic2_0PersistenceXmlContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernatePersistenceUnitProperties;
+import org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernateClassRef;
+import org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistence;
import org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistenceUnitPropertiesBuilder;
/**
@@ -32,4 +38,19 @@
public HibernatePersistenceUnitProperties buildHibernatePersistenceUnitProperties(PersistenceUnit parent) {
return new HibernatePersistenceUnitProperties(parent);
}
+
+ public Persistence buildPersistence(PersistenceXml parent, XmlPersistence xmlPersistence) {
+ return new HibernatePersistence(parent, xmlPersistence);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent, String className) {
+ return new HibernateClassRef(parent, className);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent,
+ XmlJavaClassRef classRef) {
+ return new HibernateClassRef(parent, classRef);
+ }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -86,5 +86,13 @@
@Override
protected void addPackageAnnotationDefinitionsTo(
ArrayList<AnnotationDefinition> definitions) {
+ definitions.add(GenericGeneratorAnnotationDefinition.instance());
+ definitions.add(GenericGeneratorsAnnotationDefinition.instance());
+ definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
+ definitions.add(HibernateNamedQueriesAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueryAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueriesAnnotationDefinition.instance());
+ definitions.add(TypeDefAnnotationDefinition.instance());
+ definitions.add(TypeDefsAnnotationDefinition.instance());
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -25,6 +25,7 @@
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaPlatformProvider;
import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
+import org.eclipse.jpt.jpa.core.internal.JavaPackageInfoResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
@@ -78,7 +79,10 @@
// ********** resource models **********
public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
- if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
+ if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) {
+ return JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE;
+ }
+ else if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
return JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
}
else if (contentType.equals(JptCommonCorePlugin.JAR_CONTENT_TYPE)) {
@@ -102,6 +106,7 @@
// order should not be important here
protected static final JpaResourceModelProvider[] RESOURCE_MODEL_PROVIDERS = new JpaResourceModelProvider[] {
+ JavaPackageInfoResourceModelProvider.instance(),
JavaResourceModelProvider.instance(),
JarResourceModelProvider.instance(),
PersistenceResourceModelProvider.instance(),
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -29,7 +29,6 @@
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
@@ -47,7 +46,7 @@
* @author Dmitry Geraskov
*
*/
-public class GenericGeneratorAnnotationImpl extends SourceAnnotation<Member>
+public class GenericGeneratorAnnotationImpl extends SourceAnnotation<AnnotatedElement>
implements GenericGeneratorAnnotation {
private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -69,7 +68,7 @@
* @param parent
* @param member
*/
- public GenericGeneratorAnnotationImpl(JavaResourceNode parent, Member member,
+ public GenericGeneratorAnnotationImpl(JavaResourceNode parent, AnnotatedElement member,
DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameDeclarationAdapter();
@@ -363,7 +362,7 @@
}
public static GenericGeneratorAnnotation createNestedGenericGenerator(
- JavaResourceNode parent, Member member,
+ JavaResourceNode parent, AnnotatedElement member,
int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa);
@@ -394,7 +393,7 @@
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement member) {
- return new GenericGeneratorAnnotationImpl(parent, (Member)member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ return new GenericGeneratorAnnotationImpl(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
}
public String getAnnotationName() {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -40,8 +39,8 @@
super();
}
- public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement member) {
- return new HibernateSourceNamedNativeQueriesAnnotation(parent, (Member) member);
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new HibernateSourceNamedNativeQueriesAnnotation(parent, annotatedElement);
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -43,7 +42,7 @@
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
AnnotatedElement annotatedElement) {
- return HibernateSourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent, (Member) annotatedElement);
+ return HibernateSourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent, annotatedElement);
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -42,7 +41,7 @@
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
AnnotatedElement annotatedElement) {
- return new HibernateSourceNamedQueriesAnnotation(parent, (Member) annotatedElement);
+ return new HibernateSourceNamedQueriesAnnotation(parent, annotatedElement);
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -44,7 +43,7 @@
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
- return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, (Member) annotatedElement);
+ return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, annotatedElement);
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -15,8 +15,8 @@
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.AnnotationContainerTools;
@@ -29,7 +29,7 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateSourceNamedNativeQueriesAnnotation extends SourceAnnotation<Member> implements
+public class HibernateSourceNamedNativeQueriesAnnotation extends SourceAnnotation<AnnotatedElement> implements
HibernateNamedNativeQueriesAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -37,7 +37,7 @@
private final Vector<HibernateNamedNativeQueryAnnotation> hibernateNamedNativeQueries = new Vector<HibernateNamedNativeQueryAnnotation>();
- public HibernateSourceNamedNativeQueriesAnnotation(JavaResourceNode parent, Member member) {
+ public HibernateSourceNamedNativeQueriesAnnotation(JavaResourceNode parent, AnnotatedElement member) {
super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -15,8 +15,8 @@
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.AnnotationContainerTools;
@@ -29,7 +29,7 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateSourceNamedQueriesAnnotation extends SourceAnnotation<Member> implements
+public class HibernateSourceNamedQueriesAnnotation extends SourceAnnotation<AnnotatedElement> implements
HibernateNamedQueriesAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -37,7 +37,7 @@
private final Vector<HibernateNamedQueryAnnotation> hibernateNamedQueries = new Vector<HibernateNamedQueryAnnotation>();
- public HibernateSourceNamedQueriesAnnotation(JavaResourceNode parent, Member member) {
+ public HibernateSourceNamedQueriesAnnotation(JavaResourceNode parent, AnnotatedElement member) {
super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -16,12 +16,12 @@
import org.eclipse.jpt.common.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
@@ -31,7 +31,7 @@
* @author Dmitry Geraskov
*
*/
-public class SourceParameterAnnotation extends SourceAnnotation<Member> implements
+public class SourceParameterAnnotation extends SourceAnnotation<AnnotatedElement> implements
NestableParameterAnnotation {
private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
@@ -43,7 +43,7 @@
private String value;
- public SourceParameterAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) {
+ public SourceParameterAnnotation(JavaResourceNode parent, AnnotatedElement member, IndexedDeclarationAnnotationAdapter idaa) {
super(parent, member, idaa, new ElementIndexedAnnotationAdapter(member, idaa));
this.nameDeclarationAdapter = this.buildNameAdapter(idaa);
this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
@@ -157,7 +157,7 @@
// ********** static methods **********
- public static SourceParameterAnnotation createParameter(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter annotationAdapter, String elementName, int index) {
+ public static SourceParameterAnnotation createParameter(JavaResourceNode parent, AnnotatedElement member, DeclarationAnnotationAdapter annotationAdapter, String elementName, int index) {
return new SourceParameterAnnotation(parent, member, buildParameterAnnotationAdapter(annotationAdapter, elementName, index));
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -33,7 +33,7 @@
import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
@@ -50,7 +50,7 @@
* @author Dmitry Geraskov
*
*/
-public class TypeDefAnnotationImpl extends SourceAnnotation<Member>
+public class TypeDefAnnotationImpl extends SourceAnnotation<AnnotatedElement>
implements TypeDefAnnotation {
private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -78,7 +78,7 @@
* @param parent
* @param member
*/
- public TypeDefAnnotationImpl(JavaResourceNode parent, Member member,
+ public TypeDefAnnotationImpl(JavaResourceNode parent, AnnotatedElement member,
DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
@@ -367,7 +367,7 @@
}
public static TypeDefAnnotation createNestedTypeDef(
- JavaResourceNode parent, Member member,
+ JavaResourceNode parent, AnnotatedElement member,
int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa);
@@ -417,7 +417,7 @@
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
- return new TypeDefAnnotationImpl(parent, (Member) annotatedElement,
+ return new TypeDefAnnotationImpl(parent, annotatedElement,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(annotatedElement, DECLARATION_ANNOTATION_ADAPTER));
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java 2011-08-01 12:37:29 UTC (rev 33411)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java 2011-08-01 12:43:50 UTC (rev 33412)
@@ -15,8 +15,8 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.AnnotationContainerTools;
@@ -32,7 +32,7 @@
* @author Dmitry Geraskov
*
*/
-public class TypeDefsAnnotationImpl extends SourceAnnotation<Member> implements
+public class TypeDefsAnnotationImpl extends SourceAnnotation<AnnotatedElement> implements
TypeDefsAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -40,7 +40,7 @@
private final Vector<TypeDefAnnotation> typeDefs = new Vector<TypeDefAnnotation>();
- public TypeDefsAnnotationImpl(JavaResourceNode parent, Member member) {
+ public TypeDefsAnnotationImpl(JavaResourceNode parent, AnnotatedElement member) {
super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
}
@@ -152,8 +152,8 @@
super();
}
- public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement member) {
- return new TypeDefsAnnotationImpl(parent, (Member) member);
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement member) {
+ return new TypeDefsAnnotationImpl(parent, member);
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
13 years, 4 months
JBoss Tools SVN: r33411 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-08-01 08:37:29 -0400 (Mon, 01 Aug 2011)
New Revision: 33411
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
Log:
https://issues.jboss.org/browse/JBIDE-9434
Fix NPE on validation
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2011-08-01 12:21:06 UTC (rev 33410)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2011-08-01 12:37:29 UTC (rev 33411)
@@ -23,13 +23,13 @@
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
@@ -45,7 +45,7 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateSourceNamedNativeQueryAnnotation extends SourceAnnotation<Member> implements
+public class HibernateSourceNamedNativeQueryAnnotation extends SourceAnnotation<AnnotatedElement> implements
HibernateNamedNativeQueryAnnotation {
public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -58,6 +58,7 @@
private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
private final AnnotationElementAdapter<String> queryAdapter;
private String query;
+ TextRange queryTextRange;
private final DeclarationAnnotationElementAdapter<String> flushModeDeclarationAdapter;
private final AnnotationElementAdapter<String> flushModeAdapter;
@@ -110,7 +111,7 @@
private final AnnotationElementAdapter<String> resultSetMappingAdapter;
private String resultSetMapping;
- HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, AnnotatedElement member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
@@ -150,6 +151,7 @@
this.name = this.buildName(astRoot);
this.nameTextRange = this.buildNameTextRange(astRoot);
this.query = this.buildQuery(astRoot);
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.flushMode = this.buildFlushMode(astRoot);
this.cacheMode = this.buildCacheMode(astRoot);
this.cacheable = this.buildCacheable(astRoot);
@@ -168,6 +170,7 @@
this.syncName(this.buildName(astRoot));
this.nameTextRange = this.buildNameTextRange(astRoot);
this.syncQuery(this.buildQuery(astRoot));
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.syncFlushMode(this.buildFlushMode(astRoot));
this.syncCacheMode(this.buildCacheMode(astRoot));
this.syncCacheable(this.buildCacheable(astRoot));
@@ -251,6 +254,10 @@
@Override
public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.queryTextRange;
+ }
+
+ private TextRange buildQueryTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
}
@@ -630,7 +637,7 @@
return (IndexedAnnotationAdapter) this.annotationAdapter;
}
- public static HibernateNamedNativeQueryAnnotation createNamedNativeQuery(JavaResourceNode parent, Member member) {
+ public static HibernateNamedNativeQueryAnnotation createNamedNativeQuery(JavaResourceNode parent, AnnotatedElement member) {
return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
}
@@ -694,11 +701,11 @@
// ********** static methods **********
- public static HibernateSourceNamedNativeQueryAnnotation createHibernateNamedNativeQuery(JavaResourceNode parent, Member member) {
+ public static HibernateSourceNamedNativeQueryAnnotation createHibernateNamedNativeQuery(JavaResourceNode parent, AnnotatedElement member) {
return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
}
- public static HibernateSourceNamedNativeQueryAnnotation createNestedHibernateNamedNativeQuery(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ public static HibernateSourceNamedNativeQueryAnnotation createNestedHibernateNamedNativeQuery(JavaResourceNode parent, AnnotatedElement member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa);
return new HibernateSourceNamedNativeQueryAnnotation(parent, member, idaa, annotationAdapter);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2011-08-01 12:21:06 UTC (rev 33410)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2011-08-01 12:37:29 UTC (rev 33411)
@@ -21,13 +21,13 @@
import org.eclipse.jpt.common.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
@@ -43,7 +43,7 @@
*
*/
@SuppressWarnings("restriction")
-public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<Member>
+public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<AnnotatedElement>
implements HibernateNamedQueryAnnotation {
public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -56,6 +56,7 @@
private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
private final AnnotationElementAdapter<String> queryAdapter;
private String query;
+ TextRange queryTextRange;
private final DeclarationAnnotationElementAdapter<String> flushModeDeclarationAdapter;
private final AnnotationElementAdapter<String> flushModeAdapter;
@@ -90,7 +91,7 @@
private Boolean readOnly;
- HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, AnnotatedElement member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
@@ -124,6 +125,7 @@
this.name = this.buildName(astRoot);
this.nameTextRange = this.buildNameTextRange(astRoot);
this.query = this.buildQuery(astRoot);
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.flushMode = this.buildFlushMode(astRoot);
this.cacheMode = this.buildCacheMode(astRoot);
this.cacheable = this.buildCacheable(astRoot);
@@ -139,6 +141,7 @@
this.syncName(this.buildName(astRoot));
this.nameTextRange = this.buildNameTextRange(astRoot);
this.syncQuery(this.buildQuery(astRoot));
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.syncFlushMode(this.buildFlushMode(astRoot));
this.syncCacheMode(this.buildCacheMode(astRoot));
this.syncCacheable(this.buildCacheable(astRoot));
@@ -217,6 +220,10 @@
@Override
public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.queryTextRange;
+ }
+
+ private TextRange buildQueryTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
}
@@ -493,7 +500,7 @@
return (IndexedAnnotationAdapter) this.annotationAdapter;
}
- public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent, Member member) {
+ public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent, AnnotatedElement member) {
return new HibernateSourceNamedQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
}
@@ -544,11 +551,11 @@
// ********** static methods **********
- public static HibernateSourceNamedQueryAnnotation createHibernateNamedQuery(JavaResourceNode parent, Member member) {
+ public static HibernateSourceNamedQueryAnnotation createHibernateNamedQuery(JavaResourceNode parent, AnnotatedElement member) {
return new HibernateSourceNamedQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
}
- public static HibernateSourceNamedQueryAnnotation createNestedHibernateNamedQuery(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ public static HibernateSourceNamedQueryAnnotation createNestedHibernateNamedQuery(JavaResourceNode parent, AnnotatedElement member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa);
return new HibernateSourceNamedQueryAnnotation(parent, member, idaa, annotationAdapter);
13 years, 4 months
JBoss Tools SVN: r33410 - trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests.
by jbosstools-commits@lists.jboss.org
Author: lzoubek(a)redhat.com
Date: 2011-08-01 08:21:06 -0400 (Mon, 01 Aug 2011)
New Revision: 33410
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/CreateRuntimeFromESB.java
Log:
reflect botext changes
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/CreateRuntimeFromESB.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/CreateRuntimeFromESB.java 2011-08-01 12:20:17 UTC (rev 33409)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/CreateRuntimeFromESB.java 2011-08-01 12:21:06 UTC (rev 33410)
@@ -16,7 +16,7 @@
wiz.button("Add").click();
bot.shell(IDELabel.Shell.NEW_ESB_RUNTIME).activate();
assertFalse("Finish button must not be enabled when no home dir is defined",bot.button(IDELabel.Button.FINISH).isEnabled());
- bot.text(1).setText(TestConfigurator.currentConfig.getEsb().esbHome);
+ bot.text(1).setText(TestConfigurator.currentConfig.getEsb().runtimeHome);
assertTrue("Version was not automaticly selected by setting ESB home dir",bot.comboBox().selection().equals(TestConfigurator.currentConfig.getEsb().version));
bot.text(0).setText("runtime");
String name = bot.text(0).getText();
13 years, 4 months
JBoss Tools SVN: r33409 - in trunk/tests/plugins/org.jboss.tools.ui.bot.ext: src/org/jboss/tools/ui/bot/ext and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: lzoubek(a)redhat.com
Date: 2011-08-01 08:20:17 -0400 (Mon, 01 Aug 2011)
New Revision: 33409
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ESBBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JavaBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/SeamBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java
Log:
swtbotext: support for downloading server runtimes
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties 2011-08-01 12:20:17 UTC (rev 33409)
@@ -6,6 +6,9 @@
# note : when server is type of SOA, version is version of SOA (not the bundled EAP)
SERVER=EAP,5.0,1.6,/data/jboss/jboss-eap-5.0/jboss-as
#SERVER=EAP,5.0,1.6,/data/jboss/jboss-eap-5.0/jboss-as,remote.example.com,/opt/jboss-eap-5.0/jboss-as
+# note that zip will be unzipped into <server home> minus 1-2 folders. Change <server home> to reflect
+# content of downloaded zip.
+SERVER_URL=http://localhost/eap5.zip
# remote system= <user>,<host>,<private key>
#RS=lzoubek,remote.example.com,/home/lzoubek/.ssh/id_rsa
#<seam version>,<seam runtime home>
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -176,6 +176,7 @@
} catch (Exception e) {
log.error("Fulfilling failed", e);
}
+ log.info("Done");
return super.withBeforeClasses(statement);
}
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ESBBean.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ESBBean.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ESBBean.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -1,27 +1,10 @@
package org.jboss.tools.ui.bot.ext.config;
-public class ESBBean {
- public String version;
- public String esbHome;
-
- public static ESBBean fromString(String propValue) throws Exception{
- try {
- if (propValue==null) {
- return null;
- }
- String[] esbParams = propValue.split(",");
- ESBBean bean = new ESBBean();
- bean.esbHome=esbParams[1];
- bean.version=esbParams[0];
- return bean;
- }
- catch (Exception ex) {
- throw new Exception("Cannot parse ESB property line",ex);
- }
+public class ESBBean extends RuntimeBean{
+ public ESBBean() {
+ this.key = TestConfigurator.Keys.ESB;
}
- @Override
- public String toString() {
- return String.format("ESB runtime version=%s, home=%s",
- this.version, this.esbHome);
+ public static ESBBean fromString(String propValue) throws Exception {
+ return (ESBBean)fromString(propValue, new ESBBean());
}
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JBPMBean.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -1,27 +1,11 @@
package org.jboss.tools.ui.bot.ext.config;
-public class JBPMBean {
- public String version;
- public String jbpmHome;
-
- public static JBPMBean fromString(String propValue) throws Exception{
- try {
- if (propValue==null) {
- return null;
- }
- String[] jbpmParams = propValue.split(",");
- JBPMBean bean = new JBPMBean();
- bean.jbpmHome=jbpmParams[1];
- bean.version=jbpmParams[0];
- return bean;
- }
- catch (Exception ex) {
- throw new Exception("Cannot parse jBPM property line",ex);
- }
+public class JBPMBean extends RuntimeBean {
+
+ public JBPMBean() {
+ this.key = TestConfigurator.Keys.JBPM;
}
- @Override
- public String toString() {
- return String.format("jBPM runtime version=%s, home=%s",
- this.version, this.jbpmHome);
+ public static JBPMBean fromString(String propValue) throws Exception {
+ return (JBPMBean)fromString(propValue, new JBPMBean());
}
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JavaBean.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JavaBean.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/JavaBean.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -1,27 +1,11 @@
package org.jboss.tools.ui.bot.ext.config;
-public class JavaBean {
- public String version;
- public String javaHome;
+public class JavaBean extends RuntimeBean {
- public static JavaBean fromString(String propValue) throws Exception{
- try {
- if (propValue==null) {
- return null;
- }
- String[] esbParams = propValue.split(",");
- JavaBean bean = new JavaBean();
- bean.javaHome=esbParams[1];
- bean.version=esbParams[0];
- return bean;
- }
- catch (Exception ex) {
- throw new Exception("Cannot parse JAVA property line",ex);
- }
+ public JavaBean() {
+ this.key = TestConfigurator.Keys.JAVA;
}
- @Override
- public String toString() {
- return String.format("JAVA runtime version=%s, home=%s",
- this.version, this.javaHome);
+ public static JavaBean fromString(String propValue) throws Exception {
+ return (JavaBean)fromString(propValue, new JavaBean());
}
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/SeamBean.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/SeamBean.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/SeamBean.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -1,28 +1,11 @@
package org.jboss.tools.ui.bot.ext.config;
-public class SeamBean {
-
- public String version;
- public String seamHome;
-
+public class SeamBean extends RuntimeBean{
+
+ public SeamBean() {
+ this.key = TestConfigurator.Keys.SEAM;
+ }
public static SeamBean fromString(String propValue) throws Exception {
- try {
- if (propValue == null) {
- return null;
- }
- String[] seamParams = propValue.split(",");
- SeamBean bean = new SeamBean();
- bean.seamHome = seamParams[1];
- bean.version = seamParams[0];
- return bean;
- } catch (Exception ex) {
- throw new Exception("Cannot parse SEAM property line", ex);
- }
+ return (SeamBean)fromString(propValue, new SeamBean());
}
-
- @Override
- public String toString() {
- return String.format("Seam runtime version=%s, home=%s",
- this.version, this.seamHome);
- }
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -1,16 +1,16 @@
package org.jboss.tools.ui.bot.ext.config;
-import java.util.Arrays;
+import java.io.File;
+import org.jboss.tools.ui.bot.ext.helper.FileHelper;
+
/**
*
* @author lzoubek
*
*/
-public class ServerBean {
+public class ServerBean extends RuntimeBean {
- public String version;
- public String runtimeHome;
public String withJavaVersion;
public String type;
/**
@@ -21,6 +21,24 @@
* home of app server located in remote system
*/
public String remoteHome;
+ public static ServerBean fromString(String propValue, String url) throws Exception {
+ ServerBean bean = fromString(propValue);
+ if (bean!=null && url!=null) {
+ String runtimeFile = downloadRuntime(url);
+ if (runtimeFile!=null) {
+ // where to unzip it?
+ String runtimeOutput;
+ if (TestConfigurator.Values.SERVER_TYPE_JBOSSAS.equals(bean.type)) {
+ runtimeOutput=new File(bean.runtimeHome).getParent();
+ }
+ else {
+ runtimeOutput=new File(bean.runtimeHome).getParentFile().getParent();
+ }
+ FileHelper.unzipArchive(new File(runtimeFile), new File(runtimeOutput));
+ }
+ }
+ return bean;
+ }
/**
* creates bean instance from property string
* @param propValue property value
@@ -28,12 +46,12 @@
* @throws Exception
*/
public static ServerBean fromString(String propValue) throws Exception {
+ ServerBean bean = new ServerBean();
try {
if (propValue==null) {
return null;
}
- String[] serverParams = propValue.split(",");
- ServerBean bean = new ServerBean();
+ String[] serverParams = propValue.split(",");
bean.withJavaVersion = serverParams[2];
bean.runtimeHome=serverParams[3];
bean.version=serverParams[1];
@@ -46,12 +64,12 @@
return bean;
}
catch (Exception ex) {
- throw new Exception("Cannot parse SERVER property line",ex);
+ throw new Exception("Cannot parse "+bean.key+" property line",ex);
}
}
@Override
public String toString() {
- return String.format("Server type=%s,version=%s,home=%s,withJava=%s,remoteSystem=%s", this.type,this.version,this.runtimeHome,this.withJavaVersion,this.remoteSystem);
+ return String.format("%s type=%s,version=%s,home=%s,withJava=%s,remoteSystem=%s",this.key, this.type,this.version,this.runtimeHome,this.withJavaVersion,this.remoteSystem);
}
/**
@@ -61,5 +79,8 @@
public String getName() {
return type + "-" + version;
}
+ public ServerBean() {
+ this.key = TestConfigurator.Keys.SERVER;
+ }
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -53,8 +53,7 @@
// properties got loaded
java = JavaBean.fromString(getProperty(Keys.JAVA));
printConfig(Keys.JAVA, java);
- log.info(getProperty(Keys.SERVER));
- server = ServerBean.fromString(getProperty(Keys.SERVER));
+ server = ServerBean.fromString(getProperty(Keys.SERVER),getProperty(Keys.SERVER+TestConfigurator.RUNTIME_URL_SUFFIX));
printConfig(Keys.SERVER, server);
remoteSystem = RemoteSystemBean.fromString(getProperty(Keys.RS));
printConfig(Keys.RS, remoteSystem);
@@ -70,6 +69,7 @@
printConfig("Secure Storage",secureStorage);
checkConfig();
}
+
private static void printConfig(String propName, Object bean) {
if (bean == null) {
@@ -82,15 +82,15 @@
private boolean checkConfig() throws Exception {
if (java != null)
- checkDirExists(java.javaHome);
+ checkDirExists(java.runtimeHome);
if (seam != null)
- checkDirExists(seam.seamHome);
+ checkDirExists(seam.runtimeHome);
if (server != null)
checkDirExists(server.runtimeHome);
if (esb != null)
- checkDirExists(esb.esbHome);
+ checkDirExists(esb.runtimeHome);
if (jbpm != null)
- checkDirExists(jbpm.jbpmHome);
+ checkDirExists(jbpm.runtimeHome);
if (db != null) {
if (!db.internal)
checkFileExists(db.driverPath);
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -24,7 +24,7 @@
public class TestConfigurator {
private static final Logger log = Logger.getLogger(TestConfigurator.class);
-
+ public static final String RUNTIME_URL_SUFFIX="_URL";
public class Keys {
public static final String SERVER = "SERVER";
public static final String SEAM = "SEAM";
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -13,7 +13,7 @@
@Override
public void handle() {
String esbName = "ESB-"+TestConfigurator.currentConfig.getEsb().version;
- SWTTestExt.eclipse.addESBRuntime(esbName,TestConfigurator.currentConfig.getEsb().version,TestConfigurator.currentConfig.getEsb().esbHome);
+ SWTTestExt.eclipse.addESBRuntime(esbName,TestConfigurator.currentConfig.getEsb().version,TestConfigurator.currentConfig.getEsb().runtimeHome);
SWTTestExt.configuredState.getEsb().isConfiured=true;
SWTTestExt.configuredState.getEsb().name=esbName;
SWTTestExt.configuredState.getEsb().version=TestConfigurator.currentConfig.getEsb().version;
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJBPM.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -13,7 +13,7 @@
@Override
public void handle() {
String jbpmName = "JBPM-"+TestConfigurator.currentConfig.getJBPM().version;
- SWTTestExt.eclipse.addJBPMRuntime(jbpmName, TestConfigurator.currentConfig.getJBPM().jbpmHome);
+ SWTTestExt.eclipse.addJBPMRuntime(jbpmName, TestConfigurator.currentConfig.getJBPM().runtimeHome);
SWTTestExt.configuredState.getJBPM().isConfigured=true;
SWTTestExt.configuredState.getJBPM().name=jbpmName;
SWTTestExt.configuredState.getJBPM().version=TestConfigurator.currentConfig.getJBPM().version;
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -29,7 +29,7 @@
return "JRE-"+TestConfigurator.currentConfig.getJava().version;
}
private String getJavaHome() {
- return TestConfigurator.currentConfig.getJava().javaHome;
+ return TestConfigurator.currentConfig.getJava().runtimeHome;
}
}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -13,7 +13,7 @@
@Override
public void handle() {
String seamName = "Seam-"+TestConfigurator.currentConfig.getSeam().version;
- SWTTestExt.eclipse.addSeamRuntime(seamName, TestConfigurator.currentConfig.getSeam().version, TestConfigurator.currentConfig.getSeam().seamHome);
+ SWTTestExt.eclipse.addSeamRuntime(seamName, TestConfigurator.currentConfig.getSeam().version, TestConfigurator.currentConfig.getSeam().runtimeHome);
SWTTestExt.configuredState.getSeam().isConfiured=true;
SWTTestExt.configuredState.getSeam().name=seamName;
SWTTestExt.configuredState.getSeam().version=TestConfigurator.currentConfig.getSeam().version;
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java 2011-08-01 10:28:00 UTC (rev 33408)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileHelper.java 2011-08-01 12:20:17 UTC (rev 33409)
@@ -10,12 +10,20 @@
******************************************************************************/
package org.jboss.tools.ui.bot.ext.helper;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import org.apache.log4j.Logger;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
@@ -23,82 +31,165 @@
import org.jboss.tools.ui.bot.ext.view.PackageExplorer;
/**
- * Contains some file manipulation utils
+ * Contains some file manipulation utils
+ *
* @author Vladimir Pakan
- *
+ *
*/
public class FileHelper {
- /**
- * Recursively copies files and subdirectories from fromLocation to toLocation using FileFilter fileFliter
- * @param fromLocation
- * @param toLocation
- * @param fileFilter
- * @throws IOException
- */
- public static void copyFilesBinaryRecursively(File fromLocation, File toLocation, FileFilter fileFilter ) throws IOException{
- if (fromLocation.exists()){
- for (File fileToCopy : fromLocation.listFiles(fileFilter)){
- if (fileToCopy.isDirectory()){
- File newToDir = new File(toLocation, fileToCopy.getName());
- newToDir.mkdir();
- copyFilesBinaryRecursively (fileToCopy, newToDir, fileFilter);
- }
- else{
- copyFilesBinary(fileToCopy,toLocation);
- }
- }
- }
- }
- /**
- * Copies binary file originalFile to location toLocation
- * @param originalFile
- * @param toLocation
- * @throws IOException
- */
- public static void copyFilesBinary(File originalFile, File toLocation) throws IOException{
- FileInputStream fis = null;
- FileOutputStream fos = null;
- try {
- fis = new FileInputStream(originalFile);
- fos = new FileOutputStream(new File(toLocation, originalFile.getName()));
- byte[] buffer = new byte[4096];
- int bytesRead;
+ public static final Logger log = Logger.getLogger(FileHelper.class);
- while ((bytesRead = fis.read(buffer)) != -1) {
- fos.write(buffer, 0, bytesRead); // write
- }
-
- }finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException e) {
- // do nothing
- }
- }
- if (fos != null) {
- try {
- fos.flush();
- fos.close();
- } catch (IOException e) {
- // do nothing
- }
- }
- }
- }
+ /**
+ * Recursively copies files and subdirectories from fromLocation to
+ * toLocation using FileFilter fileFliter
+ *
+ * @param fromLocation
+ * @param toLocation
+ * @param fileFilter
+ * @throws IOException
+ */
+ public static void copyFilesBinaryRecursively(File fromLocation,
+ File toLocation, FileFilter fileFilter) throws IOException {
+ if (fromLocation.exists()) {
+ for (File fileToCopy : fromLocation.listFiles(fileFilter)) {
+ if (fileToCopy.isDirectory()) {
+ File newToDir = new File(toLocation, fileToCopy.getName());
+ newToDir.mkdir();
+ copyFilesBinaryRecursively(fileToCopy, newToDir, fileFilter);
+ } else {
+ copyFilesBinary(fileToCopy, toLocation);
+ }
+ }
+ }
+ }
- public static String getProjectLocation (String projectName , SWTBot bot){
- PackageExplorer packageExplorer = new PackageExplorer();
- SWTBot packageExplorerBot = packageExplorer.show().bot();
- SWTBotTree packageExplorerTree = packageExplorerBot.tree();
- packageExplorerTree.expandNode(projectName).select();
- bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.PROPERTIES).click();
- SWTBot propertiesBot = bot.shell(IDELabel.Shell.PROPERTIES_FOR + " " + projectName).activate().bot();
- propertiesBot.tree().select(IDELabel.PropertiesWindow.RESOURCE);
- SWTBotText pathText = propertiesBot.textWithLabel(IDELabel.PropertiesWindow.ResourceProperties.LOCATION);
- String projectLocation = pathText.getText();
- propertiesBot.button(IDELabel.Button.OK).click();
- return projectLocation;
- }
-
+ /**
+ * Copies binary file originalFile to location toLocation
+ *
+ * @param originalFile
+ * @param toLocation
+ * @throws IOException
+ */
+ public static void copyFilesBinary(File originalFile, File toLocation)
+ throws IOException {
+ FileInputStream fis = null;
+ FileOutputStream fos = null;
+ try {
+ fis = new FileInputStream(originalFile);
+ fos = new FileOutputStream(new File(toLocation,
+ originalFile.getName()));
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+
+ while ((bytesRead = fis.read(buffer)) != -1) {
+ fos.write(buffer, 0, bytesRead); // write
+ }
+
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ if (fos != null) {
+ try {
+ fos.flush();
+ fos.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ public static String getProjectLocation(String projectName, SWTBot bot) {
+ PackageExplorer packageExplorer = new PackageExplorer();
+ SWTBot packageExplorerBot = packageExplorer.show().bot();
+ SWTBotTree packageExplorerTree = packageExplorerBot.tree();
+ packageExplorerTree.expandNode(projectName).select();
+ bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.PROPERTIES).click();
+ SWTBot propertiesBot = bot
+ .shell(IDELabel.Shell.PROPERTIES_FOR + " " + projectName)
+ .activate().bot();
+ propertiesBot.tree().select(IDELabel.PropertiesWindow.RESOURCE);
+ SWTBotText pathText = propertiesBot
+ .textWithLabel(IDELabel.PropertiesWindow.ResourceProperties.LOCATION);
+ String projectLocation = pathText.getText();
+ propertiesBot.button(IDELabel.Button.OK).click();
+ return projectLocation;
+ }
+
+ public static void unzipArchive(File archive, File outputDir)
+ throws Exception {
+ log.info("Unzipping " + archive.getCanonicalPath() + " to "
+ + outputDir.getCanonicalPath());
+ ZipFile zipfile = new ZipFile(archive);
+ for (Enumeration<? extends ZipEntry> e = zipfile.entries(); e
+ .hasMoreElements();) {
+ ZipEntry entry = (ZipEntry) e.nextElement();
+ unzipEntry(zipfile, entry, outputDir);
+ }
+ log.info("DONE");
+ }
+
+ static private boolean deleteDirectory(File path) {
+ if (path.exists()) {
+ File[] files = path.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ deleteDirectory(files[i]);
+ } else {
+ files[i].delete();
+ }
+ }
+ }
+ return (path.delete());
+ }
+
+ private static void unzipEntry(ZipFile zipfile, ZipEntry entry,
+ File outputDir) throws IOException {
+
+ if (entry.isDirectory()) {
+ createDir(new File(outputDir, entry.getName()));
+ return;
+ }
+
+ File outputFile = new File(outputDir, entry.getName());
+ if (!outputFile.getParentFile().exists()) {
+ createDir(outputFile.getParentFile());
+ }
+
+ BufferedInputStream inputStream = new BufferedInputStream(
+ zipfile.getInputStream(entry));
+ BufferedOutputStream outputStream = new BufferedOutputStream(
+ new FileOutputStream(outputFile));
+
+ try {
+ copy(inputStream, outputStream);
+ } finally {
+ outputStream.close();
+ inputStream.close();
+ }
+ }
+
+ private static void copy(InputStream in, OutputStream out)
+ throws IOException {
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
+ private static void createDir(File dir) {
+ if (dir.exists()) {
+ deleteDirectory(dir);
+ }
+ if (!dir.mkdirs())
+ throw new RuntimeException("Can not create dir " + dir);
+ }
}
13 years, 4 months
JBoss Tools SVN: r33408 - trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-08-01 06:28:00 -0400 (Mon, 01 Aug 2011)
New Revision: 33408
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnectionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java
Log:
JBIDE-9421 - mbean explorer for as7
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java 2011-08-01 10:13:14 UTC (rev 33407)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java 2011-08-01 10:28:00 UTC (rev 33408)
@@ -170,7 +170,8 @@
}
public void connectionRemoved(IConnectionWrapper connection) {
- server.removeServerListener(this);
+ if( connection == this )
+ server.removeServerListener(this);
}
public boolean canControl() {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnectionProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnectionProvider.java 2011-08-01 10:13:14 UTC (rev 33407)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnectionProvider.java 2011-08-01 10:28:00 UTC (rev 33408)
@@ -10,23 +10,24 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.jmx.integration;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import javax.management.MBeanServerConnection;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.IServerListener;
import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.ide.eclipse.as.core.ExtensionManager.IServerJMXRunnable;
-import org.jboss.ide.eclipse.as.core.ExtensionManager.IServerJMXRunner;
+import org.eclipse.wst.server.core.ServerEvent;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.tools.jmx.core.ExtensionManager;
import org.jboss.tools.jmx.core.IConnectionProvider;
@@ -34,6 +35,8 @@
import org.jboss.tools.jmx.core.IConnectionWrapper;
import org.jboss.tools.jmx.core.IJMXRunnable;
import org.jboss.tools.jmx.core.JMXException;
+import org.jboss.tools.jmx.core.providers.DefaultConnectionWrapper;
+import org.jboss.tools.jmx.core.providers.MBeanServerConnectionDescriptor;
public class JBossServerConnectionProvider implements IConnectionProvider, IServerLifecycleListener {
public static final String PROVIDER_ID = "org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider"; //$NON-NLS-1$
@@ -42,14 +45,14 @@
return (JBossServerConnectionProvider)ExtensionManager.getProvider(PROVIDER_ID);
}
- public static JBossServerConnection getConnection(IServer s) {
- return (JBossServerConnection)getProvider().findConnection(s);
+ public static IConnectionWrapper getConnection(IServer s) {
+ return getProvider().findConnection(s);
}
// Run this action on the server.
// If the connection doesn't exist, make a new one
public static void run(IServer s, IJMXRunnable r) throws JMXException {
- JBossServerConnection c = getConnection(s);
+ IConnectionWrapper c = getConnection(s);
if( c != null )
// JMX is not installed here
c.run(r);
@@ -59,7 +62,7 @@
private ArrayList<IConnectionProviderListener> listeners =
new ArrayList<IConnectionProviderListener>();
- private HashMap<String, JBossServerConnection> idToConnection;
+ private HashMap<String, IConnectionWrapper> idToConnection;
public JBossServerConnectionProvider() {
ServerCore.addServerLifecycleListener(this);
}
@@ -68,15 +71,77 @@
return ServerConverter.getJBossServer(server) != null;
}
- protected JBossServerConnection createConnection(IServer server) {
- return new JBossServerConnection(server);
+ protected boolean requiresDefaultProvider(IServer server) {
+ if(server.getServerType().getId().equals(IJBossToolingConstants.SERVER_AS_70))
+ return true;
+ return false;
}
+ protected IConnectionWrapper createConnection(IServer server) {
+ if( !requiresDefaultProvider(server))
+ return new JBossServerConnection(server);
+ return createDefaultServerConnection(server);
+ }
+
+ protected IConnectionWrapper createDefaultServerConnection(IServer server) {
+ String SIMPLE_PREFIX = "service:jmx:rmi:///jndi/rmi://"; //$NON-NLS-1$ constants are in jmx.ui feh
+ String SIMPLE_SUFFIX = "/jmxrmi"; //$NON-NLS-1$
+ String host = server.getHost();
+ String port = "1090"; // TODO fix hard code
+ String url = SIMPLE_PREFIX + host + ":" + port + SIMPLE_SUFFIX; //$NON-NLS-1$
+
+ MBeanServerConnectionDescriptor desc = new
+ MBeanServerConnectionDescriptor(server.getName(), url, "", "");
+ try {
+ return new ExtendedDefaultConnectionWrapper(desc, server);
+ } catch( MalformedURLException murle) {
+ // TODO log
+ return null;
+ }
+ }
+
+ private class ExtendedDefaultConnectionWrapper extends DefaultConnectionWrapper
+ implements IServerListener, IConnectionProviderListener {
+ private IServer server;
+ public ExtendedDefaultConnectionWrapper(
+ MBeanServerConnectionDescriptor descriptor, IServer server)
+ throws MalformedURLException {
+ super(descriptor);
+ this.server = server;
+ server.addServerListener(this);
+ }
+ public void serverChanged(ServerEvent event) {
+ int eventKind = event.getKind();
+ if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) {
+ // server change event
+ if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
+ boolean started = event.getServer().getServerState() == IServer.STATE_STARTED;
+ try {
+ if( started )
+ connect();
+ else
+ disconnect();
+ } catch( IOException ioe) {
+ // TODO log
+ }
+ }
+ }
+ }
+ public void connectionAdded(IConnectionWrapper connection) {
+ }
+ public void connectionRemoved(IConnectionWrapper connection) {
+ if( connection == this )
+ server.removeServerListener(this);
+ }
+ public void connectionChanged(IConnectionWrapper connection) {
+ }
+ }
+
public void serverAdded(IServer server) {
if( belongsHere(server)) {
getConnections();
if( !idToConnection.containsKey(server.getId())) {
- JBossServerConnection connection = createConnection(server);
+ IConnectionWrapper connection = createConnection(server);
idToConnection.put(server.getId(), connection);
}
fireAdded(idToConnection.get(server.getId()));
@@ -87,7 +152,7 @@
if( belongsHere(server)) {
getConnections();
if( !idToConnection.containsKey(server.getId())) {
- JBossServerConnection connection = createConnection(server);
+ IConnectionWrapper connection = createConnection(server);
idToConnection.put(server.getId(), connection);
}
fireAdded(idToConnection.get(server.getId()));
@@ -96,7 +161,7 @@
public void serverRemoved(IServer server) {
if( belongsHere(server)) {
- JBossServerConnection connection;
+ IConnectionWrapper connection;
if( idToConnection != null ) {
connection = idToConnection.get(server.getId());
if( connection != null ) {
@@ -122,9 +187,9 @@
// do it all on demand right now
if( idToConnection == null ) {
// load them all
- idToConnection = new HashMap<String, JBossServerConnection>();
+ idToConnection = new HashMap<String, IConnectionWrapper>();
IServer[] allServers = ServerCore.getServers();
- JBossServerConnection c;
+ IConnectionWrapper c;
for( int i = 0; i < allServers.length; i++ ) {
if( belongsHere(allServers[i])) {
c = createConnection(allServers[i]);
@@ -133,9 +198,9 @@
}
}
}
- ArrayList<JBossServerConnection> list = new ArrayList<JBossServerConnection>();
+ ArrayList<IConnectionWrapper> list = new ArrayList<IConnectionWrapper>();
list.addAll(idToConnection.values());
- return list.toArray(new JBossServerConnection[list.size()]);
+ return list.toArray(new IConnectionWrapper[list.size()]);
}
public String getName(IConnectionWrapper wrapper) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java 2011-08-01 10:13:14 UTC (rev 33407)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java 2011-08-01 10:28:00 UTC (rev 33408)
@@ -117,7 +117,7 @@
JBossServerConnectionProvider provider =
(JBossServerConnectionProvider)ExtensionManager.getProvider(
JBossServerConnectionProvider.PROVIDER_ID);
- JBossServerConnection connection = provider.getConnection(server);
+ IConnectionWrapper connection = provider.getConnection(server);
if( connection != null ) {
view.getCommonViewer().collapseAll();
ISelection sel = new StructuredSelection(new Object[] { connection });
13 years, 4 months
JBoss Tools SVN: r33407 - in trunk/maven/plugins: org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-08-01 06:13:14 -0400 (Mon, 01 Aug 2011)
New Revision: 33407
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java
Log:
JBIDE-8969 : force loading of MavenProject and load available profiles from parent hierarchy
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java 2011-08-01 09:18:46 UTC (rev 33406)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java 2011-08-01 10:13:14 UTC (rev 33407)
@@ -1,5 +1,6 @@
package org.jboss.tools.maven.core.internal.profiles;
+import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -10,17 +11,25 @@
import java.util.Map;
import java.util.Set;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
import org.apache.maven.model.Profile;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.SettingsUtils;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IProjectConfigurationManager;
import org.eclipse.m2e.core.project.MavenUpdateRequest;
import org.eclipse.m2e.core.project.ResolverConfiguration;
+import org.eclipse.osgi.util.NLS;
import org.jboss.tools.maven.core.profiles.IProfileManager;
import org.jboss.tools.maven.core.profiles.ProfileState;
import org.jboss.tools.maven.core.profiles.ProfileStatus;
@@ -36,17 +45,17 @@
return;
}
final IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
- final ResolverConfiguration configuration =configurationManager
- .getResolverConfiguration(mavenProjectFacade.getProject());
+ IProject project = mavenProjectFacade.getProject();
+
+ final ResolverConfiguration configuration =configurationManager.getResolverConfiguration(project);
+
final String profilesAsString = getAsString(profiles);
if (profilesAsString.equals(configuration.getActiveProfiles())) {
//Nothing changed
return;
}
- IProject project = mavenProjectFacade.getProject();
-
configuration.setActiveProfiles(profilesAsString);
boolean isSet = configurationManager.setResolverConfiguration(project, configuration);
if (isSet) {
@@ -71,30 +80,6 @@
return sb.toString();
}
- public Map<Profile, Boolean> getAvailableProfiles(IMavenProjectFacade facade) throws CoreException {
- if (facade == null) {
- return Collections.emptyMap();
- }
- List<Profile> modelProfiles = facade.getMavenProject().getModel().getProfiles();
- if (modelProfiles == null || modelProfiles.isEmpty()) {
- return Collections.emptyMap();
- }
-
- ResolverConfiguration resolverConfiguration = MavenPlugin.getProjectConfigurationManager()
- .getResolverConfiguration(facade.getProject());
-
- Map<Profile, Boolean> projectProfiles = new LinkedHashMap<Profile, Boolean>(modelProfiles.size());
- List<Profile> activeProfiles = facade.getMavenProject().getActiveProfiles();
-
- for (Profile p : modelProfiles) {
- boolean isAutomaticallyActivated = isActive(p, activeProfiles)
- && !resolverConfiguration.getActiveProfileList().contains(p.getId());
- projectProfiles.put(p, isAutomaticallyActivated);
- }
- return Collections.unmodifiableMap(projectProfiles);
- }
-
-
public Map<Profile, Boolean> getAvailableSettingProfiles() throws CoreException {
Map<Profile, Boolean> settingsProfiles = new LinkedHashMap<Profile, Boolean>();
Settings settings = MavenPlugin.getMaven().getSettings();
@@ -127,7 +112,9 @@
}
public List<ProfileStatus> getProfilesStatuses(
- IMavenProjectFacade facade) throws CoreException {
+ IMavenProjectFacade facade,
+ IProgressMonitor monitor
+ ) throws CoreException {
if (facade == null) {
return Collections.emptyList();
}
@@ -137,10 +124,10 @@
List<String> configuredProfiles = resolverConfiguration.getActiveProfileList();
- final List<Profile> activeProfiles = facade.getMavenProject().getActiveProfiles();
+ MavenProject mavenProject = facade.getMavenProject(monitor);
+
+ List<Profile> projectProfiles = getAvailableProfiles(mavenProject.getModel(), new NullProgressMonitor());
- List<Profile> projectProfiles = new ArrayList<Profile>(facade.getMavenProject().getModel().getProfiles());
-
final Map<Profile, Boolean> availableSettingsProfiles = getAvailableSettingProfiles();
Set<Profile> settingsProfiles = new HashSet<Profile>(availableSettingsProfiles.keySet());
@@ -158,7 +145,6 @@
status.setActivationState(state);
Profile p = get(id, projectProfiles);
-
if (p == null){
p = get(id, settingsProfiles);
if(p != null){
@@ -174,6 +160,7 @@
statuses.add(status);
}
+ final List<Profile> activeProfiles = mavenProject.getActiveProfiles();
//Iterate on the remaining project profiles
addStatuses(statuses, projectProfiles, new ActivationPredicate() {
@Override
@@ -192,6 +179,45 @@
return Collections.unmodifiableList(statuses);
}
+ protected List<Profile> getAvailableProfiles(Model projectModel, IProgressMonitor monitor) throws CoreException {
+ if (projectModel == null) {
+ return null;
+ }
+ List<Profile> profiles = new ArrayList<Profile>(projectModel.getProfiles());
+
+ Parent p = projectModel.getParent();
+ if (p != null) {
+ Model parentModel = resolvePomModel(p.getGroupId(), p.getArtifactId(), p.getVersion(), monitor);
+ List<Profile> parentProfiles = getAvailableProfiles(parentModel, monitor);
+ if (parentProfiles != null && !parentProfiles.isEmpty()) {
+ profiles.addAll(parentProfiles);
+ }
+ }
+
+ return profiles;
+ }
+
+ private Model resolvePomModel(String groupId, String artifactId, String version, IProgressMonitor monitor)
+ throws CoreException {
+ monitor.subTask(NLS.bind("Resolving {0}:{1}:{2}", new Object[] { groupId, artifactId, version}));
+
+ IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getMavenProject(groupId, artifactId, version);
+ IMaven maven = MavenPlugin.getMaven();
+
+ if (facade != null) {
+ return facade.getMavenProject(monitor).getModel();
+ }
+
+ List<ArtifactRepository> repositories = maven.getArtifactRepositories();
+ Artifact artifact = maven.resolve(groupId, artifactId, version, "pom", null, repositories, monitor); //$NON-NLS-1$
+ File file = artifact.getFile();
+ if(file == null) {
+ return null;
+ }
+
+ return maven.readModel(file);
+ }
+
private void addStatuses(List<ProfileStatus> statuses, Collection<Profile> profiles, ActivationPredicate predicate) {
for (Profile p : profiles) {
ProfileStatus status = new ProfileStatus(p.getId());
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java 2011-08-01 09:18:46 UTC (rev 33406)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java 2011-08-01 10:13:14 UTC (rev 33407)
@@ -16,17 +16,8 @@
*/
public interface IProfileManager {
- /**
- * Returns an unmodifiable Map of all the available profiles for a given project.
- * The value of each Map.Entry indicates if the profile is active.
- * @param mavenProjectFacade a facade of the maven project
- * @return an unmodifiable Map of all the available profiles for a given project.
- * @throws CoreException
- */
- Map<Profile, Boolean> getAvailableProfiles(IMavenProjectFacade mavenProjectFacade) throws CoreException;
+ List<ProfileStatus> getProfilesStatuses(IMavenProjectFacade mavenProjectFacade, IProgressMonitor monitor) throws CoreException;
- List<ProfileStatus> getProfilesStatuses(IMavenProjectFacade mavenProjectFacade) throws CoreException;
-
/**
* Returns an unmodifiable Map of all the available profiles defined in the
* Maven settings.xml file.<br/>
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java 2011-08-01 09:18:46 UTC (rev 33406)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java 2011-08-01 10:13:14 UTC (rev 33407)
@@ -62,19 +62,13 @@
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- final Set<IMavenProjectFacade> allfacades = getSelectedMavenProjects(event);
+ final Set<IMavenProjectFacade> facades = getSelectedMavenProjects(event);
- if (allfacades.isEmpty()) {
+ if (facades.isEmpty()) {
display(window, Messages.ProfileSelectionHandler_Select_some_maven_projects);
return null;
}
- Set<IMavenProjectFacade> facades = getValidMavenProjects(allfacades);
- if (facades.isEmpty()) {
- display(window, Messages.ProfileSelectionHandler_Maven_Builder_still_processing);
- return null;
- }
-
System.out.print("Select projects "+facades); //$NON-NLS-1$
final IProfileManager profileManager = MavenCoreActivator.getDefault().getProfileManager();
@@ -253,8 +247,9 @@
final IProfileManager profileManager) throws CoreException {
Map<IMavenProjectFacade, List<ProfileStatus>> allProfiles =
new HashMap<IMavenProjectFacade, List<ProfileStatus>>(facades.size());
+ IProgressMonitor monitor = new NullProgressMonitor();
for (IMavenProjectFacade facade : facades) {
- allProfiles.put(facade, profileManager.getProfilesStatuses(facade));
+ allProfiles.put(facade, profileManager.getProfilesStatuses(facade, monitor));
}
return allProfiles;
}
@@ -290,19 +285,6 @@
return facades;
}
-
- private Set<IMavenProjectFacade> getValidMavenProjects(Set<IMavenProjectFacade> facades) {
- Set<IMavenProjectFacade> validFacades = new HashSet<IMavenProjectFacade>(facades);
- Iterator<IMavenProjectFacade> ite = validFacades.iterator();
- while (ite.hasNext()) {
- IMavenProjectFacade facade = ite.next();
- if (facade.getMavenProject() == null) {
- System.err.println(facade.getProject() + " facade has no MavenProject!!!"); //$NON-NLS-1$
- ite.remove();
- }
- }
- return validFacades;
- }
private IProject[] getSelectedProjects(ISelection selection) {
Set<IProject> projects = new HashSet<IProject>();
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java 2011-08-01 09:18:46 UTC (rev 33406)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java 2011-08-01 10:13:14 UTC (rev 33407)
@@ -10,6 +10,7 @@
************************************************************************************/
package org.jboss.tools.maven.ui.internal.profiles;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -25,6 +26,7 @@
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
@@ -146,7 +148,8 @@
addSelectionButton(container, Messages.SelectProfilesDialog_SelectAll, true);
addSelectionButton(container, Messages.SelectProfilesDialog_DeselectAll, false);
-
+ addActivationButton(container, "Activate", true);
+ addActivationButton(container, "Deactivate", false);
offlineModeBtn = addCheckButton(container, Messages.SelectProfilesDialog_Offline, offlineMode);
forceUpdateBtn = addCheckButton(container, Messages.SelectProfilesDialog_Force_update, forceUpdate);
}
@@ -287,6 +290,41 @@
return button;
}
+ private Button addActivationButton(Composite container, String label, final boolean ischecked) {
+ Button button = new Button(container, SWT.NONE);
+ button.setLayoutData(new GridData(SWT.FILL, SWT.UP,
+ false, false, 1, 1));
+ button.setText(label);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ISelection s = profileTableViewer.getSelection();
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection sel = (IStructuredSelection) s;
+ Iterator<?> ite = sel.iterator();
+ while (ite.hasNext()) {
+ System.err.println(ite.next());
+ }
+ }
+// for (ProfileSelection profile : sharedProfiles) {
+// profileTableViewer.setChecked(profile, ischecked);
+// profile.setSelected(ischecked);
+// if (!ischecked || profile.getActivationState() == null) {
+// profile.setActivationState(ProfileState.Active);
+// }
+// }
+ profileTableViewer.refresh();
+ updateProfilesAsText();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ return button;
+ }
+
+
@Override
protected void createButtonsForButtonBar(Composite parent) {
if (profileTableViewer != null) {
13 years, 4 months
JBoss Tools SVN: r33406 - in trunk/as/plugins: org.jboss.ide.eclipse.archives.webtools/META-INF and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-08-01 05:18:46 -0400 (Mon, 01 Aug 2011)
New Revision: 33406
Added:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/OSGiPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/OSGiModuleFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/osgi16.gif
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-9424 - surprisingly easy fix to add osgi modules.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF 2011-08-01 06:28:42 UTC (rev 33405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF 2011-08-01 09:18:46 UTC (rev 33406)
@@ -28,7 +28,8 @@
org.jboss.ide.eclipse.as.wtp.ui,
org.eclipse.emf.common;bundle-version="2.7.0",
org.eclipse.emf.ecore;bundle-version="2.7.0",
- org.eclipse.wst.common.modulecore.ui;bundle-version="1.0.100"
+ org.eclipse.wst.common.modulecore.ui;bundle-version="1.0.100",
+ org.eclipse.pde.core;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.jboss.ide.eclipse.archives.webtools,
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml 2011-08-01 06:28:42 UTC (rev 33405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml 2011-08-01 09:18:46 UTC (rev 33406)
@@ -121,6 +121,11 @@
priority="3"
zipDelegate="true">
</publisher>
+ <publisher
+ class="org.jboss.ide.eclipse.archives.webtools.modules.OSGiPublisher"
+ priority="20"
+ zipDelegate="false">
+ </publisher>
</extension>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2011-08-01 06:28:42 UTC (rev 33405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2011-08-01 09:18:46 UTC (rev 33406)
@@ -96,13 +96,8 @@
if (isDeployedExploded(destination)) {
removeRemoteDeployment(sourcePath, destination.removeLastSegments(1), name, monitor);
}
- // Locally zip it up into the remote tmp folder
- result = super.publishModule(method, server, module, publishType, delta,
- AbstractServerToolsPublisher.getSubMon(monitor, 50));
- if( result.isOK() ) {
- result = remoteFullPublish(sourcePath, destination.removeLastSegments(1), name,
- AbstractServerToolsPublisher.getSubMon(monitor, 150));
- }
+
+ result = handleLocalZipAndRemotePublish(method, server, module, publishType, delta, AbstractServerToolsPublisher.getSubMon(monitor, 50));
}
if( result == null ) {
@@ -114,6 +109,26 @@
monitor.done();
}
}
+
+ protected IStatus handleLocalZipAndRemotePublish(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException {
+ IDeployableServer server2 = ServerConverter.getDeployableServer(server);
+ String remoteTempDeployRoot = getDeployRoot(module, ServerConverter.getDeployableServer(server));
+ IPath sourcePath = PublishUtil.getDeployPath(module, remoteTempDeployRoot, server2);
+ IPath destination = PublishUtil.getDeployPath(method, module, server2);
+ String name = sourcePath.lastSegment();
+
+ // Locally zip it up into the remote tmp folder
+ IStatus result = super.publishModule(method, server, module, publishType, delta, monitor);
+ if( result.isOK() ) {
+ result = remoteFullPublish(sourcePath, destination.removeLastSegments(1), name,
+ AbstractServerToolsPublisher.getSubMon(monitor, 150));
+ }
+ return result;
+ }
private boolean isDeployedExploded(IPath destination) {
File file = destination.toFile();
@@ -122,7 +137,7 @@
&& file.isDirectory();
}
- private IStatus remoteFullPublish(IPath sourcePath,
+ protected IStatus remoteFullPublish(IPath sourcePath,
IPath destFolder, String name, IProgressMonitor monitor) {
// Now transfer the file to RSE
try {
Added: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/OSGiPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/OSGiPublisher.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/OSGiPublisher.java 2011-08-01 09:18:46 UTC (rev 33406)
@@ -0,0 +1,92 @@
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.pde.core.plugin.PluginRegistry;
+import org.eclipse.pde.internal.core.exports.FeatureExportInfo;
+import org.eclipse.pde.internal.core.exports.PluginExportOperation;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.as.core.modules.OSGiModuleFactory;
+import org.jboss.ide.eclipse.as.core.publishers.AbstractServerToolsPublisher;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+public class OSGiPublisher extends AltMethodZippedJSTPublisher {
+ public boolean accepts(String method, IServer server, IModule[] module) {
+ if( module[module.length-1].getModuleType().getId().equals(OSGiModuleFactory.MODULE_TYPE))
+ return true;
+ return false;
+ }
+
+ @Override
+ public int getPublishState() {
+ return IServer.PUBLISH_STATE_NONE;
+ }
+
+ protected IStatus handleLocalZipAndRemotePublish(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException {
+
+ IDeployableServer server2 = ServerConverter.getDeployableServer(server);
+ IPath destination = PublishUtil.getDeployPath(method, module, server2);
+ String remoteTempDeployRoot = getDeployRoot(module, ServerConverter.getDeployableServer(server));
+ IPath presumedSourcePath = PublishUtil.getDeployPath(module, remoteTempDeployRoot, server2);
+ String name = presumedSourcePath.lastSegment();
+ IPath realSourcePathFolder = presumedSourcePath.removeLastSegments(1).append("plugins"); //$NON-NLS-1$
+ IProject project = module[module.length-1].getProject();
+ // Run the export job
+ IStatus result = scheduleExportJob(project, remoteTempDeployRoot, name, monitor);
+ if( result.isOK() ) {
+ String[] plugins = realSourcePathFolder.toFile().list();
+ if( plugins.length > 0 ) {
+ IPath src = realSourcePathFolder.append(plugins[0]);
+ result = remoteFullPublish(src, destination.removeLastSegments(1), name,
+ AbstractServerToolsPublisher.getSubMon(monitor, 150));
+ // Then cleanup this plugins folder >=[
+ src.toFile().delete();
+ }
+ }
+ return result;
+ }
+
+ protected IStatus scheduleExportJob(IProject project, String destFolder, String name, IProgressMonitor monitor) {
+ final FeatureExportInfo info = new FeatureExportInfo();
+ info.toDirectory = true;
+ info.useJarFormat = true;
+ info.exportSource = false;
+ info.exportSourceBundle = true;
+ info.allowBinaryCycles = true;
+ info.useWorkspaceCompiledClasses = false;
+ info.destinationDirectory = destFolder;
+ info.zipFileName = name;
+ info.items = new Object[]{PluginRegistry.findModel(project)};
+ info.signingInfo = null; //fPage.useJARFormat() ? fPage.getSigningInfo() : null;
+ info.qualifier = null; //fPage.getQualifier();
+
+ final CustomPluginExportOperation job = new CustomPluginExportOperation(info, "Exporting Plugin: " + project.getName()); //$NON-NLS-1$
+
+ IStatus s = job.run2(monitor);
+ return s;
+ }
+
+ private class CustomPluginExportOperation extends PluginExportOperation {
+ public CustomPluginExportOperation(FeatureExportInfo info, String name) {
+ super(info, name);
+ }
+
+ public IStatus run2(IProgressMonitor monitor) {
+ return super.run(monitor);
+ }
+ }
+
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2011-08-01 06:28:42 UTC (rev 33405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2011-08-01 09:18:46 UTC (rev 33406)
@@ -21,7 +21,8 @@
org.eclipse.wst.common.project.facet.core;bundle-version="1.4.200",
org.eclipse.wst.common.frameworks;bundle-version="1.2.0",
org.eclipse.jst.jee;bundle-version="1.0.401",
- org.eclipse.core.commands;bundle-version="3.6.0"
+ org.eclipse.core.commands;bundle-version="3.6.0",
+ org.eclipse.pde.core;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.ide.eclipse.as.core,
org.jboss.ide.eclipse.as.core.extensions.descriptors,
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/OSGiModuleFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/OSGiModuleFactory.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/OSGiModuleFactory.java 2011-08-01 09:18:46 UTC (rev 33406)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.modules;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.pde.core.IModel;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.PluginRegistry;
+import org.eclipse.pde.internal.core.ICoreConstants;
+import org.eclipse.pde.internal.core.WorkspaceModelManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
+import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
+
+public class OSGiModuleFactory extends ProjectModuleFactoryDelegate {
+
+ public static final String MODULE_TYPE = "jboss.osgi"; //$NON-NLS-1$
+ public static final String VERSION = "1.0"; //$NON-NLS-1$
+
+ public class OSGiModuleDelegate extends ModuleDelegate implements IJBTModule {
+ public IStatus validate() {
+ return null;
+ }
+ public IModule[] getChildModules() {
+ return new IModule[]{};
+ }
+ public IModuleResource[] members() throws CoreException {
+ return new IModuleResource[]{};
+ }
+ public IModule[] getModules() {
+ return getChildModules();
+ }
+ public String getURI(IModule module) {
+ return null;
+ }
+ public boolean isBinary() {
+ return true;
+ }
+ }
+
+ @Override
+ public ModuleDelegate getModuleDelegate(IModule module) {
+ return new OSGiModuleDelegate();
+ }
+
+ /**
+ * Creates the modules that are contained within a given project.
+ *
+ * @param project a project to create modules for
+ * @return a possibly-empty array of modules
+ */
+ protected IModule[] createModules(IProject project) {
+ if (!WorkspaceModelManager.isBinaryProject(project) && WorkspaceModelManager.isPluginProject(project)) {
+ IModel model = PluginRegistry.findModel(project);
+ if (model != null && isValidModel(model) && hasBuildProperties((IPluginModelBase) model)) {
+ IModule module = createModule(project.getName(), project.getName(),
+ MODULE_TYPE, VERSION, project);
+ return new IModule[] { module };
+ }
+ }
+ return null;
+ }
+
+ private boolean hasBuildProperties(IPluginModelBase model) {
+ File file = new File(model.getInstallLocation(), ICoreConstants.BUILD_FILENAME_DESCRIPTOR);
+ return file.exists();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.internal.ui.wizards.exports.BaseExportWizardPage#isValidModel(org.eclipse.pde.core.IModel)
+ */
+ protected boolean isValidModel(IModel model) {
+ return model != null && model instanceof IPluginModelBase;
+ }
+
+ @Override
+ protected IPath[] getListenerPaths() {
+ return new IPath[] { new Path(".project"), // nature //$NON-NLS-1$
+ new Path("META-INF/MANIFEST.MF"), // manifest //$NON-NLS-1$
+ new Path(".settings/org.eclipse.pde.core.prefs") // pde prefs //$NON-NLS-1$
+ };
+ }
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2011-08-01 06:28:42 UTC (rev 33405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2011-08-01 09:18:46 UTC (rev 33406)
@@ -478,6 +478,11 @@
types="bpel.module"
versions="1.1, 2.0">
</moduleType>
+ <moduleType
+ types="jboss.osgi"
+ versions="1.0">
+ </moduleType>
+
</runtimeType>
@@ -683,6 +688,15 @@
versions="1.0">
</moduleType>
</moduleFactory>
+ <moduleFactory
+ class="org.jboss.ide.eclipse.as.core.modules.OSGiModuleFactory"
+ id="org.jboss.ide.eclipse.as.core.osgiModuleFactory"
+ projects="true">
+ <moduleType
+ types="jboss.osgi"
+ versions="1.0">
+ </moduleType>
+ </moduleFactory>
</extension>
<extension
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/osgi16.gif
===================================================================
(Binary files differ)
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/osgi16.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2011-08-01 06:28:42 UTC (rev 33405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2011-08-01 09:18:46 UTC (rev 33406)
@@ -90,6 +90,11 @@
icon="$nl$/icons/file.gif"
id="org.jboss.ide.eclipse.as.ui.simplefile.image"
typeIds="jboss.singlefile"/>
+ <image
+ icon="icons/osgi16.gif"
+ id="org.jboss.ide.eclipse.as.ui.osgi.image"
+ typeIds="jboss.osgi">
+ </image>
</extension>
13 years, 4 months