blob: 0e308b1e2ac46ea22b4f9ca48d3382149451788c [file] [log] [blame]
kmoored9d1cec2011-02-06 02:18:04 +00001/*******************************************************************************
kmoore6a7396c2011-10-07 12:53:14 +00002 * Copyright (c) 2008, 201 Oracle. All rights reserved.
kmoored9d1cec2011-02-06 02:18:04 +00003 * 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 *******************************************************************************/
10package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching;
11
12import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo;
13import org.eclipse.jpt.common.ui.internal.widgets.Pane;
14import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
15import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
16import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
kmoore6a7396c2011-10-07 12:53:14 +000017import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching;
kmoored9d1cec2011-02-06 02:18:04 +000018import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
19import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
20import org.eclipse.swt.widgets.Composite;
21
22/**
23 * CacheSizeComposite
24 */
25public 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}