| /******************************************************************************* |
| * Copyright (c) 2008 Oracle. All rights reserved. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v1.0, which accompanies this distribution |
| * and is available at http://www.eclipse.org/legal/epl-v10.html. |
| * |
| * Contributors: |
| * Oracle - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.jpt.eclipselink.ui.internal.platform; |
| |
| import java.util.ArrayList; |
| import java.util.ListIterator; |
| |
| import org.eclipse.jpt.core.context.persistence.PersistenceUnit; |
| import org.eclipse.jpt.eclipselink.core.internal.context.EclipseLinkPersistenceUnit; |
| import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching; |
| import org.eclipse.jpt.eclipselink.core.internal.context.customization.Customization; |
| import org.eclipse.jpt.eclipselink.core.internal.context.schema.generation.SchemaGeneration; |
| import org.eclipse.jpt.eclipselink.ui.internal.caching.PersistenceXmlCachingTab; |
| import org.eclipse.jpt.eclipselink.ui.internal.customization.PersistenceXmlCustomizationTab; |
| import org.eclipse.jpt.eclipselink.ui.internal.schema.generation.PersistenceXmlSchemaGenerationTab; |
| import org.eclipse.jpt.ui.WidgetFactory; |
| import org.eclipse.jpt.ui.details.JpaPageComposite; |
| import org.eclipse.jpt.ui.internal.BaseJpaUiFactory; |
| import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; |
| import org.eclipse.jpt.utility.model.value.PropertyValueModel; |
| import org.eclipse.swt.widgets.Composite; |
| |
| /** |
| * EclipseLinkUiFactory |
| */ |
| public class EclipseLinkUiFactory extends BaseJpaUiFactory |
| { |
| public EclipseLinkUiFactory() { |
| super(); |
| } |
| |
| @Override |
| public ListIterator<JpaPageComposite<PersistenceUnit>> createPersistenceUnitComposites( |
| PropertyValueModel<PersistenceUnit> subjectHolder, |
| Composite parent, |
| WidgetFactory widgetFactory) { |
| |
| PropertyValueModel<EclipseLinkPersistenceUnit> eclipseLinkPersistenceUnitHolder = |
| this.buildEclipseLinkPersistenceUnitHolder(subjectHolder); |
| ArrayList<JpaPageComposite<PersistenceUnit>> pages = |
| new ArrayList<JpaPageComposite<PersistenceUnit>>(2); |
| |
| PropertyValueModel<SchemaGeneration> schemaGenHolder = |
| this.buildSchemaGenerationHolder(eclipseLinkPersistenceUnitHolder); |
| pages.add(new PersistenceXmlSchemaGenerationTab(schemaGenHolder, parent, widgetFactory)); |
| |
| PropertyValueModel<Caching> cachingHolder = |
| this.buildCachingHolder(eclipseLinkPersistenceUnitHolder); |
| pages.add(new PersistenceXmlCachingTab(cachingHolder, parent, widgetFactory)); |
| |
| PropertyValueModel<Customization> customizationHolder = |
| this.buildCustomizationHolder(eclipseLinkPersistenceUnitHolder); |
| pages.add(new PersistenceXmlCustomizationTab(customizationHolder, parent, widgetFactory)); |
| |
| return pages.listIterator(); |
| } |
| |
| private PropertyValueModel<Customization> buildCustomizationHolder( |
| PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) { |
| return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, Customization>(subjectHolder) { |
| @Override |
| protected Customization transform_(EclipseLinkPersistenceUnit value) { |
| return value.getCustomization(); |
| } |
| }; |
| } |
| |
| private PropertyValueModel<Caching> buildCachingHolder( |
| PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) { |
| return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, Caching>(subjectHolder) { |
| @Override |
| protected Caching transform_(EclipseLinkPersistenceUnit value) { |
| return value.getCaching(); |
| } |
| }; |
| } |
| |
| private PropertyValueModel<SchemaGeneration> buildSchemaGenerationHolder( |
| PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) { |
| return new TransformationPropertyValueModel<EclipseLinkPersistenceUnit, SchemaGeneration>(subjectHolder) { |
| @Override |
| protected SchemaGeneration transform_(EclipseLinkPersistenceUnit value) { |
| return value.getSchemaGeneration(); |
| } |
| }; |
| } |
| |
| private PropertyValueModel<EclipseLinkPersistenceUnit> buildEclipseLinkPersistenceUnitHolder( |
| PropertyValueModel<PersistenceUnit> subjectHolder) { |
| return new TransformationPropertyValueModel<PersistenceUnit, EclipseLinkPersistenceUnit>(subjectHolder) { |
| @Override |
| protected EclipseLinkPersistenceUnit transform_(PersistenceUnit value) { |
| return (EclipseLinkPersistenceUnit) value; |
| } |
| }; |
| } |
| } |