| /******************************************************************************* |
| * Copyright (c) 2008, 2013 Oracle. All rights reserved. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License 2.0, which accompanies this distribution |
| * and is available at https://www.eclipse.org/legal/epl-2.0/. |
| * |
| * Contributors: |
| * Oracle - initial API and implementation |
| ******************************************************************************/ |
| package org.eclipse.jpt.jpa.eclipselink.ui.internal.details.java; |
| |
| import org.eclipse.jface.resource.ResourceManager; |
| import org.eclipse.jpt.common.ui.WidgetFactory; |
| import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; |
| import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; |
| import org.eclipse.jpt.jpa.eclipselink.core.context.java.EclipseLinkJavaCaching; |
| import org.eclipse.jpt.jpa.eclipselink.core.context.java.EclipseLinkJavaConverterContainer; |
| import org.eclipse.jpt.jpa.eclipselink.core.context.java.EclipseLinkJavaEntity; |
| import org.eclipse.jpt.jpa.eclipselink.ui.details.JptJpaEclipseLinkUiDetailsMessages; |
| import org.eclipse.jpt.jpa.eclipselink.ui.internal.details.EclipseLinkConvertersComposite; |
| import org.eclipse.jpt.jpa.eclipselink.ui.internal.details.EclipseLinkNonEmbeddableTypeMappingAdvancedComposite; |
| import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityComposite; |
| import org.eclipse.jpt.jpa.ui.internal.details.java.JavaInheritanceComposite; |
| import org.eclipse.jpt.jpa.ui.internal.details.java.JavaSecondaryTablesComposite; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Control; |
| import org.eclipse.ui.forms.events.ExpansionAdapter; |
| import org.eclipse.ui.forms.events.ExpansionEvent; |
| import org.eclipse.ui.forms.widgets.ExpandableComposite; |
| import org.eclipse.ui.forms.widgets.Section; |
| |
| public abstract class EclipseLinkAbstractJavaEntityComposite<T extends EclipseLinkJavaEntity> |
| extends AbstractEntityComposite<T> |
| { |
| protected EclipseLinkAbstractJavaEntityComposite( |
| PropertyValueModel<? extends T> entityModel, |
| Composite parentComposite, |
| WidgetFactory widgetFactory, |
| ResourceManager resourceManager) { |
| super(entityModel, parentComposite, widgetFactory, resourceManager); |
| } |
| |
| |
| @Override |
| protected void initializeLayout(Composite container) { |
| this.initializeEntityCollapsibleSection(container); |
| this.initializeCachingCollapsibleSection(container); |
| this.initializeQueriesCollapsibleSection(container); |
| this.initializeInheritanceCollapsibleSection(container); |
| this.initializeAttributeOverridesCollapsibleSection(container); |
| this.initializeGeneratorsCollapsibleSection(container); |
| this.initializeConvertersCollapsibleSection(container); |
| this.initializeSecondaryTablesCollapsibleSection(container); |
| this.initializeAdvancedCollapsibleSection(container); |
| } |
| |
| protected void initializeCachingCollapsibleSection(Composite container) { |
| final Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE); |
| section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| section.setText(JptJpaEclipseLinkUiDetailsMessages.ECLIPSELINK_TYPE_MAPPING_COMPOSITE_CACHING); |
| |
| section.addExpansionListener(new ExpansionAdapter() { |
| @Override |
| public void expansionStateChanging(ExpansionEvent e) { |
| if (e.getState() && section.getClient() == null) { |
| section.setClient(initializeCachingSection(section)); |
| } |
| } |
| }); |
| } |
| |
| protected Control initializeCachingSection(Composite container) { |
| return new EclipseLinkJavaCachingComposite(this, buildCachingModel(), container).getControl(); |
| } |
| |
| protected PropertyAspectAdapter<T, EclipseLinkJavaCaching> buildCachingModel() { |
| return new PropertyAspectAdapter<T, EclipseLinkJavaCaching>(getSubjectHolder()) { |
| @Override |
| protected EclipseLinkJavaCaching buildValue_() { |
| return this.subject.getCaching(); |
| } |
| }; |
| } |
| |
| protected void initializeConvertersCollapsibleSection(Composite container) { |
| final Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE); |
| section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| section.setText(JptJpaEclipseLinkUiDetailsMessages.ECLIPSELINK_TYPE_MAPPING_COMPOSITE_CONVERTERS); |
| |
| section.addExpansionListener(new ExpansionAdapter() { |
| @Override |
| public void expansionStateChanging(ExpansionEvent e) { |
| if (e.getState() && section.getClient() == null) { |
| section.setClient(initializeConvertersSection(section)); |
| } |
| } |
| }); |
| } |
| |
| protected Control initializeConvertersSection(Composite container) { |
| return new EclipseLinkConvertersComposite(this, this.buildConverterContainerModel(), container).getControl(); |
| } |
| |
| private PropertyValueModel<EclipseLinkJavaConverterContainer> buildConverterContainerModel() { |
| return new PropertyAspectAdapter<T, EclipseLinkJavaConverterContainer>(getSubjectHolder()) { |
| @Override |
| protected EclipseLinkJavaConverterContainer buildValue_() { |
| return this.subject.getConverterContainer(); |
| } |
| }; |
| } |
| |
| @Override |
| protected Control initializeSecondaryTablesSection(Composite container) { |
| return new JavaSecondaryTablesComposite(this, container).getControl(); |
| } |
| |
| @Override |
| protected Control initializeInheritanceSection(Composite container) { |
| return new JavaInheritanceComposite(this, container).getControl(); |
| } |
| |
| protected void initializeAdvancedCollapsibleSection(Composite container) { |
| final Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE); |
| section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| section.setText(JptJpaEclipseLinkUiDetailsMessages.ECLIPSELINK_TYPE_MAPPING_COMPOSITE_ADVANCED); |
| |
| section.addExpansionListener(new ExpansionAdapter() { |
| @Override |
| public void expansionStateChanging(ExpansionEvent e) { |
| if (e.getState() && section.getClient() == null) { |
| section.setClient(initializeAdvancedSection(section)); |
| } |
| } |
| }); |
| } |
| |
| protected Control initializeAdvancedSection(Composite container) { |
| return new EclipseLinkNonEmbeddableTypeMappingAdvancedComposite(this, container).getControl(); |
| } |
| } |