kmoore | d9d1cec | 2011-02-06 02:18:04 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
kmoore | 6a7396c | 2011-10-07 12:53:14 +0000 | [diff] [blame] | 2 | * Copyright (c) 2008, 201 Oracle. All rights reserved. |
kmoore | d9d1cec | 2011-02-06 02:18:04 +0000 | [diff] [blame] | 3 | * This program and the accompanying materials are made available under the |
| 4 | * terms of the Eclipse Public License v1.0, which accompanies this distribution |
| 5 | * and is available at http://www.eclipse.org/legal/epl-v10.html. |
| 6 | * |
| 7 | * Contributors: |
| 8 | * Oracle - initial API and implementation |
| 9 | *******************************************************************************/ |
| 10 | package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching; |
| 11 | |
| 12 | import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo; |
| 13 | import org.eclipse.jpt.common.ui.internal.widgets.Pane; |
| 14 | import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; |
| 15 | import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; |
| 16 | import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; |
kmoore | 6a7396c | 2011-10-07 12:53:14 +0000 | [diff] [blame] | 17 | import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching; |
kmoore | d9d1cec | 2011-02-06 02:18:04 +0000 | [diff] [blame] | 18 | import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds; |
| 19 | import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages; |
| 20 | import org.eclipse.swt.widgets.Composite; |
| 21 | |
| 22 | /** |
| 23 | * CacheSizeComposite |
| 24 | */ |
| 25 | public class DefaultCacheSizeComposite<T extends Caching> extends Pane<T> |
| 26 | { |
| 27 | /** |
| 28 | * Creates a new <code>CacheTypeComposite</code>. |
| 29 | * |
| 30 | * @param parentController |
| 31 | * The parent container of this one |
| 32 | * @param parent |
| 33 | * The parent container |
| 34 | */ |
| 35 | public DefaultCacheSizeComposite(Pane<T> parentComposite, |
| 36 | Composite parent) { |
| 37 | |
| 38 | super(parentComposite, parent); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | |
| 43 | @Override |
| 44 | protected void initializeLayout(Composite container) { |
| 45 | addDefaultCacheSizeCombo(container); |
| 46 | } |
| 47 | |
| 48 | private void addDefaultCacheSizeCombo(Composite container) { |
| 49 | new IntegerCombo<Caching>(this, container) { |
| 50 | |
| 51 | @Override |
| 52 | protected String getLabelText() { |
| 53 | return EclipseLinkUiMessages.DefaultCacheSizeComposite_defaultCacheSize; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | protected String getHelpId() { |
| 58 | return EclipseLinkHelpContextIds.PERSISTENCE_CACHING_DEFAULT_SIZE; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | protected PropertyValueModel<Integer> buildDefaultHolder() { |
| 63 | return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder()) { |
| 64 | @Override |
| 65 | protected Integer buildValue_() { |
| 66 | return this.subject.getDefaultCacheSizeDefault(); |
| 67 | } |
| 68 | }; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { |
| 73 | return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder(), Caching.CACHE_SIZE_DEFAULT_PROPERTY) { |
| 74 | @Override |
| 75 | protected Integer buildValue_() { |
| 76 | return this.subject.getCacheSizeDefault(); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | protected void setValue_(Integer value) { |
| 81 | this.subject.setCacheSizeDefault(value); |
| 82 | } |
| 83 | }; |
| 84 | } |
| 85 | }; |
| 86 | } |
| 87 | |
| 88 | } |