diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink')
10 files changed, 125 insertions, 441 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java index 92cd039eee..eaf471cac5 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.caching; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Entity; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; import org.eclipse.jpt.ui.internal.widgets.IntegerCombo; @@ -23,7 +24,7 @@ import org.eclipse.swt.widgets.Composite; /** * CacheSizeComposite */ -public class CacheSizeComposite extends Pane<EntityCacheProperties> +public class CacheSizeComposite extends Pane<Entity> { /** * Creates a new <code>CacheTypeComposite</code>. @@ -33,7 +34,7 @@ public class CacheSizeComposite extends Pane<EntityCacheProperties> * @param parent * The parent container */ - public CacheSizeComposite(Pane<EntityCacheProperties> parentComposite, + public CacheSizeComposite(Pane<Entity> parentComposite, Composite parent) { super(parentComposite, parent); @@ -41,11 +42,11 @@ public class CacheSizeComposite extends Pane<EntityCacheProperties> @Override protected void initializeLayout(Composite container) { - addCacheSizeCombo(container); + this.addCacheSizeCombo(container); } private void addCacheSizeCombo(Composite container) { - new IntegerCombo<EntityCacheProperties>(this, container) { + new IntegerCombo<Entity>(this, container) { @Override protected String getLabelText() { @@ -73,26 +74,34 @@ public class CacheSizeComposite extends Pane<EntityCacheProperties> @Override protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<EntityCacheProperties, Integer>(getSubjectHolder(), EntityCacheProperties.CACHE_SIZE_PROPERTY) { + return new PropertyAspectAdapter<Entity, Integer>(this.getSubjectHolder(), Entity.CACHE_SIZE_PROPERTY) { @Override protected Integer buildValue_() { - return this.subject.getCacheSize(); + return getSubjectParent().getCacheSizeOf(getSubjectName()); } @Override protected void setValue_(Integer value) { - this.subject.setCacheSize(value); + getSubjectParent().setCacheSizeOf(getSubjectName(), value); } }; } }; } + private String getSubjectName() { + return this.getSubjectHolder().getValue().getName(); + } + + private Caching getSubjectParent() { + return this.getSubjectHolder().getValue().getParent(); + } + private PropertyValueModel<Caching> buildCachingHolder() { - return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) { + return new TransformationPropertyValueModel<Entity, Caching>(this.getSubjectHolder()) { @Override - protected Caching transform_(EntityCacheProperties value) { - return value.getCaching(); + protected Caching transform_(Entity value) { + return value.getParent(); } }; } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheTypeComposite.java index 15bf299e5e..926935c561 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheTypeComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheTypeComposite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * Copyright (c) 2008, 2009 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. @@ -12,6 +12,7 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.caching; import java.util.Collection; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.CacheType; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Entity; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper; @@ -27,7 +28,7 @@ import org.eclipse.swt.widgets.Composite; /** * CacheTypeComposite */ -public class CacheTypeComposite extends Pane<EntityCacheProperties> +public class CacheTypeComposite extends Pane<Entity> { /** * Creates a new <code>CacheTypeComposite</code>. @@ -37,7 +38,7 @@ public class CacheTypeComposite extends Pane<EntityCacheProperties> * @param parent * The parent container */ - public CacheTypeComposite(Pane<EntityCacheProperties> parentComposite, + public CacheTypeComposite(Pane<Entity> parentComposite, Composite parent) { super(parentComposite, parent); @@ -54,7 +55,7 @@ public class CacheTypeComposite extends Pane<EntityCacheProperties> ); } - private class CacheTypeCombo extends EnumFormComboViewer<EntityCacheProperties, CacheType> { + private class CacheTypeCombo extends EnumFormComboViewer<Entity, CacheType> { private CacheTypeCombo(Composite parent) { super(CacheTypeComposite.this, parent); @@ -63,14 +64,14 @@ public class CacheTypeComposite extends Pane<EntityCacheProperties> @Override protected void addPropertyNames(Collection<String> propertyNames) { super.addPropertyNames(propertyNames); - propertyNames.add(EntityCacheProperties.CACHE_TYPE_PROPERTY); + propertyNames.add(Entity.CACHE_TYPE_PROPERTY); } private PropertyValueModel<Caching> buildCachingHolder() { - return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) { + return new TransformationPropertyValueModel<Entity, Caching>(getSubjectHolder()) { @Override - protected Caching transform_(EntityCacheProperties value) { - return value.getCaching(); + protected Caching transform_(Entity value) { + return value.getParent(); } }; } @@ -111,7 +112,7 @@ public class CacheTypeComposite extends Pane<EntityCacheProperties> @Override protected CacheType getDefaultValue() { - return this.getSubject().getDefaultCacheType(); + return getSubjectParent().getDefaultCacheType(); } @Override @@ -132,7 +133,7 @@ public class CacheTypeComposite extends Pane<EntityCacheProperties> @Override protected CacheType getValue() { - return this.getSubject().getCacheType(); + return getSubjectParent().getCacheTypeOf(getSubjectName()); } @Override @@ -150,7 +151,7 @@ public class CacheTypeComposite extends Pane<EntityCacheProperties> @Override protected void setValue(CacheType value) { - this.getSubject().setCacheType(value); + getSubjectParent().setCacheTypeOf(getSubjectName(), value); } @Override @@ -158,4 +159,12 @@ public class CacheTypeComposite extends Pane<EntityCacheProperties> return false; } } + + private String getSubjectName() { + return this.getSubjectHolder().getValue().getName(); + } + + private Caching getSubjectParent() { + return this.getSubjectHolder().getValue().getParent(); + } }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java deleted file mode 100644 index edc16800f8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java +++ /dev/null @@ -1,207 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.persistence.caching; - -import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.CacheType; -import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.model.AbstractModel; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; - -/** - * EntityCacheProperties - */ -@SuppressWarnings("nls") -public class EntityCacheProperties extends AbstractModel { - - private Caching caching; - private String entityName; - - private PropertyValueModel<CacheType> cacheTypeHolder; - private PropertyChangeListener cacheTypeListener; - private PropertyValueModel<Integer> cacheSizeHolder; - private PropertyChangeListener cacheSizeListener; - private PropertyValueModel<Boolean> sharedCacheHolder; - private PropertyChangeListener sharedCacheListener; - - public static final String CACHE_TYPE_PROPERTY = Caching.CACHE_TYPE_PROPERTY; - public static final String CACHE_SIZE_PROPERTY = Caching.CACHE_SIZE_PROPERTY; - public static final String SHARED_CACHE_PROPERTY = Caching.SHARED_CACHE_PROPERTY; - - private static final long serialVersionUID = 1L; - - // ********** constructors ********** - public EntityCacheProperties(Caching caching, String entityName) { - super(); - this.caching = caching; - this.entityName = entityName; - - PropertyValueModel<Caching> cachingHolder = new SimplePropertyValueModel<Caching>(this.caching); - this.initialize(cachingHolder); - - this.engageListeners(); - } - - protected void initialize(PropertyValueModel<Caching> cachingHolder) { - this.cacheTypeHolder = this.buildCacheTypeAA(cachingHolder); - this.cacheTypeListener = this.buildCacheTypeChangeListener(); - - this.cacheSizeHolder = this.buildCacheSizeAA(cachingHolder); - this.cacheSizeListener = this.buildCacheSizeChangeListener(); - - this.sharedCacheHolder = this.buildSharedCacheAA(cachingHolder); - this.sharedCacheListener = this.buildSharedCacheChangeListener(); - } - - // ********** behavior ********** - public boolean entityNameIsValid() { - return !StringTools.stringIsEmpty(this.entityName); - } - - public Integer getCacheSize() { - return this.caching.getCacheSize(this.entityName); - } - - public CacheType getCacheType() { - return this.caching.getCacheType(this.entityName); - } - - public Caching getCaching() { - return caching; - } - - public Integer getDefaultCacheSize() { - return this.caching.getDefaultCacheSize(); - } - - public CacheType getDefaultCacheType() { - return this.caching.getDefaultCacheType(); - } - - public String getEntityName() { - return this.entityName; - } - - public Boolean getSharedCache() { - return this.caching.getSharedCache(this.entityName); - } - - public Boolean getDefaultSharedCache() { - return this.caching.getDefaultSharedCache(); - } - - public void setCacheSize(Integer cacheSize) { - Integer oldCacheSize = this.getCacheSize(); - if (this.attributeValueHasChanged(oldCacheSize, cacheSize)) { - this.caching.setCacheSize(cacheSize, this.entityName); - this.firePropertyChanged(CACHE_SIZE_PROPERTY, oldCacheSize, cacheSize); - } - } - - public void setCacheType(CacheType cacheType) { - CacheType oldCacheType = this.getCacheType(); - if (this.attributeValueHasChanged(oldCacheType, cacheType)) { - this.caching.setCacheType(cacheType, this.entityName); - this.firePropertyChanged(CACHE_TYPE_PROPERTY, oldCacheType, cacheType); - } - } - - public void setSharedCache(Boolean sharedCache) { - Boolean oldSharedCache = this.getSharedCache(); - if (this.attributeValueHasChanged(oldSharedCache, sharedCache)) { - this.caching.setSharedCache(sharedCache, this.entityName); - this.firePropertyChanged(SHARED_CACHE_PROPERTY, oldSharedCache, sharedCache); - } - } - - // ********** PropertyChangeListener ********** - - private PropertyValueModel<CacheType> buildCacheTypeAA(PropertyValueModel<Caching> subjectHolder) { - return new PropertyAspectAdapter<Caching, CacheType>( - subjectHolder, CACHE_TYPE_PROPERTY) { - @Override - protected CacheType buildValue_() { - return this.subject.getCacheType(EntityCacheProperties.this.entityName); - } - }; - } - - private PropertyChangeListener buildCacheTypeChangeListener() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent e) { - EntityCacheProperties.this.firePropertyChanged(CACHE_TYPE_PROPERTY, e.getOldValue(), e.getNewValue()); - } - }; - } - - private PropertyValueModel<Integer> buildCacheSizeAA(PropertyValueModel<Caching> subjectHolder) { - return new PropertyAspectAdapter<Caching, Integer>( - subjectHolder, CACHE_SIZE_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getCacheSize(EntityCacheProperties.this.entityName); - } - }; - } - - private PropertyChangeListener buildCacheSizeChangeListener() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent e) { - EntityCacheProperties.this.firePropertyChanged(CACHE_SIZE_PROPERTY, e.getOldValue(), e.getNewValue()); - } - }; - } - - private PropertyValueModel<Boolean> buildSharedCacheAA(PropertyValueModel<Caching> subjectHolder) { - return new PropertyAspectAdapter<Caching, Boolean>( - subjectHolder, SHARED_CACHE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return this.subject.getSharedCache(EntityCacheProperties.this.entityName); - } - }; - } - - private PropertyChangeListener buildSharedCacheChangeListener() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent e) { - EntityCacheProperties.this.firePropertyChanged(SHARED_CACHE_PROPERTY, e.getOldValue(), e.getNewValue()); - } - }; - } - - public void engageListeners() { - this.cacheTypeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener); - this.cacheSizeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheSizeListener); - this.sharedCacheHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener); - } - - public void disengageListeners() { - this.cacheTypeHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener); - this.cacheSizeHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheSizeListener); - this.sharedCacheHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener); - } - - @Override - public void toString(StringBuilder sb) { - sb.append("name: "); - sb.append(this.entityName); - sb.append(", type: "); - sb.append(this.getCacheType()); - sb.append(", size: "); - sb.append(this.getCacheSize()); - sb.append(", isShared: "); - sb.append(this.getSharedCache()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCachingPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCachingPropertyComposite.java index f20ecfc047..9080e937cd 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCachingPropertyComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCachingPropertyComposite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * Copyright (c) 2008, 2009 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. @@ -10,6 +10,7 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.caching; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Entity; import org.eclipse.jpt.ui.internal.widgets.Pane; import org.eclipse.jpt.utility.model.value.PropertyValueModel; import org.eclipse.swt.widgets.Composite; @@ -18,7 +19,7 @@ import org.eclipse.swt.widgets.Composite; * @version 2.0 * @since 2.0 */ -public class EntityCachingPropertyComposite extends Pane<EntityCacheProperties> { +public class EntityCachingPropertyComposite extends Pane<Entity> { /** * Creates a new <code>EntityCachingPropertyComposite</code>. @@ -28,7 +29,7 @@ public class EntityCachingPropertyComposite extends Pane<EntityCacheProperties> * @param parent The parent container */ public EntityCachingPropertyComposite(Pane<Caching> parentComposite, - PropertyValueModel<EntityCacheProperties> subjectHolder, + PropertyValueModel<Entity> subjectHolder, Composite parent) { super(parentComposite, subjectHolder, parent); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java index d5302cdc45..67a0ad63b1 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java @@ -24,8 +24,8 @@ import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.window.Window; -import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Entity; import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; @@ -34,7 +34,6 @@ import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; import org.eclipse.jpt.ui.internal.widgets.Pane; import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationListValueModelAdapter; import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; import org.eclipse.jpt.utility.model.value.ListValueModel; @@ -62,14 +61,14 @@ public class EntityListComposite extends Pane<Caching> container, EclipseLinkUiMessages.CachingEntityListComposite_groupTitle ); - WritablePropertyValueModel<EntityCacheProperties> entityHolder = this.buildEntityHolder(); + WritablePropertyValueModel<Entity> entityHolder = this.buildEntityHolder(); // Entities add/remove list pane new AddRemoveListPane<Caching>( this, container, this.buildEntitiesAdapter(), - this.buildEntityCachingListHolder(), + this.buildEntitiesListHolder(), entityHolder, this.buildEntityLabelProvider(), EclipseLinkHelpContextIds.PERSISTENCE_CACHING @@ -93,9 +92,8 @@ public class EntityListComposite extends Pane<Caching> public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { Caching caching = getSubject(); for (Object item : listSelectionModel.selectedValues()) { - EntityCacheProperties entityCaching = (EntityCacheProperties) item; - entityCaching.disengageListeners(); - caching.removeEntity(entityCaching.getEntityName()); + Entity entityCaching = (Entity) item; + caching.removeEntity(entityCaching.getName()); } } }; @@ -112,17 +110,17 @@ public class EntityListComposite extends Pane<Caching> } if( ! this.getSubject().entityExists(entityName)) { - String entity = this.getSubject().addEntity(entityName); - - listSelectionModel.setSelectedValue(entity); + this.getSubject().addEntity(entityName); + + listSelectionModel.setSelectedValue(entityName); } } } private String getEntityName(String fullyQualifiedTypeName) { - Entity entity = getSubject().getPersistenceUnit().getEntity(fullyQualifiedTypeName); - return entity != null ? entity.getName() : null; + org.eclipse.jpt.core.context.Entity entity = getSubject().getPersistenceUnit().getEntity(fullyQualifiedTypeName); + return (entity != null) ? entity.getName() : null; } private IType chooseEntity() { @@ -176,30 +174,21 @@ public class EntityListComposite extends Pane<Caching> return new LabelProvider() { @Override public String getText(Object element) { - EntityCacheProperties entityCaching = (EntityCacheProperties) element; - return entityCaching.getEntityName(); + Entity entityCaching = (Entity) element; + return entityCaching.getName(); } }; } - private WritablePropertyValueModel<EntityCacheProperties> buildEntityHolder() { - return new SimplePropertyValueModel<EntityCacheProperties>(); - } - - private ListValueModel<EntityCacheProperties> buildEntityCachingListHolder() { - return new TransformationListValueModelAdapter<String, EntityCacheProperties>(this.buildEntitiesListHolder()) { - @Override - protected EntityCacheProperties transformItem(String entityName) { - return new EntityCacheProperties(getSubject(), entityName); - } - }; + private WritablePropertyValueModel<Entity> buildEntityHolder() { + return new SimplePropertyValueModel<Entity>(); } - private ListValueModel<String> buildEntitiesListHolder() { - return new ListAspectAdapter<Caching, String>( + private ListValueModel<Entity> buildEntitiesListHolder() { + return new ListAspectAdapter<Caching, Entity>( this.getSubjectHolder(), Caching.ENTITIES_LIST_PROPERTY) { @Override - protected ListIterator<String> listIterator_() { + protected ListIterator<Entity> listIterator_() { return this.subject.entities(); } @Override @@ -209,7 +198,7 @@ public class EntityListComposite extends Pane<Caching> }; } - private void installPaneEnabler(WritablePropertyValueModel<EntityCacheProperties> entityHolder, + private void installPaneEnabler(WritablePropertyValueModel<Entity> entityHolder, EntityCachingPropertyComposite pane) { new PaneEnabler( @@ -218,10 +207,10 @@ public class EntityListComposite extends Pane<Caching> ); } - private PropertyValueModel<Boolean> buildPaneEnablerHolder(WritablePropertyValueModel<EntityCacheProperties> entityHolder) { - return new TransformationPropertyValueModel<EntityCacheProperties, Boolean>(entityHolder) { + private PropertyValueModel<Boolean> buildPaneEnablerHolder(WritablePropertyValueModel<Entity> entityHolder) { + return new TransformationPropertyValueModel<Entity, Boolean>(entityHolder) { @Override - protected Boolean transform_(EntityCacheProperties value) { + protected Boolean transform_(Entity value) { return value.entityNameIsValid(); } }; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/SharedCacheComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/SharedCacheComposite.java index 3440932fd1..101541b4e0 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/SharedCacheComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/SharedCacheComposite.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.caching; import java.util.ArrayList; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Entity; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; import org.eclipse.jpt.ui.internal.widgets.Pane; @@ -29,7 +30,7 @@ import org.eclipse.swt.widgets.Composite; /** * SharedCacheComposite */ -public class SharedCacheComposite extends Pane<EntityCacheProperties> +public class SharedCacheComposite extends Pane<Entity> { private TriStateCheckBox sharedCacheCheckBox; @@ -39,17 +40,17 @@ public class SharedCacheComposite extends Pane<EntityCacheProperties> * @param parentController The parent container of this one * @param parent The parent container */ - public SharedCacheComposite(Pane<EntityCacheProperties> parentComposite, + public SharedCacheComposite(Pane<Entity> parentComposite, Composite parent) { super(parentComposite, parent); } private PropertyValueModel<Caching> buildCachingHolder() { - return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) { + return new TransformationPropertyValueModel<Entity, Caching>(this.getSubjectHolder()) { @Override - protected Caching transform_(EntityCacheProperties value) { - return value.getCaching(); + protected Caching transform_(Entity value) { + return value.getParent(); } }; } @@ -101,19 +102,27 @@ public class SharedCacheComposite extends Pane<EntityCacheProperties> } private WritablePropertyValueModel<Boolean> buildSharedCacheHolder() { - return new PropertyAspectAdapter<EntityCacheProperties, Boolean>( - getSubjectHolder(), EntityCacheProperties.SHARED_CACHE_PROPERTY) { + return new PropertyAspectAdapter<Entity, Boolean>( + getSubjectHolder(), Entity.SHARED_CACHE_PROPERTY) { @Override protected Boolean buildValue_() { - return this.subject.getSharedCache(); + return getSubjectParent().getSharedCacheOf(getSubjectName()); } @Override protected void setValue_(Boolean value) { - this.subject.setSharedCache(value); + getSubjectParent().setSharedCacheOf(getSubjectName(), value); } }; } + + private String getSubjectName() { + return this.getSubjectHolder().getValue().getName(); + } + + private Caching getSubjectParent() { + return this.getSubjectHolder().getValue().getParent(); + } private ListValueModel<Boolean> buildSharedCacheListHolder() { return new PropertyListValueModelAdapter<Boolean>( diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/CustomizerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/CustomizerComposite.java index 4d7186f21f..7eae8223e4 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/CustomizerComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/CustomizerComposite.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2008 Oracle. All rights reserved. +* Copyright (c) 2008, 2009 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. @@ -12,6 +12,7 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.customization; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.eclipselink.core.context.Customizer; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Entity; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; import org.eclipse.jpt.ui.internal.widgets.Pane; @@ -22,7 +23,7 @@ import org.eclipse.swt.widgets.Composite; /** * CustomizerComposite */ -public class CustomizerComposite extends Pane<EntityCustomizerProperties> +public class CustomizerComposite extends Pane<Entity> { /** * Creates a new <code>CustomizerComposite</code>. @@ -30,23 +31,23 @@ public class CustomizerComposite extends Pane<EntityCustomizerProperties> * @param parentPane The parent pane of this one * @param parent The parent container */ - public CustomizerComposite(Pane<? extends EntityCustomizerProperties> parentPane, + public CustomizerComposite(Pane<? extends Entity> parentPane, Composite parent) { super(parentPane, parent); } - private ClassChooserPane<EntityCustomizerProperties> initializeClassChooser(Composite container) { + private ClassChooserPane<Entity> initializeClassChooser(Composite container) { - return new ClassChooserPane<EntityCustomizerProperties>(this, container) { + return new ClassChooserPane<Entity>(this, container) { @Override protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<EntityCustomizerProperties, String>( - getSubjectHolder(), Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY) { + return new PropertyAspectAdapter<Entity, String>( + this.getSubjectHolder(), Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY) { @Override protected String buildValue_() { - return this.subject.getDescriptorCustomizer(); + return getSubjectParent().getDescriptorCustomizerOf(getSubjectName()); } @Override @@ -55,14 +56,14 @@ public class CustomizerComposite extends Pane<EntityCustomizerProperties> if (value.length() == 0) { value = null; } - this.subject.setDescriptorCustomizer(value); + getSubjectParent().setDescriptorCustomizerOf(getSubjectName(), value); } }; } @Override protected String getClassName() { - return getSubject().getDescriptorCustomizer(); + return getSubjectParent().getDescriptorCustomizerOf(getSubjectName()); } @Override @@ -72,12 +73,12 @@ public class CustomizerComposite extends Pane<EntityCustomizerProperties> @Override protected JpaProject getJpaProject() { - return getSubject().getJpaProject(); + return getSubjectParent().getJpaProject(); } @Override protected void setClassName(String className) { - getSubject().setDescriptorCustomizer(className); + getSubjectParent().setDescriptorCustomizerOf(getSubjectName(), className); } @Override @@ -86,6 +87,14 @@ public class CustomizerComposite extends Pane<EntityCustomizerProperties> } }; } + + private String getSubjectName() { + return this.getSubjectHolder().getValue().getName(); + } + + private Customization getSubjectParent() { + return this.getSubjectHolder().getValue().getParent(); + } @Override protected void initializeLayout(Composite container) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizationPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizationPropertyComposite.java index 47cf823b83..cde8fe68cc 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizationPropertyComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizationPropertyComposite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * Copyright (c) 2008, 2009 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. @@ -10,6 +10,7 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.customization; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Entity; import org.eclipse.jpt.ui.internal.widgets.Pane; import org.eclipse.jpt.utility.model.value.PropertyValueModel; import org.eclipse.swt.widgets.Composite; @@ -17,7 +18,7 @@ import org.eclipse.swt.widgets.Composite; /** * EntityCustomizationPropertyComposite */ -public class EntityCustomizationPropertyComposite extends Pane<EntityCustomizerProperties> { +public class EntityCustomizationPropertyComposite extends Pane<Entity> { /** * Creates a new <code>EntityCustomizationPropertyComposite</code>. @@ -27,7 +28,7 @@ public class EntityCustomizationPropertyComposite extends Pane<EntityCustomizerP * @param parent The parent container */ public EntityCustomizationPropertyComposite(Pane<Customization> parentComposite, - PropertyValueModel<EntityCustomizerProperties> subjectHolder, + PropertyValueModel<Entity> subjectHolder, Composite parent) { super(parentComposite, subjectHolder, parent); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java deleted file mode 100644 index d2d29ac1ef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.persistence.customization; - -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.model.AbstractModel; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; - -/** - * EntityCustomizerProperties - */ -public class EntityCustomizerProperties extends AbstractModel { - - private Customization customization; - private String entityName; - - PropertyValueModel<String> descriptorCustomizerHolder; - PropertyChangeListener descriptorCustomizerListener; - - public static final String DESCRIPTOR_CUSTOMIZER_PROPERTY = Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY; - - private static final long serialVersionUID = 1L; - - // ********** constructors ********** - public EntityCustomizerProperties(Customization customization, String entityName) { - super(); - this.customization = customization; - this.entityName = entityName; - - PropertyValueModel<Customization> customizationHolder = new SimplePropertyValueModel<Customization>(this.customization); - this.initialize(customizationHolder); - - this.engageListeners(); - } - - protected void initialize(PropertyValueModel<Customization> customizationHolder) { - this.descriptorCustomizerHolder = this.buildDescriptorCustomizerAA(customizationHolder); - this.descriptorCustomizerListener = this.buildDescriptorCustomizerChangeListener(); - } - - // ********** behavior ********** - public boolean entityNameIsValid() { - return !StringTools.stringIsEmpty(this.entityName); - } - - public String getEntityName() { - return this.entityName; - } - - public String getDescriptorCustomizer() { - return this.customization.getDescriptorCustomizer(this.entityName); - } - - public String getDefaultDescriptorCustomizer() { - return this.customization.getDefaultDescriptorCustomizer(); - } - - public void setDescriptorCustomizer(String descriptorCustomizer) { - String old = this.getDescriptorCustomizer(); - if (this.attributeValueHasChanged(old, descriptorCustomizer)) { - this.customization.setDescriptorCustomizer(descriptorCustomizer, this.entityName); - this.firePropertyChanged(DESCRIPTOR_CUSTOMIZER_PROPERTY, old, descriptorCustomizer); - } - } - - public JpaProject getJpaProject() { - return this.customization.getJpaProject(); - } - - // ********** PropertyChangeListener ********** - - private PropertyValueModel<String> buildDescriptorCustomizerAA(PropertyValueModel<Customization> subjectHolder) { - return new PropertyAspectAdapter<Customization, String>( - subjectHolder, DESCRIPTOR_CUSTOMIZER_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getDescriptorCustomizer(EntityCustomizerProperties.this.entityName); - } - }; - } - - private PropertyChangeListener buildDescriptorCustomizerChangeListener() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent e) { - EntityCustomizerProperties.this.descriptorCustomizerChanged(e); - } - }; - } - - protected void descriptorCustomizerChanged(PropertyChangeEvent e) { - String old = (String) e.getOldValue(); - String newDescriptorCustomizer = (String) e.getNewValue(); - this.firePropertyChanged(DESCRIPTOR_CUSTOMIZER_PROPERTY, old, newDescriptorCustomizer); - return; - } - - public void engageListeners() { - this.descriptorCustomizerHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.descriptorCustomizerListener); - } - - public void disengageListeners() { - this.descriptorCustomizerHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.descriptorCustomizerListener); - } - - @Override - public void toString(StringBuilder sb) { - sb.append("name: "); - sb.append(this.entityName); - sb.append(", descriptorCustomizer: "); - sb.append(this.getDescriptorCustomizer()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java index 4033fb67b7..9a2860283f 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java @@ -24,8 +24,8 @@ import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.window.Window; -import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization; +import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Entity; import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds; import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; @@ -35,7 +35,6 @@ import org.eclipse.jpt.ui.internal.widgets.Pane; import org.eclipse.jpt.utility.internal.CollectionTools; import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationListValueModelAdapter; import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; import org.eclipse.jpt.utility.model.value.ListValueModel; @@ -51,7 +50,7 @@ import org.eclipse.ui.progress.IProgressService; */ public class EntityListComposite extends Pane<Customization> { - private WritablePropertyValueModel<EntityCustomizerProperties> entityHolder; + private WritablePropertyValueModel<Entity> entityHolder; public EntityListComposite(Pane<Customization> parentComposite, Composite parent) { @@ -77,7 +76,7 @@ public class EntityListComposite extends Pane<Customization> this, container, this.buildEntitiesAdapter(), - this.buildEntityCustomizationListHolder(), + this.buildEntitiesListHolder(), this.entityHolder, this.buildEntityLabelProvider(), EclipseLinkHelpContextIds.PERSISTENCE_CUSTOMIZATION @@ -101,9 +100,8 @@ public class EntityListComposite extends Pane<Customization> public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { Customization customization = getSubject(); for (Object item : listSelectionModel.selectedValues()) { - EntityCustomizerProperties entityCustomization = (EntityCustomizerProperties) item; - entityCustomization.disengageListeners(); - customization.removeEntity(entityCustomization.getEntityName()); + Entity entityCustomization = (Entity) item; + customization.removeEntity(entityCustomization.getName()); } } }; @@ -122,7 +120,7 @@ public class EntityListComposite extends Pane<Customization> if( ! this.getSubject().entityExists(entityName)) { this.getSubject().addEntity(entityName); int index = CollectionTools.indexOf(this.getSubject().entities(), entityName); - EntityCustomizerProperties entity = (EntityCustomizerProperties) listSelectionModel.getListModel().getElementAt(index); + Entity entity = (Entity) listSelectionModel.getListModel().getElementAt(index); this.entityHolder.setValue(entity); } } @@ -130,7 +128,7 @@ public class EntityListComposite extends Pane<Customization> private String getEntityName(String fullyQualifiedTypeName) { - Entity entity = getSubject().getPersistenceUnit().getEntity(fullyQualifiedTypeName); + org.eclipse.jpt.core.context.Entity entity = getSubject().getPersistenceUnit().getEntity(fullyQualifiedTypeName); return entity != null ? entity.getName() : null; } @@ -185,30 +183,21 @@ public class EntityListComposite extends Pane<Customization> return new LabelProvider() { @Override public String getText(Object element) { - EntityCustomizerProperties entityCustomization = (EntityCustomizerProperties) element; - return entityCustomization.getEntityName(); + Entity entityCustomization = (Entity) element; + return entityCustomization.getName(); } }; } - private WritablePropertyValueModel<EntityCustomizerProperties> buildEntityHolder() { - return new SimplePropertyValueModel<EntityCustomizerProperties>(); + private WritablePropertyValueModel<Entity> buildEntityHolder() { + return new SimplePropertyValueModel<Entity>(); } - private ListValueModel<EntityCustomizerProperties> buildEntityCustomizationListHolder() { - return new TransformationListValueModelAdapter<String, EntityCustomizerProperties>(this.buildEntitiesListHolder()) { - @Override - protected EntityCustomizerProperties transformItem(String entityName) { - return new EntityCustomizerProperties(getSubject(), entityName); - } - }; - } - - private ListValueModel<String> buildEntitiesListHolder() { - return new ListAspectAdapter<Customization, String>( + private ListValueModel<Entity> buildEntitiesListHolder() { + return new ListAspectAdapter<Customization, Entity>( this.getSubjectHolder(), Customization.ENTITIES_LIST_PROPERTY) { @Override - protected ListIterator<String> listIterator_() { + protected ListIterator<Entity> listIterator_() { return this.subject.entities(); } @Override @@ -218,7 +207,7 @@ public class EntityListComposite extends Pane<Customization> }; } - private void installPaneEnabler(WritablePropertyValueModel<EntityCustomizerProperties> entityHolder, + private void installPaneEnabler(WritablePropertyValueModel<Entity> entityHolder, EntityCustomizationPropertyComposite pane) { new PaneEnabler( @@ -227,10 +216,10 @@ public class EntityListComposite extends Pane<Customization> ); } - private PropertyValueModel<Boolean> buildPaneEnablerHolder(WritablePropertyValueModel<EntityCustomizerProperties> entityHolder) { - return new TransformationPropertyValueModel<EntityCustomizerProperties, Boolean>(entityHolder) { + private PropertyValueModel<Boolean> buildPaneEnablerHolder(WritablePropertyValueModel<Entity> entityHolder) { + return new TransformationPropertyValueModel<Entity, Boolean>(entityHolder) { @Override - protected Boolean transform_(EntityCustomizerProperties value) { + protected Boolean transform_(Entity value) { return value.entityNameIsValid(); } }; |