kmoore | d9d1cec | 2011-02-06 02:18:04 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 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 | *******************************************************************************/ |
| 10 | package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options; |
| 11 | |
| 12 | import org.eclipse.jdt.core.IJavaProject; |
| 13 | import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserPane; |
| 14 | import org.eclipse.jpt.common.ui.internal.widgets.Pane; |
| 15 | import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; |
| 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.Options; |
kmoore | d9d1cec | 2011-02-06 02:18:04 +0000 | [diff] [blame] | 18 | import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages; |
| 19 | import org.eclipse.swt.widgets.Composite; |
| 20 | |
| 21 | /** |
| 22 | * EventListenerComposite |
| 23 | */ |
| 24 | public 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 | } |