Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortle2008-04-29 22:12:13 +0000
committertle2008-04-29 22:12:13 +0000
commit53429766a6f2e134df41dffa810a30a0afe454cc (patch)
treea46c701f431423f4604c02796735649470bfb411
parentcd69958db82911b33c6b2b09192844fa392fb091 (diff)
downloadwebtools.dali-53429766a6f2e134df41dffa810a30a0afe454cc.tar.gz
webtools.dali-53429766a6f2e134df41dffa810a30a0afe454cc.tar.xz
webtools.dali-53429766a6f2e134df41dffa810a30a0afe454cc.zip
228032 - Remove entity from cache list ... - patch from Pascal
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/customization/EntityListComposite.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AddRemovePane.java19
4 files changed, 57 insertions, 13 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
index b5159c220c..0fe159e179 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
@@ -12,7 +12,6 @@ package org.eclipse.jpt.eclipselink.ui.internal.caching;
import java.util.Collection;
import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheType;
-import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
@@ -42,14 +41,14 @@ public class CacheTypeComposite extends AbstractPane<EntityCacheProperties>
@Override
protected void addPropertyNames(Collection<String> propertyNames) {
super.addPropertyNames(propertyNames);
- propertyNames.add(Caching.CACHE_TYPE_PROPERTY);
+ propertyNames.add(EntityCacheProperties.CACHE_TYPE_PROPERTY);
}
@Override
protected CacheType[] choices() {
return CacheType.values();
}
-
+
@Override
protected boolean sortChoices() {
return false;
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java
index 8584a789c8..b4a33092f5 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityCacheProperties.java
@@ -17,13 +17,18 @@ import org.eclipse.jpt.utility.internal.model.AbstractModel;
/**
* EntityCacheProperties
*/
+@SuppressWarnings("nls")
public class EntityCacheProperties extends AbstractModel {
private Caching caching;
private String entityName;
private static final long serialVersionUID = 1L;
-
+
+ public static final String CACHE_SIZE_PROPERTY = Caching.CACHE_SIZE_PROPERTY;
+ public static final String CACHE_TYPE_PROPERTY = Caching.CACHE_TYPE_PROPERTY;
+ public static final String SHARED_CACHE_PROPERTY = Caching.SHARED_CACHE_DEFAULT_PROPERTY;
+
// ********** constructors **********
public EntityCacheProperties(Caching caching, String entityName) {
super();
@@ -43,6 +48,10 @@ public class EntityCacheProperties extends AbstractModel {
return this.caching.getCacheType(this.entityName);
}
+ public Caching getCaching() {
+ return caching;
+ }
+
public Integer getDefaultCacheSize() {
return this.caching.getDefaultCacheSize();
}
@@ -63,16 +72,22 @@ public class EntityCacheProperties extends AbstractModel {
return this.caching.getDefaultSharedCache();
}
- public void setCacheSize(Integer cachingSize) {
- this.caching.setCacheSize(cachingSize, this.entityName);
+ public void setCacheSize(Integer cacheSize) {
+ Integer oldCacheSize = this.getCacheSize();
+ this.caching.setCacheSize(cacheSize, this.entityName);
+ this.firePropertyChanged(CACHE_SIZE_PROPERTY, oldCacheSize, cacheSize);
}
public void setCacheType(CacheType cacheType) {
+ CacheType oldCacheType = this.getCacheType();
this.caching.setCacheType(cacheType, this.entityName);
+ this.firePropertyChanged(CACHE_TYPE_PROPERTY, oldCacheType, cacheType);
}
public void setSharedCache(Boolean sharedCache) {
+ Boolean oldSharedCache = this.getSharedCache();
this.caching.setSharedCache(sharedCache, this.entityName);
+ this.firePropertyChanged(SHARED_CACHE_PROPERTY, oldSharedCache, sharedCache);
}
@Override
@@ -85,6 +100,7 @@ public class EntityCacheProperties extends AbstractModel {
return sb.toString();
}
+ @Override
public void toString(StringBuilder sb) {
sb.append("name: ");
sb.append(this.entityName);
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 13c9cc3685..3ac60dbbce 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
@@ -21,6 +21,7 @@ import org.eclipse.jpt.eclipselink.ui.internal.EntityDialog;
import org.eclipse.jpt.ui.internal.util.PaneEnabler;
import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane;
+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;
@@ -36,12 +37,20 @@ import org.eclipse.swt.widgets.Composite;
*/
public class EntityListComposite extends AbstractPane<Customization>
{
+ private WritablePropertyValueModel<EntityCustomizerProperties> entityHolder;
+
public EntityListComposite(AbstractPane<Customization> parentComposite, Composite parent) {
super(parentComposite, parent);
}
@Override
+ protected void initialize() {
+ super.initialize();
+ entityHolder = this.buildEntityHolder();
+ }
+
+ @Override
protected void initializeLayout(Composite container) {
container = this.buildTitledPane(
@@ -49,10 +58,8 @@ public class EntityListComposite extends AbstractPane<Customization>
EclipseLinkUiMessages.CustomizationEntityListComposite_groupTitle
);
- WritablePropertyValueModel<EntityCustomizerProperties> entityHolder = this.buildEntityHolder();
-
// Entities add/remove list pane
- AddRemoveListPane<Customization> listPane = new AddRemoveListPane<Customization>(
+ new AddRemoveListPane<Customization>(
this,
container,
this.buildEntitiesAdapter(),
@@ -98,7 +105,8 @@ public class EntityListComposite extends AbstractPane<Customization>
}
public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
- Customization customization = subject();
+ Customization customization = subject();
+
for (Object item : listSelectionModel.selectedValues()) {
EntityCustomizerProperties entityCustomization = (EntityCustomizerProperties) item;
customization.removeEntity(entityCustomization.getEntityName());
@@ -113,9 +121,11 @@ public class EntityListComposite extends AbstractPane<Customization>
if (dialog.open() == Window.OK) {
String name = dialog.getSelectedName();
- String entity = this.subject().addEntity(name);
+ this.subject().addEntity(name);
- listSelectionModel.setSelectedValue(entity);
+ int index = CollectionTools.indexOf(this.subject().entities(), name);
+ EntityCustomizerProperties item = (EntityCustomizerProperties) listSelectionModel.getListModel().getElementAt(index);
+ entityHolder.setValue(item);
}
}
@@ -159,4 +169,4 @@ public class EntityListComposite extends AbstractPane<Customization>
}
};
}
-}
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AddRemovePane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AddRemovePane.java
index b53f180057..2a1df95058 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AddRemovePane.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AddRemovePane.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.widgets;
+import java.util.Arrays;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jpt.ui.internal.JptUiMessages;
import org.eclipse.jpt.ui.internal.listeners.SWTListChangeListenerWrapper;
@@ -542,7 +543,25 @@ public abstract class AddRemovePane<T extends Model> extends AbstractPane<T>
* @category Remove
*/
protected void removeItems() {
+
+ // Keep track of the selected indices so we can select an item
+ // before the lowest index
+ int[] indices = selectionModel.selectedIndices();
+ Arrays.sort(indices);
+
+ // Notify the adapter to remove the selected items
adapter.removeSelectedItems(selectionModel);
+
+ // Select a new item
+ if (getListHolder().size() > 0) {
+ int index = Math.min(indices[0], getListHolder().size() - 1);
+ Object item = getListHolder().get(index);
+ selectedItemHolder.setValue(item);
+ }
+ // The list is empty, clear the value
+ else {
+ selectedItemHolder.setValue(null);
+ }
}
/**

Back to the top