diff options
author | kmoore | 2008-07-25 17:27:32 +0000 |
---|---|---|
committer | kmoore | 2008-07-25 17:27:32 +0000 |
commit | 75726a151172cc9db06c577e69eba8db577771f3 (patch) | |
tree | 4cb64cb28e67f34346624f2ccd7d9db9d6d72f24 | |
parent | bc37e1ac643524dda604f91c80aba09c3bfa8d1d (diff) | |
download | webtools.dali-75726a151172cc9db06c577e69eba8db577771f3.tar.gz webtools.dali-75726a151172cc9db06c577e69eba8db577771f3.tar.xz webtools.dali-75726a151172cc9db06c577e69eba8db577771f3.zip |
partial support for EclipseLink platform java entity caching
39 files changed, 2240 insertions, 31 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF index 9ec11b8c52..7bfd4076a8 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF @@ -18,13 +18,19 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)", org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)", org.eclipse.wst.validation;bundle-version="[1.2.0,2.0.0)" Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.jpt.eclipselink.core.internal;x-friends:="org.eclipse.jpt.eclipselink.ui,org.eclipse.jpt.eclipselink.core.tests", +Export-Package: org.eclipse.jpt.eclipselink.core, + org.eclipse.jpt.eclipselink.core.context, + org.eclipse.jpt.eclipselink.core.context.java, + org.eclipse.jpt.eclipselink.core.internal;x-friends:="org.eclipse.jpt.eclipselink.ui,org.eclipse.jpt.eclipselink.core.tests", org.eclipse.jpt.eclipselink.core.internal.context;x-friends:="org.eclipse.jpt.eclipselink.ui,org.eclipse.jpt.eclipselink.core.tests", org.eclipse.jpt.eclipselink.core.internal.context.caching, org.eclipse.jpt.eclipselink.core.internal.context.connection, org.eclipse.jpt.eclipselink.core.internal.context.customization, + org.eclipse.jpt.eclipselink.core.internal.context.java;x-friends:="org.eclipse.jpt.eclipselink.ui,org.eclipse.jpt.eclipselink.core.tests", org.eclipse.jpt.eclipselink.core.internal.context.logging, org.eclipse.jpt.eclipselink.core.internal.context.options, org.eclipse.jpt.eclipselink.core.internal.context.schema.generation, - org.eclipse.jpt.eclipselink.core.internal.ddlgen + org.eclipse.jpt.eclipselink.core.internal.ddlgen, + org.eclipse.jpt.eclipselink.core.internal.resource.java, + org.eclipse.jpt.eclipselink.core.resource.java Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/EclipseLinkJpaFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/EclipseLinkJpaFactory.java new file mode 100644 index 0000000000..575ed1acad --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/EclipseLinkJpaFactory.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.eclipselink.core; + +import org.eclipse.jpt.core.JpaFactory; +import org.eclipse.jpt.core.context.java.JavaPersistentType; +import org.eclipse.jpt.core.context.java.JavaTypeMapping; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEntity; + +/** + * Use EclipseLinkJpaFactory to create any EclispeLink specific + * java, orm, or persistence context model objects. + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkJpaFactory extends JpaFactory +{ + + EclipseLinkJavaEntity buildJavaEntity(JavaPersistentType parent); + + EclipseLinkJavaCaching buildEclipseLinkJavaCaching(JavaTypeMapping parent); +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/CacheType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/CacheType.java new file mode 100644 index 0000000000..cad9013e68 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/CacheType.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.context; + + +/** + * + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public enum CacheType { + + SOFT_WEAK, + HARD_WEAK, + WEAK, + SOFT, + FULL, + CACHE, + NONE; + + + public static CacheType fromJavaResourceModel(org.eclipse.jpt.eclipselink.core.resource.java.CacheType javaCacheType) { + if (javaCacheType == null) { + return null; + } + switch (javaCacheType) { + case FULL: + return FULL; + case WEAK: + return WEAK; + case SOFT: + return SOFT; + case SOFT_WEAK: + return SOFT_WEAK; + case HARD_WEAK: + return HARD_WEAK; + case CACHE: + return CACHE; + case NONE: + return NONE; + default: + throw new IllegalArgumentException("unknown cache type: " + javaCacheType); + } + } + + public static org.eclipse.jpt.eclipselink.core.resource.java.CacheType toJavaResourceModel(CacheType cacheType) { + if (cacheType == null) { + return null; + } + switch (cacheType) { + case FULL: + return org.eclipse.jpt.eclipselink.core.resource.java.CacheType.FULL; + case WEAK: + return org.eclipse.jpt.eclipselink.core.resource.java.CacheType.WEAK; + case SOFT: + return org.eclipse.jpt.eclipselink.core.resource.java.CacheType.SOFT; + case SOFT_WEAK: + return org.eclipse.jpt.eclipselink.core.resource.java.CacheType.SOFT_WEAK; + case HARD_WEAK: + return org.eclipse.jpt.eclipselink.core.resource.java.CacheType.HARD_WEAK; + case CACHE: + return org.eclipse.jpt.eclipselink.core.resource.java.CacheType.CACHE; + case NONE: + return org.eclipse.jpt.eclipselink.core.resource.java.CacheType.NONE; + default: + throw new IllegalArgumentException("unknown cache type: " + cacheType); + } + } + + +// public static CacheType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.FetchType ormCacheType) { +// if (ormCacheType == null) { +// return null; +// } +// switch (ormCacheType) { +// case FULL: +// return FULL; +// case WEAK: +// return WEAK; +// case SOFT: +// return SOFT; +// case SOFT_WEAK: +// return SOFT_WEAK; +// case HARD_WEAK: +// return HARD_WEAK; +// case CACHE: +// return CACHE; +// case NONE: +// return NONE; +// default: +// throw new IllegalArgumentException("unknown cache type: " + ormCacheType); +// } +// } +// +// public static org.eclipse.jpt.core.resource.orm.FetchType toOrmResourceModel(CacheType cacheType) { +// if (cacheType == null) { +// return null; +// } +// switch (cacheType) { +// case FULL: +// return org.eclipse.jpt.core.resource.orm.FetchType.FULL; +// case WEAK: +// return org.eclipse.jpt.core.resource.orm.FetchType.WEAK; +// case SOFT: +// return org.eclipse.jpt.core.resource.orm.FetchType.SOFT; +// case SOFT_WEAK: +// return org.eclipse.jpt.core.resource.orm.FetchType.SOFT_WEAK; +// case HARD_WEAK: +// return org.eclipse.jpt.core.resource.orm.FetchType.HARD_WEAK; +// case CACHE: +// return org.eclipse.jpt.core.resource.orm.FetchType.CACHE; +// case NONE: +// return org.eclipse.jpt.core.resource.orm.FetchType.NONE; +// default: +// throw new IllegalArgumentException("unknown cache type: " + cacheType); +// } +// } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkCaching.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkCaching.java new file mode 100644 index 0000000000..66444187ca --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkCaching.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.context; + +import org.eclipse.jpt.core.context.java.JavaJpaContextNode; + +/** + * + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkCaching extends JavaJpaContextNode +{ + //***************** shared ************************ + + Boolean getShared(); + + Boolean getDefaultShared(); + String DEFAULT_SHARED_PROPERTY = "defaultSharedProperty"; + Boolean DEFAULT_SHARED = Boolean.TRUE; + + Boolean getSpecifiedShared(); + /** + * Setting this to false means that cacheType, alwaysRefresh, refreshOnlyIfNewer, + * disableHits will all be set to their default states. They do not apply + * to a cache that is not shared + * @param newSpecifiedShared + */ + void setSpecifiedShared(Boolean newSpecifiedShared); + String SPECIFIED_SHARED_PROPERTY = "specifiedSharedProperty"; + + + //***************** cache type ************************ + + CacheType getCacheType(); + + CacheType getDefaultCacheType(); + String DEFAULT_CACHE_TYPE_PROPERTY = "defaultCacheTypeProperty"; + CacheType DEFAULT_CACHE_TYPE = CacheType.SOFT_WEAK; + + CacheType getSpecifiedCacheType(); + void setSpecifiedCacheType(CacheType newSpecifiedCacheType); + String SPECIFIED_CACHE_TYPE_PROPERTY = "specifiedCacheTypeProperty"; + + + //***************** always refresh ************************ + + Boolean getAlwaysRefresh(); + + Boolean getDefaultAlwaysRefresh(); + String DEFAULT_ALWAYS_REFRESH_PROPERTY = "defaultAlwaysRefreshProperty"; + Boolean DEFAULT_ALWAYS_REFRESH = Boolean.FALSE; + + Boolean getSpecifiedAlwaysRefresh(); + void setSpecifiedAlwaysRefresh(Boolean newSpecifiedAlwaysRefresh); + String SPECIFIED_ALWAYS_REFRESH_PROPERTY = "specifiedAlwaysRefreshProperty"; + + + //***************** refresh only if newer ************************ + + Boolean getRefreshOnlyIfNewer(); + + Boolean getDefaultRefreshOnlyIfNewer(); + String DEFAULT_REFRESH_ONLY_IF_NEWER_PROPERTY = "defaultRefreshOnlyIfNewerProperty"; + Boolean DEFAULT_REFRESH_ONLY_IF_NEWER = Boolean.FALSE; + + Boolean getSpecifiedRefreshOnlyIfNewer(); + void setSpecifiedRefreshOnlyIfNewer(Boolean newSpecifiedRefreshOnlyIfNewer); + String SPECIFIED_REFRESH_ONLY_IF_NEWER_PROPERTY = "specifiedRefreshOnlyIfNewerProperty"; + + + //***************** disable hits ************************ + + Boolean getDisableHits(); + + Boolean getDefaultDisableHits(); + String DEFAULT_DISABLE_HITS_PROPERTY = "defaultDisableHitsProperty"; + Boolean DEFAULT_DISABLE_HITS = Boolean.FALSE; + + Boolean getSpecifiedDisableHits(); + void setSpecifiedDisableHits(Boolean newSpecifiedDisableHits); + String SPECIFIED_DISABLE_HITS_PROPERTY = "specifiedDisableHitsProperty"; + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkEntity.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkEntity.java new file mode 100644 index 0000000000..1fbda9a0d8 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkEntity.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.context; + +import org.eclipse.jpt.core.context.Entity; + +/** + * + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkEntity extends Entity +{ + EclipseLinkCaching getCaching(); +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaCaching.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaCaching.java new file mode 100644 index 0000000000..3bcbaba776 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaCaching.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.context.java; + +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; + +/** + * + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkJavaCaching extends EclipseLinkCaching +{ + void initialize(JavaResourcePersistentType resourcePersistentType); + + void update(JavaResourcePersistentType resourcePersistentType); + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaEntity.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaEntity.java new file mode 100644 index 0000000000..e673947fbe --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaEntity.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.context.java; + +import org.eclipse.jpt.core.context.java.JavaEntity; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; + +/** + * + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkJavaEntity extends JavaEntity +{ + EclipseLinkCaching getCaching(); + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaAnnotationProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaAnnotationProvider.java new file mode 100644 index 0000000000..0e15377e6a --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaAnnotationProvider.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.internal; + +import java.util.Collection; +import org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationProvider; +import org.eclipse.jpt.core.resource.java.AnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.CacheImpl.CacheAnnotationDefinition; + +public class EclipseLinkJpaAnnotationProvider + extends GenericJpaAnnotationProvider +{ + + @Override + protected void addTypeAnnotationDefinitionsTo(Collection<AnnotationDefinition> definitions) { + super.addTypeAnnotationDefinitionsTo(definitions); + definitions.add(CacheAnnotationDefinition.instance()); + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaFactoryImpl.java index 2f3268cfe1..439df3f664 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkFactory.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaFactoryImpl.java @@ -9,15 +9,22 @@ *******************************************************************************/ package org.eclipse.jpt.eclipselink.core.internal; +import org.eclipse.jpt.core.context.java.JavaPersistentType; +import org.eclipse.jpt.core.context.java.JavaTypeMapping; import org.eclipse.jpt.core.context.persistence.Persistence; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.core.internal.platform.GenericJpaFactory; import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit; +import org.eclipse.jpt.eclipselink.core.EclipseLinkJpaFactory; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEntity; import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkPersistenceUnit; +import org.eclipse.jpt.eclipselink.core.internal.context.java.EclipseLinkJavaCachingImpl; +import org.eclipse.jpt.eclipselink.core.internal.context.java.EclipseLinkJavaEntityImpl; -public class EclipseLinkFactory extends GenericJpaFactory +public class EclipseLinkJpaFactoryImpl extends GenericJpaFactory implements EclipseLinkJpaFactory { - protected EclipseLinkFactory() { + protected EclipseLinkJpaFactoryImpl() { super(); } @@ -25,4 +32,14 @@ public class EclipseLinkFactory extends GenericJpaFactory public PersistenceUnit buildPersistenceUnit(Persistence parent, XmlPersistenceUnit persistenceUnit) { return new EclipseLinkPersistenceUnit(parent, persistenceUnit); } + + @Override + public EclipseLinkJavaEntity buildJavaEntity(JavaPersistentType parent) { + return new EclipseLinkJavaEntityImpl(parent); + } + + public EclipseLinkJavaCaching buildEclipseLinkJavaCaching(JavaTypeMapping parent) { + return new EclipseLinkJavaCachingImpl(parent); + } + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkPlatform.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkPlatform.java index 5cb623740d..8a2c93d5e0 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkPlatform.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkPlatform.java @@ -24,18 +24,18 @@ public class EclipseLinkPlatform extends GenericJpaPlatform @Override public String getId() { - return ID; + return EclipseLinkPlatform.ID; } // ********* Model construction / updating ********* @Override protected JpaFactory buildJpaFactory() { - return new EclipseLinkFactory(); + return new EclipseLinkJpaFactoryImpl(); } - // ********* java annotation support ********* + // ********* java annotation support ********* @Override - public JpaAnnotationProvider getAnnotationProvider() { - return super.getAnnotationProvider(); + protected JpaAnnotationProvider buildAnnotationProvider() { + return new EclipseLinkJpaAnnotationProvider(); } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaCachingImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaCachingImpl.java new file mode 100644 index 0000000000..1177136a7a --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaCachingImpl.java @@ -0,0 +1,239 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.internal.context.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.context.java.JavaTypeMapping; +import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.context.CacheType; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; + +public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode implements EclipseLinkJavaCaching +{ + + protected CacheType specifiedCacheType; + protected Boolean specifiedShared; + protected Boolean specifiedAlwaysRefresh; + protected Boolean specifiedRefreshOnlyIfNewer; + protected Boolean specifiedDisableHits; + + protected JavaResourcePersistentType resourcePersistentType; + + public EclipseLinkJavaCachingImpl(JavaTypeMapping parent) { + super(parent); + } + + @Override + public JavaTypeMapping getParent() { + return (JavaTypeMapping) super.getParent(); + } + + //query for the cache annotation every time on setters. + //call one setter and the CacheAnnotation could change. + //You could call more than one setter before this object has received any notification + //from the java resource model + protected CacheAnnotation getCacheAnnotation() { + return (CacheAnnotation) this.resourcePersistentType.getNonNullAnnotation(getCacheAnnotationName()); + } + + protected String getCacheAnnotationName() { + return CacheAnnotation.ANNOTATION_NAME; + } + + + public CacheType getCacheType() { + return (this.getSpecifiedCacheType() == null) ? this.getDefaultCacheType() : this.getSpecifiedCacheType(); + } + + public CacheType getDefaultCacheType() { + return DEFAULT_CACHE_TYPE; + } + + public CacheType getSpecifiedCacheType() { + return this.specifiedCacheType; + } + + public void setSpecifiedCacheType(CacheType newSpecifiedCacheType) { + CacheType oldCacheType = this.specifiedCacheType; + this.specifiedCacheType = newSpecifiedCacheType; + this.getCacheAnnotation().setType(CacheType.toJavaResourceModel(newSpecifiedCacheType)); + firePropertyChanged(SPECIFIED_CACHE_TYPE_PROPERTY, oldCacheType, newSpecifiedCacheType); + } + + /** + * internal setter used only for updating from the resource model. + * There were problems with InvalidThreadAccess exceptions in the UI + * when you set a value from the UI and the annotation doesn't exist yet. + * Adding the annotation causes an update to occur and then the exception. + */ + protected void setSpecifiedCacheType_(CacheType newSpecifiedCacheType) { + CacheType oldCacheType = this.specifiedCacheType; + this.specifiedCacheType = newSpecifiedCacheType; + firePropertyChanged(SPECIFIED_CACHE_TYPE_PROPERTY, oldCacheType, newSpecifiedCacheType); + } + + public Boolean getShared() { + return (this.getSpecifiedShared() == null) ? this.getDefaultShared() : this.getSpecifiedShared(); + } + + public Boolean getDefaultShared() { + return EclipseLinkCaching.DEFAULT_SHARED; + } + + public Boolean getSpecifiedShared() { + return this.specifiedShared; + } + + //TODO when this is set to false need to set all other caching option except existence checking to their default + public void setSpecifiedShared(Boolean newSpecifiedShared) { + Boolean oldShared = this.specifiedShared; + this.specifiedShared = newSpecifiedShared; + this.getCacheAnnotation().setShared(newSpecifiedShared); + firePropertyChanged(EclipseLinkCaching.SPECIFIED_SHARED_PROPERTY, oldShared, newSpecifiedShared); + } + + protected void setSpecifiedShared_(Boolean newSpecifiedShared) { + Boolean oldShared = this.specifiedShared; + this.specifiedShared = newSpecifiedShared; + firePropertyChanged(EclipseLinkCaching.SPECIFIED_SHARED_PROPERTY, oldShared, newSpecifiedShared); + } + + public Boolean getAlwaysRefresh() { + return (this.getSpecifiedAlwaysRefresh() == null) ? this.getDefaultAlwaysRefresh() : this.getSpecifiedAlwaysRefresh(); + } + + public Boolean getDefaultAlwaysRefresh() { + return EclipseLinkCaching.DEFAULT_ALWAYS_REFRESH; + } + + public Boolean getSpecifiedAlwaysRefresh() { + return this.specifiedAlwaysRefresh; + } + + public void setSpecifiedAlwaysRefresh(Boolean newSpecifiedAlwaysRefresh) { + Boolean oldAlwaysRefresh = this.specifiedAlwaysRefresh; + this.specifiedAlwaysRefresh = newSpecifiedAlwaysRefresh; + this.getCacheAnnotation().setAlwaysRefresh(newSpecifiedAlwaysRefresh); + firePropertyChanged(EclipseLinkCaching.SPECIFIED_ALWAYS_REFRESH_PROPERTY, oldAlwaysRefresh, newSpecifiedAlwaysRefresh); + } + + protected void setSpecifiedAlwaysRefresh_(Boolean newSpecifiedAlwaysRefresh) { + Boolean oldAlwaysRefresh = this.specifiedAlwaysRefresh; + this.specifiedAlwaysRefresh = newSpecifiedAlwaysRefresh; + firePropertyChanged(EclipseLinkCaching.SPECIFIED_ALWAYS_REFRESH_PROPERTY, oldAlwaysRefresh, newSpecifiedAlwaysRefresh); + } + + public Boolean getRefreshOnlyIfNewer() { + return (this.getSpecifiedRefreshOnlyIfNewer() == null) ? this.getDefaultRefreshOnlyIfNewer() : this.getSpecifiedRefreshOnlyIfNewer(); + } + + public Boolean getDefaultRefreshOnlyIfNewer() { + return EclipseLinkCaching.DEFAULT_REFRESH_ONLY_IF_NEWER; + } + + public Boolean getSpecifiedRefreshOnlyIfNewer() { + return this.specifiedRefreshOnlyIfNewer; + } + + public void setSpecifiedRefreshOnlyIfNewer(Boolean newSpecifiedRefreshOnlyIfNewer) { + Boolean oldRefreshOnlyIfNewer = this.specifiedRefreshOnlyIfNewer; + this.specifiedRefreshOnlyIfNewer = newSpecifiedRefreshOnlyIfNewer; + this.getCacheAnnotation().setRefreshOnlyIfNewer(newSpecifiedRefreshOnlyIfNewer); + firePropertyChanged(EclipseLinkCaching.SPECIFIED_REFRESH_ONLY_IF_NEWER_PROPERTY, oldRefreshOnlyIfNewer, newSpecifiedRefreshOnlyIfNewer); + } + + protected void setSpecifiedRefreshOnlyIfNewer_(Boolean newSpecifiedRefreshOnlyIfNewer) { + Boolean oldRefreshOnlyIfNewer = this.specifiedRefreshOnlyIfNewer; + this.specifiedRefreshOnlyIfNewer = newSpecifiedRefreshOnlyIfNewer; + firePropertyChanged(EclipseLinkCaching.SPECIFIED_REFRESH_ONLY_IF_NEWER_PROPERTY, oldRefreshOnlyIfNewer, newSpecifiedRefreshOnlyIfNewer); + } + + public Boolean getDisableHits() { + return (this.getSpecifiedDisableHits() == null) ? this.getDefaultDisableHits() : this.getSpecifiedDisableHits(); + } + + public Boolean getDefaultDisableHits() { + return EclipseLinkCaching.DEFAULT_DISABLE_HITS; + } + + public Boolean getSpecifiedDisableHits() { + return this.specifiedDisableHits; + } + + public void setSpecifiedDisableHits(Boolean newSpecifiedDisableHits) { + Boolean oldDisableHits = this.specifiedDisableHits; + this.specifiedDisableHits = newSpecifiedDisableHits; + this.getCacheAnnotation().setDisableHits(newSpecifiedDisableHits); + firePropertyChanged(EclipseLinkCaching.SPECIFIED_DISABLE_HITS_PROPERTY, oldDisableHits, newSpecifiedDisableHits); + } + + protected void setSpecifiedDisableHits_(Boolean newSpecifiedDisableHits) { + Boolean oldDisableHits = this.specifiedDisableHits; + this.specifiedDisableHits = newSpecifiedDisableHits; + firePropertyChanged(EclipseLinkCaching.SPECIFIED_DISABLE_HITS_PROPERTY, oldDisableHits, newSpecifiedDisableHits); + } + + public void initialize(JavaResourcePersistentType resourcePersistentType) { + this.resourcePersistentType = resourcePersistentType; + initializeFromResource(getCacheAnnotation()); + } + + protected void initializeFromResource(CacheAnnotation cache) { + this.specifiedCacheType = this.specifiedCacheType(cache); + this.specifiedShared = this.specifiedShared(cache); + this.specifiedAlwaysRefresh = this.specifiedAlwaysRefresh(cache); + this.specifiedRefreshOnlyIfNewer = this.specifiedRefreshOnlyIfNewer(cache); + this.specifiedDisableHits = this.specifiedDisableHits(cache); + } + + public void update(JavaResourcePersistentType resourcePersistentType) { + this.resourcePersistentType = resourcePersistentType; + update(getCacheAnnotation()); + } + + protected void update(CacheAnnotation cache) { + setSpecifiedCacheType_(this.specifiedCacheType(cache)); + setSpecifiedShared_(this.specifiedShared(cache)); + setSpecifiedAlwaysRefresh_(this.specifiedAlwaysRefresh(cache)); + setSpecifiedRefreshOnlyIfNewer_(this.specifiedRefreshOnlyIfNewer(cache)); + setSpecifiedDisableHits_(this.specifiedDisableHits(cache)); + } + + protected CacheType specifiedCacheType(CacheAnnotation cache) { + return CacheType.fromJavaResourceModel(cache.getType()); + } + + protected Boolean specifiedShared(CacheAnnotation cache) { + return cache.getShared(); + } + + protected Boolean specifiedAlwaysRefresh(CacheAnnotation cache) { + return cache.getAlwaysRefresh(); + } + + protected Boolean specifiedRefreshOnlyIfNewer(CacheAnnotation cache) { + return cache.getRefreshOnlyIfNewer(); + } + + protected Boolean specifiedDisableHits(CacheAnnotation cache) { + return cache.getDisableHits(); + } + + + public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = getCacheAnnotation().getTextRange(astRoot); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaEntityImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaEntityImpl.java new file mode 100644 index 0000000000..5fc8e00560 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaEntityImpl.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.internal.context.java; + +import org.eclipse.jpt.core.context.java.JavaPersistentType; +import org.eclipse.jpt.core.internal.context.java.GenericJavaEntity; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.eclipselink.core.EclipseLinkJpaFactory; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEntity; + +public class EclipseLinkJavaEntityImpl extends GenericJavaEntity implements EclipseLinkJavaEntity +{ + protected EclipseLinkJavaCaching eclipseLinkCaching; + + public EclipseLinkJavaEntityImpl(JavaPersistentType parent) { + super(parent); + this.eclipseLinkCaching = getJpaFactory().buildEclipseLinkJavaCaching(this); + } + + + public EclipseLinkCaching getCaching() { + return this.eclipseLinkCaching; + } + + @Override + protected EclipseLinkJpaFactory getJpaFactory() { + return (EclipseLinkJpaFactory) super.getJpaFactory(); + } + + + @Override + public void update(JavaResourcePersistentType resourcePersistentType) { + super.update(resourcePersistentType); + this.eclipseLinkCaching.update(resourcePersistentType); + } + + @Override + public void initializeFromResource(JavaResourcePersistentType resourcePersistentType) { + super.initializeFromResource(resourcePersistentType); + this.eclipseLinkCaching.initialize(resourcePersistentType); + } +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java new file mode 100644 index 0000000000..a58d678796 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java @@ -0,0 +1,241 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; +import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; +import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.Annotation; +import org.eclipse.jpt.core.resource.java.AnnotationDefinition; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + + +public class CacheImpl extends AbstractResourceAnnotation<Type> implements CacheAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final AnnotationElementAdapter<String> typeAdapter; + private final AnnotationElementAdapter<Boolean> sharedAdapter; + private final AnnotationElementAdapter<Boolean> alwaysRefreshAdapter; + private final AnnotationElementAdapter<Boolean> refreshOnlyIfNewerAdapter; + private final AnnotationElementAdapter<Boolean> disableHitsAdapter; + + private static final DeclarationAnnotationElementAdapter<String> TYPE_ADAPTER = buildTypeAdapter(); + private static final DeclarationAnnotationElementAdapter<Boolean> SHARED_ADAPTER = buildSharedAdapter(); + private static final DeclarationAnnotationElementAdapter<Boolean> ALWAYS_REFRESH_ADAPTER = buildAlwaysRefreshAdapter(); + private static final DeclarationAnnotationElementAdapter<Boolean> REFRESH_ONLY_IF_NEWER_ADAPTER = buildRefreshOnlyIfNewerAdapter(); + private static final DeclarationAnnotationElementAdapter<Boolean> DISABLE_HITS_ADAPTER = buildDisableHitsAdapter(); + + + private CacheType type; + private Boolean shared; + private Boolean alwaysRefresh; + private Boolean refreshOnlyIfNewer; + private Boolean disableHits; + + protected CacheImpl(JavaResourcePersistentType parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.typeAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, TYPE_ADAPTER); + this.sharedAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, SHARED_ADAPTER); + this.alwaysRefreshAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, ALWAYS_REFRESH_ADAPTER); + this.refreshOnlyIfNewerAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, REFRESH_ONLY_IF_NEWER_ADAPTER); + this.disableHitsAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, DISABLE_HITS_ADAPTER); + } + + public void initialize(CompilationUnit astRoot) { + this.type = this.type(astRoot); + this.shared = this.shared(astRoot); + this.alwaysRefresh = this.alwaysRefresh(astRoot); + this.refreshOnlyIfNewer = this.refreshOnlyIfNewer(astRoot); + this.disableHits = this.disableHits(astRoot); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + //*************** CacheAnnotation implementation **************** + + public CacheType getType() { + return this.type; + } + + public void setType(CacheType newType) { + if (attributeValueHasNotChanged(this.type, newType)) { + return; + } + CacheType oldType = this.type; + this.type = newType; + this.typeAdapter.setValue(CacheType.toJavaAnnotationValue(newType)); + firePropertyChanged(TYPE_PROPERTY, oldType, newType); + } + + public Boolean getShared() { + return this.shared; + } + + public void setShared(Boolean newShared) { + if (attributeValueHasNotChanged(this.shared, newShared)) { + return; + } + Boolean oldShared = this.shared; + this.shared = newShared; + this.sharedAdapter.setValue(newShared); + firePropertyChanged(SHARED_PROPERTY, oldShared, newShared); + } + + public Boolean getAlwaysRefresh() { + return this.alwaysRefresh; + } + + public void setAlwaysRefresh(Boolean newAlwaysRefresh) { + if (attributeValueHasNotChanged(this.alwaysRefresh, newAlwaysRefresh)) { + return; + } + Boolean oldAlwaysRefresh = this.alwaysRefresh; + this.alwaysRefresh = newAlwaysRefresh; + this.alwaysRefreshAdapter.setValue(newAlwaysRefresh); + firePropertyChanged(ALWAYS_REFRESH_PROPERTY, oldAlwaysRefresh, newAlwaysRefresh); + } + + public Boolean getRefreshOnlyIfNewer() { + return this.refreshOnlyIfNewer; + } + + public void setRefreshOnlyIfNewer(Boolean newRefreshOnlyIfNewer) { + if (attributeValueHasNotChanged(this.refreshOnlyIfNewer, newRefreshOnlyIfNewer)) { + return; + } + Boolean oldRefreshOnlyIfNewer = this.refreshOnlyIfNewer; + this.refreshOnlyIfNewer = newRefreshOnlyIfNewer; + this.refreshOnlyIfNewerAdapter.setValue(newRefreshOnlyIfNewer); + firePropertyChanged(REFRESH_ONLY_IF_NEWER_PROPERTY, oldRefreshOnlyIfNewer, newRefreshOnlyIfNewer); + } + + public Boolean getDisableHits() { + return this.disableHits; + } + + public void setDisableHits(Boolean newDisableHits) { + if (attributeValueHasNotChanged(this.disableHits, newDisableHits)) { + return; + } + Boolean oldDisableHits = this.disableHits; + this.disableHits = newDisableHits; + this.disableHitsAdapter.setValue(newDisableHits); + firePropertyChanged(DISABLE_HITS_PROPERTY, oldDisableHits, newDisableHits); + } + + public TextRange getTypeTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(TYPE_ADAPTER, astRoot); + } + + public TextRange getSharedTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(SHARED_ADAPTER, astRoot); + } + + public void updateFromJava(CompilationUnit astRoot) { + this.setType(this.type(astRoot)); + this.setShared(this.shared(astRoot)); + this.setAlwaysRefresh(this.alwaysRefresh(astRoot)); + this.setRefreshOnlyIfNewer(this.refreshOnlyIfNewer(astRoot)); + this.setDisableHits(this.disableHits(astRoot)); + } + + protected CacheType type(CompilationUnit astRoot) { + return CacheType.fromJavaAnnotationValue(this.typeAdapter.getValue(astRoot)); + } + + protected Boolean shared(CompilationUnit astRoot) { + return this.sharedAdapter.getValue(astRoot); + } + + protected Boolean alwaysRefresh(CompilationUnit astRoot) { + return this.alwaysRefreshAdapter.getValue(astRoot); + } + + protected Boolean refreshOnlyIfNewer(CompilationUnit astRoot) { + return this.refreshOnlyIfNewerAdapter.getValue(astRoot); + } + + protected Boolean disableHits(CompilationUnit astRoot) { + return this.disableHitsAdapter.getValue(astRoot); + } + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter<String> buildTypeAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__TYPE, false); + } + + private static DeclarationAnnotationElementAdapter<Boolean> buildSharedAdapter() { + return new ConversionDeclarationAnnotationElementAdapter<Boolean>(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__SHARED, false, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter<Boolean> buildAlwaysRefreshAdapter() { + return new ConversionDeclarationAnnotationElementAdapter<Boolean>(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__ALWAYS_REFRESH, false, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter<Boolean> buildRefreshOnlyIfNewerAdapter() { + return new ConversionDeclarationAnnotationElementAdapter<Boolean>(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__REFRESH_ONLY_IF_NEWER, false, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter<Boolean> buildDisableHitsAdapter() { + return new ConversionDeclarationAnnotationElementAdapter<Boolean>(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__DISABLE_HITS, false, BooleanExpressionConverter.instance()); + } + + + public static class CacheAnnotationDefinition implements AnnotationDefinition + { + // singleton + private static final CacheAnnotationDefinition INSTANCE = new CacheAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static CacheAnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure non-instantiability. + */ + private CacheAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new CacheImpl((JavaResourcePersistentType) parent, (Type) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { + return new NullCacheAnnotation(parent); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java new file mode 100644 index 0000000000..fd55259a78 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; + +public class NullCacheAnnotation extends AbstractJavaResourceNode implements CacheAnnotation, Annotation +{ + protected NullCacheAnnotation(JavaResourcePersistentMember parent) { + super(parent); + } + + @Override + public JavaResourcePersistentMember getParent() { + return (JavaResourcePersistentMember) super.getParent(); + } + + public String getAnnotationName() { + return CacheAnnotation.ANNOTATION_NAME; + } + + public void initialize(CompilationUnit astRoot) { + //null, nothing to initialize + } + + public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { + return null; + } + + public void newAnnotation() { + throw new UnsupportedOperationException(); + } + + public void removeAnnotation() { + throw new UnsupportedOperationException(); + } + + protected CacheAnnotation createCacheResource() { + return (CacheAnnotation) getParent().addAnnotation(getAnnotationName()); + } + + public CacheType getType() { + return null; + } + + public void setType(CacheType type) { + if (type != null) { + createCacheResource().setType(type); + } + } + + public Boolean getShared() { + return null; + } + + public void setShared(Boolean shared) { + if (shared != null) { + createCacheResource().setShared(shared); + } + } + + public Boolean getAlwaysRefresh() { + return null; + } + + public void setAlwaysRefresh(Boolean alwaysRefresh) { + if (alwaysRefresh != null) { + createCacheResource().setAlwaysRefresh(alwaysRefresh); + } + } + + public Boolean getRefreshOnlyIfNewer() { + return null; + } + + public void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer) { + if (refreshOnlyIfNewer != null) { + createCacheResource().setRefreshOnlyIfNewer(refreshOnlyIfNewer); + } + } + + public Boolean getDisableHits() { + return null; + } + + public void setDisableHits(Boolean disableHits) { + if (disableHits != null) { + createCacheResource().setDisableHits(disableHits); + } + } + + public TextRange getTextRange(CompilationUnit astRoot) { + return null; + } + + public TextRange getTypeTextRange(CompilationUnit astRoot) { + return null; + } + + public TextRange getSharedTextRange(CompilationUnit astRoot) { + return null; + } + + public void updateFromJava(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java new file mode 100644 index 0000000000..40b3f0345a --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.resource.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.utility.TextRange; + +/** + * Resource model interface that represents the + * org.eclipse.persistence.annotations.Cache annotation + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface CacheAnnotation extends JavaResourceNode +{ + + String ANNOTATION_NAME = EclipseLinkJPA.CACHE; + + /** + * Corresponds to the type element of the Cache annotation. + * Returns null if the type element does not exist in java. + */ + CacheType getType(); + + /** + * Corresponds to the type element of the Cache annotation. + * Set to null to remove the type element. + */ + void setType(CacheType type); + String TYPE_PROPERTY = "typeProperty"; + + + + /** + * Corresponds to the shared element of the Cache annotation. + * Returns null if the shared element does not exist in java. + */ + Boolean getShared(); + + /** + * Corresponds to the shared element of the Cache annotation. + * Set to null to remove the shared element. + */ + void setShared(Boolean shared); + String SHARED_PROPERTY = "sharedProperty"; + + +// /** +// * Corresponds to the size element of the Cache annotation. +// * Returns null if the size valuePair does not exist in the annotation +// */ +// Integer getSize(); +// +// /** +// * Corresponds to the size element of the javax.persistence.Column annotation. +// * Set to null to remove the size valuePair from the annotation +// */ +// void setSize(Integer size); +// String SIZE_PROPERTY = "sizeProperty"; + +// /** +// * Corresponds to the expiry element of the Cache annotation. +// * Returns null if the expiry valuePair does not exist in the annotation +// */ +// Integer getExpiry(); +// +// /** +// * Corresponds to the expiry element of the javax.persistence.Column annotation. +// * Set to null to remove the expiry valuePair from the annotation +// */ +// void setExpiry(Integer expiry); +// String EXPIRY_PROPERTY = "expiryProperty"; +// +//TimeOfDay + + /** + * Corresponds to the alwaysRefresh element of the Cache annotation. + * Returns null if the alwaysRefresh element does not exist in java. + */ + Boolean getAlwaysRefresh(); + + /** + * Corresponds to the alwaysRefresh element of the Cache annotation. + * Set to null to remove the alwaysRefresh element. + */ + void setAlwaysRefresh(Boolean alwaysRefresh); + String ALWAYS_REFRESH_PROPERTY = "alwaysRefreshProperty"; + + /** + * Corresponds to the refreshOnlyIfNewer element of the Cache annotation. + * Returns null if the refreshOnlyIfNewer element does not exist in java. + */ + Boolean getRefreshOnlyIfNewer(); + + /** + * Corresponds to the refreshOnlyIfNewer element of the Cache annotation. + * Set to null to remove the refreshOnlyIfNewer element. + */ + void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer); + String REFRESH_ONLY_IF_NEWER_PROPERTY = "refreshOnlyIfNewerProperty"; + + /** + * Corresponds to the disableHits element of the Cache annotation. + * Returns null if the disableHits element does not exist in java. + */ + Boolean getDisableHits(); + + /** + * Corresponds to the disableHits element of the Cache annotation. + * Set to null to remove the disableHits element. + */ + void setDisableHits(Boolean disableHits); + String DISABLE_HITS_PROPERTY = "disableHitsProperty"; + + /** + * Return the {@link TextRange} for the type element. If the type element + * does not exist return the {@link TextRange} for the Cache annotation. + */ + TextRange getTypeTextRange(CompilationUnit astRoot); + + /** + * Return the {@link TextRange} for the shared element. If the shared element + * does not exist return the {@link TextRange} for the Cache annotation. + */ + TextRange getSharedTextRange(CompilationUnit astRoot); + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheType.java new file mode 100644 index 0000000000..1e8fc9effa --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheType.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.resource.java; + +/** + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public enum CacheType { + + FULL, + WEAK, + SOFT, + SOFT_WEAK, + HARD_WEAK, + CACHE, + NONE; + + + public static CacheType fromJavaAnnotationValue(Object javaAnnotationValue) { + if (javaAnnotationValue == null) { + return null; + } + if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__FULL)) { + return FULL; + } + if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__WEAK)) { + return WEAK; + } + if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__SOFT)) { + return SOFT; + } + if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__SOFT_WEAK)) { + return SOFT_WEAK; + } + if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__HARD_WEAK)) { + return HARD_WEAK; + } + if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__CACHE)) { + return CACHE; + } + if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__NONE)) { + return NONE; + } + return null; + } + + public static String toJavaAnnotationValue(CacheType cacheType) { + if (cacheType == null) { + return null; + } + switch (cacheType) { + case FULL : + return EclipseLinkJPA.CACHE_TYPE__FULL; + case WEAK : + return EclipseLinkJPA.CACHE_TYPE__WEAK; + case SOFT : + return EclipseLinkJPA.CACHE_TYPE__SOFT; + case SOFT_WEAK : + return EclipseLinkJPA.CACHE_TYPE__SOFT_WEAK; + case HARD_WEAK : + return EclipseLinkJPA.CACHE_TYPE__HARD_WEAK; + case CACHE : + return EclipseLinkJPA.CACHE_TYPE__CACHE; + case NONE : + return EclipseLinkJPA.CACHE_TYPE__NONE; + default : + throw new IllegalArgumentException("unknown cache type: " + cacheType); + } + } +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/EclipseLinkJPA.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/EclipseLinkJPA.java new file mode 100644 index 0000000000..0496ac5fcf --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/EclipseLinkJPA.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.resource.java; + + +/** + * EclipseLink JPA Java-related stuff (annotations etc.) + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkJPA { + + // EclipseLink JPA package + String PACKAGE = "org.eclipse.persistence.annotations"; + String PACKAGE_ = PACKAGE + "."; + + + // ********** API ********** + + // JPA annotations + String CACHE = PACKAGE_ + "Cache"; + String CACHE__SHARED = "shared"; + String CACHE__TYPE = "type"; + String CACHE__ALWAYS_REFRESH = "alwaysRefresh"; + String CACHE__REFRESH_ONLY_IF_NEWER = "refreshOnlyIfNewer"; + String CACHE__DISABLE_HITS = "disableHits"; + String CACHE_TYPE = PACKAGE_ + "CacheType"; + String CACHE_TYPE_ = CACHE_TYPE + "."; + String CACHE_TYPE__FULL = CACHE_TYPE_ + "FULL"; + String CACHE_TYPE__WEAK = CACHE_TYPE_ + "WEAK"; + String CACHE_TYPE__SOFT = CACHE_TYPE_ + "SOFT"; + String CACHE_TYPE__SOFT_WEAK = CACHE_TYPE_ + "SOFT_WEAK"; + String CACHE_TYPE__HARD_WEAK = CACHE_TYPE_ + "HARD_WEAK"; + String CACHE_TYPE__CACHE = CACHE_TYPE_ + "CACHE"; + String CACHE_TYPE__NONE = CACHE_TYPE_ + "NONE"; + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF index 2dc41c7174..370837d3da 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.jpt.eclipselink.ui;singleton:=true Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin +Bundle-Activator: org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin Bundle-ClassPath: . Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", @@ -21,10 +21,17 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)" Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.jpt.eclipselink.ui.internal, +Export-Package: org.eclipse.jpt.eclipselink.ui, + org.eclipse.jpt.eclipselink.ui.internal, org.eclipse.jpt.eclipselink.ui.internal.caching, + org.eclipse.jpt.eclipselink.ui.internal.connection, org.eclipse.jpt.eclipselink.ui.internal.customization, + org.eclipse.jpt.eclipselink.ui.internal.ddlgen, + org.eclipse.jpt.eclipselink.ui.internal.ddlgen.wizards, + org.eclipse.jpt.eclipselink.ui.internal.java.details, org.eclipse.jpt.eclipselink.ui.internal.logging, + org.eclipse.jpt.eclipselink.ui.internal.mappings, + org.eclipse.jpt.eclipselink.ui.internal.mappings.details, org.eclipse.jpt.eclipselink.ui.internal.options, org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details, org.eclipse.jpt.eclipselink.ui.internal.platform, diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml index de2d94cccd..02b40c7cf2 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml @@ -5,7 +5,7 @@ <extension point="org.eclipse.jpt.ui.jpaPlatform"> <jpaPlatform - class="org.eclipse.jpt.eclipselink.ui.internal.platform.EclipseLinkPlatformUI" + class="org.eclipse.jpt.eclipselink.ui.internal.platform.EclipseLinkJpaPlatformUI" id="org.eclipse.eclipselink.platform"> </jpaPlatform> </extension> diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties index 0d972cff18..e5716f2a09 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties @@ -1,6 +1,12 @@ ############################################################################### -# Copyright (c) 2007, 2008 Oracle. - initial API and implementation -############################################################################### +# Copyright (c) 2007, 2008 Oracle. All rights reserved. +# This program and the accompanying materials are made available under the terms of +# the Eclipse Public License v1.0, which accompanies this distribution and is available at +# http://www.eclipse.org/legal/epl-v10.html. +# +# Contributors: +# Oracle - initial API and implementation +############################################################################### Boolean_True = True Boolean_False = False diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties new file mode 100644 index 0000000000..7e8b30fa80 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties @@ -0,0 +1,30 @@ +############################################################################### +# Copyright (c) 2008 Oracle. All rights reserved. +# This program and the accompanying materials are made available under the terms of +# the Eclipse Public License v1.0, which accompanies this distribution and is available at +# http://www.eclipse.org/legal/epl-v10.html. +# +# Contributors: +# Oracle - initial API and implementation +############################################################################### + +CacheTypeComposite_label = Type: +EclipseLinkJavaEntityComposite_caching = Caching +CacheTypeComposite_full = Full +CacheTypeComposite_weak = Weak +CacheTypeComposite_soft = Soft +CacheTypeComposite_soft_weak = Weak with Soft Subcache +CacheTypeComposite_hard_weak = Weak with Hard Subcache +CacheTypeComposite_cache = Cache +CacheTypeComposite_none = None + +CachingComposite_sharedLabelDefault = Shared ({0}) +CachingComposite_sharedLabel = Shared + +AlwaysRefreshComposite_alwaysRefreshDefault = Always Refresh ({0}) +AlwaysRefreshComposite_alwaysRefreshLabel = Always Refresh +RefreshOnlyIfNewerComposite_refreshOnlyIfNewerDefault = Refresh Only if Newer ({0}) +RefreshOnlyIfNewerComposite_refreshOnlyIfNewerLabel = Refresh Only if Newer +DisableHitsComposite_disableHitsDefault = Disable Hits ({0}) +DisableHitsComposite_disableHitsLabel = Disable Hits + diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/EclipseLinkJpaUiFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/EclipseLinkJpaUiFactory.java new file mode 100644 index 0000000000..102380be55 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/EclipseLinkJpaUiFactory.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui; + +import org.eclipse.jpt.ui.JpaUiFactory; + +/** + * + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface EclipseLinkJpaUiFactory extends JpaUiFactory +{ + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/JptEclipseLinkUiPlugin.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/JptEclipseLinkUiPlugin.java index 638046d4de..63e2d93f19 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/JptEclipseLinkUiPlugin.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/JptEclipseLinkUiPlugin.java @@ -7,7 +7,7 @@ * Contributors: * Oracle - initial API and implementation *******************************************************************************/ -package org.eclipse.jpt.eclipselink.ui.internal; +package org.eclipse.jpt.eclipselink.ui; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -18,6 +18,13 @@ import org.osgi.framework.BundleContext; /** * The activator class controls the plug-in life cycle + * + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. */ public class JptEclipseLinkUiPlugin extends AbstractUIPlugin { @@ -82,6 +89,7 @@ public class JptEclipseLinkUiPlugin extends AbstractUIPlugin * * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; @@ -92,6 +100,7 @@ public class JptEclipseLinkUiPlugin extends AbstractUIPlugin * * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkHelpContextIds.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkHelpContextIds.java new file mode 100644 index 0000000000..9f80930978 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkHelpContextIds.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0, which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal; + +import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; + +/** + * Help context ids for the Dali EclipseLink UI. + * <p> + * This interface contains constants only; it is not intended to be + * implemented. + * </p> + */ +@SuppressWarnings("nls") +public interface EclipseLinkHelpContextIds { + + //ContextID prefix + public static final String PREFIX = JptEclipseLinkUiPlugin.PLUGIN_ID + "."; + + //Persistent Type composites + public static final String CACHING_CACHE_TYPE = PREFIX + "caching_cacheType"; + public static final String CACHING_SHARED = PREFIX + "caching_shared"; + public static final String CACHING_ALWAYS_REFRESH = PREFIX + "caching_alwaysRefresh"; + public static final String CACHING_REFRESH_ONLY_IF_NEWER = PREFIX + "caching_refreshOnlyIfNewer"; + public static final String CACHING_DISABLE_HITS = PREFIX + "caching_disableHits"; + + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkUiFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkJpaUiFactoryImpl.java index aef68fcbcd..ee35381ba1 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkUiFactory.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkJpaUiFactoryImpl.java @@ -7,11 +7,11 @@ * Contributors: * Oracle - initial API and implementation *******************************************************************************/ -package org.eclipse.jpt.eclipselink.ui.internal.platform; +package org.eclipse.jpt.eclipselink.ui.internal; import java.util.ArrayList; import java.util.ListIterator; - +import org.eclipse.jpt.core.context.java.JavaEntity; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkPersistenceUnit; import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching; @@ -20,13 +20,16 @@ import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customiza import org.eclipse.jpt.eclipselink.core.internal.context.logging.Logging; import org.eclipse.jpt.eclipselink.core.internal.context.options.Options; import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration; +import org.eclipse.jpt.eclipselink.ui.EclipseLinkJpaUiFactory; import org.eclipse.jpt.eclipselink.ui.internal.caching.PersistenceXmlCachingTab; import org.eclipse.jpt.eclipselink.ui.internal.connection.PersistenceXmlConnectionTab; import org.eclipse.jpt.eclipselink.ui.internal.customization.PersistenceXmlCustomizationTab; +import org.eclipse.jpt.eclipselink.ui.internal.java.details.EclipseLinkJavaEntityComposite; import org.eclipse.jpt.eclipselink.ui.internal.logging.PersistenceXmlLoggingTab; import org.eclipse.jpt.eclipselink.ui.internal.options.PersistenceXmlOptionsTab; import org.eclipse.jpt.eclipselink.ui.internal.schema.generation.PersistenceXmlSchemaGenerationTab; import org.eclipse.jpt.ui.WidgetFactory; +import org.eclipse.jpt.ui.details.JpaComposite; import org.eclipse.jpt.ui.details.JpaPageComposite; import org.eclipse.jpt.ui.internal.BaseJpaUiFactory; import org.eclipse.jpt.ui.internal.persistence.details.PersistenceUnitGeneralComposite; @@ -36,15 +39,24 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel; import org.eclipse.swt.widgets.Composite; /** - * EclipseLinkUiFactory + * EclipseLinkJpaUiFactory */ -public class EclipseLinkUiFactory extends BaseJpaUiFactory +public class EclipseLinkJpaUiFactoryImpl extends BaseJpaUiFactory implements EclipseLinkJpaUiFactory { - public EclipseLinkUiFactory() { + public EclipseLinkJpaUiFactoryImpl() { super(); } @Override + public JpaComposite createJavaEntityComposite( + PropertyValueModel<JavaEntity> subjectHolder, + Composite parent, + WidgetFactory widgetFactory) { + + return new EclipseLinkJavaEntityComposite(subjectHolder, parent, widgetFactory); + } + + @Override public ListIterator<JpaPageComposite> createPersistenceUnitComposites( PropertyValueModel<PersistenceUnit> subjectHolder, Composite parent, diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java index b2398b5182..76ab8848b0 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java @@ -30,8 +30,8 @@ import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.core.context.PersistentType; import org.eclipse.jpt.core.context.TypeMapping; import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching; +import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; -import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin; import org.eclipse.jpt.ui.internal.util.PaneEnabler; import org.eclipse.jpt.ui.internal.widgets.AbstractPane; import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java index 03422763f7..44dde05c93 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java @@ -16,8 +16,8 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection; +import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; -import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin; import org.eclipse.jpt.ui.internal.widgets.AbstractPane; import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java index 0c7bc630c3..b68e09205f 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/CustomizerComposite.java @@ -16,8 +16,8 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization; +import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; -import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin; import org.eclipse.jpt.ui.internal.widgets.AbstractPane; import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java index 6556d52807..c34b8d9b5b 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java @@ -30,8 +30,8 @@ import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.core.context.PersistentType; import org.eclipse.jpt.core.context.TypeMapping; import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization; +import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; -import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin; import org.eclipse.jpt.ui.internal.util.PaneEnabler; import org.eclipse.jpt.ui.internal.widgets.AbstractPane; import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java index 03537a4d3d..5cc9cecfff 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/SessionCustomizerComposite.java @@ -16,8 +16,8 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization; +import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; -import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin; import org.eclipse.jpt.ui.internal.widgets.AbstractPane; import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/java/details/EclipseLinkJavaEntityComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/java/details/EclipseLinkJavaEntityComposite.java new file mode 100644 index 0000000000..c01aa2e3b8 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/java/details/EclipseLinkJavaEntityComposite.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal.java.details; + +import org.eclipse.jpt.core.context.java.JavaEntity; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEntity; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.details.CachingComposite; +import org.eclipse.jpt.ui.WidgetFactory; +import org.eclipse.jpt.ui.internal.java.details.JavaInheritanceComposite; +import org.eclipse.jpt.ui.internal.java.details.JavaSecondaryTablesComposite; +import org.eclipse.jpt.ui.internal.mappings.details.AbstractEntityComposite; +import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; +import org.eclipse.jpt.utility.model.value.PropertyValueModel; +import org.eclipse.swt.widgets.Composite; + +/** + * The pane used for an EclipseLink Java entity. + * + * @see EclipseLinkJavaEntity + * @see EclipselinkJpaUiFactory - The factory creating this pane + * + * @version 2.0 + * @since 1.0 + */ +public class EclipseLinkJavaEntityComposite extends AbstractEntityComposite<JavaEntity> +{ + /** + * Creates a new <code>JavaEntityComposite</code>. + * + * @param subjectHolder The holder of the subject <code>JavaEntity</code> + * @param parent The parent container + * @param widgetFactory The factory used to create various common widgets + */ + public EclipseLinkJavaEntityComposite(PropertyValueModel<? extends JavaEntity> subjectHolder, + Composite parent, + WidgetFactory widgetFactory) { + + super(subjectHolder, parent, widgetFactory); + } + + + @Override + protected void initializeLayout(Composite container) { + initializeGeneralPane(container); + initializeCachingPane(container); + initializeQueriesPane(container); + initializeInheritancePane(container); + initializeAttributeOverridesPane(container); + initializeGeneratorsPane(container); + initializeSecondaryTablesPane(container); + } + + protected void initializeCachingPane(Composite container) { + + container = buildCollapsableSection( + buildSubPane(container, 5), + EclipseLinkUiMappingsMessages.EclipseLinkJavaEntityComposite_caching + ); + + new CachingComposite(this, buildCachingHolder(), container); + } + + private PropertyAspectAdapter<JavaEntity, EclipseLinkCaching> buildCachingHolder() { + return new PropertyAspectAdapter<JavaEntity, EclipseLinkCaching>( + getSubjectHolder()) + { + @Override + protected EclipseLinkCaching buildValue_() { + return ((EclipseLinkJavaEntity) this.subject).getCaching(); + } + }; + + } + + @Override + protected void buildSecondaryTablesComposite(Composite container) { + new JavaSecondaryTablesComposite(this, container); + } + + @Override + protected void buildInheritanceComposite(Composite container) { + new JavaInheritanceComposite(this, container); + } + +}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java new file mode 100644 index 0000000000..901ed4dfdf --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0, which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal.mappings; + +import org.eclipse.osgi.util.NLS; + +/** + * The localized strings used by the mapping panes. + * + * @version 2.0 + * @since 1.0 + */ +@SuppressWarnings("nls") +public class EclipseLinkUiMappingsMessages extends NLS { + + public static String CacheTypeComposite_label; + public static String CacheTypeComposite_full; + public static String CacheTypeComposite_weak; + public static String CacheTypeComposite_soft; + public static String CacheTypeComposite_soft_weak; + public static String CacheTypeComposite_hard_weak; + public static String CacheTypeComposite_cache; + public static String CacheTypeComposite_none; + public static String EclipseLinkJavaEntityComposite_caching; + + public static String CachingComposite_sharedLabelDefault; + public static String CachingComposite_sharedLabel; + public static String AlwaysRefreshComposite_alwaysRefreshDefault; + public static String AlwaysRefreshComposite_alwaysRefreshLabel; + public static String RefreshOnlyIfNewerComposite_refreshOnlyIfNewerDefault; + public static String RefreshOnlyIfNewerComposite_refreshOnlyIfNewerLabel; + public static String DisableHitsComposite_disableHitsDefault; + public static String DisableHitsComposite_disableHitsLabel; + + static { + NLS.initializeMessages("eclipselink_ui_mappings", EclipseLinkUiMappingsMessages.class); + } + + private EclipseLinkUiMappingsMessages() { + throw new UnsupportedOperationException(); + } +}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/AlwaysRefreshComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/AlwaysRefreshComposite.java new file mode 100644 index 0000000000..28b8b8bfe5 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/AlwaysRefreshComposite.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal.mappings.details; + +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages; +import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages; +import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane; +import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; +import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; +import org.eclipse.jpt.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Composite; + + +/** + * This composite simply shows a tri-state check box for the Always Refresh option. + * + * @see EclipseLinkCaching + * @see CachingComposite - A container of this widget + * + * @version 2.1 + * @since 2.1 + */ +public class AlwaysRefreshComposite extends AbstractFormPane<EclipseLinkCaching> +{ + /** + * Creates a new <code>OptionalComposite</code>. + * + * @param parentPane The parent container of this one + * @param parent The parent container + */ + public AlwaysRefreshComposite(AbstractFormPane<? extends EclipseLinkCaching> parentPane, + Composite parent) + { + super(parentPane, parent); + } + + private WritablePropertyValueModel<Boolean> buildAlwaysRefreshHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_ALWAYS_REFRESH_PROPERTY) { + @Override + protected Boolean buildValue_() { + return this.subject.getSpecifiedAlwaysRefresh(); + } + + @Override + protected void setValue_(Boolean value) { + this.subject.setSpecifiedAlwaysRefresh(value); + } + + @Override + protected void subjectChanged() { + Object oldValue = this.getValue(); + super.subjectChanged(); + Object newValue = this.getValue(); + + // Make sure the default value is appended to the text + if (oldValue == newValue && newValue == null) { + this.fireAspectChange(Boolean.TRUE, newValue); + } + } + }; + } + + private PropertyValueModel<String> buildAlwaysRefreshStringHolder() { + + return new TransformationPropertyValueModel<Boolean, String>(buildAlwaysRefreshHolder()) { + + @Override + protected String transform(Boolean value) { + + if ((subject() != null) && (value == null)) { + + Boolean defaultValue = subject().getDefaultAlwaysRefresh(); + + if (defaultValue != null) { + + String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True : + JptUiMappingsMessages.Boolean_False; + + return NLS.bind( + EclipseLinkUiMappingsMessages.AlwaysRefreshComposite_alwaysRefreshDefault, + defaultStringValue + ); + } + } + + return EclipseLinkUiMappingsMessages.AlwaysRefreshComposite_alwaysRefreshLabel; + } + }; + } + + /* + * (non-Javadoc) + */ + @Override + protected void initializeLayout(Composite container) { + + buildTriStateCheckBoxWithDefault( + container, + EclipseLinkUiMappingsMessages.AlwaysRefreshComposite_alwaysRefreshLabel, + buildAlwaysRefreshHolder(), + buildAlwaysRefreshStringHolder(), + EclipseLinkHelpContextIds.CACHING_ALWAYS_REFRESH + ); + } +}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CacheTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CacheTypeComposite.java new file mode 100644 index 0000000000..4fccac255b --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CacheTypeComposite.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Oracle. - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal.mappings.details; + +import java.util.Collection; +import org.eclipse.jpt.eclipselink.core.context.CacheType; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages; +import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane; +import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; +import org.eclipse.swt.widgets.Composite; + +/** + * Here is the layout of this pane: + * <pre> + * ---------------------------------------------------------------------------- + * | ------------------------------------------------------------------ | + * | Type: | |v| | + * | ------------------------------------------------------------------ | + * ----------------------------------------------------------------------------</pre> + * + * @see EclipseLinkCaching + * @see CachingComposite - A container of this widget + * + * @version 2.1 + * @since 2.1 + */ +public class CacheTypeComposite extends AbstractFormPane<EclipseLinkCaching> { + + /** + * Creates a new <code>FetchTypeComposite</code>. + * + * @param parentPane The parent container of this one + * @param parent The parent container + */ + public CacheTypeComposite(AbstractFormPane<? extends EclipseLinkCaching> parentPane, + Composite parent) { + + super(parentPane, parent); + } + + private EnumFormComboViewer<EclipseLinkCaching, CacheType> buildCacheTypeCombo(Composite container) { + + return new EnumFormComboViewer<EclipseLinkCaching, CacheType>(this, container) { + + @Override + protected void addPropertyNames(Collection<String> propertyNames) { + super.addPropertyNames(propertyNames); + propertyNames.add(EclipseLinkCaching.DEFAULT_CACHE_TYPE_PROPERTY); + propertyNames.add(EclipseLinkCaching.SPECIFIED_CACHE_TYPE_PROPERTY); + } + + @Override + protected CacheType[] choices() { + return CacheType.values(); + } + + @Override + protected CacheType defaultValue() { + return subject().getDefaultCacheType(); + } + + @Override + protected String displayString(CacheType value) { + return buildDisplayString( + EclipseLinkUiMappingsMessages.class, + CacheTypeComposite.this, + value + ); + } + + @Override + protected CacheType getValue() { + return subject().getSpecifiedCacheType(); + } + + @Override + protected void setValue(CacheType value) { + subject().setSpecifiedCacheType(value); + } + + @Override + protected boolean sortChoices() { + return false; + } + }; + } + + /* + * (non-Javadoc) + */ + @Override + protected void initializeLayout(Composite container) { + + buildLabeledComposite( + container, + EclipseLinkUiMappingsMessages.CacheTypeComposite_label, + buildCacheTypeCombo(container), + EclipseLinkHelpContextIds.CACHING_CACHE_TYPE + ); + } +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java new file mode 100644 index 0000000000..871c49314a --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java @@ -0,0 +1,144 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal.mappings.details; + +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages; +import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages; +import org.eclipse.jpt.ui.internal.util.PaneEnabler; +import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane; +import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; +import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; +import org.eclipse.jpt.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Composite; + +/** + * This pane shows the caching options. + * <p> + * Here the layout of this pane: + * <pre> + * ----------------------------------------------------------------------------- + * | x Shared | + * | CacheTypeComposite | + * | AlwaysRefreshComposite | + * | RefreshOnlyIfNewerComposite | + * | DisableHitsComposite | + * -----------------------------------------------------------------------------</pre> + * + * @see Entity + * @see EclipseLinkCaching + * @see EclipseLinkJavaEntityComposite - The parent container + * @see CacheTypeComposite + * @see AlwaysRefreshComposite + * @see RefreshOnlyIfNewerComposite + * @see DisableHitsComposite + * + * @version 2.1 + * @since 2.1 + */ +public class CachingComposite extends AbstractFormPane<EclipseLinkCaching> +{ + + public CachingComposite(AbstractFormPane<?> parentPane, + PropertyValueModel<EclipseLinkCaching> subjectHolder, + Composite parent) { + + super(parentPane, subjectHolder, parent); + } + + @Override + protected void initializeLayout(Composite container) { + + //Shared Check box, uncheck this and the rest of the panel is disabled + buildTriStateCheckBoxWithDefault( + buildSubPane(container, 8), + EclipseLinkUiMappingsMessages.CachingComposite_sharedLabel, + buildSharedHolder(), + buildSharedStringHolder(), + EclipseLinkHelpContextIds.CACHING_SHARED + ); + + Composite subPane = buildSubPane(container, 0, 16); + + new PaneEnabler(buildSharedCacheEnabler(), + new CacheTypeComposite(this, subPane), + new AlwaysRefreshComposite(this, subPane), + new RefreshOnlyIfNewerComposite(this, subPane), + new DisableHitsComposite(this, subPane) + ); + } + + + private PropertyValueModel<Boolean> buildSharedCacheEnabler() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_SHARED_PROPERTY) { + @Override + protected Boolean buildValue_() { + return this.subject.getShared(); + } + }; + } + private WritablePropertyValueModel<Boolean> buildSharedHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_SHARED_PROPERTY) { + @Override + protected Boolean buildValue_() { + return this.subject.getSpecifiedShared(); + } + + @Override + protected void setValue_(Boolean value) { + this.subject.setSpecifiedShared(value); + } + + @Override + protected void subjectChanged() { + Object oldValue = this.getValue(); + super.subjectChanged(); + Object newValue = this.getValue(); + + // Make sure the default value is appended to the text + if (oldValue == newValue && newValue == null) { + this.fireAspectChange(Boolean.TRUE, newValue); + } + } + }; + } + + private PropertyValueModel<String> buildSharedStringHolder() { + + return new TransformationPropertyValueModel<Boolean, String>(buildSharedHolder()) { + + @Override + protected String transform(Boolean value) { + + if ((subject() != null) && (value == null)) { + + Boolean defaultValue = subject().getDefaultShared(); + + if (defaultValue != null) { + + String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True : + JptUiMappingsMessages.Boolean_False; + + return NLS.bind( + EclipseLinkUiMappingsMessages.CachingComposite_sharedLabelDefault, + defaultStringValue + ); + } + } + + return EclipseLinkUiMappingsMessages.CachingComposite_sharedLabel; + } + }; + } + +}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/DisableHitsComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/DisableHitsComposite.java new file mode 100644 index 0000000000..f509f4d3cb --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/DisableHitsComposite.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal.mappings.details; + +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages; +import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages; +import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane; +import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; +import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; +import org.eclipse.jpt.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Composite; + +/** + * This composite simply shows a tri-state check box for the Disable Hits option. + * + * @see EclipseLinkCaching + * @see CachingComposite - A container of this widget + * + * @version 2.1 + * @since 2.1 + */ +public class DisableHitsComposite extends AbstractFormPane<EclipseLinkCaching> +{ + /** + * Creates a new <code>OptionalComposite</code>. + * + * @param parentPane The parent container of this one + * @param parent The parent container + */ + public DisableHitsComposite(AbstractFormPane<? extends EclipseLinkCaching> parentPane, + Composite parent) + { + super(parentPane, parent); + } + + private WritablePropertyValueModel<Boolean> buildDisableHitsHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_DISABLE_HITS_PROPERTY) { + @Override + protected Boolean buildValue_() { + return this.subject.getSpecifiedDisableHits(); + } + + @Override + protected void setValue_(Boolean value) { + this.subject.setSpecifiedDisableHits(value); + } + + @Override + protected void subjectChanged() { + Object oldValue = this.getValue(); + super.subjectChanged(); + Object newValue = this.getValue(); + + // Make sure the default value is appended to the text + if (oldValue == newValue && newValue == null) { + this.fireAspectChange(Boolean.TRUE, newValue); + } + } + }; + } + + private PropertyValueModel<String> buildDisableHitsStringHolder() { + + return new TransformationPropertyValueModel<Boolean, String>(buildDisableHitsHolder()) { + + @Override + protected String transform(Boolean value) { + + if ((subject() != null) && (value == null)) { + + Boolean defaultValue = subject().getDefaultDisableHits(); + + if (defaultValue != null) { + + String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True : + JptUiMappingsMessages.Boolean_False; + + return NLS.bind( + EclipseLinkUiMappingsMessages.DisableHitsComposite_disableHitsDefault, + defaultStringValue + ); + } + } + + return EclipseLinkUiMappingsMessages.DisableHitsComposite_disableHitsLabel; + } + }; + } + + /* + * (non-Javadoc) + */ + @Override + protected void initializeLayout(Composite container) { + + buildTriStateCheckBoxWithDefault( + container, + EclipseLinkUiMappingsMessages.DisableHitsComposite_disableHitsLabel, + buildDisableHitsHolder(), + buildDisableHitsStringHolder(), + EclipseLinkHelpContextIds.CACHING_DISABLE_HITS + ); + } +}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/RefreshOnlyIfNewerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/RefreshOnlyIfNewerComposite.java new file mode 100644 index 0000000000..8f99e664b3 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/RefreshOnlyIfNewerComposite.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.eclipselink.ui.internal.mappings.details; + +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages; +import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages; +import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane; +import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; +import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; +import org.eclipse.jpt.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Composite; + +/** + * This composite simply shows a tri-state check box for the Refresh Only If Newer option. + * + * @see EclipseLinkCaching + * @see CachingComposite - A container of this widget + * + * @version 2.1 + * @since 2.1 + */ +public class RefreshOnlyIfNewerComposite extends AbstractFormPane<EclipseLinkCaching> +{ + /** + * Creates a new <code>OptionalComposite</code>. + * + * @param parentPane The parent container of this one + * @param parent The parent container + */ + public RefreshOnlyIfNewerComposite(AbstractFormPane<? extends EclipseLinkCaching> parentPane, + Composite parent) + { + super(parentPane, parent); + } + + private WritablePropertyValueModel<Boolean> buildRefreshOnlyIfNewerHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_REFRESH_ONLY_IF_NEWER_PROPERTY) { + @Override + protected Boolean buildValue_() { + return this.subject.getSpecifiedRefreshOnlyIfNewer(); + } + + @Override + protected void setValue_(Boolean value) { + this.subject.setSpecifiedRefreshOnlyIfNewer(value); + } + + @Override + protected void subjectChanged() { + Object oldValue = this.getValue(); + super.subjectChanged(); + Object newValue = this.getValue(); + + // Make sure the default value is appended to the text + if (oldValue == newValue && newValue == null) { + this.fireAspectChange(Boolean.TRUE, newValue); + } + } + }; + } + + private PropertyValueModel<String> buildRefreshOnlyIfNewerStringHolder() { + + return new TransformationPropertyValueModel<Boolean, String>(buildRefreshOnlyIfNewerHolder()) { + + @Override + protected String transform(Boolean value) { + + if ((subject() != null) && (value == null)) { + + Boolean defaultValue = subject().getDefaultRefreshOnlyIfNewer(); + + if (defaultValue != null) { + + String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True : + JptUiMappingsMessages.Boolean_False; + + return NLS.bind( + EclipseLinkUiMappingsMessages.RefreshOnlyIfNewerComposite_refreshOnlyIfNewerDefault, + defaultStringValue + ); + } + } + + return EclipseLinkUiMappingsMessages.RefreshOnlyIfNewerComposite_refreshOnlyIfNewerLabel; + } + }; + } + + /* + * (non-Javadoc) + */ + @Override + protected void initializeLayout(Composite container) { + + buildTriStateCheckBoxWithDefault( + container, + EclipseLinkUiMappingsMessages.RefreshOnlyIfNewerComposite_refreshOnlyIfNewerLabel, + buildRefreshOnlyIfNewerHolder(), + buildRefreshOnlyIfNewerStringHolder(), + EclipseLinkHelpContextIds.CACHING_REFRESH_ONLY_IF_NEWER + ); + } +}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java index 82c57733b2..6e7dca94d0 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/options/EventListenerComposite.java @@ -16,8 +16,8 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jpt.eclipselink.core.internal.context.options.Options; +import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; -import org.eclipse.jpt.eclipselink.ui.internal.JptEclipseLinkUiPlugin; import org.eclipse.jpt.ui.internal.widgets.AbstractPane; import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkPlatformUI.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkJpaPlatformUI.java index 7c7f7518d1..176e2eefd0 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkPlatformUI.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/platform/EclipseLinkJpaPlatformUI.java @@ -18,9 +18,10 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.context.AttributeMapping; import org.eclipse.jpt.core.context.TypeMapping; +import org.eclipse.jpt.eclipselink.ui.EclipseLinkJpaUiFactory; +import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkJpaUiFactoryImpl; import org.eclipse.jpt.eclipselink.ui.internal.ddlgen.EclipseLinkDDLGeneratorUi; import org.eclipse.jpt.eclipselink.ui.internal.persistencexml.details.PersistenceDetailsProvider; -import org.eclipse.jpt.ui.JpaUiFactory; import org.eclipse.jpt.ui.details.AttributeMappingUiProvider; import org.eclipse.jpt.ui.details.JpaDetailsProvider; import org.eclipse.jpt.ui.details.TypeMappingUiProvider; @@ -32,9 +33,9 @@ import org.eclipse.swt.widgets.Shell; /** * EclipseLinkPlatformUI */ -public class EclipseLinkPlatformUI extends BaseJpaPlatformUi +public class EclipseLinkJpaPlatformUI extends BaseJpaPlatformUi { - public EclipseLinkPlatformUI() { + public EclipseLinkJpaPlatformUI() { super(); } @@ -44,8 +45,8 @@ public class EclipseLinkPlatformUI extends BaseJpaPlatformUi } @Override - protected JpaUiFactory createJpaUiFactory() { - return new EclipseLinkUiFactory(); + protected EclipseLinkJpaUiFactory createJpaUiFactory() { + return new EclipseLinkJpaUiFactoryImpl(); } public void generateDDL(JpaProject project, IStructuredSelection selection) { |