blob: 2891beac230269c3c7e8e810745814d0244e3ddb [file] [log] [blame]
kmoored9d1cec2011-02-06 02:18:04 +00001/*******************************************************************************
2* Copyright (c) 2008, 2011 Oracle. All rights reserved.
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*******************************************************************************/
10package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options;
11
12import org.eclipse.jdt.core.IJavaProject;
13import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserPane;
14import org.eclipse.jpt.common.ui.internal.widgets.Pane;
15import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
16import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
kmoore6a7396c2011-10-07 12:53:14 +000017import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Options;
kmoored9d1cec2011-02-06 02:18:04 +000018import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
19import org.eclipse.swt.widgets.Composite;
20
21/**
22 * EventListenerComposite
23 */
24public class EventListenerComposite extends Pane<Options>
25{
26 /**
27 * Creates a new <code>EventListenerComposite</code>.
28 *
29 * @param parentPane The parent pane of this one
30 * @param parent The parent container
31 */
32 public EventListenerComposite(Pane<? extends Options> parentPane,
33 Composite parent) {
34
35 super(parentPane, parent);
36 }
37
38 private ClassChooserPane<Options> initializeClassChooser(Composite container) {
39
40 return new ClassChooserPane<Options>(this, container) {
41
42 @Override
43 protected WritablePropertyValueModel<String> buildTextHolder() {
44 return new PropertyAspectAdapter<Options, String>(
45 this.getSubjectHolder(), Options.SESSION_EVENT_LISTENER_PROPERTY) {
46 @Override
47 protected String buildValue_() {
48 return this.subject.getEventListener();
49 }
50
51 @Override
52 protected void setValue_(String value) {
53
54 if (value.length() == 0) {
55 value = null;
56 }
57 this.subject.setEventListener(value);
58 }
59 };
60 }
61
62 @Override
63 protected String getClassName() {
64 return this.getSubject().getEventListener();
65 }
66
67 @Override
68 protected String getLabelText() {
69 return EclipseLinkUiMessages.PersistenceXmlOptionsTab_eventListenerLabel;
70 }
71
72 @Override
73 protected IJavaProject getJavaProject() {
74 return getSubject().getJpaProject().getJavaProject();
75 }
76
77 @Override
78 protected void setClassName(String className) {
79 this.getSubject().setEventListener(className);
80 }
81
82 @Override
83 protected String getSuperInterfaceName() {
84 return Options.ECLIPSELINK_EVENT_LISTENER_CLASS_NAME;
85 }
86 };
87 }
88
89 @Override
90 protected void initializeLayout(Composite container) {
91 this.initializeClassChooser(container);
92 }
93}